Makefile 2.0 KB

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