Makefile 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. # --- set these according to your configuration ---
  2. LINUXSDL = ../../SDL2-master
  3. MINGWSDL = ../../SDL2-mingw
  4. MACSDL = /Library/Frameworks/SDL2.framework
  5. # -------------------------------------------------
  6. TARGET = sfnedit
  7. include ../libsfn/Makefile.env
  8. SRCS = $(filter-out $(wildcard ui_*.c),$(wildcard *.c))
  9. # DUMMY driver for a hobby OS
  10. ifeq ("$(USE_X11)","")
  11. ifneq ("$(wildcard path/to/your/uiheader.h)","")
  12. SRCS += ui_dummy.c
  13. CFLAGS += -Ipath/to/your/uiheader
  14. LIBS += -lyouruilib
  15. PLAT = x86_64-dummy
  16. DRIVER = dummy
  17. endif
  18. endif
  19. # OS/Z driver
  20. ifeq ("$(USE_X11)$(DRIVER)","")
  21. ifneq ("$(wildcard ../../include/osZ/osZ.h)","")
  22. SRCS += ui_osZ.c
  23. CFLAGS += -I../../include
  24. LIBS += -lui
  25. PLAT = x86_64-osZ
  26. DRIVER = osZ
  27. endif
  28. endif
  29. # SDL driver
  30. ifeq ("$(USE_X11)$(DRIVER)","")
  31. # MacOSX
  32. ifneq ("$(wildcard $(MACSDL)/libSDL.a)","")
  33. SRCS += ui_sdl.c
  34. CFLAGS += -D__MACOSX__=1 -I$(MACSDL)/include
  35. EXTRA += $(MACSDL)/libSDL.a
  36. LIBS += -framework CoreVideo -framework Cocoa -framework Carbon -framework Metal -framework IOKit
  37. PLAT = intel-macosx
  38. DRIVER = sdl
  39. else
  40. ifneq ("$(wildcard $(MACSDL)/Headers)","")
  41. SRCS += ui_sdl.c
  42. CFLAGS += -D__MACOSX__=1 -I$(MACSDL)/Headers -I$(MACSDL)/Versions/A/Headers
  43. LIBDIRS = -F$(MACSDL:/SDL2.framework=)
  44. LIBS += -framework SDL2
  45. PLAT = intel-macosx
  46. DRIVER = sdl
  47. else
  48. # Linux
  49. ifneq ("$(wildcard $(LINUXSDL)/libSDL.a)","")
  50. SRCS += ui_sdl.c
  51. CFLAGS += -I$(LINUXSDL)/include
  52. EXTRA += $(LINUXSDL)/libSDL.a
  53. ifneq ("$(shell grep 'define SDL_VIDEO_DRIVER_WAYLAND 1' $(LINUXSDL)/include/SDL_config.h)","")
  54. LIBS += -lm -lwayland
  55. else
  56. LIBS += -lm -lX11 -lXcursor -lXext
  57. endif
  58. DRIVER = sdl
  59. else
  60. ifneq ("$(wildcard /usr/local/include/SDL2/SDL.h)","")
  61. SRCS += ui_sdl.c
  62. CFLAGS += -I/usr/local/include/SDL2
  63. LIBS += -L/usr/local/lib -lSDL2
  64. DRIVER = sdl
  65. else
  66. ifneq ("$(wildcard /usr/include/SDL2/SDL.h)","")
  67. SRCS += ui_sdl.c
  68. CFLAGS += -I/usr/include/SDL2
  69. LIBS += -lSDL2
  70. DRIVER = sdl
  71. else
  72. # Windows MinGW
  73. ifneq ("$(wildcard $(MINGWSDL)/libSDL.a)","")
  74. SRCS += ui_sdl.c
  75. CFLAGS += -I$(MINGWSDL)/include
  76. EXTRA += $(MINGWSDL)/libSDL.a resource.o
  77. LIBDIRS = -mwindows -static-libgcc
  78. LIBS += -Wl,--nxcompat -lole32 -loleaut32 -lwinmm -limm32 -luuid -lversion
  79. PLAT = i686-win
  80. DRIVER = sdl
  81. else
  82. ifneq ("$(wildcard $(MINGWSDL)/i686-w64-mingw32/include/SDL2/SDL.h)","")
  83. SRCS += ui_sdl.c
  84. CFLAGS += -I$(MINGWSDL)/i686-w64-mingw32/include/SDL2
  85. LIBDIRS = -mwindows -static-libgcc -L$(MINGWSDL)/i686-w64-mingw32/lib -L$(MINGWSDL)/i686-w64-mingw32/bin
  86. LIBS += -lSDL2
  87. EXTRA += resource.o
  88. PLAT = i686-win
  89. DRIVER = sdl
  90. endif
  91. endif
  92. endif
  93. endif
  94. endif
  95. endif
  96. endif
  97. endif
  98. # fallback native X11 driver
  99. ifeq ("$(DRIVER)","")
  100. ifneq ("$(wildcard /opt/local/include/X11/Xlib.h)","")
  101. SRCS += ui_x11.c
  102. CFLAGS += -I/opt/local/include/X11
  103. LIBS +=-L/opt/X11/lib -L/opt/local/lib -lX11
  104. ifneq ("$(wildcard /opt/X11/lib/libXmu*)","")
  105. CFLAGS += -DHAS_XMU=1
  106. LIBS += -lXmu
  107. endif
  108. DRIVER = x11
  109. else
  110. ifneq ("$(wildcard /usr/local/lib/libX11*)","")
  111. SRCS += ui_x11.c
  112. CFLAGS += -I/usr/local/include/X11
  113. LIBS += -L/usr/local/lib -L/usr/local/X11/lib -lX11
  114. ifneq ("$(wildcard /usr/local/X11/lib/libXmu*)","")
  115. CFLAGS += -DHAS_XMU=1
  116. LIBS += -lXmu
  117. endif
  118. DRIVER = x11
  119. else
  120. ifneq ("$(wildcard /usr/lib/libX11*)","")
  121. SRCS += ui_x11.c
  122. CFLAGS += -I/usr/include/X11
  123. LIBS += -lX11
  124. ifneq ("$(wildcard /usr/lib/libX1mu*)","")
  125. CFLAGS += -DHAS_XMU=1
  126. LIBS += -lXmu
  127. endif
  128. DRIVER = x11
  129. endif
  130. endif
  131. endif
  132. endif
  133. ifeq ("$(PLAT)","")
  134. PLAT = x86_64-linux
  135. endif
  136. OBJS = $(SRCS:.c=.o)
  137. all: configure $(TARGET)
  138. configure:
  139. ifeq ("$(DRIVER)","")
  140. @echo "No ui driver can be detected. Install libsdl-dev or libx11-dev."
  141. @false
  142. endif
  143. resource.o: misc/resource.rc
  144. @windres misc/resource.rc -o resource.o
  145. %: %.c icon.h lang.h
  146. $(CC) $(CFLAGS) $< -c $@
  147. # include libsfn .o files directly so that we don't rely on 'ar' under mingw
  148. $(TARGET): $(OBJS) $(EXTRA)
  149. ifeq ($(wildcard ../libsfn/*.o),)
  150. @make -C ../libsfn all
  151. endif
  152. $(CC) $(OBJS) ../libsfn/*.o ../libsfn/potracelib/*.o $(EXTRA) -o $(TARGET) $(LIBDIRS) $(LIBS)
  153. ### packaging stuff ###
  154. zip: $(TARGET)
  155. ifeq ("$(PLAT)","i686-win")
  156. @mkdir SSFN
  157. @cp ../ssfn.h SSFN
  158. @cp $(TARGET).exe SSFN
  159. ifneq ("$(wildcard ../sfnconv/sfnconv.exe)","")
  160. @cp ../sfnconv/sfnconv.exe SSFN
  161. endif
  162. @rm ../ssfn_2.0.0-$(PLAT).zip 2>/dev/null || true
  163. zip -r -9 ../ssfn_2.0.0-$(PLAT).zip SSFN
  164. @rm -rf SSFN
  165. else
  166. ifeq ("$(PLAT)","intel-macosx")
  167. @mkdir SFNEdit.app SFNEdit.app/Contents SFNEdit.app/Contents/MacOS SFNEdit.app/Contents/Resources SFNEdit.app/Contents/Frameworks SFNEdit.app/Contents/Frameworks/SSFN.framework SFNEdit.app/Contents/Frameworks/SSFN.framework/Headers
  168. @cp $(TARGET) SFNEdit.app/Contents/MacOS
  169. ifneq ("$(wildcard ../sfnconv/sfnconv)","")
  170. @cp ../sfnconv/sfnconv SFNEdit.app/Contents/MacOS
  171. endif
  172. @cp ../ssfn.h SFNEdit.app/Contents/Frameworks/SSFN.framework/Headers
  173. @cp -r $(MACSDL) SFNEdit.app/Contents/Frameworks
  174. @cp misc/Info.plist SFNEdit.app/Contents
  175. @cp misc/sfnedit.icns SFNEdit.app/Contents/Resources
  176. @rm ../ssfn_2.0.0-$(PLAT).zip 2>/dev/null || true
  177. zip -r -9 ../ssfn_2.0.0-$(PLAT).zip SFNEdit.app
  178. @rm -rf SFNEdit.app
  179. else
  180. @mkdir bin include
  181. @cp ../ssfn.h include
  182. @cp $(TARGET) bin
  183. ifneq ("$(wildcard ../sfnconv/sfnconv)","")
  184. @cp ../sfnconv/sfnconv bin
  185. endif
  186. @rm ../ssfn_2.0.0-$(PLAT).zip 2>/dev/null || true
  187. zip -r -9 ../ssfn_2.0.0-$(PLAT).zip bin include
  188. @rm -rf bin include
  189. endif
  190. endif
  191. deb: $(TARGET)
  192. @mkdir DEBIAN usr usr/bin usr/include usr/share usr/share/man usr/share/man/man1 usr/share/man/man3 usr/share/applications usr/share/icons usr/share/icons/hicolor usr/share/icons/hicolor/16x16 usr/share/icons/hicolor/16x16/apps usr/share/icons/hicolor/32x32 usr/share/icons/hicolor/32x32/apps usr/share/icons/hicolor/64x64 usr/share/icons/hicolor/64x64/apps usr/share/icons/hicolor/128x128 usr/share/icons/hicolor/128x128/apps
  193. @cp $(TARGET) usr/bin
  194. ifneq ("$(wildcard ../sfnconv/sfnconv)","")
  195. @cp ../sfnconv/sfnconv usr/bin
  196. @cp misc/sfnconv.1.gz usr/share/man/man1
  197. endif
  198. @cp ../ssfn.h usr/include
  199. @cp misc/ssfn.h.3.gz usr/share/man/man3
  200. @cp misc/sfnedit.1.gz usr/share/man/man1
  201. @cp misc/sfnedit.desktop usr/share/applications
  202. @cp misc/icon128.png usr/share/icons/hicolor/128x128/apps/sfnedit.png
  203. @cp misc/icon64.png usr/share/icons/hicolor/64x64/apps/sfnedit.png
  204. @cp misc/icon32.png usr/share/icons/hicolor/32x32/apps/sfnedit.png
  205. @cp misc/icon16.png usr/share/icons/hicolor/16x16/apps/sfnedit.png
  206. @cat misc/deb_control | sed s/SIZE/`du -s usr|cut -f 1`/g >DEBIAN/control
  207. @md5sum `find usr -type f` >DEBIAN/md5sums
  208. @cp ../LICENSE DEBIAN/copyright
  209. @echo "2.0" >debian-binary
  210. @tar -czvf data.tar.gz usr
  211. @tar -C DEBIAN -czvf control.tar.gz control copyright md5sums
  212. @ar r ../ssfn_2.0.0-amd64.deb debian-binary control.tar.gz data.tar.gz
  213. @rm -rf debian-binary control.tar.gz data.tar.gz DEBIAN usr
  214. clean:
  215. @rm $(TARGET) *.o 2>/dev/null || true