1# Project: Linwarrior 3D 2# Makefile with auto-dependency generation 3 4# Add Include directories here. 5INCLUDES = -I . `${SDL_CONFIG} --cflags` 6 7# Automatic searching for source files. 8# Objects to compile are all sources (cpp) and put the .o below build-dir. 9OBJECTS=$(addprefix build/, $(subst .cpp,.o, $(wildcard source/*.cpp source/*/*.cpp) ) ) 10 11# Different Parameters and Programms for different OSes. 12ifneq (,$(findstring Win,$(OS))) 13 LIBRARIES= -lmingw32 -lSDLmain -lSDL -lOpenGL32 -lGLU32 -lopenal32 -lalut 14 TARGET=dist\linwarrior.exe 15 MKDIR=mkdir 16 CP=copy 17 RM=cmd /C del /Q 18 RMREC=cmd /C del /Q /S 19 CPP=c++ 20 LIMITER=$(dir \file) 21 CFLAGS+= -static-libgcc 22else 23 LIBRARIES= ${LDFLAGS} -lGL -lGLU `${SDL_CONFIG} --libs` -lopenal -lalut 24 TARGET=dist/linwarrior 25 MKDIR=mkdir 26 RM=rm -f 27 RMREC=rm -f -r 28 CP=cp 29 CPP=${CXX} 30 LIMITER=/ 31endif 32 33# Creation of dependency information when compiling. 34 35# Print warnings when compiling. 36CXXFLAGS += -Wall 37 38# Use the given includepathes. 39CXXFLAGS += $(INCLUDES) 40 41# Optimizations. 42 43# Default makefile Target. 44all: $(TARGET) 45 46# For executable we need all sources compiled to objects. 47$(TARGET): $(OBJECTS) 48 $(CXX) -o $(TARGET) $(OBJECTS) ${LDFLAGS} $(LIBRARIES) 49 50# Compile all Source files, creates output directories as necessary. 51build/%.o: %.cpp 52 $(shell $(MKDIR) build 2>/dev/null) 53 $(shell $(MKDIR) $(dir $@) 2>/dev/null) 54 $(CXX) $(CXXFLAGS) -c $< -o $@ 55 56# IDE may call makefile with target "build" instead of "all". 57build: all 58 59# May call clean before build to delete previous relics. 60.PHONY: clean 61clean: 62 $(RM) $(TARGET) 63 $(RM) dep$(LIMITER)*.o.d 64 $(RM) build$(LIMITER)source$(LIMITER)*.o 65 66clean_win: 67 $(RM) '$(TARGET)' 68 $(RM) 'dep$(LIMITER)*.o.d' 69 $(RM) 'build$(LIMITER)source$(LIMITER)*.o' 70 71# Target to compile doxygen helpfiles from code and comments see conf file. 72doxygen: 73 doxygen doxygen.conf 74 75# Include autogenerated dependency files (silently makedir if not exiting). 76-include $(shell $(MKDIR) dep 2>/dev/null) $(wildcard dep/*) 77 78