All pastes #1475561 Raw Edit

Universal Makefile

public shellscript v1 · immutable
#1475561 ·published 2009-06-26 15:37 UTC
rendered paste body
# UNIVERSAL MAKEFILE# Credits: Massimo "Keebus" Tristano #          www.keebus.net#          <massimo.tristano@gmail.com># Licensed under GNU GPL license.#EDIT THIS!TARGET_NAME := application_nameSOURCE_DIR := source#Release Configuration. Simply type "make" to compile with this configuration.CFLAGS := -O3 -WallLDFLAGS :=LDLIBS :=INCLUDES := -I$(SOURCE_DIR)#Debug Configuration. Type "make debug" to compile with this configuration.CFLAGS_D := -g -O0 -WallLDFLAGS_D :=LDFLAGS_D :=INCLUDES_D := -I$(SOURCE_DIR)#######DONT EDIT THIS PART IF YOU DONT KNOW EXACTLY WHAT YOU'RE DOING###########CC = gccTARGET:= $(TARGET_NAME)TARGET_D := $(TARGET)_dSRC := $(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 :)"