Makefile 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # General makefile for generic unix & linux platforms
  2. TARGET = sdlpal
  3. TEST_TARGET = ./sdlpal-tests
  4. HOST =
  5. TEST_CCFLAGS =
  6. GTEST_DIR = ../3rd/googletest/googletest
  7. CFILES = $(wildcard ../adplug/*.c) $(wildcard ../libmad/*.c) $(wildcard ../liboggvorbis/src/*.c) $(wildcard ../*.c)
  8. CPPFILES = $(wildcard ../adplug/*.cpp) $(wildcard ../*.cpp) $(wildcard ./*.cpp)
  9. OBJFILES = $(CFILES:.c=.o) $(CPPFILES:.cpp=.o)
  10. TEST_CPPFILES = $(wildcard ../tests/*.cpp)
  11. TEST_OBJFILES = $(TEST_CPPFILES:.cpp=.o)
  12. 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)
  13. CXXFLAGS = $(CCFLAGS) -std=c++11 `fltk-config --cxxflags`
  14. CFLAGS = $(CCFLAGS) -std=gnu99 `fltk-config --cflags`
  15. LDFLAGS = `sdl2-config --libs` `fltk-config --ldflags` -lstdc++ -lm -pthread
  16. TEST_CXXFLAGS += -isystem $(GTEST_DIR)/include -I $(GTEST_DIR) -g -Wall -Wextra -pthread
  17. .PHONY : all clean check
  18. all: $(TARGET)
  19. $(TARGET): $(OBJFILES)
  20. @echo [LD] $@
  21. @$(HOST)gcc $^ -o $@ $(LDFLAGS)
  22. gtest-all.o : $(GTEST_DIR)/src/gtest-all.cc
  23. @echo [CC] $^
  24. @$(HOST)g++ $(TEST_CXXFLAGS) -c $< -o $@
  25. %.o: %.c
  26. @echo [CC] $^
  27. @$(HOST)gcc $(CFLAGS) -c $< -o $@
  28. %.o: %.cpp
  29. @echo [CC] $^
  30. @$(HOST)g++ $(CXXFLAGS) -c $< -o $@
  31. $(TEST_TARGET): $(OBJFILES) $(TEST_OBJFILES) gtest-all.o
  32. @echo [LD] $@
  33. @$(HOST)g++ $^ -o $@ $(LDFLAGS) -lpthread
  34. clean:
  35. -rm -f $(TARGET) $(TEST_TARGET) *.o ../*.o ../adplug/*.o ../libmad/*.o ../liboggvorbis/src/*.o ../tests/*.o
  36. check: TEST_CCFLAGS = -DUNIT_TEST=1 -isystem $(GTEST_DIR)/include
  37. check: $(TEST_TARGET)
  38. @echo [EXEC] $(TEST_TARGET)
  39. @chmod +x $(TEST_TARGET)
  40. @exec $(TEST_TARGET)