forked from cil-project/cil
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.in
371 lines (314 loc) · 12.9 KB
/
Makefile.in
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
# -*- Mode: makefile -*-
# Makefile for the cil wrapper
# @do_not_edit@ Makefile.in
#
# authors: George Necula, Gabriel Kerneis
CILLY = cilly
CIL_VERSION = @CIL_VERSION@
# Avoid using CIL_FEATURES when building doc or tests
unexport CIL_FEATURES
.PHONY: all
all: install-local
# look out for outdated Makefile; if it's out of date, this will automatically
# re-run ./config.status, then re-exec make with the same arguments
Makefile: config.status Makefile.in
./$<
config.status: configure
./$@ --recheck
$(srcdir)/configure: configure.ac aclocal.m4
cd '$(srcdir)' && autoconf
# autoheader might not change config.h.in, so touch a stamp file.
$(srcdir)/config.h.in: stamp-h.in
$(srcdir)/stamp-h.in: configure.ac aclocal.m4
cd '$(srcdir)' && autoheader
echo timestamp > '$(srcdir)/stamp-h.in'
config.h: stamp-h
stamp-h: config.h.in config.status
./config.status
CC=@CC@
@DEFAULT_COMPILER@=1
# We have to use _build because of OCaml's bug #0004502
OBJDIR = _build
BINDIR = bin
CILLYDIR = lib/perl5
# Ocaml tools
OCAMLC = @OCAMLC@
OCAMLOPT = @OCAMLOPT@
OCAMLFIND = @OCAMLFIND@
OCAMLBUILD = @OCAMLBUILD@
OCAMLNATDYNLINK = @OCAMLNATDYNLINK@
PERL = @PERL@
# Build the list of files for cillib
CILLIB_TARGETS=
CILLY_EXE_FILES=
CIL_PLUGINS_DIR = src/ext
CIL_EXCLUDE_PLUGINS =
CIL_PLUGINS = $(addprefix $(OBJDIR)/,$(filter-out $(addprefix $(CIL_PLUGINS_DIR)/, $(CIL_EXCLUDE_PLUGINS)),$(wildcard $(CIL_PLUGINS_DIR)/*)))
CIL_DEFAULT_PLUGINS = $(patsubst $(CIL_PLUGINS_DIR)/%/default,cil.%,$(wildcard $(CIL_PLUGINS_DIR)/*/default))
ifneq ($(OCAMLC),no)
CILLIB_TARGETS += $(OBJDIR)/src/cil.cma
CILLIB_TARGETS += $(addsuffix .cma,$(CIL_PLUGINS))
CILLY_EXE_FILES += $(OBJDIR)/src/main.byte
endif
ifneq ($(OCAMLOPT),no)
# build native version only if natdynlink is available
ifeq ($(OCAMLNATDYNLINK),yes)
CILLIB_TARGETS += $(OBJDIR)/src/cil.cmxa $(OBJDIR)/src/cil.a
CILLIB_TARGETS += $(addsuffix .cmxa,$(CIL_PLUGINS))
CILLIB_TARGETS += $(addsuffix .cmxs,$(CIL_PLUGINS))
CILLIB_TARGETS += $(addsuffix .a,$(CIL_PLUGINS))
CILLY_EXE_FILES += $(OBJDIR)/src/main.native
endif
endif
CILLIB_FILES = $(OBJDIR)/src/cil.libfiles $(addsuffix .libfiles,$(CIL_PLUGINS))
CILDOC_INDEX = $(OBJDIR)/cil.docdir/index.html
CILLY_EXE_BIN = $(patsubst $(OBJDIR)/src/main.%,bin/$(CILLY).%,$(CILLY_EXE_FILES))
# Force a single invocation of ocamlbuild per make execution
override OCAMLBUILD += -build-dir $(OBJDIR) -use-ocamlfind -no-links -classic-display
OCAMLBUILD_TARGETS = \
$(CILLIB_TARGETS) \
$(CILLIB_FILES) \
$(CILLY_EXE_FILES) \
$(CILDOC_INDEX)
# Trick: this no-op rule is executed for each target, but
# its PHONY dependency is built exactly once.
$(OCAMLBUILD_TARGETS): ocamlbuild
@:
.PHONY: ocamlbuild
ocamlbuild:
export CIL_VERSION
MAKE=$(MAKE) $(OCAMLBUILD) $(patsubst $(OBJDIR)/%,%,$(OCAMLBUILD_TARGETS))
.PHONY: META
META:
@rm -f $@
@printf "description = \"C Intermediate Language\"\n" >>$@
@printf "requires = \"unix str num dynlink\"\n" >>$@
@printf "version = \"$(CIL_VERSION)\"\n\n" >>$@
@printf "archive(byte) = \"cil.cma\"\n" >>$@
@printf "archive(native) = \"cil.cmxa\"\n\n" >>$@
@printf "package \"default-features\" (\n" >>$@
@printf "requires=\"$(CIL_DEFAULT_PLUGINS)\"\n" >>$@
@printf "version = \"$(CIL_VERSION)\"\n" >>$@
@printf ")\n\n" >>$@
@printf "package \"all-features\" (\n" >>$@
@printf "requires=\"$(patsubst $(OBJDIR)/$(CIL_PLUGINS_DIR)/%,cil.%,$(CIL_PLUGINS))\"\n" >>$@
@printf "version = \"$(CIL_VERSION)\"\n" >>$@
@printf ")\n\n" >>$@
@$(foreach plugin,$(patsubst $(OBJDIR)/$(CIL_PLUGINS_DIR)/%,%,$(CIL_PLUGINS)),\
printf "package \"$(plugin)\" (\n" >> $@;\
cat $(CIL_PLUGINS_DIR)/$(plugin)/META >> $@;\
printf "version = \"$(CIL_VERSION)\"\n" >>$@;\
printf "archive(byte) = \"$(plugin).cma\"\n" >> $@;\
printf "archive(byte,plugin) = \"$(plugin).cma\"\n" >> $@;\
printf "archive(native) = \"$(plugin).cmxa\"\n" >> $@;\
printf "archive(native,plugin) = \"$(plugin).cmxs\"\n" >> $@;\
printf ")\n\n" >> $@;\
)
# cilly perl wrapper
prefix = @prefix@
INSTALL_BASE = $(prefix)
CILLYMOD := Cilly
$(CILLYDIR)/Makefile: $(CILLYDIR)/Makefile.PL $(CILLYDIR)/App/$(CILLYMOD).pm
cd $(CILLYDIR); $(PERL) Makefile.PL INSTALL_BASE="$(INSTALL_BASE)"
bin/$(CILLY).%: $(OBJDIR)/src/main.%
cp $< $@
.PHONY: $(CILLY)
$(CILLY): $(CILLY_EXE_BIN) $(CILLYDIR)/Makefile
$(MAKE) -C $(CILLYDIR)
# Create the machine dependency module
# If the cl command cannot be run then the MSVC part will be identical to GCC
.PHONY : machdep
machdep: $(OBJDIR)/machdep.ml
$(OBJDIR)/machdep.ml : src/machdep-ml.c configure.ac Makefile.in
@rm -f $@
@mkdir -p $(OBJDIR)
@echo "(* This module was generated automatically by code in Makefile and $(<F) *)" >$@
@echo "type mach = {" >> $@
@echo " version_major: int; (* Major version number *)" >> $@
@echo " version_minor: int; (* Minor version number *)" >> $@
@echo " version: string; (* gcc version string *)" >> $@
@echo " underscore_name: bool; (* If assembly names have leading underscore *)" >> $@
@echo " sizeof_short: int; (* Size of \"short\" *)" >> $@
@echo " sizeof_int: int; (* Size of \"int\" *)" >> $@
@echo " sizeof_bool: int; (* Size of \"_Bool\" *)" >> $@
@echo " sizeof_long: int ; (* Size of \"long\" *)" >> $@
@echo " sizeof_longlong: int; (* Size of \"long long\" *)" >> $@
@echo " sizeof_ptr: int; (* Size of pointers *)" >> $@
@echo " sizeof_float: int; (* Size of \"float\" *)" >> $@
@echo " sizeof_double: int; (* Size of \"double\" *)" >> $@
@echo " sizeof_longdouble: int; (* Size of \"long double\" *)" >> $@
@echo " sizeof_void: int; (* Size of \"void\" *)" >> $@
@echo " sizeof_fun: int; (* Size of function *)" >> $@
@echo " size_t: string; (* Type of \"sizeof(T)\" *)" >> $@
@echo " wchar_t: string; (* Type of \"wchar_t\" *)" >> $@
@echo " alignof_short: int; (* Alignment of \"short\" *)" >> $@
@echo " alignof_int: int; (* Alignment of \"int\" *)" >> $@
@echo " alignof_bool: int; (* Alignment of \"_Bool\" *)" >> $@
@echo " alignof_long: int; (* Alignment of \"long\" *)" >> $@
@echo " alignof_longlong: int; (* Alignment of \"long long\" *)" >> $@
@echo " alignof_ptr: int; (* Alignment of pointers *)" >> $@
@echo " alignof_enum: int; (* Alignment of enum types *)" >> $@
@echo " alignof_float: int; (* Alignment of \"float\" *)" >> $@
@echo " alignof_double: int; (* Alignment of \"double\" *)" >> $@
@echo " alignof_longdouble: int; (* Alignment of \"long double\" *)" >> $@
@echo " alignof_str: int; (* Alignment of strings *)" >> $@
@echo " alignof_fun: int; (* Alignment of function *)" >> $@
@echo " alignof_aligned: int; (* Alignment of anything with the \"aligned\" attribute *)" >> $@
@echo " char_is_unsigned: bool; (* Whether \"char\" is unsigned *)">> $@
@echo " const_string_literals: bool; (* Whether string literals have const chars *)">> $@
@echo " little_endian: bool; (* whether the machine is little endian *)">>$@
@echo " __thread_is_keyword: bool; (* whether __thread is a keyword *)">>$@
@echo " __builtin_va_list: bool; (* whether __builtin_va_list is builtin (gccism) *)">>$@
@echo "}" >> $@
@if $(CC) -D_GNUCC $< -o $(OBJDIR)/machdep-ml.exe ;then \
echo "machdep-ml.exe created succesfully." \
;else \
rm -f $@; exit 1 \
;fi
@echo "let gcc = {" >>$@
@$(OBJDIR)/machdep-ml.exe >>$@
@echo "}" >>$@
@if cl -D_MSVC $< -Fe$(OBJDIR)/machdep-ml.exe -Fo$(OBJDIR)/machdep-ml.obj ;then \
echo "let hasMSVC = true" >>$@ ;\
echo "let msvc = {" >>$@ ;\
$(OBJDIR)/machdep-ml.exe >>$@ ;\
echo "}" >>$@ \
;else \
echo "let hasMSVC = false" >>$@ ;\
echo "let msvc = gcc" >> $@ \
;fi
@echo "let theMachine : mach ref = ref gcc" >>$@
$(CILLYDIR)/App/$(CILLYMOD).pm: $(CILLYDIR)/App/$(CILLYMOD).pm.in src/machdep-ml.c configure.ac Makefile.in
cp $(CILLYDIR)/App/$(CILLYMOD).pm.in $(CILLYDIR)/App/$(CILLYMOD).pm
sed -e "s|CIL_VERSION|$(CIL_VERSION)|" $(CILLYDIR)/App/$(CILLYMOD).pm > $(CILLYDIR)/App/$(CILLYMOD).pm.tmp; \
mv $(CILLYDIR)/App/$(CILLYMOD).pm.tmp $(CILLYDIR)/App/$(CILLYMOD).pm; \
if $(CC) -D_GNUCC -m32 src/machdep-ml.c -o $(OBJDIR)/machdep-ml32.exe ;then \
sed -e "s|nogcc32model|`$(OBJDIR)/machdep-ml32.exe --env`|" $(CILLYDIR)/App/$(CILLYMOD).pm > $(CILLYDIR)/App/$(CILLYMOD).pm.tmp; \
mv $(CILLYDIR)/App/$(CILLYMOD).pm.tmp $(CILLYDIR)/App/$(CILLYMOD).pm; \
fi
if $(CC) -D_GNUCC -m64 src/machdep-ml.c -o $(OBJDIR)/machdep-ml64.exe ;then \
sed -e "s|nogcc64model|`$(OBJDIR)/machdep-ml64.exe --env`|" $(CILLYDIR)/App/$(CILLYMOD).pm > $(CILLYDIR)/App/$(CILLYMOD).pm.tmp; \
mv $(CILLYDIR)/App/$(CILLYMOD).pm.tmp $(CILLYDIR)/App/$(CILLYMOD).pm; \
fi
### DOCUMENTATION
# You should usually run this twice to get all of the references linked
# correctly.
.PHONY: doc
doc: texdoc pdfdoc odoc
.PHONY: odoc texdoc pdfdoc
# Documentation generated by "ocamldoc"
odoc: $(CILDOC_INDEX)
-rm -rf doc/html/cil/api
-mkdir -p doc/html/cil/
-cp -r $(dir $<) doc/html/cil/api
doc/cilpp.tex: doc/cilcode.pl doc/cil.tex $(CILLY)
-rm -rf doc/html/cil
-mkdir -p doc/html/cil
-mkdir -p doc/html/cil/examples
cd doc; $(PERL) cilcode.pl cil.tex >cilpp.tex.tmp
mv doc/cilpp.tex.tmp $@
# Documentation generated from latex files using "hevea"
texdoc: doc/cilpp.tex
cd doc/html/cil; printf '\\def\\cilversion{$(CIL_VERSION)}\n' >cil.version.tex
cd doc/html/cil; hevea -exec xxdate.exe ../../cilpp
cd doc/html/cil; hevea -exec xxdate.exe ../../cilpp
cd doc/html/cil; mv cilpp.html cil.html
cd doc/html/cil; hacha -o ciltoc.html cil.html
cp -f doc/index.html doc/html/cil/index.html
cp -f doc/header.html doc/html/cil
pdfdoc: doc/cilpp.tex
cd doc; printf '\\def\\cilversion{$(CIL_VERSION)}\n' >cil.version.tex
cd doc; pdflatex cilpp.tex; pdflatex cilpp.tex
cd doc; mv cilpp.pdf html/cil/CIL.pdf
.PHONY: distclean clean
distclean: clean
$(MAKE) -C test distclean
rm -rf autom4te.cache/
rm -f Makefile
rm -f $(CILLYDIR)/App/$(CILLYMOD)/CilConfig.pm
rm -f config.h
rm -f config.log
rm -f config.mk
rm -f config.status
rm -f doc/header.html
rm -f doc/index.html
rm -f src/machdep-ml.c src/cilversion.ml
rm -f stamp-h
clean: $(CILLYDIR)/Makefile
rm -rf $(OBJDIR)
rm -f $(BINDIR)/$(CILLY).*
rm -rf lib/cil share/
rm -f META
rm -rf doc/html/
rm -rf doc/cilcode.tmp/
rm -f doc/cil.version.*
rm -f doc/cilpp.*
$(MAKE) -C $(CILLYDIR) clean
rm -f $(CILLYDIR)/App/$(CILLYMOD).pm
rm -f $(CILLYDIR)/Makefile.old
$(MAKE) -C test clean
.PHONY: test
test:
ifneq ($(VERBOSE),)
cd test; CC=@CC@ ./testcil -r --regrtest || { cat cil.log; exit 1; }
else
cd test; CC=@CC@ ./testcil -r --regrtest
endif
########################################################################
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
exec_prefix = @exec_prefix@
datarootdir = @datarootdir@
datadir = $(datarootdir)/cil
bindir = @bindir@
CYGPATH=@CYGPATH@
# Make DESTDIR absolute (necessary for perl installation), and add trailing
# backspace.
ifneq ($(DESTDIR),)
ifneq ($(CYGPATH),)
override DESTDIR := $(shell $(CYGPATH) -ua $(DESTDIR)/)
else
override DESTDIR := $(abspath $(DESTDIR)/)
endif
endif
MAKE_CILLY = $(MAKE) -C $(CILLYDIR) DESTDIR=$(DESTDIR) INSTALL_BASE=$(INSTALL_BASE)
install: $(CILLY) install-findlib install-data
$(MAKE_CILLY) pure_install
$(INSTALL) -m 0755 $(BINDIR)/$(CILLY).* $(DESTDIR)$(bindir)
uninstall: $(CILLYDIR)/Makefile uninstall-findlib uninstall-data
-rm -f $(DESTDIR)$(bindir)/$(CILLY).*
$(MAKE_CILLY) force_uninstall
.PHONY: install-findlib uninstall-findlib
# Get the default OCAMLFIND_DESTDIR
OCAMLFIND_DESTDIR=$(shell ocamlfind printconf destdir)
# Add DESTDIR in front of OCAMLFIND_DESTDIR. Do the necessary conversions on
# cygwin, since the former is in unix format whereas the later and the result
# are in windows (mixed) format.
ifneq ($(CYGPATH),)
OCAMLFIND_UNIXDIR=$(shell $(CYGPATH) -ua "$(OCAMLFIND_DESTDIR)")
OCAMLFIND_INSTALLDIR=$(shell $(CYGPATH) -ma "$(DESTDIR)$(OCAMLFIND_UNIXDIR)")
else
OCAMLFIND_INSTALLDIR=$(DESTDIR)$(OCAMLFIND_DESTDIR)
endif
install-findlib: META $(CILLIB_FILES) $(CILLIB_TARGETS) uninstall-findlib
mkdir -p $(OCAMLFIND_INSTALLDIR)
OCAMLFIND_DESTDIR=$(OCAMLFIND_INSTALLDIR) \
$(OCAMLFIND) install cil META $(CILLIB_TARGETS) `cat $(CILLIB_FILES)`
uninstall-findlib:
OCAMLFIND_DESTDIR=$(OCAMLFIND_INSTALLDIR) $(OCAMLFIND) remove cil
.PHONY: install-data uninstall-data
install-data:
mkdir -p $(DESTDIR)$(datadir)
ifneq ($(CYGPATH),)
printf $(shell $(CYGPATH) -ma "$(OCAMLFIND_DESTDIR)") > ocamlpath
else
printf $(abspath $(OCAMLFIND_DESTDIR)) > ocamlpath
endif
$(INSTALL_DATA) ocamlpath $(DESTDIR)$(datadir)
rm -f ocamlpath
uninstall-data:
rm -rf $(DESTDIR)$(datadir)
.PHONY: install-local
# Recursive call to install-findlib builds $(CILLIB_TARGETS)
install-local:
$(MAKE) $(CILLY) install-findlib install-data PREFIX=. datarootdir=share DESTDIR= OCAMLFIND_DESTDIR=lib