Makefile 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # Makefile for win32 platforms with mingw
  2. TARGET = sdlpal.exe
  3. TEST_TARGET = ./sdlpal-tests
  4. HOST =
  5. 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
  6. CFILES := $(filter-out ../main.c, $(CFILES))
  7. CPPFILES = $(wildcard ../adplug/*.cpp) $(wildcard ../*.cpp) $(wildcard ./*.cpp)
  8. OBJFILES = $(CFILES:.c=.o) $(CPPFILES:.cpp=.o) sdlpal.o
  9. TEST_CPPFILES = $(wildcard ../tests/*.cpp)
  10. TEST_OBJFILES = $(TEST_CPPFILES:.cpp=.o)
  11. GTEST_DIR = ../3rd/googletest/googletest
  12. GTEST_HEADERS = $(GTEST_DIR)/include/gtest/*.h \
  13. $(GTEST_DIR)/include/gtest/internal/*.h
  14. GTEST_SRCS_ = $(GTEST_DIR)/src/*.cc $(GTEST_DIR)/src/*.h $(GTEST_HEADERS)
  15. TEST_CPPFLAGS += -isystem $(GTEST_DIR)/include
  16. TEST_CXXFLAGS += -g -Wall -Wextra -pthread
  17. override CCFLAGS += `sdl2-config --cflags` -msse -Wall -O2 -fno-strict-aliasing -I. -I../ -I../liboggvorbis/include -I../liboggvorbis/src -DPAL_HAS_PLATFORM_SPECIFIC_UTILS -I$(GTEST_DIR)
  18. CXXFLAGS = $(CCFLAGS) -std=c++11 $(TEST_CPPFLAGS) $(TEST_CXXFLAGS)
  19. CFLAGS = $(CCFLAGS) -std=gnu99
  20. LDFLAGS = `sdl2-config --libs` -lm -lwinmm -lole32 -loleaut32 -limm32 -lcomctl32 -luuid -ldxguid -lversion -static -static-libgcc -static-libstdc++
  21. TEST_LDFLAGS = -L/mingw32/lib -lSDL2 -mconsole -lm -lgdi32 -lwinmm -lole32 -loleaut32 -limm32 -lcomctl32 -luuid -ldxguid -lversion -static -static-libgcc -static-libstdc++
  22. all: $(TARGET)
  23. gtest-all.o : $(GTEST_SRCS_)
  24. $(CXX) $(CXXFLAGS) -c \
  25. $(GTEST_DIR)/src/gtest-all.cc
  26. $(TARGET): $(OBJFILES) ../main.o
  27. $(HOST)g++ $^ -o $@ $(LDFLAGS)
  28. $(TEST_TARGET): $(OBJFILES) $(TEST_OBJFILES) main-test.o gtest-all.o
  29. $(HOST)g++ $^ -o $@ $(TEST_LDFLAGS)
  30. %.o: %.c
  31. $(HOST)gcc $(CFLAGS) -c $< -o $@
  32. %.o: %.cpp
  33. $(HOST)g++ $(CXXFLAGS) -c $< -o $@
  34. main-test.o: ../main.c
  35. $(HOST)gcc $(CFLAGS) -DUNIT_TEST=1 -c $< -o $@
  36. %.o: %.rc
  37. windres -i $< -o $@
  38. clean:
  39. -rm -f $(TARGET) $(TEST_TARGET) *.o ../*.o ../adplug/*.o ../libmad/*.o ../liboggvorbis/src/*.o
  40. check: $(TEST_TARGET)
  41. chmod +x $(TEST_TARGET)
  42. exec $(TEST_TARGET)