-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
59 lines (42 loc) · 913 Bytes
/
Makefile
File metadata and controls
59 lines (42 loc) · 913 Bytes
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
SRC := test/hello.c test/plusplus.cpp
BUILDDIR := obj
MAGIC_DEFAULT_PROFILE := debug
define PROFILE.debug
MAGIC_TARGET := build
CFLAGS += -g
EXE_PREFIX := db_
endef
define PROFILE.release
MAGIC_TARGET := build
CFLAGS += -O2
LDFLAGS += -s
EXE_PREFIX := r_
endef
define PROFILE.profile
MAGIC_TARGET := build
CFLAGS += -O2 -g
EXE_PREFIX := p_
endef
define PROFILE.clean
MAGIC_NODEP := 1
endef
define PROFILE.run
$(PROFILE.debug)
PROFILEDIR := debug
endef
include magic.mk
CXXFLAGS := $(CFLAGS) -std=c++11
CFLAGS += -std=gnu99
EXEDIR := .
EXE := $(addprefix $(EXEDIR)/$(EXE_PREFIX),$(basename $(notdir $(SRC))))
.PHONY: build clean
build: $(EXE)
@echo "$(PROFILE) build complete."
define \n
endef
run: $(EXE)
$(foreach @,$(EXE),./$@ $(ARGS) $(\n))
$(EXE): $(EXEDIR)/$(EXE_PREFIX)%: $(OBJDIR)/%.o
$(CC) $^ $(LDFLAGS) -o $@
clean:
rm -f `find $(BUILDDIR)/ -name "*.[od]"`