File: Makefile.common

package info (click to toggle)
frama-c 20161101%2Bsilicon%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 42,324 kB
  • ctags: 35,695
  • sloc: ml: 200,142; ansic: 31,465; makefile: 2,334; sh: 1,643; lisp: 259; python: 85; asm: 26
file content (259 lines) | stat: -rw-r--r-- 8,659 bytes parent folder | download
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
##########################################################################
#                                                                        #
#  This file is part of Frama-C.                                         #
#                                                                        #
#  Copyright (C) 2007-2016                                               #
#    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).            #
#                                                                        #
##########################################################################

##########################################################################
#                                                                        #
# Define common stuff shared by makefiles.                               #
#                                                                        #
##########################################################################

include $(MAKECONFIG_DIR)/Makefile.config

#######################
# Working directories #
#######################

# Frama-C kernel directories
FRAMAC_SRC_DIRS= plugins/slicing_types plugins/pdg_types plugins/value_types \
	       libraries/stdlib libraries/utils \
	       libraries/project libraries/datatype \
	       kernel_internals/parsing \
	       kernel_internals/typing \
	       kernel_internals/runtime \
	       kernel_services/parsetree \
	       kernel_services/ast_data \
	       kernel_services/ast_queries \
	       kernel_services/ast_printing \
	       kernel_services/cmdline_parameters \
	       kernel_services/plugin_entry_points \
	       kernel_services/abstract_interp \
	       kernel_services/visitors \
	       kernel_services/analysis \
	       kernel_services/ast_transformations \
	       plugins/gui
FRAMAC_SRC_DIRS:= $(addprefix src/, $(FRAMAC_SRC_DIRS))

#################
# OCaml version #
#################

# Cumulative semantics: HAS_OCAMLnnn should be set if OCaml version is mmm
# with mmm >= nnn

# findstring returns an empty string if it does not match, and the value it
# searches if it matches. Hence we compare with the empty string
HAS_OCAML403=no
ifeq ($(findstring 4.02,$(OCAMLVERSION)),)
  HAS_OCAML403 = yes
endif


##################
# Flags          #
##################

# Flags to be used by ocamlc and ocamlopt when compiling Frama-C
# itself. For development versions, we add -warn-error for most
# warnings -warn-error has effect only for warnings that are
# explicitely set using '-w'.
ifeq ($(DEVELOPMENT),yes)
# Most warnings are activated by default. The few that are deactivated are
# impossible to silence with the current Frama-C. Those settings are inherited
# in the compilation of external plugins.
WARNINGS ?= -w +a-4-6-9-41-44-45-48-50
WARN_ERROR ?= -warn-error +a-3-32-33-34-35-36-37-38-39-58
else
WARNINGS ?= -w -a
endif #DEVELOPMENT

FLAGS	= $(WARNINGS) $(WARN_ERROR) $(OCAML_ANNOT_OPTION) -strict-sequence \
          -safe-string
DEBUG	= -g

#############
# Verbosing #
#############

ifneq ($(VERBOSEMAKE),no) # Do not change to ifeq ($(VERBOSEMAKE),yes), as this
                          # version makes it easier for the user to set the
			  # option on the command-line to investigate
			  # Makefile-related problems
# ignore the PRINT_* materials but print all the other commands
  PRINT = @true
# prevent the warning "jobserver unavailable: using -j1".
# see GNU make manual (section 5.7.1 and appendix B)
  QUIET_MAKE:= + $(MAKE)
# prevent the warning: "-jN forced in submake: disabling jobserver mode".
# see GNU make manual (appendix B)
  MAKE := MAKEFLAGS="$(patsubst j,,$(MAKEFLAGS))" $(MAKE)
else
# print the PRINT_* materials
  PRINT = @echo
# but silently execute all the other commands
# fixed bug #637: do not write spaces between flags
  OLDFLAGS:=r$(MAKEFLAGS)
  MAKEFLAGS:=rs$(MAKEFLAGS)
# do not silently execute other makefiles (e.g the one of why):
# the redefinition of MAKE below is for this purpose
# but use QUIET_MAKE in order to call silently the initial Makefile
  QUIET_MAKE:= + $(MAKE)
  MAKE := MAKEFLAGS="$(OLDFLAGS)" $(MAKE)
endif


##################
# Shell commands #
##################

# prefer to use these commands and not directly "cp" or others

CAT	= cat
CHMOD	= chmod
CHMOD_RO= true
CHMOD_RW= sh -c \
'for f in "$$@"; do \
  if test -e $$f; then chmod u+w $$f; fi \
done' chmod_rw
CP      = cp
CP_IF_DIFF = sh -c \
  'if cmp -s $$1 $$2; \
   then touch -r $$2 $$1; \
   else echo "Generating  $$2"; install $$1 $$2; fi' cpifdiff
