-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
95 lines (65 loc) · 2.08 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
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
87
88
89
90
91
###############################################################################
#
# Makefile for fpcc
#
# Daniel Prokesch <daniel.prokesch@gmail.com>
###############################################################################
SUITE = fpcc
TOOL_PREFIX = $(SUITE)-
TOOLS = sig comp idx map paths help diff
# all the tools in the resulting bin directory
SUITE_TOOLS = $(addprefix bin/, $(SUITE) \
$(addprefix $(TOOL_PREFIX), $(TOOLS)))
# the manpages are generated from the doc/*.txt files
MANTXT = $(wildcard doc/*.txt)
MANPAGES = $(MANTXT:.txt=.1.gz)
###############################################################################
CC = gcc
CFLAGS = -std=c99 -pedantic -Wall -g -D_DEFAULT_SOURCE
LDFLAGS =
ifeq ($(DEBUG),1)
CFLAGS += -DDEBUG
endif
ifeq ($(RELEASE),1)
CFLAGS = -std=c99 -pedantic -Wall -O3 -D_DEFAULT_SOURCE -DNDEBUG
endif
###############################################################################
.PHONY: all clean tools docs list
all: tools docs
tools: $(SUITE_TOOLS)
docs: $(MANPAGES)
$(SUITE_TOOLS): | bin
bin:
test -e $@ -a -d $@ || mkdir $@
# shared header
$(patsubst %.c, %.o, $(wildcard src/*.c)): src/common.h
COMMON_OBJ = src/common.o
# rule to build a C tool
bin/$(TOOL_PREFIX)%: src/%.o $(COMMON_OBJ)
$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
# rules related to sig
src/lex.yy.o: src/lex.yy.c src/ccode.tab.h
# we are only interested in the header for the tokens
src/ccode.tab.h: src/ccode.y
bison --defines=$@ --output=/dev/null $<
src/lex.yy.c: src/ccode.lex
flex -o $@ $<
bin/$(TOOL_PREFIX)sig: LDLIBS = -lcrypto
bin/$(TOOL_PREFIX)sig: src/lex.yy.o
bin/%: utils/%
cp $< $@
%.1.gz: %.txt
txt2man -t "$(TOOL_PREFIX)$(*F)" -s1 $< | gzip > $@
# Generate a list of tools with their description.
# This assumes that this information is in the second line of the doc/.txt file.
list:
@for t in $(MANTXT); do \
head -n2 $$t | tail -n1 | \
sed -e "s/$(TOOL_PREFIX)\([[:alnum:]]\+\)[[:space:]]\+-[[:space:]]\+\(.*\)$$/\1\t\t\2/" ;\
done
clean:
rm -fr bin
rm -f src/ccode.tab.[ch] src/lex.yy.c src/*.o
rm -f $(MANPAGES)