-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
45 lines (34 loc) · 886 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
SDIR=src
IDIR=include
ODIR=obj
LDIR=lib
OUTDIR=bin
TESTSDIR=tests
OUTNAME=pascal
CC=gcc
CFLAGS=-Wall -I$(IDIR) -g -std=c99
LIBS=
_DEPS =
DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS))
_OBJ = $(patsubst $(SDIR)/%.c,%.o,$(wildcard $(SDIR)/*.c))
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))
OBJ_TEST = $(filter-out obj/pascal.o,$(OBJ))
TESTS = $(wildcard $(TESTSDIR)/*.c)
$(ODIR)/%.o: $(SDIR)/%.c $(DEPS)
@mkdir -p $(ODIR)
$(CC) -c -o $@ $< $(CFLAGS)
$(OUTDIR)/$(OUTNAME): $(OBJ)
@mkdir -p $(OUTDIR)
gcc -o $@ $^ $(CFLAGS) $(LIBS)
.PHONY: clean check test
clean:
rm -f $(ODIR)/*.o *~ core $(IDIR)/*~ $(OUTDIR)/$(OUTNAME) $(OUTDIR)/tests
rm -rf $(OUTDIR)/tests.dSYM
check: $(TESTS) $(OBJ_TEST)
@mkdir -p $(OUTDIR)
gcc -o $(OUTDIR)/tests $^ `pkg-config --cflags --libs check` $(CFLAGS) $(LIBS)
@./$(OUTDIR)/tests
@rm -f $(OUTDIR)/tests
@rm -rf $(OUTDIR)/tests.dSYM
test:
@make check