Makefile (1000B)
1 SOURCE_PATH := src 2 OBJECT_PATH := dist 3 BIN_PATH := bin 4 EXECUTABLE := init 5 EXEC_SRC_PATH := src/exec 6 7 CC := gcc 8 CFLAGS := -O2 -Wall -Wextra -Iincl 9 LDFLAGS := -static 10 11 EXEC_SRC_FILES := $(wildcard $(EXEC_SRC_PATH)/*.c) 12 EXEC_FILES := $(patsubst $(EXEC_SRC_PATH)/%.c,$(BIN_PATH)/%,$(EXEC_SRC_FILES)) 13 14 SOURCE_FILES := $(wildcard $(SOURCE_PATH)/*.c) 15 OBJECT_FILES := $(patsubst $(SOURCE_PATH)/%.c,$(OBJECT_PATH)/%.o,$(SOURCE_FILES)) 16 17 .PRECIOUS: $(OBJECT_PATH)/%.o 18 19 all: compile_flags.txt $(EXEC_FILES) 20 21 clean: 22 rm -rf $(BIN_PATH) $(OBJECT_PATH) 23 24 $(BIN_PATH) $(OBJECT_PATH): 25 mkdir -p $@ 26 27 $(OBJECT_PATH)/%.o: $(SOURCE_PATH)/%.c Makefile $(HEADER_FILES) | $(OBJECT_PATH) 28 $(CC) -o $@ -c $(CFLAGS) $< 29 30 $(BIN_PATH)/%: $(EXEC_SRC_PATH)/%.c $(OBJECT_FILES) $(HEADER_FILES) | $(BIN_PATH) 31 $(CC) -o $@ $(CFLAGS) $< $(OBJECT_FILES) $(LDFLAGS) $(LDFLAGS_$(patsubst $(BIN_PATH)/%,%,$@)) 32 33 compile_flags.txt: Makefile 34 echo $(CFLAGS) | tr " " "\n" > compile_flags.txt