Makefile.generating 7.77 KB
Newer Older
1
2
3
4
##########################################################################
#                                                                        #
#  This file is part of Frama-C.                                         #
#                                                                        #
Andre Maroneze's avatar
Andre Maroneze committed
5
#  Copyright (C) 2007-2020                                               #
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
#    CEA (Commissariat à l'énergie atomique et aux énergies              #
#         alternatives)                                                  #
#                                                                        #
#  you can redistribute it and/or modify it under the terms of the GNU   #
#  Lesser General Public License as published by the Free Software       #
#  Foundation, version 2.1.                                              #
#                                                                        #
#  It is distributed in the hope that it will be useful,                 #
#  but WITHOUT ANY WARRANTY; without even the implied warranty of        #
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         #
#  GNU Lesser General Public License for more details.                   #
#                                                                        #
#  See the GNU Lesser General Public License version 2.1                 #
#  for more details (enclosed in the file licenses/LGPLv2.1).            #
#                                                                        #
##########################################################################

ptests/ptests_config.ml: Makefile.generating share/Makefile.config
	$(PRINT_MAKING) $@
	$(RM) $@
	$(TOUCH) $@
	$(CHMOD_RO) $@

tests/ptests_config: Makefile.generating share/Makefile.config
	$(PRINT_MAKING) $@
	$(RM) $@
	$(TOUCH) $@
	$(ECHO) "DEFAULT_SUITES=$(PLUGIN_TESTS_LIST)" >> $@
	$(ECHO) "TOPLEVEL_PATH=bin/toplevel.$(OCAMLBEST)$(EXE)" >> $@
	$(ECHO) "OCAMLRUNPARAM=" >> $@
	$(ECHO) "FRAMAC_SESSION=." >> $@
	$(ECHO) "FRAMAC_SHARE=./share" >> $@
	$(ECHO) "FRAMAC_PLUGIN=./lib/plugins" >> $@
	$(ECHO) "FRAMAC_PLUGIN_GUI=./lib/plugins/gui" >> $@
	$(ECHO) "FRAMAC_LIB=./lib/fc" >> $@
	$(CHMOD_RO) $@

ALL_LIBRARY_NAMES=$(shell ocamlfind query -r -p-format $(LIBRARY_NAMES) $(LIBRARY_NAMES_GUI))
44
45
MAJOR_VERSION=$(shell $(SED) -E 's/^([0-9]+)\..*/\1/' VERSION)
MINOR_VERSION=$(shell $(SED) -E 's/^[0-9]+\.([0-9]+).*/\1/' VERSION)
46
47
48
49

$(CONFIG_FILE): $(CONFIG_FILE).in VERSION VERSION_CODENAME share/Makefile.config Makefile.generating configure.in
	$(SED) \
	  -e "s|@VERSION@|$(VERSION)|" \
50
          -e "s|@VERSION_CODENAME@|$(VERSION_CODENAME)|" \
51
          -e "s|@CURR_DATE@|$$(LC_ALL=C date)|" \
