-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
51 lines (36 loc) · 808 Bytes
/
Makefile
File metadata and controls
51 lines (36 loc) · 808 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
45
46
47
48
49
50
51
IDIR=include
SDIR=src
ODIR=obj
TODIR=$(ODIR)
BDIR=bin
TDIR=test
CC=gcc
MKDIR_P=mkdir -p
CFLAGS=-I$(IDIR) -I$(TDIR)
LFLAGS=-lm
DEPS=$(wildcard $(IDIR)/*.h)
TDEPS=$(wildcard $(TDIR)/*.h)
SRC=$(wildcard $(SDIR)/*.c)
TSRC=$(wildcard $(TDIR)/*.c)
OBJ=$(patsubst $(SDIR)/%.c, $(ODIR)/%.o, $(SRC))
TOBJ=$(patsubst $(TDIR)/%.c, $(TODIR)/%.o, $(TSRC))
all: directories build
$(ODIR):
@$(MKDIR_P) $@
$(BDIR):
@$(MKDIR_P) $@
$(TODIR)/%.o: $(TDIR)/%.c $(DEPS) $(TDEPS)
@$(CC) -c -o $@ $< $(CFLAGS)
$(ODIR)/%.o: $(SDIR)/%.c $(DEPS)
@$(CC) -c -o $@ $< $(CFLAGS)
.PHONY: clean
clean:
@rm -rf $(ODIR) $(BDIR)
.PHONY: directories
directories: $(ODIR) $(BDIR)
build: directories $(BDIR)/run_tests
$(BDIR)/run_tests: $(OBJ) $(TOBJ)
@$(CC) -o $@ $^ $(CFLAGS) $(LFLAGS)
.PHONY: test
test:
@$(BDIR)/run_tests