-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile-old
98 lines (83 loc) · 3.48 KB
/
Makefile-old
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
################################################################################
#| Project: RicoTech
#| Date: 2016-11-03
#| Author: Dan Bechard
################################################################################
# Directories
SRC_DIR := src
INC_DIR := include include/SDL include/GL include/AL ../dlb/include
OBJ_DIR := obj
LIB_DIR := lib
SRC_FILE := chet.c
OUT_FILE := $(LIB_DIR)/rico.lib
INCLUDE_DIRS := $(INC_DIR:%=-I%)
#SOURCES := $(wildcard $(SRC_DIR)/*.c)
#SOURCES := $(filter-out $(SRC_DIR)/notes.c, $(SOURCES))
#OBJECTS := $(patsubst $(SRC_DIR)/%,$(OBJ_DIR)/%,$(SOURCES:.c=.o))
SOURCES := $(SRC_FILE:%=$(SRC_DIR)/%)
OBJECTS := $(subst $(SRC_DIR)/,$(OBJ_DIR)/,$(SOURCES:.c=.o))
DEPS := $(OBJECTS:.o=.d)
# Compiler & flags
# Optimization flags:
# -O0 Disabled
# -Og Debug
# -O2 Release
# -O3 Extreme (Careful, might make EXE bigger or invoke undefined behavior!)
SHARED_FLAGS = -std=c99 -g -MMD -O0 -Wall -Wextra -Werror -Wno-unused-function #-Wno-missing-field-initializers -Wno-missing-braces -Wno-deprecated-declarations #-Wno-error=incompatible-pointer-types
GCC_FLAGS = -fmax-errors=3 -fsanitize=address -fno-omit-frame-pointer
#CLANG_FLAGS = -ferror-limit=3 -fcolor-diagnostics -Wno-macro-redefined -Wno-unknown-pragmas
CLANG_FLAGS = -fcolor-diagnostics -Wno-macro-redefined -Wno-unknown-pragmas -Wno-missing-field-initializers -Wno-missing-braces
CC = gcc #-v
CFLAGS = $(SHARED_FLAGS) $(GCC_FLAGS)
LDFLAGS = # None
default: prebuild build
copyright:
$(info =========================================================)
$(info # ______ _______ _ #)
$(info # | __ \ O |__ __| | | #)
$(info # | |__| |_ ___ ___ | | ___ ___| |__ #)
$(info # | _ /| |/ __/ _ \ | |/ _ \/ __| `_ \ #)
${info # | | \ \| | |_| (_) || | __/ |__| | | | #}
$(info # |_| \_\_|\___\___/ |_|\___|\___|_| |_| #)
$(info # #)
$(info # Copyright 2018 Dan Bechard #)
$(info =========================================================)
prebuild: copyright make-build-dirs
build: $(OUT_FILE)
################################################################################
# Link library
$(OUT_FILE): $(OBJECTS)
$(info [LIB] $@)
$(foreach O,$^,$(info + [OBJ] ${O}))
@ar rcs $@ $^
# Compile C files into OBJ files and generate dependencies
$(OBJECTS): $(SOURCES)
$(info [OBJ] $@)
$(foreach S,$^,$(info + [SRC] ${S}))
@$(CC) $(CFLAGS) $(INCLUDE_DIRS) -o $@ -c $<
make-build-dirs:
@mkdir -p $(LIB_DIR) $(OBJ_DIR)
# Include generated dependency files
-include $(DEPS)
# Delete all generated files
.PHONY: clean
clean:
$(info )
$(info ---- Clean [clean] -------------------------------------------------)
$(info [DEL] $(OUT_FILE))
-@rm $(OUT_FILE)
$(info [DEL] $(OBJ_DIR)/*)
-@rm -r $(OBJ_DIR)
$(info [DEL] $(LIB_DIR)/*)
-@rm -r $(LIB_DIR)
################################################################################
# Miscellaneous notes
################################################################################
#| $@ File name of target
#| $< Name of first prerequisite
#| $^ Name of all prerequisites, with spaces between them
#| $? Name of all prerequisites which have changed
#| % Wildcard, can be neighbored by prefix, suffix, or both
################################################################################
# Note: To use this, run e.g. `make print-SOURCES`
print-% : ; @echo $* = $($*)