-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
40 lines (29 loc) · 904 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
CC=gcc
CFLAGS=-ansi -pedantic -Wall -Iinclude -O3
ODIR=bin
OTESTS=$(ODIR)/tests
OEXAMPLES=$(ODIR)/examples
OUTPUTLIB=$(ODIR)/libht.a
OUTPUTTESTS=$(OTESTS)/ll_test $(OTESTS)/ht_test
OUTPUTEXAMPLES=$(OEXAMPLES)/example1 $(OEXAMPLES)/example2 $(OEXAMPLES)/example3
all: lib tests examples
lib: $(OUTPUTLIB)
tests: $(OUTPUTTESTS)
examples: $(OUTPUTEXAMPLES)
$(ODIR)/%.o: src/%.c
mkdir -p $(ODIR)
$(CC) -c -o $@ $< $(CFLAGS)
$(OUTPUTLIB): $(ODIR)/ht.o $(ODIR)/ll.o
ar rcs $@ $(ODIR)/*.o
$(OTESTS)/%.o: tests/%.c
mkdir -p $(OTESTS)
$(CC) -c -o $@ $< $(CFLAGS)
$(OTESTS)/%: $(OTESTS)/%.o $(OUTPUTLIB)
$(CC) -L$(ODIR) -lht -o $@ $^
$(OEXAMPLES)/%.o: examples/%.c
mkdir -p $(OEXAMPLES)
$(CC) -c -o $@ $< $(CFLAGS)
$(OEXAMPLES)/%: $(OEXAMPLES)/%.o $(OUTPUTLIB)
$(CC) -L$(ODIR) -lht -o $@ $^
clean:
rm -f $(ODIR)/*.o $(OTESTS)/*.o $(OEXAMPLES)/*.o $(OUTPUTLIB) $(OUTPUTTESTS) $(OUTPUTEXAMPLES)