52
          -e "s|@LABLGTK@|$(LABLGTK)|" \
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
	  -e "s|@OCAMLC@|$(OCAMLC)|" \
          -e "s|@OCAMLOPT@|$(OCAMLOPT)|" \
	  -e "s|@WARNINGS@|$(WARNINGS)|" \
          -e "s|@FRAMAC_DATADIR@|$(FRAMAC_DATADIR)|" \
	  -e "s|@FRAMAC_LIBDIR@|$(FRAMAC_LIBDIR)|" \
	  -e "s|@FRAMAC_ROOT_SRCDIR@|$(FRAMAC_ROOT_SRCDIR)|" \
	  -e "s|@FRAMAC_PLUGINDIR@|$(FRAMAC_PLUGINDIR)|" \
	  -e "s|@FRAMAC_DEFAULT_CPP@|$(FRAMAC_DEFAULT_CPP)|" \
          -e "s|@FRAMAC_DEFAULT_CPP_ARGS@|$(FRAMAC_DEFAULT_CPP_ARGS)|" \
	  -e "s|@FRAMAC_GNU_CPP@|$(FRAMAC_GNU_CPP)|" \
          -e "s|@DEFAULT_CPP_KEEP_COMMENTS@|$(DEFAULT_CPP_KEEP_COMMENTS)|" \
          -e "s|@DEFAULT_CPP_SUPPORTED_ARCH_OPTS@|$(DEFAULT_CPP_SUPPORTED_ARCH_OPTS)|" \
          -e "s|@COMPILATION_UNITS@|$(COMPILATION_UNITS)|" \
          -e "s|@LIBRARY_NAMES@|$(foreach p,$(ALL_LIBRARY_NAMES),\"$p\";)|" \
	  -e "s|@OPTDOT@|$(OPTDOT)|" \
          -e "s|@EXE@|$(EXE)|" \
          -e "s|@MAJOR_VERSION@|$(MAJOR_VERSION)|" \
          -e "s|@MINOR_VERSION@|$(MINOR_VERSION)|" \
          $< > $@.tmp
	@touch -r $@.tmp $<
	$(CP_IF_DIFF) $@.tmp $@
	$(RM) $@.tmp
	$(CHMOD_RO) $@

ifeq ("$(LOCAL_MACHDEP)","yes")

MACHDEP_PATH=share

# Create the machine dependency module
# If the cl command cannot be run then the MSVC part will be identical to GCC
.PHONY : machdep $(MACHDEP_PATH)/local_machdep.ml
machdep: $(MACHDEP_PATH)/local_machdep.ml
bin/machdep.exe: machdep

config.h: 
	$(PRINT_MAKING) $@
	$(ECHO) "missing config.h file generated at configure stage using --enable-localmachdep option."
	exit 1;

$(MACHDEP_PATH)/local_machdep.ml: \
  $(MACHDEP_PATH)/machdep.c config.h Makefile.generating
	$(PRINT_MAKING) $@
	$(RM) $@
	$(ECHO) "(* This module was generated automatically by code in Makefile and machdep.c *)" >$@
# Now generate the type definition
	$(ECHO) "open Cil_types" >> $@
	if $(CC) -D_GNUCC $< -o bin/machdep.exe ;then \
	    $(ECHO) "machdep.exe created successfully."; \
	else \
	    $(RM) $@; exit 1; \
	fi
	$(ECHO) "let gcc = {" >>$@
	./bin/machdep.exe >>$@
	$(ECHO) "	 underscore_name = $(UNDERSCORE_NAME) ;" >> $@
	$(ECHO) "}"          >>$@
	if cl /D_MSVC $< /Febin/machdep.exe /Fobin/machdep.obj ;then \
	   $(ECHO) "let hasMSVC = true" >>$@; \
	else \
	   $(ECHO) "let hasMSVC = false" >>$@; \
	fi
	$(ECHO) "let msvc = {" >>$@
	./bin/machdep.exe >>$@
	$(ECHO) "	 underscore_name = true ;" >> $@
	$(ECHO) "}"          >>$@
	$(ECHO) \
	  "let gccHas__builtin_va_list = $(HAVE_BUILTIN_VA_LIST)" >>$@
	$(ECHO) \
	  "$@ generated. You may have this file merged into Frama-C by developers."
	$(CHMOD_RO) $@

endif

# transitioning.ml

GENERATED+= src/libraries/utils/json.ml src/libraries/stdlib/transitioning.ml

src/libraries/stdlib/transitioning.ml: \
  src/libraries/stdlib/transitioning.ml.in \
  Makefile.generating share/Makefile.config
	$(PRINT_MAKING) $@
	rm -f $@
134
	cat $< > $@
135
136
	$(CHMOD_RO) $@

