# UNIVERSAL MAKEFILE # Credits: Massimo "Keebus" Tristano # www.keebus.net # # Licensed under GNU GPL license. #EDIT THIS! TARGET_NAME := application_name SOURCE_DIR := source #Release Configuration. Simply type "make" to compile with this configuration. CFLAGS := -O3 -Wall LDFLAGS := LDLIBS := INCLUDES := -I$(SOURCE_DIR) #Debug Configuration. Type "make debug" to compile with this configuration. CFLAGS_D := -g -O0 -Wall LDFLAGS_D := LDFLAGS_D := INCLUDES_D := -I$(SOURCE_DIR) #######DONT EDIT THIS PART IF YOU DONT KNOW EXACTLY WHAT YOU'RE DOING########### CC = gcc TARGET:= $(TARGET_NAME) TARGET_D := $(TARGET)_d SRC := $(shell find . -name "*.c" -print) OBJS := $(SRC:./$(SOURCE_DIR)/%.c=build/release/%.o) OBJS_D := $(SRC:./$(SOURCE_DIR)/%.c=build/debug/%.o) SRCDIR := $(shell find $(SOURCE_DIR) -type d -exec ls -d {} \;) DIR :=$(SRCDIR:$(SOURCE_DIR)%=build/release/%) DIR_D := $(SRCDIR:$(SOURCE_DIR)%=build/debug/%) ##########RELEASE############ all: release-info directories $(TARGET) @echo ">> Done :)" release-info: @echo ">> Building $(TARGET_NAME) with the release configuration..." directories: @mkdir -p $(DIR) $(TARGET) : $(OBJS) @echo ">> Linking..." $(CC) $(LDFLAGS) $(LDLIBS) $(OBJS) -o $(TARGET) $(OBJS): ./build/release/%.o : ./$(SOURCE_DIR)/%.c $(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@ ##########DEBUG############ debug: debug-info directories_d $(TARGET_D) @echo ">> Done :)" debug-info: @echo ">> Building $(TARGET_NAME) with the debug configuration..." directories_d: @mkdir -p $(DIR_D) $(TARGET_D) : $(OBJS_D) @echo ">> Linking..." $(CC) $(LDFLAGS_D) $(LDLIBS_D) $(OBJS_D) -o $(TARGET_D) $(OBJS_D): ./build/debug/%.o : ./$(SOURCE_DIR)/%.c $(CC) $(CFLAGS_D) $(INCLUDES_D) -c $< -o $@ ##########EXTRA########### clean: @echo ">> Polishing..." -rm -rf $(TARGET) $(TARGET_D) build @echo ">> Done :)"