Makefile 2.0 KB

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