-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
50 lines (34 loc) · 809 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
RM = rm -f
MKDIR = mkdir -p
7ZA = 7za
UNZIP = unzip -qq
BUILDD ?= build
SRCD ?= src
DATABASE ?= database.zip
PROGNAME ?= sql
EXECUTABLE ?= $(BUILDD)/$(PROGNAME)
ZIPFILE ?= ../zipfile.zip
CFILES = $(wildcard $(SRCD)/*.c)
OFILES = $(patsubst %.c,%.o, $(CFILES))
CFLAGS += -Wall
.PHONY: all clean zip run prepare_db valgrind debug
all: $(EXECUTABLE)
clean:
@$(RM) $(OFILES)
@$(RM) $(ZIPFILE)
@$(RM) $(EXECUTABLE)
zip: clean prepare_db
$(7ZA) a $(ZIPFILE) ./*
prepare_db:
@$(MKDIR) $(BUILDD)
$(UNZIP) -u -d $(BUILDD) $(DATABASE)
run: $(EXECUTABLE)
cd $(BUILDD) && ./$(PROGNAME)
valgrind: $(EXECUTABLE)
cd $(BUILDD) && valgrind ./$(PROGNAME)
debug: CFLAGS+=-g
debug: clean
debug: $(EXECUTABLE)
$(EXECUTABLE): $(OFILES)
@$(MKDIR) $(BUILDD)
$(CC) $(LDFLAGS) $(OFILES) -o $(EXECUTABLE)