Makefile 2.2 KB

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