Makefile 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # General makefile for generic unix & linux platforms
  2. TARGET = sdlpal
  3. TEST_TARGET = ./sdlpal-tests
  4. HOST =
  5. CFILES = $(wildcard ../adplug/*.c) $(wildcard ../libmad/*.c) $(wildcard ../liboggvorbis/src/*.c) $(wildcard ../*.c)
  6. CFILES := $(filter-out ../main.c, $(CFILES))
  7. CPPFILES = $(wildcard ../adplug/*.cpp) $(wildcard ../*.cpp) $(wildcard ./*.cpp)
  8. OBJFILES = $(CFILES:.c=.o) $(CPPFILES:.cpp=.o)
  9. TEST_CPPFILES = $(wildcard ../tests/*.cpp)
  10. TEST_OBJFILES = $(TEST_CPPFILES:.cpp=.o)
  11. GTEST_DIR = ../3rd/googletest/googletest
  12. GTEST_HEADERS = $(GTEST_DIR)/include/gtest/*.h \
  13. $(GTEST_DIR)/include/gtest/internal/*.h
  14. GTEST_SRCS_ = $(GTEST_DIR)/src/*.cc $(GTEST_DIR)/src/*.h $(GTEST_HEADERS)
  15. TEST_CPPFLAGS += -isystem $(GTEST_DIR)/include
  16. TEST_CXXFLAGS += -g -Wall -Wextra -pthread
  17. CCFLAGS = `sdl2-config --cflags` -g -Wall -O2 -fno-strict-aliasing -I. -I../ -I../liboggvorbis/include -I../liboggvorbis/src -DPAL_HAS_PLATFORM_SPECIFIC_UTILS -I$(GTEST_DIR)
  18. CXXFLAGS = $(CCFLAGS) -std=c++11 `fltk-config --cxxflags` $(TEST_CPPFLAGS) $(TEST_CXXFLAGS)
  19. CFLAGS = $(CCFLAGS) -std=gnu99 `fltk-config --cflags`
  20. LDFLAGS = `sdl2-config --libs` `fltk-config --ldflags` -lstdc++ -lm
  21. all: $(TARGET)
  22. gtest-all.o : $(GTEST_SRCS_)
  23. $(CXX) $(CXXFLAGS) -c \
  24. $(GTEST_DIR)/src/gtest-all.cc
  25. $(TARGET): $(OBJFILES) ../main.o
  26. $(HOST)g++ $^ -o $@ $(LDFLAGS)
  27. $(TEST_TARGET): $(OBJFILES) $(TEST_OBJFILES) main-test.o gtest-all.o
  28. $(HOST)g++ $^ -o $@ $(LDFLAGS)
  29. %.o: %.c
  30. $(HOST)gcc $(CFLAGS) -c $< -o $@
  31. %.o: %.cpp
  32. $(HOST)g++ $(CXXFLAGS) -c $< -o $@
  33. main-test.o: ../main.c
  34. $(HOST)gcc $(CFLAGS) -DUNIT_TEST=1 -c $< -o $@
  35. clean:
  36. -rm -f $(TARGET) $(TEST_TARGET) *.o ../*.o ../adplug/*.o ../libmad/*.o ../liboggvorbis/src/*.o
  37. check: $(TEST_TARGET)
  38. chmod +x $(TEST_TARGET)
  39. exec $(TEST_TARGET)