Makefile 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. # General makefile for generic unix & linux platforms
  2. TARGET = sdlpal
  3. TEST_TARGET = ./sdlpal-tests
  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)
  10. CPPFILES = $(wildcard ../adplug/*.cpp) $(wildcard ../*.cpp) $(wildcard ./*.cpp)
  11. OBJFILES = $(CFILES:.c=.o) $(CPPFILES:.cpp=.o)
  12. DEPFILES = $(OBJFILES:.o=.d)
  13. TEST_CPPFILES = $(wildcard ../tests/*.cpp)
  14. TEST_OBJFILES = $(TEST_CPPFILES:.cpp=.o)
  15. CCFLAGS = `sdl2-config --cflags` -g -Wall -O2 -fno-strict-aliasing -I. -I../ -I../liboggvorbis/include -I../liboggvorbis/src -DPAL_HAS_PLATFORM_SPECIFIC_UTILS $(TEST_CCFLAGS) $(GENERATED)
  16. CXXFLAGS = $(CCFLAGS) -std=c++11 `fltk-config --cxxflags`
  17. CFLAGS = $(CCFLAGS) -std=gnu99 `fltk-config --cflags`
  18. LDFLAGS = `sdl2-config --libs` `fltk-config --ldflags` -lstdc++ -lm -pthread
  19. TEST_CXXFLAGS += -isystem $(GTEST_DIR)/include -I $(GTEST_DIR) -g -Wall -Wextra -pthread
  20. POSTCOMPILE = @mv -f $*.Td $*.d && touch $@
  21. .PHONY : all clean check
  22. all: $(TARGET)
  23. $(TARGET): $(OBJFILES)
  24. @echo [LD] $@
  25. @$(HOST)gcc $^ -o $@ $(LDFLAGS)
  26. gtest-all.o : $(GTEST_DIR)/src/gtest-all.cc %.d
  27. @echo [CC] $<
  28. @$(HOST)g++ $(DEPFLAGS) $(TEST_CXXFLAGS) -c $< -o $@
  29. $(POSTCOMPILE)
  30. %.o: %.c %.d
  31. @echo [CC] $<
  32. @$(HOST)gcc $(DEPFLAGS) $(CFLAGS) -c $< -o $@
  33. $(POSTCOMPILE)
  34. %.o: %.cpp %.d
  35. @echo [CC] $<
  36. @$(HOST)g++ $(DEPFLAGS) $(CXXFLAGS) -c $< -o $@
  37. $(POSTCOMPILE)
  38. $(TEST_TARGET): $(OBJFILES) $(TEST_OBJFILES) gtest-all.o
  39. @echo [LD] $@
  40. @$(HOST)g++ $^ -o $@ $(LDFLAGS) -lpthread
  41. clean:
  42. -rm -f $(TARGET) $(TEST_TARGET) $(OBJFILES) $(TEST_OBJFILES) $(DEPFILES)
  43. %.d: ;
  44. .PRECIOUS: %.d
  45. -include $(DEPFILES)
  46. check: TEST_CCFLAGS = -DUNIT_TEST=1 -isystem $(GTEST_DIR)/include
  47. check: $(TEST_TARGET)
  48. @echo [EXEC] $(TEST_TARGET)
  49. @chmod +x $(TEST_TARGET)
  50. @exec $(TEST_TARGET)