# A makefile that should work for any SSDL projects running on Unix # Adapt as needed # -- from the SDL (Simple SDL) library, but no copyright is claimed # Thanks https://stackoverflow.com/questions/50114325/capitalize-first-letter-of-string-in-makefile-using-bash-4-syntax EXECUTABLE = $(shell basename $(CURDIR)) #What are our source files, and where are they? # All .c, .cpp, and .cc files C_SOURCES = $(wildcard *.c) CPP_SOURCES = $(wildcard *.cpp) CC_SOURCES = $(wildcard *.cc) #So what are our object files, and where are they? # Anything we can make with those source files C_OBJECTS = ${C_SOURCES: .c =.o} CPP_OBJECTS = ${CPP_SOURCES:.cpp=.o} CC_OBJECTS = ${CC_SOURCES: .cc =.o} ALL_OBJECTS = $(notdir $(C_OBJECTS) $(CPP_OBJECTS) $(CC_OBJECTS)) #Tell g++ where to find include files for SDL2, SSDL, {fmt} INCLUDE_FLAGS = `sdl2-config --cflags` -I${HOME}/external/SSDL/include \ -I${HOME}/external/fmt-master/include LANGUAGE_FLAGS = -std=gnu++2a #Specify language standard: C++20 #MinGW can't do the fmt library # unless we specify gnu++ to add gnu # extensions, so I'll just use it throughout. #Tell g++ where to find library files for SDL2, SSDL LIBRARIES = ssdl SDL2_image SDL2_ttf SDL2_mixer LIBRARY_DIRS = ${HOME}/external/SSDL/unix LIB_FLAGS = -L$(LIBRARY_DIRS) `sdl2-config --libs` \ $(foreach library,$(LIBRARIES), -l$(library)) ALL_FLAGS = $(INCLUDE_FLAGS) $(LANGUAGE_FLAGS) $(LIB_FLAGS) ########################################################################## all: $(EXECUTABLE) .PHONY: all clean showvars showvars: @ echo $(CPP_SOURCES) "-->" $(CPP_OBJECTS) @ echo ALL_FLAGS $(ALL_FLAGS) $(EXECUTABLE): $(ALL_OBJECTS) # @ echo 'ALL_FLAGS :' $(ALL_FLAGS) g++ -o $@ -g $^ $(ALL_FLAGS) # @ # -g means: support debugging # @ # $^ means: use all the objects # @ # -o $@ means: let the output be called $(EXECUTABLE) clean: rm -f $(EXECUTABLE) rm -f $(ALL_OBJECTS) rm -f core rm -f *.ncb *.sdf rm -r -f Debug Release .vs Backup $(C_OBJECTS): %.o : %.c g++ -g -c $(INCLUDE_FLAGS) $(LANGUAGE_FLAGS) $< -o $@ $(CC_OBJECTS): %.o : %.cc g++ -g -c $(INCLUDE_FLAGS) $(LANGUAGE_FLAGS) $< -o $@ $(CPP_OBJECTS): %.o : %.cpp g++ -g -c $(INCLUDE_FLAGS) $(LANGUAGE_FLAGS) $< -o $@