Makefile 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. GTEST_DIR = ../3rd/googletest/googletest
  7. CFILES = $(wildcard ../adplug/*.c) $(wildcard ../libmad/*.c) $(wildcard ../liboggvorbis/src/*.c) $(wildcard ../*.c) $(wildcard ../native_midi/*.c) $(wildcard ../win32/*.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 += `sdl2-config --cflags` -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 = `sdl2-config --libs` -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. -rm -f $(TARGET) $(TEST_TARGET) $(OBJFILES) $(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)