This repository has been archived by the owner on Jun 17, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GNUmakefile
86 lines (65 loc) · 1.74 KB
/
GNUmakefile
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# Common
prefix= /usr/local
libdir= $(prefix)/lib
incdir= $(prefix)/include
CC= clang
CFLAGS+= $(cflags)
CFLAGS+= -std=c99
CFLAGS+= -Wall -Wextra -Werror -Wsign-conversion
CFLAGS+= -Wno-unused-parameter -Wno-unused-function
LDFLAGS+= $(ldflags)
PANDOC_OPTS= -s --toc --email-obfuscation=none
# Platform specific
platform= $(shell uname -s)
ifeq ($(platform), Linux)
CFLAGS+= -DHTTP_PLATFORM_LINUX
CFLAGS+= -D_POSIX_C_SOURCE=200809L
endif
# Debug
debug=0
ifeq ($(debug), 1)
CFLAGS+= -g -ggdb
else
CFLAGS+= -O2
endif
# Target: libutest
libutest_LIB= libutest.a
libutest_SRC= $(wildcard src/*.c)
libutest_PUBINC= src/utest.h
libutest_INC= $(wildcard src/*.h)
libutest_OBJ= $(subst .c,.o,$(libutest_SRC))
# Target: tests
tests_SRC= $(wildcard tests/*.c)
tests_OBJ= $(subst .c,.o,$(tests_SRC))
tests_BIN= $(subst .o,,$(tests_OBJ))
$(tests_BIN): LDFLAGS+= -L.
$(tests_BIN): LDLIBS+= -lutest
# Target: doc
doc_SRC= $(wildcard doc/*.mkd)
doc_HTML= $(subst .mkd,.html,$(doc_SRC))
# Rules
all: lib $(tests_BIN) $(doc_HTML)
lib: $(libutest_LIB)
$(libutest_OBJ): $(libutest_INC)
$(libutest_LIB): $(libutest_OBJ)
$(AR) cr $@ $(libutest_OBJ)
$(tests_OBJ): $(libutest_LIB) $(libutest_INC)
tests/%: tests/%.o
$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
doc/%.html: doc/*.mkd
pandoc $(PANDOC_OPTS) -t html5 -o $@ $<
clean:
$(RM) $(libutest_LIB) $(wildcard libutest/*.o)
$(RM) $(tests_BIN) $(wildcard tests/*.o)
$(RM) -r $(doc_HTML)
install: lib
mkdir -p $(libdir) $(incdir)
install -m 644 $(libutest_LIB) $(libdir)
install -m 644 $(libutest_PUBINC) $(incdir)
uninstall:
$(RM) $(addprefix $(libdir)/,$(libutest_LIB))
$(RM) $(addprefix $(incdir)/,$(libutest_PUBINC))
tags:
$(RM) -f .tags
ctags -o .tags -a $(wildcard src/*.[hc])
.PHONY: all clean install lib uninstall tags