Makefile.mingw 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # Makefile for win32 platforms with mingw under win32
  2. TARGET = sdlpal.exe
  3. TEST_TARGET = sdlpal-tests.exe
  4. HOST =
  5. TEST_CCFLAGS =
  6. GTEST_DIR = ../3rd/googletest/googletest
  7. CFILES = $(wildcard ../adplug/*.c) $(wildcard ../libmad/*.c) $(wildcard ../liboggvorbis/src/*.c) $(wildcard ../*.c) ../native_midi/native_midi_win32.c ../native_midi/native_midi_common.c
  8. CPPFILES = $(wildcard ../adplug/*.cpp) $(wildcard ../*.cpp) $(wildcard ./*.cpp)
  9. RCFILES = $(wildcard ./sdlpal.rc)
  10. OBJFILES = $(CFILES:.c=.o) $(CPPFILES:.cpp=.o) $(RCFILES:.rc=.o)
  11. TEST_CPPFILES = $(wildcard ../tests/*.cpp)
  12. TEST_OBJFILES = $(TEST_CPPFILES:.cpp=.o)
  13. override CCFLAGS += -g -msse -Wall -O2 -fno-strict-aliasing -I. -I../ -I../liboggvorbis/include -I../liboggvorbis/src -DPAL_HAS_PLATFORM_SPECIFIC_UTILS $(TEST_CCFLAGS)
  14. CXXFLAGS = $(CCFLAGS) -std=c++11
  15. CFLAGS = $(CCFLAGS) -std=gnu99
  16. LDFLAGS = -lmingw32 -lSDL2main -lSDL2 -mwindows -lm -lwinmm -lole32 -loleaut32 -limm32 -lcomctl32 -luuid -ldxguid -lversion -static -static-libgcc -static-libstdc++
  17. TEST_CXXFLAGS += -isystem $(GTEST_DIR)/include -I $(GTEST_DIR) -g -Wall -Wextra -pthread
  18. .PHONY : all clean check
  19. all: $(TARGET)
  20. $(TARGET): $(OBJFILES)
  21. @echo [LD] $@
  22. @$(HOST)g++ $^ -o $@ $(LDFLAGS)
  23. gtest-all.o : $(GTEST_DIR)/src/gtest-all.cc
  24. @echo [CC] $^
  25. @$(HOST)g++ $(TEST_CXXFLAGS) -c $^ -o $@
  26. %.o: %.c
  27. @echo [CC] $^
  28. @$(HOST)gcc $(CFLAGS) -c $^ -o $@
  29. %.o: %.cpp
  30. @echo [CC] $^
  31. @$(HOST)g++ $(CXXFLAGS) -c $^ -o $@
  32. %.o: %.rc
  33. @echo [RES] $^
  34. @$(HOST)windres -i $^ -o $@
  35. $(TEST_TARGET): $(OBJFILES) $(TEST_OBJFILES) gtest-all.o
  36. @echo [LD] $@
  37. @$(HOST)g++ $^ -o $@ $(LDFLAGS) -pthread
  38. clean:
  39. -del /Q $(subst /,\,$(TARGET)) $(subst /,\,$(TEST_TARGET)) $(subst /,\,$(OBJFILES)) $(subst /,\,$(TEST_OBJFILES))
  40. check: TEST_CCFLAGS = -DUNIT_TEST=1 -isystem $(GTEST_DIR)/include
  41. check: $(TEST_TARGET)
  42. @echo [EXEC] $(TEST_TARGET)
  43. @chmod +x $(TEST_TARGET)
  44. @exec $(TEST_TARGET)