Makefile 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. # Makefile for win32 platforms with mingw under msys or linux
  2. TARGET = sdlpal.exe
  3. TEST_TARGET = sdlpal-tests.exe
  4. INTER=.msys
  5. HOST =
  6. TEST_CCFLAGS =
  7. GENERATED = -DPAL_HAS_GIT_REVISION $(shell ../scripts/gengitrev)
  8. DEPFLAGS = -MT $@ -MMD -MP -MF $*$(INTER).Td
  9. GTEST_DIR = ../3rd/googletest/googletest
  10. CFILES = $(wildcard ../adplug/*.c) $(wildcard ../libmad/*.c) $(wildcard ../liboggvorbis/src/*.c) $(wildcard ../*.c) $(wildcard ../native_midi/*.c) $(wildcard ../win32/*.c)
  11. CPPFILES = $(wildcard ../adplug/*.cpp) $(wildcard ../*.cpp) $(wildcard ./*.cpp)
  12. RCFILES = $(wildcard ./sdlpal.rc)
  13. OBJFILES = $(CFILES:.c=$(INTER).o) $(CPPFILES:.cpp=$(INTER).o) $(RCFILES:.rc=$(INTER).o)
  14. DEPFILES = $(CFILES:.c=$(INTER).d) $(CPPFILES:.cpp=$(INTER).d)
  15. TEST_CPPFILES = $(wildcard ../tests/*.cpp)
  16. TEST_OBJFILES = $(TEST_CPPFILES:.cpp=.o)
  17. SDL_CONFIG = sdl2-config
  18. override CCFLAGS += `$(SDL_CONFIG) --cflags` -g -msse2 -Wall -O2 -fno-strict-aliasing -I. -I../ -I../liboggvorbis/include -I../liboggvorbis/src -DPAL_HAS_PLATFORM_SPECIFIC_UTILS $(TEST_CCFLAGS) $(GENERATED)
  19. CXXFLAGS = $(CCFLAGS) -std=c++11
  20. CFLAGS = $(CCFLAGS) -std=gnu99
  21. LDFLAGS = `$(SDL_CONFIG) --libs` -lm -lwinmm -lole32 -loleaut32 -limm32 -lcomctl32 -luuid -ldxguid -lstrmiids -lversion -static -static-libgcc -static-libstdc++
  22. TEST_CXXFLAGS += -isystem $(GTEST_DIR)/include -I $(GTEST_DIR) -g -Wall -Wextra -pthread
  23. POSTCOMPILE = @mv -f $*$(INTER).Td $*$(INTER).d && touch $@
  24. .PHONY : all clean check
  25. all: $(TARGET)
  26. $(TARGET): $(OBJFILES)
  27. @echo [LD] $@
  28. @$(HOST)g++ $^ -o $@ $(LDFLAGS)
  29. gtest-all.o : $(GTEST_DIR)/src/gtest-all.cc %.d
  30. @echo [CC] $<
  31. @$(HOST)g++ $(DEPFLAGS) $(TEST_CXXFLAGS) -c $< -o $@
  32. $(POSTCOMPILE)
  33. %$(INTER).o: %.c %$(INTER).d
  34. @echo [CC] $<
  35. @$(HOST)gcc $(DEPFLAGS) $(CFLAGS) -c $< -o $@
  36. $(POSTCOMPILE)
  37. %$(INTER).o: %.cpp %$(INTER).d
  38. @echo [CC] $<
  39. @$(HOST)g++ $(DEPFLAGS) $(CXXFLAGS) -c $< -o $@
  40. $(POSTCOMPILE)
  41. %$(INTER).o: %.rc
  42. @echo [RES] $^
  43. @$(HOST)windres -i $^ -o $@
  44. $(TEST_TARGET): $(OBJFILES) $(TEST_OBJFILES) gtest-all.o
  45. @echo [LD] $@
  46. @$(HOST)g++ $^ -o $@ $(LDFLAGS) -pthread
  47. clean:
  48. -rm -f $(TARGET) $(TEST_TARGET) $(OBJFILES) $(TEST_OBJFILES) $(DEPFILES)
  49. %.d: ;
  50. .PRECIOUS: %.d
  51. -include $(DEPFILES)
  52. check: TEST_CCFLAGS = -DUNIT_TEST=1 -isystem $(GTEST_DIR)/include
  53. check: $(TEST_TARGET)
  54. @echo [EXEC] $(TEST_TARGET)
  55. @chmod +x $(TEST_TARGET)
  56. @exec $(TEST_TARGET)