-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
44 lines (35 loc) · 802 Bytes
/
Makefile
File metadata and controls
44 lines (35 loc) · 802 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
CC=gcc
OBJDIR=obj
# open all warning
CFLAGS = -Wall
# include directories
CFLAGS += -I. -Iinclude
# library directories
LIB_DIRS = . src/
# libraries
LIBS = -lm
# set source files and object files under LIB_DIRS
SOURCE_FILES = ${foreach d, $(LIB_DIRS), ${subst ${d}/,,${wildcard $(d)/*.c}}}
OBJ_FILES := $(SOURCE_FILES:%.c=$(OBJDIR)/%.o)
#TODO: detect header file changes
# add src directories to path for building object files
vpath %.c $(LIB_DIRS)
# for tracing compilation
TRACE_CC = @echo " CC " $<
Q=@
# rules
build: $(OBJDIR) $(OBJ_FILES)
$(Q)echo " LINK"
$(CC) -o test $(OBJ_FILES) $(LIBS)
$(OBJDIR)/%.o: %.c
$(TRACE_CC)
$(Q)$(CC) $(CFLAGS) -c $< -o $@
$(OBJDIR):
$(Q)mkdir -p $(OBJDIR)
run:
$(Q)./test
clean:
rm -rf $(OBJDIR)
rm -f test
rm -f *.txt
rm -f images/*.bmp