-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
59 lines (46 loc) · 1.13 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
SRC=src
ODIR=obj
LIB=lib
TDIR=test
INC=include
BIN=bin
LIB=lib
TODIR=$(ODIR)/test
_OBJ=list_creation.o list_removal.o list_transformation.o list_retrieval.o
_TOBJ=unittest.o test_list.o test_remove.o
LD_LIBRARY_PATH=$(HOME)/.local/lib
OBJ=$(patsubst %,$(ODIR)/%, $(_OBJ))
TOBJ=$(patsubst %,$(TODIR)/%, $(_TOBJ))
DEST=$(HOME)/.local
all: clean $(OBJ)
$(ODIR)/%.o: $(SRC)/%.c
gcc $(DBG) -c -o $@ $< -iquote $(INC)/
.PHONY: tree
tree:
tree
$(TODIR)/%.o: $(TDIR)/%.c
gcc $(DBG) -c -o $@ $< -iquote $(INC)/
unittest: $(TOBJ) $(OBJ)
gcc -o $(BIN)/$@ $^ -L$(DEST)/$(LIB) -llist -lcunit -I $(DEST)/$(INC)
debug_tests: debug unittest
$(BIN)/unittest
run_tests: unittest
$(BIN)/$<
static_lib: $(OBJ)
ar rcs $(LIB)/liblist.a $<
install: static_lib
cp $(LIB)/liblist.a $(DEST)/$(LIB)
cp $(INC)/list.h $(DEST)/$(INC)
test_install: install
gcc -o $(BIN)/listtest $(TDIR)/listtest.c -llist -I $(DEST)/include/ -L $(LD_LIBRARY_PATH)
$(BIN)/listtest
.PHONY: uninstall
uninstall:
rm -f $(DEST)/$(LIB)/liblist.a
rm -f $(DEST)/$(INC)/list.h
.PHONY: clean
clean:
rm -f $(BIN)/* $(ODIR)/*.o $(TODIR)/*
debug: unittest
$(eval DBG=-g)
gdb $(BIN)/$<