Makefile 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. WORKDIR = `pwd`
  2. CC = gcc
  3. CXX = g++
  4. AR = ar
  5. LD = g++
  6. WINDRES = windres
  7. INC =
  8. RESINC =
  9. LIBDIR =
  10. ifdef MINGW
  11. CFLAGS = -std=gnu++0x -Wall -I/usr/include -I/usr/include/SDL -D_GNU_SOURCE=1 -Dmain=SDL_main
  12. LIB = /usr/lib/libjack.lib /usr/lib/libSDL_gfx.dll.a /usr/lib/SDL_ttf.lib
  13. LDFLAGS = -L/usr/lib -lmingw32 -lSDLmain -lSDL -mwindows
  14. else
  15. CFLAGS = -std=gnu++0x -Wall `sdl-config --cflags`
  16. LIB =
  17. LDFLAGS = `sdl-config --libs` `pkg-config x11 --libs` `pkg-config SDL_ttf --libs` `pkg-config SDL_gfx --libs` `pkg-config jack --libs`
  18. endif
  19. INC_DEBUG = $(INC)
  20. CFLAGS_DEBUG = $(CFLAGS) -g
  21. RESINC_DEBUG = $(RESINC)
  22. RCFLAGS_DEBUG = $(RCFLAGS)
  23. LIBDIR_DEBUG = $(LIBDIR)
  24. LIB_DEBUG = $(LIB)
  25. LDFLAGS_DEBUG = $(LDFLAGS)
  26. OBJDIR_DEBUG = ./obj/Debug
  27. BINDIR_DEBUG = ./bin/Debug
  28. DEP_DEBUG =
  29. OUT_DEBUG = $(BINDIR_DEBUG)/loopidity-dbg
  30. INC_RELEASE = $(INC)
  31. CFLAGS_RELEASE = $(CFLAGS) -O3
  32. RESINC_RELEASE = $(RESINC)
  33. RCFLAGS_RELEASE = $(RCFLAGS)
  34. LIBDIR_RELEASE = $(LIBDIR)
  35. LIB_RELEASE = $(LIB)
  36. LDFLAGS_RELEASE = $(LDFLAGS) -s
  37. OBJDIR_RELEASE = ./obj/Release
  38. BINDIR_RELEASE = ./bin/Release
  39. DEP_RELEASE =
  40. OUT_RELEASE = $(BINDIR_RELEASE)/loopidity
  41. ASSETS_DIR = ../assets
  42. ifdef MINGW
  43. SYSBIN_DIR = /usr/bin
  44. else
  45. SYSBIN_DIR = /usr/bin
  46. endif
  47. OBJ_DEBUG = $(OBJDIR_DEBUG)/__/src/jack_io.o \
  48. $(OBJDIR_DEBUG)/__/src/loopidity.o \
  49. $(OBJDIR_DEBUG)/__/src/loopidity_sdl.o \
  50. $(OBJDIR_DEBUG)/__/src/main.o \
  51. $(OBJDIR_DEBUG)/__/src/scene.o \
  52. $(OBJDIR_DEBUG)/__/src/scene_sdl.o \
  53. $(OBJDIR_DEBUG)/__/src/trace.o
  54. OBJ_RELEASE = $(OBJDIR_RELEASE)/__/src/jack_io.o \
  55. $(OBJDIR_RELEASE)/__/src/loopidity.o \
  56. $(OBJDIR_RELEASE)/__/src/loopidity_sdl.o \
  57. $(OBJDIR_RELEASE)/__/src/main.o \
  58. $(OBJDIR_RELEASE)/__/src/scene.o \
  59. $(OBJDIR_RELEASE)/__/src/scene_sdl.o \
  60. $(OBJDIR_RELEASE)/__/src/trace.o
  61. ASSETS = histogram_gradient.bmp \
  62. loop_gradient.argb.bmp \
  63. scope_gradient.bmp \
  64. Purisa.ttf
  65. ifdef MINGW
  66. WINLIBS = SDL.dll \
  67. SDL_gfx.dll \
  68. SDL_ttf.dll \
  69. libfreetype-6.dll \
  70. zlib1.dll
  71. else
  72. WINLIBS =
  73. endif
  74. all: debug release
  75. clean: clean_debug clean_release
  76. debug: before_debug out_debug after_debug
  77. before_debug:
  78. @echo ; echo "building debug configuration" ;
  79. @test -d $(BINDIR_DEBUG) || mkdir -p $(BINDIR_DEBUG)
  80. @test -d $(OBJDIR_DEBUG)/__/src || mkdir -p $(OBJDIR_DEBUG)/__/src
  81. after_debug: $(ASSETS) $(WINLIBS)
  82. out_debug: before_debug $(OBJ_DEBUG) $(DEP_DEBUG)
  83. @echo "linking debug binary"
  84. @$(LD) $(LIBDIR_DEBUG) -o $(OUT_DEBUG) $(OBJ_DEBUG) $(LDFLAGS_DEBUG) $(LIB_DEBUG)
  85. $(OBJ_DEBUG): $(OBJDIR_DEBUG)/__/src/%.o: ../src/%.cpp
  86. @echo " -> compiling $*.cpp"
  87. @$(CXX) $(CFLAGS_DEBUG) $(INC_DEBUG) -c $< -o $@
  88. clean_debug:
  89. @rm -f $(OBJ_DEBUG) $(OUT_DEBUG)
  90. @rm -rf $(BINDIR_DEBUG)
  91. @rm -rf $(OBJDIR_DEBUG)/__/src
  92. release: before_release out_release after_release
  93. before_release:
  94. @echo ; echo "building release configuration" ;
  95. @test -d $(BINDIR_RELEASE) || mkdir -p $(BINDIR_RELEASE)
  96. @test -d $(OBJDIR_RELEASE)/__/src || mkdir -p $(OBJDIR_RELEASE)/__/src
  97. after_release: $(ASSETS) $(WINLIBS)
  98. out_release: before_release $(OBJ_RELEASE) $(DEP_RELEASE)
  99. @echo "linking release binary"
  100. @$(LD) $(LIBDIR_RELEASE) -o $(OUT_RELEASE) $(OBJ_RELEASE) $(LDFLAGS_RELEASE) $(LIB_RELEASE)
  101. $(OBJ_RELEASE): $(OBJDIR_RELEASE)/__/src/%.o: ../src/%.cpp
  102. @echo " -> compiling $*.cpp"
  103. @$(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c $< -o $@
  104. clean_release:
  105. @rm -f $(OBJ_RELEASE) $(OUT_RELEASE)
  106. @rm -rf $(BINDIR_RELEASE)
  107. @rm -rf $(OBJDIR_RELEASE)/__/src
  108. $(ASSETS):
  109. @[ ! -d $(BINDIR_DEBUG) ] || [ -f $(BINDIR_DEBUG)/$@ ] || \
  110. ( echo "copying asset to debug bin directory: '$@'" ; \
  111. cp $(ASSETS_DIR)/$@ $(BINDIR_DEBUG)/$@ )
  112. @[ ! -d $(BINDIR_RELEASE) ] || [ -f $(BINDIR_RELEASE)/$@ ] || \
  113. ( echo "copying asset to release bin directory: '$@'" ; \
  114. cp $(ASSETS_DIR)/$@ $(BINDIR_RELEASE)/$@ )
  115. $(WINLIBS):
  116. @[ ! -d $(BINDIR_DEBUG) ] || [ -f $(BINDIR_DEBUG)/$@ ] || \
  117. ( echo "copying asset to debug bin directory: '$@'" ; \
  118. cp $(SYSBIN_DIR)/$@ $(BINDIR_DEBUG)/$@ )
  119. @[ ! -d $(BINDIR_RELEASE) ] || [ -f $(BINDIR_RELEASE)/$@ ] || \
  120. ( echo "copying asset to release bin directory: '$@'" ; \
  121. cp $(SYSBIN_DIR)/$@ $(BINDIR_RELEASE)/$@ )
  122. .PHONY: before_debug after_debug clean_debug before_release after_release clean_release