-
Notifications
You must be signed in to change notification settings - Fork 6
/
makefile
43 lines (32 loc) · 1.18 KB
/
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
36
37
38
39
40
41
42
#-----------------------------------------------------------------------
# config
#-----------------------------------------------------------------------
# name of the target executable
EXE := test
# list of files tp delete when cleaning
TO_CLEAN := *.o $(EXE)
# override compiler flags to give us no break
CFLAGS := -Wall -pedantic $(DEBUG)
# compiler
CC := g++
#-----------------------------------------------------------------------
# main
#-----------------------------------------------------------------------
# create the list of *.o files based on auto dependencies
OBJECTS := $(shell $(CC) -MM $(INCLUDE) test.cpp html_template.cpp | awk -F": " '{ if(NF<2){next;} ;ORS=" "; print $$1}')
#-----------------------------------------------------------------------
all: $(EXE)
# rule to create an object file
%.o: %.cpp %.h
$(CC) $(CFLAGS) $(INCLUDE) $(LIB) -c $<
# create the executable
$(EXE): $(OBJECTS)
$(CC) $(CFLAGS) $^ -o $@
#-----------------------------------------------------------------------
clean:
-rm $(TO_CLEAN)
#-----------------------------------------------------------------------
.PHONY: debug
debug:
$(MAKE) clean
$(MAKE) DEBUG="-g -DDEBUG -DDEBUG2 -DDEBUG3"