Makefile.mingw 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. # Makefile for win32 platforms with mingw under win32
  2. TARGET = sdlpal-mingw.exe
  3. TEST_TARGET = sdlpal-mingw-tests.exe
  4. INTER=.mingw
  5. HOST =
  6. TEST_CCFLAGS =
  7. GENERATED = -DPAL_HAS_GIT_REVISION $(shell ..\scripts\gengitrev.bat)
  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. override CCFLAGS += -g -msse2 -Wall -O2 -fno-strict-aliasing -I../3rd/mingw-std-threads -I../3rd/SDL/include -I. -I../ -I../liboggvorbis/include -I../liboggvorbis/src -DPAL_HAS_PLATFORM_SPECIFIC_UTILS $(TEST_CCFLAGS) $(GENERATED)
  18. CXXFLAGS = $(CCFLAGS) -std=c++11
  19. CFLAGS = $(CCFLAGS) -std=gnu99
  20. LDFLAGS = -lmingw32 -lSDL2main -lSDL2 -mwindows -lm -lwinmm -lole32 -loleaut32 -limm32 -lcomctl32 -luuid -lstrmiids -ldxguid -lversion -static -static-libgcc -static-libstdc++
  21. TEST_CXXFLAGS += -isystem $(GTEST_DIR)/include -I $(GTEST_DIR) -g -Wall -Wextra -pthread
  22. POSTCOMPILE = @move /Y $(subst /,\,$*)$(INTER).Td $(subst /,\,$*)$(INTER).d > NUL 2>&1 && type NUL >> $(subst /,\,$@)
  23. .PHONY : all clean check
  24. all: $(TARGET)
  25. $(TARGET): $(OBJFILES)
  26. @echo [LD] $@
  27. @$(HOST)g++ $^ -o $@ $(LDFLAGS)
  28. gtest-all.o : $(GTEST_DIR)/src/gtest-all.cc %.d
  29. @echo [CC] $<
  30. @$(HOST)g++ $(DEPFLAGS) $(TEST_CXXFLAGS) -c $< -o $@
  31. $(POSTCOMPILE)
  32. %$(INTER).o: %.c %$(INTER).d
  33. @echo [CC] $<
  34. @$(HOST)gcc $(DEPFLAGS) $(CFLAGS) -c $< -o $@
  35. $(POSTCOMPILE)
  36. %$(INTER).o: %.cpp %$(INTER).d
  37. @echo [CC] $<
  38. @$(HOST)g++ $(DEPFLAGS) $(CXXFLAGS) -c $< -o $@
  39. $(POSTCOMPILE)
  40. %$(INTER).o: %.rc
  41. @echo [RES] $^
  42. @$(HOST)windres -i $^ -o $@
  43. $(TEST_TARGET): $(OBJFILES) $(TEST_OBJFILES) gtest-all.o
  44. @echo [LD] $@
  45. @$(HOST)g++ $^ -o $@ $(LDFLAGS) -pthread
  46. clean:
  47. -del /Q $(subst /,\,$(TARGET)) $(subst /,\,$(TEST_TARGET)) $(subst /,\,$(OBJFILES)) $(subst /,\,$(TEST_OBJFILES)) $(subst /,\,$(DEPFILES)) 2> NUL
  48. %.d: ;
  49. .PRECIOUS: %.d
  50. -include $(DEPFILES)
  51. check: TEST_CCFLAGS = -DUNIT_TEST=1 -isystem $(GTEST_DIR)/include
  52. check: $(TEST_TARGET)
  53. @echo [EXEC] $(TEST_TARGET)
  54. @chmod +x $(TEST_TARGET)
  55. @exec $(TEST_TARGET)