123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- # General makefile for generic unix & linux platforms
- TARGET = sdlpal
- TEST_TARGET = ./sdlpal-tests
- HOST =
- TEST_CCFLAGS =
- GENERATED = -DPAL_HAS_GIT_REVISION $(shell ../scripts/gengitrev)
- DEPFLAGS = -MT $@ -MMD -MP -MF $*.Td
- GTEST_DIR = ../3rd/googletest/googletest
- CFILES = $(wildcard ../adplug/*.c) $(wildcard ../libmad/*.c) $(wildcard ../liboggvorbis/src/*.c) $(wildcard ../*.c)
- CPPFILES = $(wildcard ../adplug/*.cpp) $(wildcard ../*.cpp) $(wildcard ./*.cpp)
- OBJFILES = $(CFILES:.c=.o) $(CPPFILES:.cpp=.o)
- DEPFILES = $(OBJFILES:.o=.d)
- TEST_CPPFILES = $(wildcard ../tests/*.cpp)
- TEST_OBJFILES = $(TEST_CPPFILES:.cpp=.o)
- 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) $(GENERATED)
- CXXFLAGS = $(CCFLAGS) -std=c++11 `fltk-config --cxxflags`
- CFLAGS = $(CCFLAGS) -std=gnu99 `fltk-config --cflags`
- LDFLAGS = `sdl2-config --libs` `fltk-config --ldflags` -lstdc++ -lm -pthread
- TEST_CXXFLAGS += -isystem $(GTEST_DIR)/include -I $(GTEST_DIR) -g -Wall -Wextra -pthread
- POSTCOMPILE = @mv -f $*.Td $*.d && touch $@
- .PHONY : all clean check
- all: $(TARGET)
- $(TARGET): $(OBJFILES)
- @echo [LD] $@
- @$(HOST)gcc $^ -o $@ $(LDFLAGS)
- gtest-all.o : $(GTEST_DIR)/src/gtest-all.cc %.d
- @echo [CC] $<
- @$(HOST)g++ $(DEPFLAGS) $(TEST_CXXFLAGS) -c $< -o $@
- $(POSTCOMPILE)
- %.o: %.c %.d
- @echo [CC] $<
- @$(HOST)gcc $(DEPFLAGS) $(CFLAGS) -c $< -o $@
- $(POSTCOMPILE)
- %.o: %.cpp %.d
- @echo [CC] $<
- @$(HOST)g++ $(DEPFLAGS) $(CXXFLAGS) -c $< -o $@
- $(POSTCOMPILE)
- $(TEST_TARGET): $(OBJFILES) $(TEST_OBJFILES) gtest-all.o
- @echo [LD] $@
- @$(HOST)g++ $^ -o $@ $(LDFLAGS) -lpthread
- clean:
- -rm -f $(TARGET) $(TEST_TARGET) $(OBJFILES) $(TEST_OBJFILES) $(DEPFILES)
- %.d: ;
- .PRECIOUS: %.d
- -include $(DEPFILES)
- check: TEST_CCFLAGS = -DUNIT_TEST=1 -isystem $(GTEST_DIR)/include
- check: $(TEST_TARGET)
- @echo [EXEC] $(TEST_TARGET)
- @chmod +x $(TEST_TARGET)
- @exec $(TEST_TARGET)
|