137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
ifeq ($(HAS_DGRAPH),yes)
  DGRAPHFILES:=debug_manager
  GENERATED+=src/plugins/gui/debug_manager.ml
  ifeq ($(HAS_OCAMLGRAPH_2), yes)
	DGRAPH_MODULE=Graph_gtk
	DGRAPH_ERROR=Graph_gtk.DGraphMake.DotError
  else
	DGRAPH_MODULE=Dgraph
	DGRAPH_ERROR=Dgraph.DGraphModel.DotError
  endif
  src/plugins/gui/debug_manager.ml \
  src/plugins/gui/dgraph_helper.ml \
  src/plugins/callgraph/cg_viewer.ml: %.ml: %.yes.ml Makefile.generating share/Makefile.config
	$(RM) $@
	$(SED) -e 's/DGRAPH_MODULE/$(DGRAPH_MODULE)/g' \
               -e 's/DGRAPH_ERROR/$(DGRAPH_ERROR)/g' $< > $@
	$(CHMOD_RO) $@
else
  DGRAPHFILES:=
  src/plugins/gui/dgraph_helper.ml: src/plugins/gui/dgraph_helper.no.ml Makefile.generating share/Makefile.config
	$(CP) $< $@
	$(CHMOD_RO) $@
endif

161
162
163
164
##################
# Frama-C-config #
##################

165
src/kernel_internals/runtime/frama_c_config.ml: src/kernel_internals/runtime/fc_config.ml \
166
167
168
169
	src/kernel_internals/runtime/frama_c_config.ml.in Makefile.generating
	$(PRINT_MAKING) $@
	$(RM) $@
	$(ECHO) "module Filepath = struct let add_symbolic_dir _ _ = () end" >> $@
170
171
	$(ECHO) "module Fc_config = struct" >> $@
	$(CAT) src/kernel_internals/runtime/fc_config.ml >> $@
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
	$(ECHO) "end" >> $@
	$(CAT) src/kernel_internals/runtime/frama_c_config.ml.in >> $@
	$(CHMOD_RO) $@

GENERATED+= src/kernel_internals/runtime/frama_c_config.ml

bin/fc-config$(EXE): src/kernel_internals/runtime/frama_c_config.ml
ifeq ($(OCAMLBEST),opt)
	$(OCAMLOPT) str.cmxa $< -o $@
else
	$(OCAMLC) str.cma $< -o $@
endif

# Merlin #

.PHONY:merlin
.merlin merlin: share/Makefile.config Makefile.generating
#create Merlin file
	$(PRINT_MAKING) $@
	echo "FLG -c $(FLAGS) $(FRAMAC_USER_MERLIN_FLAGS)" > .merlin
	for PKG in $(LIBRARY_NAMES); do echo PKG $$PKG >> .merlin; done
	for PKG in $(LIBRARY_NAMES_GUI); do echo PKG $$PKG >> .merlin; done
	for PKG in $(MERLIN_PACKAGES); do echo PKG $$PKG >> .merlin; done
	echo "B lib/plugins" >> .merlin
	echo "B lib/plugins/gui" >> .merlin
	find src \( -name '.*' -o -name tests -o -name doc -o -name '*.cache' \) -prune \
	      -o \( -type d -exec printf "B %s\n" {} \; -exec printf "S %s\n" {} \; \) >> .merlin

ifeq ("$(DEVELOPMENT)","yes")
all:: .merlin
endif

François Bobot's avatar
François Bobot committed
204
205
lib/fc/META.frama-c: share/META.frama-c share/Makefile.config Makefile.generating
	$(MKDIR) lib/fc/
206
	$(SED) "s/@REQUIRES/$(LIBRARY_NAMES)/" $< > $@
François Bobot's avatar
François Bobot committed
207
208
209

GENERATED += lib/fc/META.frama-c

210
211
212
213

# Local Variables:
# mode: makefile
# End: