Makefile 2.1 KB

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