-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
35 lines (26 loc) · 826 Bytes
/
Makefile
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
# Project name (can be overridden by PROJ_NAME=... make ...)
PROJ_NAME ?= $(shell basename $(CURDIR))
# Compiler options
CCDEFS := -D_UNIT_TEST_ -DCUTEST_PROJECT_NAME="\"$(PROJ_NAME)\""
CCFLAGS := -Wall
# Linker options
LDFLAGS := -z execstack
# Auto-detect include dirs
INCLUDE := $(shell find -type d -not -path '.' -not -path './.*')
# Auto-detect sources and generate object names
SRCS := $(shell find -name '*.c')
OBJS := $(SRCS:%.c=%.o)
# Used libraries
LIBS := cutest
# Compile object files
%.o: %.c
gcc $(CCFLAGS) $(CCDEFS) $(addprefix -I,$(INCLUDE)) -c $< -o $@
# Link into executable
$(PROJ_NAME): $(OBJS)
gcc $^ $(LDFLAGS) $(addprefix -l,$(LIBS)) -o $@
# 'all' build target
all: $(PROJ_NAME)
./$<
# 'clean' build target
clean:
@rm -rf $(PROJ_NAME) $(OBJS) report.html