-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
79 lines (46 loc) · 1.6 KB
/
makefile
File metadata and controls
79 lines (46 loc) · 1.6 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
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
####################################################
# #
# Men became scientific because they expected #
# law in nature, and they expected law in nature #
# because they believed in a Legislator. #
# #
# ~ C.S. Lewis #
# #
####################################################
# Specify output binary name:
TARGET := swap-vector
CC := gcc
INCLUDES := include
LIBS :=
LIBDIRS :=
SOURCES := src
BUILD := build
export INCLUDE := $(foreach dir, $(INCLUDES), -I$(dir))
SRCS := $(foreach f, $(SOURCES), $(wildcard $(f)/*.c))
FILES := $(CFILES:.c=)
export OBJS := $(foreach f, $(SRCS), $(addprefix $(BUILD)/, $(f:.c=.o)))
DEPENDS := $(wildcard ../$(BUILD)/*.d)
LDFLAGS :=
VPATH = $(foreach dir, $(SOURCES), ../$(dir)) $(foreach dir, $(INCLUDES), $(dir))
OPTFLAGS := -Ofast -ffast-math \
-ffunction-sections \
-fmerge-all-constants -Wl,--gc-sections \
-flto -fomit-frame-pointer \
DEBUGOPTFLAGS := -g
NO_WARNINGS := -Wno-unused-result
CFLAGS := $(INCLUDE) $(OPTFLAGS) $(NO_WARNINGS) -std=c17 -MMD -MP -Wall
.PHONY: all dev clean
all: $(TARGET)
-include $(DEPENDS)
$(OBJS): $(BUILD)/%.o : %.c | $(BUILD) $(BUILD)/src
$(CC) $(CFLAGS) $(CPPFLAGS) $< -MMD -MF $(@:.o=.d) -c -o $@
$(TARGET): $(OBJS) | $(BUILD)
$(CC) $(OBJS) -o $(TARGET) $(LDFLAGS)
$(BUILD) $(BUILD)/src:
mkdir -p $@
clean:
@echo clean ...
@rm -f $(TARGET)
@rm -rf $(BUILD)
run:
@./$(TARGET)