-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmakefile
More file actions
47 lines (35 loc) · 1.52 KB
/
Copy pathmakefile
File metadata and controls
47 lines (35 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
INC_DIR = ./inc
SRC_DIR = ./src
OBJ_DIR = ./build/obj
BIN_DIR = ./build/out
SRC_FILES = $(wildcard $(SRC_DIR)/*.c)
OBJ_FILES = $(patsubst $(SRC_DIR)%.c,$(OBJ_DIR)%.o,$(SRC_FILES))
all: build_folders $(OBJ_FILES)
gcc $(OBJ_FILES) -o $(BIN_DIR)/app.out
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
gcc -c $< -I$(INC_DIR) -o $@
###############################################################################
# Creation of output folders
build_folders: $(BIN_DIR) $(LIB_DIR) $(OBJ_DIR) $(DOC_DIR) $(DPN_DIR) $(RST_DIR)
$(OUT_DIR):
@echo Creating output root folder
@mkdir $(OUT_DIR)
$(BIN_DIR): $(OUT_DIR)
@echo Creating output binaries folder
@mkdir $(BIN_DIR)
$(OBJ_DIR): $(OUT_DIR)
@echo Creating output objects folder
@mkdir $(OBJ_DIR)
###############################################################################
# Creation of file from
AUTHOR ?= $(shell git config --get user.name) <$(shell git config --get user.email)>
YEAR = $(shell echo $$(date +%Y))
.PRECIOUS: inc/%.h src/%.c
template/%: inc/%.h src/%.c
@echo "Creando un archivo desde las plantillas"
inc/%.h:
@echo "Creando $@ desde plantilla para $(AUTHOR)"
@awk "{gsub(/<year>/,\"$(YEAR)\");gsub(/<copyright holders>/,\"$(AUTHOR)\");gsub(/TEMPLATE_H_/,toupper(\"$*_H_\"));print}" templates/template.h >$@ && echo >>$@ && clang-format -i $@
src/%.c:
@echo "Creando $@ desde plantilla para $(AUTHOR)"
@awk "{gsub(/<year>/,\"$(YEAR)\");gsub(/<copyright holders>/,\"$(AUTHOR)\");gsub(/\"template.h\"/,\"\\\"$*.h\\\"\");print}" templates/template.c >$@ && echo >>$@ && clang-format -i $@