#follow symbolic link
CP_L    = cp -fL
ECHO	= echo
MKDIR   = mkdir -p
MV	= mv
ISED	= sh -c \
'new_temp=`mktemp /tmp/frama-c.XXXXXXX` || exit 1; \
sed "$$@" > $$new_temp; \
eval last=\$${$$\#}; \
mv $$new_temp $$last' sed_inplace
SED	= LC_ALL=C sed
RM	= rm -f
TAR	= tar
TOUCH	= touch
GIT	= git

##################
# Make commands #
##################

map=$(foreach a,$(2),$(call $(1),$(a)))

define assert_defined
ifndef $(1)
$$(error Undefined variable $(1) please report.)
endif
endef

###########################
# Command pretty printing #
###########################

PRINT_OCAMLC   	=$(PRINT) 'Ocamlc      '#
PRINT_OCAMLOPT 	=$(PRINT) 'Ocamlopt    '#
PRINT_DEP      	=$(PRINT) 'Ocamldep    '#
PRINT_OCAMLLEX 	=$(PRINT) 'Ocamllex    '#
PRINT_OCAMLYACC	=$(PRINT) 'Ocamlyacc   '#
PRINT_OCAMLMKTOP=$(PRINT) 'Ocamlmktop  '#
PRINT_DOC	=$(PRINT) 'Ocamldoc    '#
PRINT_OCAMLCP  	=$(PRINT) 'Profiling   '#
PRINT_CAMLP4   	=$(PRINT) 'Camlp4      '#
PRINT_PACKING  	=$(PRINT) 'Packing     '#
PRINT_LINKING  	=$(PRINT) 'Linking     '#
PRINT_INFERRING	=$(PRINT) 'Inferring   '#
PRINT_CC   	=$(PRINT) 'CC          '#

PRINT_MAKING   	=$(PRINT) 'Generating  '#
PRINT_MV       	=$(PRINT) 'Moving to   '#
PRINT_CP       	=$(PRINT) 'Copying to  '#
PRINT_RM       	=$(PRINT) 'Cleaning    '#
PRINT_EXEC	=$(PRINT) 'Running     '#
PRINT_TAR    	=$(PRINT) 'Archiving   '#
PRINT_UNTAR    	=$(PRINT) 'Unarchiving '#
PRINT_CONFIG   	=$(PRINT) 'Configuring '#
PRINT_BUILD   	=$(PRINT) 'Building    '#
PRINT_INSTALL  	=$(PRINT) 'Installing  '#
PRINT_UPDATE  	=$(PRINT) 'Updating    '#

PRINT_DOT	=$(PRINT) 'Dot         '#
PRINT_LATEX	=$(PRINT) 'Latex       '#
PRINT_DVIPS	=$(PRINT) 'Dvips       '#
PRINT_HEVEA	=$(PRINT) 'Hevea       '#

#########
# Tests #
#########


#################
# Documentation #
#################

NATIVE_OCAMLDOC:=$(shell ocamlfind ocamldoc -v | grep -o ocamldoc.opt)

ifeq ("$(NATIVE_OCAMLDOC)","ocamldoc.opt")
DOC_PLUGIN=$(DOC_DIR)/docgen.cmxs
else
DOC_PLUGIN=$(DOC_DIR)/docgen.cmo
endif

##########################
# Plugin File Generation #
##########################

#take the name of the plugin as argument $(1)
define include_generic_plugin_Makefile
$(call assert_defined,PLUGIN_DIR)
$(PLUGIN_DIR)/.Makefile.plugin.generated: $(MAKECONFIG_DIR)/Makefile.plugin.template
	$(PRINT_MAKING)	$$@
	$(SED) -e "s/@PLUGIN_NAME@/$(1)/g" $$< > $$@

# We still clean the old Makefile.plugin.generated (without the dot) temporarily
clean::
	rm -rf $(PLUGIN_DIR)/.Makefile.plugin.generated
	rm -rf $(PLUGIN_DIR)/Makefile.plugin.generated

#We always define this variable because it can't wait the generation
#of the Makefile.plugin.generated since the targets of rules defined in the
#Makefile of the plugins could use this variable
$(1)_DIR:=$(PLUGIN_DIR)

sinclude $(PLUGIN_DIR)/.Makefile.plugin.generated

endef

%.check_mli_exists: %.mli
	touch $@

.PHONY:common_force_rule

%.check_mli_exists: common_force_rule
	$(error "The file '$*.mli' must be provided. The simplest workaround is 'touch $*.mli')


##########################################################################
# Local Variables:
# compile-command: "make"
# mode: makefile
# End: