This repository has been archived by the owner on Sep 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
190 lines (149 loc) · 5.06 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# -- Configuration -------------------------------------------------------------
CC?=cc
OPTIMIZATION?=-O3 -g -ggdb
STD = -std=c99
WARN = -Wall -Wextra -Wno-sign-compare #-Werror
OPT = $(OPTIMIZATION)
ANTIHAX = -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all -fPIC
ANTIHAXLD = -pie -z now
INSTALLPREFIX?=/usr/local
PREFIX?=$(INSTALLPREFIX)
DPREFIX=$(DESTDIR)$(PREFIX)
INSTALL_LIB=$(DPREFIX)/lib
INSTALL_INCLUDE=$(DPREFIX)/include
INSTALL_MAN=$(DPREFIX)/share/man
INSTALL=install
MAN3DIR=$(INSTALL_MAN)/man3
PERL?=perl
# -- Setup ---------------------------------------------------------------------
USING_COMPCERT=$(shell sh -c '(($(CC) --help | grep CompCert) > /dev/null && echo YES) || echo NO')
IS_DARWIN=$(shell sh -c '((uname | grep Darwin) > /dev/null && echo YES) || echo NO')
IS_LINUX=$(shell sh -c '((uname | grep Linux) > /dev/null && echo YES) || echo NO')
ifeq ($(IS_DARWIN),YES)
SOEXT=dylib
endif
ifeq ($(IS_LINUX),YES)
SOEXT=so
endif
ifdef DEBUG
DEBUGOPT=-g
ifneq ($(USING_COMPCERT),YES)
DEBUGOPT+=-ggdb
endif
ifdef ASAN
DEBUGOPT+=-fsanitize=address
endif
ifdef UBSAN
DEBUGOPT+=-fsanitize=undefined
endif
# If we're debugging, we just override OPTIMIZATION above, since we
# don't want it anyway.
CFLAGS+=-DDEBUG
OPT=$(DEBUGOPT)
else
# Turn off assertions
CFLAGS+=-DNDEBUG
endif
ifeq ($(USING_COMPCERT),YES)
# CompCert has pretty non-standard flags - we're careful to only use
# DEBUGOPT here, because OPT flags might not work!
MY_CFLAGS=$(DEBUGOPT) -finline-asm
MY_LDFLAGS=
else
MY_CFLAGS=$(STD) $(WARN) $(OPT) $(ANTIHAX) $(CFLAGS)
MY_LDFLAGS=$(ANTIHAXLD)
endif
ifdef LTO
OPT+=-flto -fuse-linker-plugin
endif
CCCOLOR="\033[34m"
LINKCOLOR="\033[34;1m"
SRCCOLOR="\033[33m"
BINCOLOR="\033[37;1m"
MAKECOLOR="\033[32;1m"
ENDCOLOR="\033[0m"
ifndef V
EDSIGN_CC = @printf ' %b %b\n' $(CCCOLOR)CC$(ENDCOLOR) $(SRCCOLOR)$@$(ENDCOLOR) 1>&2;
EDSIGN_LINK = @printf ' %b %b\n' $(LINKCOLOR)LINK$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR) 1>&2;
EDSIGN_AR = @printf ' %b %b\n' $(CCCOLOR)AR$(ENDCOLOR) $(SRCCOLOR)$@$(ENDCOLOR) 1>&2;
EDSIGN_RANLIB = @printf ' %b %b\n' $(LINKCOLOR)RANLIB$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR) 1>&2;
EDSIGN_INSTALL = @printf ' %b %b\n' $(LINKCOLOR)INSTALL$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR) 1>&2;
EDSIGN_FRAMAC = @printf ' %b %b\n' $(LINKCOLOR)FRAMA-C$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR) 1>&2;
EDSIGN_MKAMALG = @printf ' %b %b -> %b\n' $(CCCOLOR)PERL$(ENDCOLOR) $(SRCCOLOR)$<$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR) 1>&2;
endif
QCC=$(EDSIGN_CC) $(CC)
QLINK=$(EDSIGN_LINK) $(CC)
QINSTALL=$(EDSIGN_INSTALL) $(INSTALL)
QAR=$(EDSIGN_AR) ar
QRANLIB=$(EDSIGN_RANLIB) ranlib
QFRAMAC=$(EDSIGN_FRAMAC) frama-c
QAMALG=$(EDSIGN_MKAMALG) $(PERL) etc/amalg/mkamalg.pl
E=@echo
ifndef V
Q=@
else
Q=
endif
MY_INCLUDES=-Ilib
# -- Primary build, tagging, etc -----------------------------------------------
VERSION=$(shell cat VERSION)
MY_CFLAGS+=$(MY_INCLUDES)
all: lib/libedsign.a lib/libedsign.$(SOEXT)
world: all check framalyze
tag:
$(Q)git tag -u $(GPGID) -sam 'Version $(VERSION)' $(VERSION)
## -- Rules
include rules.mk
include lib/rules.mk
include t/rules.mk
framalyze: $(FRAMAC_ANALYSIS)
check: $(TEST_EXES)
$(Q)for d in $(TEST_EXES); do ($$d > /dev/null); done
# If we ask to build the the amalgamation, *or* we are in the source
# distribution (which already contains it), then we perform a slight
# hack: clear the set of object files to build, and initialize them to
# point only to the amalgamation
ifneq ($(filter amalg, $(MAKECMDGOALS)),)
# Slight hack - reset STATIC and DYNAMIC objs to only contain amalg
STATIC_OBJS=
DYNAMIC_OBJS=
$(eval $(call c-objs,lib,edsign-amalg.c))
endif
amalg: lib/libedsign.a lib/libedsign.$(SOEXT)
amalg-src: lib/edsign-amalg.c
lib/edsign-amalg.c: etc/amalg/mkamalg.pl
$(QAMALG) -o $@
lib/libedsign.$(SOEXT): $(DYNAMIC_OBJS)
$(QLINK) -shared -o $@ $(DYNAMIC_OBJS)
lib/libedsign.a: $(STATIC_OBJS)
$(QAR) -rc $@ $(STATIC_OBJS)
$(QRANLIB) $@
sdistprep: amalg-src
# -- Cleanup -------------------------------------------------------------------
distclean: clean
$(Q)rm -f lib/edsign-amalg.c
clean:
$(Q)rm -f *.xz $(DYNAMIC_OBJS) $(STATIC_OBJS)
$(Q)rm -f lib/*.$(SOEXT) lib/*.a lib/*.o lib/*.dyn_o
$(Q)rm -rf $(AIGFILES) $(BCFILES) $(CHECKFILES) $(PROVEFILES)
$(Q)rm -rf $(FRAMAC_ANALYSIS) $(TEST_EXES) $(TEST_OBJS)
$(Q)rm -rf $(KATFILES) cryptol/specs/*.aig
$(Q)rm -rf cov-int
$(Q)rm -f result
# -- Install rules -------------------------------------------------------------
install: $(INSTALL_LIB)/libedsign.a \
$(INSTALL_LIB)/libedsign.$(SOEXT) \
$(INSTALL_INCLUDE)/edsign.h
$(INSTALL_INCLUDE)/edsign.h: lib/edsign.h
$(Q)mkdir -p $(INSTALL_INCLUDE)
$(QINSTALL) $< $(INSTALL_INCLUDE)
$(INSTALL_LIB)/libedsign.a: lib/libedsign.a
$(Q)mkdir -p $(INSTALL_LIB)
$(QINSTALL) $< $(INSTALL_LIB)
$(INSTALL_LIB)/libedsign.$(SOEXT): lib/libedsign.$(SOEXT)
$(Q)mkdir -p $(INSTALL_LIB)
$(QINSTALL) $< $(INSTALL_LIB)
uninstall:
$(Q)rm -f $(INSTALL_LIB)/libedsign.a
$(Q)rm -f $(INSTALL_LIB)/libedsign.$(SOEXT)
$(Q)rm -f $(INSTALL_INCLUDE)/edsign.h