Makefile 87 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
#    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).            #
#                                                                        #
##########################################################################

# This file is the main makefile of Frama-C.

FRAMAC_SRC=.
MAKECONFIG_DIR=share
PLUGIN_TESTS_LIST:=
include share/Makefile.common
include share/Makefile.dynamic_config.internal

#Check share/Makefile.config available
ifndef FRAMAC_ROOT_SRCDIR
33
34
$(error \
  "You should run ./configure first (or autoconf if there is no configure)")
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
endif

###################
# Frama-C Version #
###################

VERSION:=$(shell $(CAT) VERSION)
VERSION_CODENAME:=$(shell $(CAT) VERSION_CODENAME)

###########################
# Global plugin variables #
###########################

# the directory where compiled plugin non-GUI files are stored
PLUGIN_TOP_LIB_DIR= $(PLUGIN_LIB_DIR)/top

# the directory where compiled plugin GUI files are stored
PLUGIN_GUI_LIB_DIR= $(PLUGIN_LIB_DIR)/gui

# the directory where the other Makefiles are
FRAMAC_SHARE	= share

# Shared lists between Makefile.plugin and Makefile :
# initialized them as "simply extended variables" (with :=)
# for a correct behavior of += (see section 6.6 of GNU Make manual)
PLUGIN_LIST	:=
PLUGIN_GENERATED_LIST:=
PLUGIN_CMO_LIST	:=
PLUGIN_CMX_LIST	:=
PLUGIN_META_LIST :=
PLUGIN_DYN_CMI_LIST :=
PLUGIN_DYN_CMO_LIST :=
PLUGIN_DYN_CMX_LIST :=
PLUGIN_INTERNAL_CMO_LIST:=
PLUGIN_INTERNAL_CMX_LIST:=
PLUGIN_GUI_CMO_LIST:=
PLUGIN_GUI_CMX_LIST:=
PLUGIN_DYN_DEP_GUI_CMO_LIST:=
PLUGIN_DYN_DEP_GUI_CMX_LIST:=
PLUGIN_DYN_GUI_CMO_LIST :=
PLUGIN_DYN_GUI_CMX_LIST :=
PLUGIN_TYPES_CMO_LIST :=
PLUGIN_TYPES_CMX_LIST :=
PLUGIN_DEP_LIST:=
PLUGIN_DOC_LIST :=
PLUGIN_DOC_DIRS :=
PLUGIN_DISTRIBUTED_LIST:=
PLUGIN_DIST_TARGET_LIST:=
PLUGIN_DIST_DOC_LIST:=
PLUGIN_BIN_DOC_LIST:=
PLUGIN_DIST_EXTERNAL_LIST:=
PLUGIN_DIST_TESTS_LIST:=
PLUGIN_DISTRIBUTED_NAME_LIST:=
MERLIN_PACKAGES:=

PLUGIN_HEADER_SPEC_LIST :=
PLUGIN_HEADER_DIRS_LIST :=
PLUGIN_HEADER_EXCEPTIONS_LIST :=
PLUGIN_CEA_PROPRIETARY_HEADERS_LIST :=
PLUGIN_CEA_PROPRIETARY_FILES_LIST :=

# default value used for HEADER_SPEC and PLUGIN_HEADER_SPEC
DEFAULT_HEADER_SPEC := headers/header_spec.txt
# default value used for HEADER_DIRS and PLUGIN_HEADER_DIRS
DEFAULT_HEADER_DIRS := headers
# default value used for HEADER_EXCEPTIONS and PLUGIN_HEADER_EXCEPTIONS
DEFAULT_HEADER_EXCEPTIONS := configure
# default value used for CEA_PROPRIETARY_FILES and PLUGIN_CEA_PROPRIETARY_FILES
DEFAULT_CEA_PROPRIETARY_FILES := tests/non-free/%
104
105
# default value used for CEA_PROPRIETARY_HEADERS
# and PLUGIN_CEA_PROPRIETARY_HEADERS
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
DEFAULT_CEA_PROPRIETARY_HEADERS := CEA_PROPRIETARY

MERLIN_PACKAGES:=

###############################
# Additional global variables #
###############################

# Directories containing some source code
SRC_DIRS= ptests $(PLUGIN_LIB_DIR) $(FRAMAC_SRC_DIRS)

# Directory containing source code documentation
DOC_DIR	= doc/code

# Source files to document
MODULES_TODOC=

# Directories to include when compiling
INCLUDES=$(addprefix -I ,$(FRAMAC_SRC_DIRS)) -I $(PLUGIN_LIB_DIR)
ifneq ($(ENABLE_GUI),no)
GUI_INCLUDES = $(addprefix -package ,$(LIBRARY_NAMES_GUI))
else
GUI_INCLUDES =
endif

# Files for which dependencies must be computed.
# Other files are added later in this Makefile.
FILES_FOR_OCAMLDEP+=$(PLUGIN_LIB_DIR)/*.mli

BFLAGS	= $(PACKAGES) $(FLAGS) $(DEBUG) $(INCLUDES) \
		$(FRAMAC_USER_BFLAGS)
OFLAGS	= $(PACKAGES) $(FLAGS) $(DEBUG) $(INCLUDES) -compact \
		$(FRAMAC_USER_OFLAGS)

BLINKFLAGS += -linkpkg $(BFLAGS) -linkall -custom
OLINKFLAGS += -linkpkg $(OFLAGS) -linkall

143
DOC_FLAGS= -charset utf8 -colorize-code -stars -m A $(PACKAGES) $(INCLUDES) $(GUI_INCLUDES)
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

ifneq ($(VERBOSEMAKE),yes)
DOC_FLAGS+= -hide-warnings
endif

# Files that depend on external libraries -namely Zarith- whose interface
# has not been explicitely declared -opaque, hence would trigger warning 58.
# This can't be solved by Frama-C itself, we can only wait for an update of
# said library.

NON_OPAQUE_DEPS:=

# Libraries generated by Frama-C
GEN_BYTE_LIBS=
GEN_OPT_LIBS=

# Libraries used in Frama-C
EXTRA_OPT_LIBS:=
PACKAGES = $(addprefix -package ,$(LIBRARY_NAMES))
BYTE_LIBS = $(GEN_BYTE_LIBS)
OPT_LIBS = $(EXTRA_OPT_LIBS)

OPT_LIBS+= $(GEN_OPT_LIBS)

ICONS:= $(addprefix share/,\
		frama-c.ico frama-c.png unmark.png \
		switch-on.png switch-off.png)

THEME_ICON_NAMES:= \
		never_tried.png \
		unknown.png \
		surely_valid.png \
		surely_invalid.png \
		considered_valid.png \
		valid_under_hyp.png \
		invalid_under_hyp.png \
		invalid_but_dead.png \
		unknown_but_dead.png \
		valid_but_dead.png \
		inconsistent.png \
		fold.png unfold.png

THEME_ICONS_DEFAULT:= \
  $(addprefix share/theme/default/,$(THEME_ICON_NAMES))
THEME_ICONS_COLORBLIND:= \
  $(addprefix share/theme/colorblind/,$(THEME_ICON_NAMES))
THEME_ICONS_FLAT:= \
  $(addprefix share/theme/flat/,$(THEME_ICON_NAMES))

ROOT_LIBC_DIR:= share/libc
Andre Maroneze's avatar
Andre Maroneze committed
194
LIBC_SUBDIRS:= sys netinet net arpa
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
LIBC_DIR:= $(ROOT_LIBC_DIR) $(addprefix $(ROOT_LIBC_DIR)/,$(LIBC_SUBDIRS))
LIBC_FILES:= \
	$(wildcard share/*.h share/*.c) \
	$(wildcard $(addsuffix /*.h,$(LIBC_DIR))) \
	$(wildcard $(addsuffix /*.c,$(LIBC_DIR)))

# Checks that all .h can be included multiple times.
ALL_LIBC_HEADERS:=$(wildcard share/*.h $(addsuffix /*.h,$(LIBC_DIR)))

check-libc: bin/toplevel.$(OCAMLBEST)$(EXE)
	@echo "checking libc..."; \
	 EXIT_VALUE=0; \
	 for file in $(filter-out share/builtin.h,$(ALL_LIBC_HEADERS)); do \
	   echo "#include \"$$file\"" > check-libc.c; \
	   echo "#include \"$$file\"" >> check-libc.c; \
	   FRAMAC_SHARE=share bin/toplevel.$(OCAMLBEST)$(EXE) \
	   -cpp-extra-args="-Ishare/libc -nostdinc" check-libc.c \
	       > $$(basename $$file .h).log 2>&1; \
	   if test $$? -ne 0; then \
	     if grep -q -e '#error "Frama-C:' $$file; then : ; \
	     else \
	       echo "$$file cannot be included twice. \
Output is in $$(basename $$file .h).log"; \
	       EXIT_VALUE=1; \
	     fi; \
	   else \
	     rm $$(basename $$file .h).log; \
	   fi; \
	 done; \
	 rm check-libc.c; \
	 exit $$EXIT_VALUE

clean-check-libc:
	$(RM) *.log

# Kernel files to be included in the distribution.
# Plug-ins should use PLUGIN_DISTRIB_EXTERNAL if they export something else
# than *.ml* files in their directory.
# NB: configure for the distribution is generated in the distrib directory
# itself, rather than copied: otherwise, it could include references to
# non-distributed plug-ins.
DISTRIB_FILES:=\
237
      $(wildcard bin/migration_scripts/*2*.sh) bin/local_export.sh      \
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
      bin/frama-c bin/frama-c.byte bin/frama-c-gui bin/frama-c-gui.byte \
      bin/frama-c-config bin/frama-c-script                             \
      share/frama-c.WIN32.rc share/frama-c.Unix.rc                      \
      $(ICONS) $(THEME_ICONS_DEFAULT) $(THEME_ICONS_COLORBLIND)         \
      $(THEME_ICONS_FLAT)                                               \
      man/frama-c.1 doc/README						\
      doc/code/docgen.ml                                                \
      doc/code/*.css doc/code/intro_plugin.txt				\
      doc/code/intro_plugin_D_and_S.txt                                 \
      doc/code/intro_plugin_default.txt                                 \
      doc/code/intro_kernel_plugin.txt					\
      doc/code/toc_head.htm                                             \
      doc/code/toc_tail.htm                                             \
      doc/Makefile                                                      \
      $(filter-out ptests/ptests_config.ml,$(wildcard ptests/*.ml*))   \
      configure.in Makefile Makefile.generating				\
      Changelog config.h.in						\
      VERSION VERSION_CODENAME $(wildcard licenses/*)                   \
      $(LIBC_FILES)							\
257
      share/analysis-scripts/analysis.mk                                \
258
      share/analysis-scripts/benchmark_database.py                      \
259
      share/analysis-scripts/cmd-dep.sh                                 \
260
      share/analysis-scripts/concat-csv.sh                              \
261
      share/analysis-scripts/clone.sh                                   \
262
      share/analysis-scripts/creduce.sh                                 \
263
      share/analysis-scripts/epilogue.mk                                \
264
      share/analysis-scripts/fc_stubs.c                                 \
265
      share/analysis-scripts/find_fun.py                                \
266
      share/analysis-scripts/flamegraph.pl                              \
267
      share/analysis-scripts/frama_c_results.py                         \
268
      share/analysis-scripts/function_finder.py                         \
269
      share/analysis-scripts/git_utils.py                               \
270
      share/analysis-scripts/list_files.py                              \
271
      share/analysis-scripts/make_template.py                           \
272
      share/analysis-scripts/make_wrapper.py                            \
273
      share/analysis-scripts/normalize_jcdb.py                          \
274
      share/analysis-scripts/parse-coverage.sh                          \
275
      share/analysis-scripts/prologue.mk                                \
276
      share/analysis-scripts/README.md                                  \
277
278
      share/analysis-scripts/results_display.py                         \
      share/analysis-scripts/summary.py                                 \
279
280
281
      share/analysis-scripts/template.mk                                \
      $(wildcard share/emacs/*.el) share/autocomplete_frama-c           \
      share/_frama-c                                                    \
282
283
284
285
      share/compliance/c11_functions.json                               \
      share/compliance/glibc_functions.json                             \
      share/compliance/nonstandard_identifiers.json                     \
      share/compliance/posix_identifiers.json                           \
286
287
288
289
290
291
      share/configure.ac                                                \
      share/Makefile.config.in share/Makefile.common                    \
      share/Makefile.generic						\
      share/Makefile.plugin.template share/Makefile.dynamic		\
      share/Makefile.dynamic_config.external				\
      share/Makefile.dynamic_config.internal				\
292
      share/META.frama-c                                                \
293
      $(filter-out src/kernel_internals/runtime/fc_config.ml,              \
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
	  $(wildcard src/kernel_internals/runtime/*.ml*))               \
      $(wildcard src/kernel_services/abstract_interp/*.ml*)             \
      $(wildcard src/plugins/gui/*.ml*)                                 \
      $(wildcard src/libraries/stdlib/*.ml*)                            \
      $(wildcard src/libraries/utils/*.ml*)                             \
      $(wildcard src/libraries/utils/*.c)                               \
      $(wildcard src/libraries/project/*.ml*)                           \
      $(filter-out src/kernel_internals/parsing/check_logic_parser.ml,  \
          $(wildcard src/kernel_internals/parsing/*.ml*))               \
      $(wildcard src/kernel_internals/typing/*.ml*)                     \
      $(wildcard src/kernel_services/ast_data/*.ml*)                    \
      $(wildcard src/kernel_services/ast_queries/*.ml*)                 \
      $(wildcard src/kernel_services/ast_printing/*.ml*)                \
      $(wildcard src/kernel_services/cmdline_parameters/*.ml*)          \
      $(wildcard src/kernel_services/analysis/*.ml*)                    \
      $(wildcard src/kernel_services/ast_transformations/*.ml*)         \
      $(wildcard src/kernel_services/plugin_entry_points/*.ml*)         \
      $(wildcard src/kernel_services/visitors/*.ml*)                    \
      $(wildcard src/kernel_services/parsetree/*.ml*)                   \
      $(wildcard src/libraries/datatype/*.ml*)                          \
      bin/sed_get_make_major bin/sed_get_make_minor                     \
      INSTALL.md README.md .make-clean	                        \
      .make-clean-stamp .force-reconfigure 	\
317
      opam/opam \
318
319
320

# Test files to be included in the distribution (without header checking).
# Plug-ins should use PLUGIN_DISTRIB_TESTS to export their test files. 
321
322
323
324
DISTRIB_TESTS=$(shell git ls-files \
                  tests \
                  src/plugins/aorai/tests \
                  src/plugins/report/tests \
325
                  src/plugins/wp/tests | $(SED) 's/ /@/g')
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


# files that are needed to compile API documentation of external plugins
DOC_GEN_FILES:=$(addprefix doc/code/,\
	*.css intro_plugin.txt intro_kernel_plugin.txt \
	intro_plugin_default.txt intro_plugin_D_and_S \
	kernel-doc.ocamldoc \
	docgen.ml docgen.cm* *.htm)

################
# Main targets #
################

# additional compilation targets for 'make all'.
# cannot be delayed after 'make all'
EXTRAS	= ptests bin/fc-config$(EXE)

ifneq ($(ENABLE_GUI),no)
ifeq ($(HAS_LABLGTK),yes)
EXTRAS	+= gui
endif
endif

all:: byte $(OCAMLBEST) $(EXTRAS) plugins_ptests_config

.PHONY: top opt byte dist bdist rebuild rebuild-branch

dist: clean
	$(QUIET_MAKE) all

clean-rebuild: clean
	$(QUIET_MAKE) all

rebuild: config.status
	$(MAKE) smartclean
	$(MAKE) depend $(FRAMAC_PARALLEL)
	$(MAKE) all $(FRAMAC_PARALLEL) || \
		(touch .force-reconfigure; \
		 $(MAKE) config.status && \
		 $(MAKE) depend $(FRAMAC_PARALLEL) && \
		 $(MAKE) all $(FRAMAC_PARALLEL))

368
369
sinclude .Makefile.user
# Should define FRAMAC_PARALLEL, FRAMAC_USER_FLAGS, FRAMAC_USER_MERLIN_FLAGS
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401

#Create link in share for local execution if
.PHONY:create_share_link
create_share_link: share/.gitignore

# note: when using opam pin path in a cloned Frama-C git, the symbolic links
# become directories, so a different command is necessary for each situation

share/.gitignore: share/Makefile.config
	if test -f $@; then \
	  for link in $$(cat $@); do \
	    if test -L share$$link; then \
	      rm -f share$$link \
	    else \
	      rm -rf share$$link; \
	    fi; \
	  done; \
	fi
	$(RM) $@.tmp
	touch $@.tmp
	$(foreach dir,$(EXTERNAL_PLUGINS),\
		if test -d $(dir)/share; then \
			echo "Sharing $(dir)/link"; \
			ln -s $(realpath $(dir)/share) share/$(notdir $(dir)); \
			echo /$(notdir $(dir)) >> $@.tmp; \
		fi; )
	mv $@.tmp $@

ifeq ("$(DEVELOPMENT)","yes")
all:: share/.gitignore
endif

François Bobot's avatar
François Bobot committed
402
clean_share_link:
403
404
405
406
407
408
409
410
411
412
413
	if test -f share/.gitignore; then \
	  for link in $$(cat share/.gitignore); do \
	    if test -L share$$link; then \
	      rm -f share$$link \
	    else \
	      rm -rf share$$link; \
	    fi; \
	  done; \
	  rm share/.gitignore; \
	fi

François Bobot's avatar
François Bobot committed
414
415
clean:: clean_share_link

416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
##################
# Frama-C Kernel #
##################

# Libraries which could be compiled fully independently
#######################################################

VERY_FIRST_CMO = src/kernel_internals/runtime/frama_c_init.cmo
CMO	+= $(VERY_FIRST_CMO)

LIB_CMO =\
        src/libraries/stdlib/transitioning \
	src/libraries/stdlib/FCHashtbl \
	src/libraries/stdlib/extlib \
	src/libraries/datatype/unmarshal \
	src/libraries/datatype/unmarshal_z \
	src/libraries/datatype/structural_descr \
	src/libraries/datatype/type \
	src/libraries/datatype/descr \
	src/libraries/utils/filepath \
436
	src/libraries/utils/sanitizer \
437
438
439
440
441
442
443
444
445
446
447
448
	src/libraries/utils/pretty_utils \
	src/libraries/utils/hook \
	src/libraries/utils/bag \
	src/libraries/utils/wto \
	src/libraries/utils/vector \
	src/libraries/utils/indexer \
	src/libraries/utils/rgmap \
	src/libraries/utils/bitvector \
	src/libraries/utils/qstack \
	src/libraries/stdlib/integer \
	src/libraries/utils/json \
	src/libraries/utils/markdown \
Loïc Correnson's avatar
Loïc Correnson committed
449
450
	src/libraries/utils/rich_text \
	src/libraries/utils/dotgraph
451
452
453
454
455
456
457
458
459
460
461

NON_OPAQUE_DEPS+=\
  src/libraries/datatype/unmarshal_z \
  src/libraries/stdlib/integer

LIB_CMO:= $(addsuffix .cmo,$(LIB_CMO))
CMO	+= $(LIB_CMO)

# Very first files to be linked (most modules use them)
###############################

462
FIRST_CMO= src/kernel_internals/runtime/fc_config \
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
	src/kernel_internals/runtime/gui_init \
	src/kernel_services/plugin_entry_points/log \
	src/kernel_services/cmdline_parameters/cmdline \
	src/libraries/project/project_skeleton \
	src/libraries/datatype/datatype \
	src/kernel_services/plugin_entry_points/journal

# project_skeleton requires log
# datatype requires project_skeleton
# rangemap requires datatype

FIRST_CMO:= $(addsuffix .cmo,$(FIRST_CMO))
CMO	+= $(FIRST_CMO)

#Project (Project_skeleton must be linked before Journal)
PROJECT_CMO= \
	state \
	state_dependency_graph \
	state_topological \
	state_selection \
	project \
	state_builder
PROJECT_CMO:= $(patsubst %,src/libraries/project/%.cmo,$(PROJECT_CMO))
CMO	+= $(PROJECT_CMO)

# kernel
########

KERNEL_CMO=\
	src/libraries/utils/utf8_logic.cmo                              \
	src/libraries/utils/binary_cache.cmo                            \
	src/libraries/utils/hptmap.cmo                                  \
	src/libraries/utils/hptset.cmo                                  \
	src/libraries/utils/escape.cmo                                  \
	src/kernel_services/ast_queries/cil_datatype.cmo             \
	src/kernel_services/cmdline_parameters/typed_parameter.cmo      \
	src/kernel_services/plugin_entry_points/dynamic.cmo             \
	src/kernel_services/cmdline_parameters/parameter_category.cmo   \
	src/kernel_services/cmdline_parameters/parameter_customize.cmo  \
	src/kernel_services/cmdline_parameters/parameter_state.cmo      \
	src/kernel_services/cmdline_parameters/parameter_builder.cmo    \
	src/kernel_services/plugin_entry_points/plugin.cmo              \
	src/kernel_services/plugin_entry_points/kernel.cmo              \
	src/libraries/utils/unicode.cmo                                 \
	src/kernel_services/plugin_entry_points/emitter.cmo             \
	src/libraries/utils/floating_point.cmo                          \
	src/libraries/utils/rangemap.cmo                                \
	src/kernel_services/ast_printing/cil_types_debug.cmo            \
	src/kernel_services/ast_printing/printer_builder.cmo            \
	src/libraries/utils/cilconfig.cmo                               \
	src/kernel_internals/typing/alpha.cmo                         \
	src/kernel_services/ast_queries/cil_state_builder.cmo        \
	src/kernel_internals/runtime/machdeps.cmo                       \
	src/kernel_services/ast_queries/cil_const.cmo                \
	src/kernel_services/ast_queries/logic_env.cmo                \
	src/kernel_services/ast_queries/logic_const.cmo              \
519
	src/kernel_services/visitors/visitor_behavior.cmo		\
520
521
522
523
524
525
526
527
528
529
530
	src/kernel_services/ast_queries/cil.cmo                      \
	src/kernel_internals/parsing/errorloc.cmo                      \
	src/kernel_services/ast_printing/cil_printer.cmo                \
	src/kernel_services/ast_printing/cil_descriptive_printer.cmo    \
	src/kernel_services/parsetree/cabs.cmo                               \
	src/kernel_services/parsetree/cabshelper.cmo                         \
	src/kernel_services/ast_printing/logic_print.cmo                \
	src/kernel_services/ast_queries/logic_utils.cmo              \
	src/kernel_internals/parsing/logic_parser.cmo                  \
	src/kernel_internals/parsing/logic_lexer.cmo                   \
	src/kernel_services/ast_queries/logic_typing.cmo             \
531
	src/kernel_services/ast_queries/acsl_extension.cmo				\
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
	src/kernel_services/ast_queries/ast_info.cmo                 \
	src/kernel_services/ast_data/ast.cmo                            \
	src/kernel_services/ast_printing/cprint.cmo                     \
	src/kernel_services/visitors/cabsvisit.cmo                      \
	src/kernel_internals/typing/cabs2cil.cmo                      \
	src/kernel_services/ast_data/globals.cmo                        \
	src/kernel_internals/typing/cfg.cmo                           \
	src/kernel_services/ast_data/kernel_function.cmo                \
	src/kernel_services/ast_data/property.cmo                       \
	src/kernel_services/ast_data/property_status.cmo                \
	src/kernel_services/ast_data/annotations.cmo                    \
	src/kernel_services/ast_printing/printer.cmo                    \
	src/kernel_internals/typing/logic_builtin.cmo                 \
	src/kernel_services/ast_printing/cabs_debug.cmo                 \
	src/kernel_internals/parsing/lexerhack.cmo                     \
	src/kernel_internals/parsing/clexer.cmo                        \
	src/kernel_internals/parsing/cparser.cmo                       \
	src/kernel_internals/parsing/logic_preprocess.cmo              \
	src/kernel_internals/typing/mergecil.cmo                      \
	src/kernel_internals/typing/rmtmps.cmo                        \
	src/kernel_internals/typing/oneret.cmo                        \
	src/kernel_internals/typing/frontc.cmo                        \
554
	src/kernel_internals/typing/substitute_const_globals.cmo        \
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
	src/kernel_services/analysis/ordered_stmt.cmo                   \
	src/kernel_services/analysis/wto_statement.cmo                  \
	src/kernel_services/analysis/dataflows.cmo                      \
	src/kernel_services/analysis/dataflow2.cmo                      \
	src/kernel_services/analysis/stmts_graph.cmo                    \
	src/kernel_services/analysis/dominators.cmo                     \
	src/kernel_services/analysis/service_graph.cmo                  \
	src/kernel_services/analysis/undefined_sequence.cmo             \
	src/kernel_services/analysis/interpreted_automata.cmo           \
	src/kernel_services/ast_data/alarms.cmo                         \
	src/kernel_services/ast_printing/description.cmo                \
	src/kernel_services/abstract_interp/lattice_messages.cmo        \
	src/kernel_services/abstract_interp/abstract_interp.cmo         \
	src/kernel_services/abstract_interp/bottom.cmo                  \
	src/kernel_services/abstract_interp/int_Base.cmo                \
	src/kernel_services/analysis/bit_utils.cmo                      \
	src/kernel_services/abstract_interp/fc_float.cmo                \
	src/kernel_services/abstract_interp/float_interval.cmo          \
	src/kernel_services/abstract_interp/fval.cmo                    \
574
575
	src/kernel_services/abstract_interp/int_interval.cmo            \
	src/kernel_services/abstract_interp/int_set.cmo                 \
576
	src/kernel_services/abstract_interp/int_val.cmo                 \
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
	src/kernel_services/abstract_interp/ival.cmo                    \
	src/kernel_services/abstract_interp/base.cmo                    \
	src/kernel_services/abstract_interp/origin.cmo                  \
	src/kernel_services/abstract_interp/map_lattice.cmo             \
	src/kernel_services/abstract_interp/tr_offset.cmo               \
	src/kernel_services/abstract_interp/offsetmap.cmo               \
	src/kernel_services/abstract_interp/int_Intervals.cmo           \
	src/kernel_services/abstract_interp/locations.cmo               \
	src/kernel_services/abstract_interp/lmap.cmo                    \
	src/kernel_services/abstract_interp/lmap_bitwise.cmo            \
	src/kernel_services/visitors/visitor.cmo                        \
	src/kernel_services/ast_data/statuses_by_call.cmo               \
	src/kernel_services/ast_printing/printer_tag.cmo                \
	$(PLUGIN_TYPES_CMO_LIST)                                        \
	src/kernel_services/plugin_entry_points/db.cmo                  \
	src/libraries/utils/command.cmo                                 \
	src/libraries/utils/task.cmo                                    \
	src/kernel_services/ast_queries/filecheck.cmo                \
	src/kernel_services/ast_queries/json_compilation_database.cmo   \
	src/kernel_services/ast_queries/file.cmo                     \
	src/kernel_internals/typing/translate_lightweight.cmo         \
598
	src/kernel_internals/typing/ghost_cfg.cmo			\
599
	src/kernel_internals/typing/ghost_accesses.cmo  		\
600
601
602
603
604
605
606
607
608
609
610
	src/kernel_internals/typing/allocates.cmo                     \
	src/kernel_internals/typing/unroll_loops.cmo                  \
	src/kernel_internals/typing/asm_contracts.cmo                 \
	src/kernel_services/analysis/loop.cmo                           \
	src/kernel_services/analysis/exn_flow.cmo                       \
        src/kernel_services/analysis/destructors.cmo                    \
	src/kernel_services/analysis/logic_interp.cmo                   \
	src/kernel_internals/typing/infer_annotations.cmo             \
	src/kernel_services/ast_transformations/clone.cmo                           \
	src/kernel_services/ast_transformations/filter.cmo                          \
	src/kernel_services/ast_transformations/inline.cmo              \
611
	src/kernel_internals/runtime/dump_config.cmo                    \
612
613
614
615
616
617
618
619
620
621
622
623
624
625
	src/kernel_internals/runtime/special_hooks.cmo                  \
	src/kernel_internals/runtime/messages.cmo

CMO	+= $(KERNEL_CMO)

MLI_ONLY+=\
	src/libraries/utils/hptmap_sig.mli                                   \
	src/kernel_services/cmdline_parameters/parameter_sig.mli             \
	src/kernel_services/ast_data/cil_types.mli                           \
	src/kernel_services/parsetree/logic_ptree.mli                             \
	src/kernel_services/ast_printing/printer_api.mli                     \
	src/kernel_services/abstract_interp/float_sig.mli                    \
	src/kernel_services/abstract_interp/float_interval_sig.mli           \
	src/kernel_services/abstract_interp/lattice_type.mli                 \
626
	src/kernel_services/abstract_interp/eva_lattice_type.mli             \
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
	src/kernel_services/abstract_interp/int_Intervals_sig.mli            \
	src/kernel_services/abstract_interp/offsetmap_lattice_with_isotropy.mli \
	src/kernel_services/abstract_interp/offsetmap_sig.mli                \
	src/kernel_services/abstract_interp/lmap_sig.mli                     \
	src/kernel_services/abstract_interp/offsetmap_bitwise_sig.mli

NO_MLI+= src/kernel_services/parsetree/cabs.mli                \
	src/kernel_internals/runtime/machdep_ppc_32.mli         \
	src/kernel_internals/runtime/machdep_x86_16.mli         \
	src/kernel_internals/runtime/machdep_x86_32.mli         \
	src/kernel_internals/runtime/machdep_x86_64.mli         \
	src/kernel_services/ast_printing/cabs_debug.mli        \
	src/kernel_internals/parsing/logic_lexer.mli           \
	src/kernel_internals/parsing/lexerhack.mli             \

MODULES_NODOC+= src/kernel_internals/runtime/machdep_ppc_32.ml \
	src/kernel_internals/runtime/machdep_x86_16.ml         \
	src/kernel_internals/runtime/machdep_x86_32.ml         \
	src/kernel_internals/runtime/machdep_x86_64.ml         \
	external/unmarshal_z.mli


GENERATED += $(addprefix src/kernel_internals/parsing/,\
		clexer.ml cparser.ml cparser.mli \
		logic_lexer.ml logic_parser.ml \
		logic_parser.mli logic_preprocess.ml)


.PHONY: check-logic-parser-wildcard
check-logic-parser-wildcard:
	cd src/kernel_internals/parsing && ocaml check_logic_parser.ml

NON_OPAQUE_DEPS+= src/kernel_services/plugin_entry_points/dynamic

# C Bindings
############

GEN_C_BINDINGS=src/libraries/utils/c_bindings.o
GEN_C_BINDINGS_FLAGS= -fPIC
GEN_BYTE_LIBS+= $(GEN_C_BINDINGS)
GEN_OPT_LIBS+= $(GEN_C_BINDINGS)

src/libraries/utils/c_bindings.o: src/libraries/utils/c_bindings.c
	$(PRINT_CC) $@
	$(CC) $(GEN_C_BINDINGS_FLAGS) -c -I$(call winpath,$(OCAMLLIB)) -O3 -Wall -o $@ $<

# Common startup module
# All link command should add it as last linked module and depend on it.
########################################################################

STARTUP_CMO=src/kernel_internals/runtime/boot.cmo
STARTUP_CMX=$(STARTUP_CMO:.cmo=.cmx)

# GUI modules
# See below for GUI compilation
##############################################################################

WTOOLKIT= \
	wutil widget wbox wfile wpane wpalette wtext wtable

687
ifeq ("$(LABLGTK_VERSION)","3")
688

689
src/plugins/gui/GSourceView.ml: src/plugins/gui/GSourceView3.ml.in
690
691
692
	$(CP) $< $@
	$(CHMOD_RO) $@

693
src/plugins/gui/GSourceView.mli: src/plugins/gui/GSourceView3.mli.in
694
695
696
	$(CP) $< $@
	$(CHMOD_RO) $@

697
698
699
700
701
702
703
704
else
src/plugins/gui/GSourceView.ml: src/plugins/gui/GSourceView2.ml.in
	$(CP) $< $@
	$(CHMOD_RO) $@

src/plugins/gui/GSourceView.mli: src/plugins/gui/GSourceView2.mli.in
	$(CP) $< $@
	$(CHMOD_RO) $@
705

706
707
endif

708
SOURCEVIEWCOMPAT:=GSourceView
709
710
GENERATED+=src/plugins/gui/GSourceView.ml src/plugins/gui/GSourceView.mli \
           src/plugins/gui/dgraph_helper.ml src/plugins/gui/gtk_compat.ml
711

712
713
ifeq ($(LABLGTK),lablgtk3)
src/plugins/gui/gtk_compat.ml: src/plugins/gui/gtk_compat.3.ml
714
715
	$(CP) $< $@
	$(CHMOD_RO) $@
716
717
else
src/plugins/gui/gtk_compat.ml: src/plugins/gui/gtk_compat.2.ml
718
719
	$(CP) $< $@
	$(CHMOD_RO) $@
720
endif
721
GENERATED+=src/plugins/gui/gtk_compat.ml
722

723
SINGLE_GUI_CMO:= \
724
	wutil_once \
725
	gtk_compat \
726
	$(WTOOLKIT) \
727
	$(SOURCEVIEWCOMPAT) \
728
	gui_parameters \
729
	gtk_helper \
730
        dgraph_helper \
731
        gtk_form \
732
733
734
735
736
737
738
739
	source_viewer pretty_source source_manager book_manager \
	warning_manager \
	filetree \
	launcher \
	menu_manager \
	history \
	gui_printers \
	design \
740
	analyses_manager file_manager project_manager \
741
	help_manager \
742
743
        $(DGRAPHFILES) \
        property_navigator \
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782

SINGLE_GUI_CMO:= $(patsubst %,src/plugins/gui/%.cmo,$(SINGLE_GUI_CMO))

###############################################################################
#                                                                             #
####################                                                          #
# Plug-in sections #                                                          #
####################                                                          #
#                                                                             #
# For 'internal' developers:                                                  #
# you can add your own plug-in here,                                          #
# but it is better to have your own separated Makefile                        #
###############################################################################

###########
# Metrics #
###########

PLUGIN_ENABLE:=$(ENABLE_METRICS)
PLUGIN_NAME:=Metrics
PLUGIN_DISTRIBUTED:=yes
PLUGIN_DIR:=src/plugins/metrics
PLUGIN_CMO:= metrics_parameters css_html metrics_base metrics_acsl \
	     metrics_cabs metrics_cilast metrics_coverage \
	     register
PLUGIN_GUI_CMO:= metrics_gui register_gui
PLUGIN_DEPENDENCIES:=Eva
PLUGIN_INTERNAL_TEST:=yes
$(eval $(call include_generic_plugin_Makefile,$(PLUGIN_NAME)))

#############
# Callgraph #
#############

PLUGIN_ENABLE:=$(ENABLE_CALLGRAPH)
PLUGIN_NAME:=Callgraph
PLUGIN_DISTRIBUTED:=yes
PLUGIN_DIR:=src/plugins/callgraph
PLUGIN_CMO:= options journalize subgraph cg services uses register
783
ifeq ($(HAS_DGRAPH),yes)
784
PLUGIN_GUI_CMO:=cg_viewer
785
PLUGIN_GENERATED:=$(PLUGIN_DIR)/cg_viewer.ml
786
787
else
PLUGIN_GUI_CMO:=
788
PLUGIN_DISTRIB_EXTERNAL:=cg_viewer.ml
789
endif
790
791
792
793
794
795
796
797
798
799
800
801
802
803
PLUGIN_CMI:= callgraph_api
PLUGIN_INTERNAL_TEST:=yes
PLUGIN_TESTS_DIRS:=callgraph
PLUGIN_TESTS_LIB:=tests/callgraph/function_pointer.ml
$(eval $(call include_generic_plugin_Makefile,$(PLUGIN_NAME)))


##################
# Evolved Value Analysis #
##################

PLUGIN_ENABLE:=$(ENABLE_EVA)
PLUGIN_NAME:=Eva
PLUGIN_DIR:=src/plugins/value
804
PLUGIN_EXTRA_DIRS:=engine values domains api domains/cvalue domains/apron \
805
	domains/gauges domains/equality legacy partitioning utils gui_files \
806
	api values/numerors domains/numerors
807
PLUGIN_TESTS_DIRS+=value/traces
808
809
810
811

# Files for the binding to Apron domains. Only available if Apron is available.
ifeq ($(HAS_APRON),yes)
PLUGIN_REQUIRES+= apron.octMPQ apron.boxMPQ apron.polkaMPQ apron.apron gmp
812
APRON_CMO:= domains/apron/apron_domain
813
else
814
APRON_CMO:=
815
PLUGIN_DISTRIB_EXTERNAL+= \
816
817
	domains/apron/apron_domain.ml domains/apron/apron_domain.mli
endif
818
819
820
821
822

# Files for the numerors domain. Only available is MPFR is available.
NUMERORS_FILES:= \
	values/numerors/numerors_utils values/numerors/numerors_float \
	values/numerors/numerors_interval values/numerors/numerors_arithmetics \
823
	values/numerors/numerors_value domains/numerors/numerors_domain
824
825
826
827
828
829
830
831
832
833
834
835
836
837

ifeq ($(HAS_MPFR),yes)
PLUGIN_REQUIRES+= gmp
PLUGIN_TESTS_DIRS+=value/numerors
NUMERORS_CMO:= $(NUMERORS_FILES)
else
# Do not compile numerors files, but include them in the distributed files.
NUMERORS_CMO:=
PLUGIN_DISTRIB_EXTERNAL+= $(addsuffix .ml,$(NUMERORS_FILES))
PLUGIN_DISTRIB_EXTERNAL+= $(addsuffix .mli,$(NUMERORS_FILES))
endif

# General rules for ordering files within PLUGIN_CMO:
# - try to keep the legacy Value before Eva
838
PLUGIN_CMO:= partitioning/split_strategy domains/domain_mode value_parameters \
839
840
	utils/value_perf utils/eva_annotations \
	utils/value_util utils/red_statuses \
841
	utils/mark_noresults \
842
	utils/widen_hints_ext utils/widen \
843
	partitioning/split_return \
844
	partitioning/per_stmt_slevel \
845
846
	utils/library_functions \
	utils/eval_typ utils/backward_formals \
847
	alarmset eval utils/structure utils/abstract \
848
849
850
851
852
853
854
855
	values/value_product values/location_lift \
	values/cvalue_forward values/cvalue_backward \
	values/main_values values/main_locations \
	values/offsm_value values/sign_value \
	legacy/eval_op legacy/function_args \
	domains/domain_store domains/domain_builder \
	domains/domain_product domains/domain_lift domains/unit_domain \
	domains/printer_domain \
856
	domains/traces_domain \
857
	domains/simple_memory \
David Bühler's avatar
David Bühler committed
858
	domains/octagons \
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
	domains/gauges/gauges_domain \
	domains/hcexprs \
	domains/equality/equality domains/equality/equality_domain \
	domains/offsm_domain \
	domains/symbolic_locs \
	domains/sign_domain \
	domains/cvalue/warn domains/cvalue/locals_scoping \
	domains/cvalue/cvalue_offsetmap \
	utils/value_results \
	domains/cvalue/builtins domains/cvalue/builtins_malloc \
	domains/cvalue/builtins_string domains/cvalue/builtins_misc \
	domains/cvalue/builtins_memory domains/cvalue/builtins_print_c \
	domains/cvalue/builtins_watchpoint \
	domains/cvalue/builtins_float domains/cvalue/builtins_split \
	domains/inout_domain \
	legacy/eval_terms legacy/eval_annots \
	domains/powerset engine/transfer_logic \
	domains/cvalue/cvalue_transfer domains/cvalue/cvalue_init \
	domains/cvalue/cvalue_specification \
	domains/cvalue/cvalue_domain \
879
	engine/subdivided_evaluation engine/evaluation engine/abstractions \
880
	engine/recursion engine/transfer_stmt engine/transfer_specification \
881
	partitioning/auto_loop_unroll \
882
883
884
	partitioning/partition partitioning/partitioning_parameters \
	partitioning/partitioning_index partitioning/trace_partitioning \
	engine/mem_exec engine/iterator engine/initialization \
885
	engine/compute_functions engine/analysis register \
886
	api/general_requests \
Loïc Correnson's avatar
Loïc Correnson committed
887
	utils/unit_tests \
888
	api/values_request \
889
	$(APRON_CMO) $(NUMERORS_CMO)
890
891
PLUGIN_CMI:= values/abstract_value values/abstract_location \
	domains/abstract_domain domains/simpler_domains
892
PLUGIN_DEPENDENCIES:=Callgraph LoopAnalysis RteGen Server
893
894
895
896
897
898
899
900

# These files are used by the GUI, but do not depend on Lablgtk
VALUE_GUI_AUX:=gui_files/gui_types gui_files/gui_eval \
		gui_files/gui_callstacks_filters
PLUGIN_GUI_CMO:=$(VALUE_GUI_AUX) gui_files/gui_callstacks_manager \
		gui_files/gui_red gui_files/register_gui

PLUGIN_INTERNAL_TEST:= yes
901
PLUGIN_TESTS_LIB=tests/float/fval_test.ml
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
PLUGIN_DISTRIBUTED:=yes
VALUE_TYPES:=$(addprefix src/plugins/value_types/,\
		cilE cvalue precise_locs value_types widen_type)
PLUGIN_TYPES_CMO:=$(VALUE_TYPES)
PLUGIN_TYPES_TODOC:=$(addsuffix .mli,$(VALUE_TYPES))

$(eval $(call include_generic_plugin_Makefile,$(PLUGIN_NAME)))

##################
# Occurrence     #
##################

PLUGIN_ENABLE:=$(ENABLE_OCCURRENCE)
PLUGIN_NAME:=Occurrence
PLUGIN_DISTRIBUTED:=yes
PLUGIN_DIR:=src/plugins/occurrence
PLUGIN_CMO:= options register
PLUGIN_GUI_CMO:=register_gui
PLUGIN_INTRO:=doc/code/intro_occurrence.txt
PLUGIN_INTERNAL_TEST:=yes
PLUGIN_DEPENDENCIES:=Eva
$(eval $(call include_generic_plugin_Makefile,$(PLUGIN_NAME)))

################################################
# Runtime Error Annotation Generation analysis #
################################################

PLUGIN_ENABLE:=$(ENABLE_RTEGEN)
PLUGIN_NAME:=RteGen
PLUGIN_DIR:=src/plugins/rte
932
PLUGIN_CMO:= options generator rte flags visit register
933
934
935
PLUGIN_DISTRIBUTED:=yes
PLUGIN_INTERNAL_TEST:=yes
PLUGIN_TESTS_DIRS:=rte rte_manual
936
937
938
939
940
PLUGIN_TESTS_LIB:=\
  tests/rte/my_annotation/my_annotation.ml \
  tests/rte/rte_api/rte_get_annot.ml \
  tests/rte/compute_annot/compute_annot.ml \
  tests/rte/my_annot_proxy/my_annot_proxy.ml
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
$(eval $(call include_generic_plugin_Makefile,$(PLUGIN_NAME)))

#################
# From analysis #
#################

PLUGIN_ENABLE:=$(ENABLE_FROM_ANALYSIS)
PLUGIN_NAME:=From
PLUGIN_DIR:=src/plugins/from
PLUGIN_CMO:= from_parameters from_compute \
	functionwise callwise from_register
PLUGIN_GUI_CMO:=from_register_gui
PLUGIN_TESTS_DIRS:=idct test float
PLUGIN_DISTRIBUTED:=yes
PLUGIN_INTERNAL_TEST:=yes
FROM_TYPES:=src/plugins/value_types/function_Froms
PLUGIN_TYPES_CMO:=$(FROM_TYPES)
PLUGIN_TYPES_TODOC:=$(addsuffix .mli,$(FROM_TYPES))
PLUGIN_DEPENDENCIES:=Callgraph Eva Postdominators

$(eval $(call include_generic_plugin_Makefile,$(PLUGIN_NAME)))

##################
# Users analysis #
##################

PLUGIN_ENABLE:=$(ENABLE_USERS)
PLUGIN_NAME:=Users
PLUGIN_DIR:=src/plugins/users
PLUGIN_CMO:= users_register
PLUGIN_NO_TEST:=yes
PLUGIN_DISTRIBUTED:=yes
PLUGIN_INTERNAL_TEST:=yes
PLUGIN_DEPENDENCIES:=Callgraph Eva

$(eval $(call include_generic_plugin_Makefile,$(PLUGIN_NAME)))

########################
# Constant propagation #
########################

PLUGIN_ENABLE:=$(ENABLE_CONSTANT_PROPAGATION)
PLUGIN_NAME:=Constant_Propagation
PLUGIN_DIR:=src/plugins/constant_propagation
985
PLUGIN_TESTS_LIB:=tests/constant_propagation/introduction_of_non_explicit_cast.ml
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
PLUGIN_CMO:= propagationParameters \
	api
PLUGIN_DISTRIBUTED:=yes
PLUGIN_INTERNAL_TEST:=yes
PLUGIN_DEPENDENCIES:=Eva

$(eval $(call include_generic_plugin_Makefile,$(PLUGIN_NAME)))

###################
# Post-dominators #
###################

PLUGIN_ENABLE:=$(ENABLE_POSTDOMINATORS)
PLUGIN_NAME:=Postdominators
PLUGIN_DIR:=src/plugins/postdominators
PLUGIN_CMO:= postdominators_parameters print compute
PLUGIN_NO_TEST:=yes
PLUGIN_DISTRIBUTED:=yes
PLUGIN_INTERNAL_TEST:=yes
$(eval $(call include_generic_plugin_Makefile,$(PLUGIN_NAME)))

#########
# inout #
#########

PLUGIN_ENABLE:=$(ENABLE_INOUT)
PLUGIN_NAME:=Inout
PLUGIN_DIR:=src/plugins/inout
PLUGIN_CMO:= inout_parameters cumulative_analysis \
	     operational_inputs outputs inputs derefs register
PLUGIN_NO_TEST:=yes
PLUGIN_DISTRIBUTED:=yes
PLUGIN_INTERNAL_TEST:=yes
INOUT_TYPES:=src/plugins/value_types/inout_type
PLUGIN_TYPES_CMO:=$(INOUT_TYPES)
PLUGIN_TYPES_TODOC:=$(addsuffix .mli,$(INOUT_TYPES))
PLUGIN_DEPENDENCIES:=Callgraph Eva From

$(eval $(call include_generic_plugin_Makefile,$(PLUGIN_NAME)))

###################
# Impact analysis #
###################

PLUGIN_ENABLE:=$(ENABLE_IMPACT)
PLUGIN_NAME:=Impact
PLUGIN_DIR:=src/plugins/impact
PLUGIN_CMO:= options pdg_aux reason_graph compute_impact register
PLUGIN_GUI_CMO:= register_gui
PLUGIN_DISTRIBUTED:=yes
PLUGIN_INTERNAL_TEST:=yes
PLUGIN_DEPENDENCIES:=Inout Eva Pdg Slicing

$(eval $(call include_generic_plugin_Makefile,$(PLUGIN_NAME)))

##################################
# PDG : program dependence graph #
##################################

PLUGIN_ENABLE:=$(ENABLE_PDG)
PLUGIN_NAME:=Pdg
PLUGIN_DIR:=src/plugins/pdg
1048
1049
PLUGIN_TESTS_LIB:=tests/pdg/dyn_dpds.ml \
                  tests/pdg/sets.ml
1050
PLUGIN_TESTS_DIRS:=pdg
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
PLUGIN_CMO:= pdg_parameters \
	    ctrlDpds \
	    pdg_state \
	    build \
	    sets \
	    annot \
	    marks \
	    register

PDG_TYPES:=pdgIndex pdgTypes pdgMarks
PDG_TYPES:=$(addprefix src/plugins/pdg_types/,$(PDG_TYPES))
PLUGIN_TYPES_CMO:=$(PDG_TYPES)

PLUGIN_INTRO:=doc/code/intro_pdg.txt
PLUGIN_TYPES_TODOC:=$(addsuffix .mli,$(PDG_TYPES))
PLUGIN_DEPENDENCIES:=Callgraph Eva From
PLUGIN_DISTRIBUTED:=yes
PLUGIN_INTERNAL_TEST:=yes

$(eval $(call include_generic_plugin_Makefile,$(PLUGIN_NAME)))

################################################
# Scope : show different kinds of dependencies #
################################################

PLUGIN_ENABLE:=$(ENABLE_SCOPE)
PLUGIN_NAME:=Scope
PLUGIN_DIR:=src/plugins/scope
1079
1080
PLUGIN_TESTS_LIB:=tests/scope/bts971.ml \
                  tests/scope/zones.ml
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
PLUGIN_CMO:= datascope zones defs
PLUGIN_GUI_CMO:=dpds_gui
PLUGIN_DEPENDENCIES:=Eva Inout
PLUGIN_INTRO:=doc/code/intro_scope.txt
PLUGIN_DISTRIBUTED:=yes
PLUGIN_INTERNAL_TEST:=yes
$(eval $(call include_generic_plugin_Makefile,$(PLUGIN_NAME)))

#####################################
# Sparecode : unused code detection #
#####################################

PLUGIN_ENABLE:=$(ENABLE_SPARECODE)
PLUGIN_NAME:=Sparecode
PLUGIN_DIR:=src/plugins/sparecode
PLUGIN_CMO:= sparecode_params globs spare_marks transform register
PLUGIN_INTRO:=doc/code/intro_sparecode.txt
PLUGIN_DISTRIBUTED:=yes
PLUGIN_INTERNAL_TEST:=yes
PLUGIN_DEPENDENCIES:=Pdg Eva Users

$(eval $(call include_generic_plugin_Makefile,$(PLUGIN_NAME)))

###########
# Slicing #
###########

PLUGIN_ENABLE:=$(ENABLE_SLICING)
PLUGIN_NAME:=Slicing
PLUGIN_DIR:=src/plugins/slicing
PLUGIN_CMO:= slicingInternals \
	    slicingTypes \
	    slicingParameters \
	    slicingState \
	    slicingMacros \
	    slicingMarks \
	    slicingActions \
	    fct_slice \
	    printSlice \
	    slicingProject \
	    slicingTransform \
	    slicingSelect \
	    slicingCmds \
	    api \
	    register

PLUGIN_GUI_CMO:=register_gui

PLUGIN_INTRO:=doc/code/intro_slicing.txt
PLUGIN_UNDOC:=register.ml # slicing_gui.ml

PLUGIN_TESTS_DIRS:= slicing
PLUGIN_TESTS_LIB:= tests/slicing/libSelect.ml tests/slicing/libAnim.ml \
	tests/slicing/simple_intra_slice.ml tests/slicing/combine.ml \
	tests/slicing/ex_spec_interproc.ml tests/slicing/horwitz.ml \
	tests/slicing/mark_all_slices.ml tests/slicing/merge.ml \
	tests/slicing/min_call.ml tests/slicing/select_by_annot.ml \
	tests/slicing/select_simple.ml tests/slicing/simple_intra_slice.ml \
	tests/slicing/slice_no_body.ml tests/slicing/switch.ml \
	tests/slicing/adpcm.ml
PLUGIN_DISTRIBUTED:=yes
PLUGIN_INTERNAL_TEST:=yes
1143
PLUGIN_DEPENDENCIES:=Pdg Callgraph Eva Sparecode
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211

$(eval $(call include_generic_plugin_Makefile,$(PLUGIN_NAME)))

#####################
# External plug-ins #
#####################

define INCLUDE_PLUGIN
FRAMAC_SHARE:=$(FRAMAC_ROOT_SRCDIR)/share
FRAMAC_PLUGIN:=$(FRAMAC_ROOT_SRCDIR)/lib/plugins
FRAMAC_PLUGIN_GUI:=$(FRAMAC_ROOT_SRCDIR)/lib/plugins/gui
PLUGIN_DIR:=$(1)
include $(1)/Makefile
endef

$(foreach p,$(EXTERNAL_PLUGINS),$(eval $(call INCLUDE_PLUGIN,$p)))

###############################################################################
#                                                                             #
###########################                                                   #
# End of plug-in sections #                                                   #
###########################                                                   #
#                                                                             #
###############################################################################

#####################
# Generic variables #
#####################

CMX	= $(CMO:.cmo=.cmx)
CMI	= $(CMO:.cmo=.cmi)

ALL_CMO	= $(CMO) $(PLUGIN_CMO_LIST) $(STARTUP_CMO)
ALL_CMX	= $(CMX) $(PLUGIN_CMX_LIST) $(STARTUP_CMX)

FILES_FOR_OCAMLDEP+= $(addsuffix /*.mli,$(FRAMAC_SRC_DIRS)) \
	$(addsuffix /*.ml,$(FRAMAC_SRC_DIRS))

MODULES_TODOC+=$(filter-out $(MODULES_NODOC),\
	$(MLI_ONLY) $(NO_MLI:.mli=.ml) \
	$(filter-out $(NO_MLI),\
	$(filter-out $(PLUGIN_TYPES_CMO_LIST:.cmo=.mli),$(CMO:.cmo=.mli))))

################################
# toplevel.{byte,opt} binaries #
################################

ALL_BATCH_CMO= $(filter-out src/kernel_internals/runtime/gui_init.cmo,\
	$(ALL_CMO))
ALL_BATCH_CMX= $(filter-out src/kernel_internals/runtime/gui_init.cmx,\
	$(ALL_CMX))

bin/toplevel.byte$(EXE): $(ALL_BATCH_CMO) $(GEN_BYTE_LIBS) \
			$(PLUGIN_DYN_CMO_LIST)
	$(PRINT_LINKING) $@
	$(OCAMLC) $(BLINKFLAGS) -o $@ $(BYTE_LIBS) $(ALL_BATCH_CMO)

#Profiling version of toplevel.byte using ocamlprof
bin/toplevel.prof$(EXE): $(ALL_BATCH_CMO) $(GEN_BYTE_LIBS) \
			$(PLUGIN_DYN_CMO_LIST)
	$(PRINT_OCAMLCP) $@
	$(OCAMLCP) $(BLINKFLAGS) -o $@ $(BYTE_LIBS) $(ALL_BATCH_CMO)

bin/toplevel.opt$(EXE): $(ALL_BATCH_CMX) $(GEN_OPT_LIBS) \
			$(PLUGIN_DYN_CMX_LIST)
	$(PRINT_LINKING) $@
	$(OCAMLOPT) $(OLINKFLAGS) -o $@ $(OPT_LIBS) $(ALL_BATCH_CMX)

François Bobot's avatar
François Bobot committed
1212
1213
1214
LIB_KERNEL_CMO= $(filter-out src/kernel_internals/runtime/gui_init.cmo, $(CMO))
LIB_KERNEL_CMX= $(filter-out src/kernel_internals/runtime/gui_init.cmx, $(CMX))

1215
1216
lib/fc/frama-c.cma: $(LIB_KERNEL_CMO) $(GEN_BYTE_LIBS) lib/fc/META.frama-c
	$(PRINT_LINKING) $@
François Bobot's avatar
François Bobot committed
1217
	$(MKDIR) $(FRAMAC_LIB)
1218
	$(OCAMLMKLIB) -o lib/fc/frama-c $(BYTE_LIBS) $(LIB_KERNEL_CMO)
François Bobot's avatar
François Bobot committed
1219

1220
1221
1222
1223
lib/fc/frama-c.cmxa: lib/fc/frama-c.cma $(GEN_OPT_LIBS) $(LIB_KERNEL_CMX)
	$(MKDIR) $(FRAMAC_LIB)
	$(PRINT_LINKING) $@
	$(OCAMLMKLIB) -o lib/fc/frama-c $(OPT_LIBS) $(LIB_KERNEL_CMX)
François Bobot's avatar
François Bobot committed
1224

1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
####################
# (Ocaml) Toplevel #
####################

bin/toplevel.top$(EXE): $(filter-out src/kernel_internals/runtime/boot.ml,$(ALL_BATCH_CMO)) \
			src/kernel_internals/runtime/toplevel_config.cmo \
			$(GEN_BYTE_LIBS) $(PLUGIN_DYN_CMO_LIST)
	$(PRINT_OCAMLMKTOP) $@
	$(OCAMLMKTOP) $(BFLAGS) -warn-error -31 -custom -o $@ \
	  -linkpkg $(BYTE_LIBS) $(ALL_BATCH_CMO) \
	   src/kernel_internals/runtime/toplevel_config.cmo

#######
# GUI #
#######

ifneq ($(ENABLE_GUI),no)

SINGLE_GUI_CMI = $(SINGLE_GUI_CMO:.cmo=.cmi)
SINGLE_GUI_CMX = $(SINGLE_GUI_CMO:.cmo=.cmx)

GUICMO += $(SINGLE_GUI_CMO) $(PLUGIN_GUI_CMO_LIST)

MODULES_TODOC+= $(filter-out src/plugins/gui/book_manager.mli,\
	$(SINGLE_GUI_CMO:.cmo=.mli))

GUICMI = $(GUICMO:.cmo=.cmi)
GUICMX = $(SINGLE_GUI_CMX) $(PLUGIN_GUI_CMX_LIST)

$(GUICMI) $(GUICMO) bin/viewer.byte$(EXE): BFLAGS+= $(GUI_INCLUDES)
$(GUICMX) bin/viewer.opt$(EXE): OFLAGS+= $(GUI_INCLUDES)

$(PLUGIN_DYN_DEP_GUI_CMO_LIST): BFLAGS+= $(GUI_INCLUDES)
$(PLUGIN_DYN_DEP_GUI_CMX_LIST): OFLAGS+= $(GUI_INCLUDES)

.PHONY:gui

gui-byte:: bin/viewer.byte$(EXE) share/Makefile.dynamic_config \
           $(PLUGIN_META_LIST)

gui-opt:: gui-byte bin/viewer.opt$(EXE)

gui: gui-$(OCAMLBEST)

ALL_GUI_CMO= $(ALL_CMO) $(GRAPH_GUICMO) $(GUICMO)
ALL_GUI_CMX= $(patsubst %.cma,%.cmxa,$(ALL_GUI_CMO:.cmo=.cmx))

bin/viewer.byte$(EXE): BYTE_LIBS+= $(GRAPH_GUICMO)
bin/viewer.byte$(EXE): $(filter-out $(GRAPH_GUICMO),$(ALL_GUI_CMO)) \
			$(GEN_BYTE_LIBS) \
			$(PLUGIN_DYN_CMO_LIST) $(PLUGIN_DYN_GUI_CMO_LIST)
	$(PRINT_LINKING) $@
1277
	$(OCAMLC) $(BLINKFLAGS) $(THREAD) -o $@ $(BYTE_LIBS) \
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
	  $(CMO) \
	  $(filter-out \
	    $(patsubst $(PLUGIN_GUI_LIB_DIR)/%,$(PLUGIN_LIB_DIR)/%,\
		$(PLUGIN_GUI_CMO_LIST)),\
	    $(PLUGIN_CMO_LIST)) \
	  $(GUICMO) $(STARTUP_CMO)

bin/viewer.opt$(EXE): OPT_LIBS+= $(GRAPH_GUICMX)
bin/viewer.opt$(EXE): $(filter-out $(GRAPH_GUICMX),$(ALL_GUI_CMX)) \
			$(GEN_OPT_LIBS) \
			$(PLUGIN_DYN_CMX_LIST) $(PLUGIN_DYN_GUI_CMX_LIST) \
			$(PLUGIN_CMX_LIST) $(PLUGIN_GUI_CMX_LIST)
	$(PRINT_LINKING) $@
1291
	$(OCAMLOPT) $(OLINKFLAGS) $(THREAD) -o $@ $(OPT_LIBS) \
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
	  $(CMX) \
	  $(filter-out \
	    $(patsubst $(PLUGIN_GUI_LIB_DIR)/%,$(PLUGIN_LIB_DIR)/%,\
	      $(PLUGIN_GUI_CMX_LIST)),\
	    $(PLUGIN_CMX_LIST)) \
	  $(GUICMX) $(STARTUP_CMX)
endif

#####################
# Config Ocaml File #
#####################

CONFIG_DIR=src/kernel_internals/runtime
1305
1306
CONFIG_FILE=$(CONFIG_DIR)/fc_config.ml
CONFIG_CMO=$(CONFIG_DIR)/fc_config.cmo
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
GENERATED +=$(CONFIG_FILE)
#Generated in Makefile.generating

empty:=
space:=$(empty) $(empty)

ifeq ($(ENABLE_GUI),no)
CONFIG_CMO=$(ALL_CMO)
CONFIG_PLUGIN_CMO=$(PLUGIN_CMO_LIST)
else
CONFIG_CMO=$(ALL_GUI_CMO)
CONFIG_PLUGIN_CMO=$(PLUGIN_GUI_CMO_LIST)
endif

ifeq ($(HAS_DOT),yes)
OPTDOT=Some \"$(DOT)\"
else
OPTDOT=None
endif

COMPILATION_UNITS=\
  $(foreach p,$(CONFIG_CMO),\"$(notdir $(patsubst %.cmo,%,$p))\"; )

###################
# Generating part #
###################
# It is in another file in order to have a dependency only on Makefile.generating.
# It must be before `.depend` definition because it modifies $GENERATED.

include Makefile.generating

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

1342
ifeq ($(OCAMLBEST),opt)
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
PTESTS_FILES=ptests_config.cmi ptests_config.cmx ptests_config.o
else
PTESTS_FILES=ptests_config.cmi ptests_config.cmo
endif

.PHONY: tests oracles btests tests_dist libc_tests plugins_ptests_config external_tests \
	update_external_tests

tests:: byte opt ptests
	$(PRINT_EXEC) ptests
	time -p $(PTESTS) $(PTESTS_OPTS) $(FRAMAC_PARALLEL) \
		-make "$(MAKE)" $(PLUGIN_TESTS_LIST)

external_tests: byte opt ptests
tests:: external_tests

update_external_tests: PTESTS_OPTS="-update"
update_external_tests: external_tests

oracles: byte opt ptests
	$(PRINT_MAKING) oracles
1364
	./bin/ptests.$(OCAMLBEST)$(EXE) -make "$(MAKE)" $(PLUGIN_TESTS_LIST) \
1365
		> /dev/null 2>&1
1366
	./bin/ptests.$(OCAMLBEST)$(EXE) -make "$(MAKE)" -update \
1367
1368
1369
1370
1371
1372
1373
1374
1375
		$(PLUGIN_TESTS_LIST)

btests: byte ./bin/ptests.byte$(EXE)
	$(PRINT_EXEC) ptests -byte
	time -p ./bin/ptests.byte$(EXE) -make "$(MAKE)" -byte \
		$(PLUGIN_TESTS_LIST)

tests_dist: dist ptests
	$(PRINT_EXEC) ptests
1376
	time -p ./bin/ptests.$(OCAMLBEST)$(EXE) -make "$(MAKE)" \
1377
1378
1379
1380
1381
		$(PLUGIN_TESTS_LIST)

# test only one test suite : make suite_tests
%_tests: opt ptests
	$(PRINT_EXEC) ptests
1382
	./bin/ptests.$(OCAMLBEST)$(EXE) -make "$(MAKE)" $($*_TESTS_OPTS) $*
1383
1384
1385
1386
1387
1388
1389
1390
1391

# full test suite
wp_TESTS_OPTS=-j 1
fulltests: tests wp_tests

acsl_tests: byte
	$(PRINT_EXEC) acsl_tests
	find doc/speclang -name \*.c -exec ./bin/toplevel.byte$(EXE) {} \; > /dev/null

1392
1393
1394
1395
1396
1397
1398
LONELY_TESTS_DIR:=$(wildcard $(TEST_DIRS_AS_PLUGIN:%=tests/%))
ifeq ($(strip $(LONELY_TESTS_DIR)),)
  LONELY_TESTS_ML_FILES:=
else
  LONELY_TESTS_ML_FILES:=\
    $(sort $(shell find $(TEST_DIRS_AS_PLUGIN:%=tests/%) -not -path '*/\.*' -name '*.ml'))
endif
1399
1400
1401
1402
1403
1404
1405
$(foreach file,$(LONELY_TESTS_ML_FILES),\
  $(eval $(file:%.ml=%.cmo): BFLAGS+=-I $(dir $(file))))
$(foreach file,$(LONELY_TESTS_ML_FILES),\
  $(eval $(file:%.ml=%.cmx): OFLAGS+=-I $(dir $(file))))
$(foreach file,$(LONELY_TESTS_ML_FILES),\
  $(eval $(file:%.ml=%.cmxs): OFLAGS+=-I $(dir $(file))))
.PRECIOUS: $(LONELY_TESTS_ML_FILES:%.ml=%.cmx) \
1406
1407
1408
           $(LONELY_TESTS_ML_FILES:%.ml=%.cmxs) \
           $(LONELY_TESTS_ML_FILES:%.ml=%.cmo) \
           $(LONELY_TESTS_ML_FILES:%.ml=%.cmi)
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423

bin/ocamldep_transitive_closure: devel_tools/ocamldep_transitive_closure.ml
	$(OCAMLOPT) -package ocamlgraph -package str -linkpkg -o $@ $<

tests/crowbar/.%.depend: tests/crowbar/%.ml
	$(OCAMLDEP) $(INCLUDES) $< > $@

tests/crowbar/%: tests/crowbar/%.ml tests/crowbar/.%.depend .depend \
                 bin/ocamldep_transitive_closure bin/toplevel.opt
	$(OCAMLOPT) $(OLINKFLAGS) -w -42 -package crowbar -o $@ \
        $(GEN_C_BINDINGS) \
        $$(bin/ocamldep_transitive_closure -root tests/crowbar/$*.cmx \
             -deps tests/crowbar/.$*.depend -deps .depend) \
        $<

1424
1425
1426
1427
tests/crowbar/full-link-%: tests/crowbar/%.ml lib/fc/frama-c.cmxa
	$(OCAMLOPT) $(OLINKFLAGS) -ccopt "-Llib/fc" -w -42 -package crowbar -o $@ \
	lib/fc/frama-c.cmxa $<

1428
1429
1430
1431
1432
crowbar-%: tests/crowbar/%
	$<

crowbar-afl-%: tests/crowbar/%
	$(MKDIR) tests/crowbar/output-$*
1433
	afl-fuzz $(AFL_OPTS) -i tests/crowbar/input -o tests/crowbar/output-$* $< @@
1434

1435
1436
1437
1438
1439
crowbar-afl-check-%: tests/crowbar/%
	$(foreach file,$(wildcard tests/crowbar/output-$*/crashes/id*), \
          $< $(file) >/dev/null 2>&1 || \
          echo "$(file) leads to a real test failure";)

1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
##############
# Emacs tags #
##############

.PHONY: tags
# otags gives a better tagging of ocaml files than etags
ifdef OTAGS
tags:
	$(OTAGS) -r src lib
vtags:
	$(OTAGS) -vi -r src lib
else
tags:
	find . -name "*.ml[ily]" -o -name "*.ml" | sort -r | xargs \
	etags "--regex=/[ \t]*let[ \t]+\([^ \t]+\)/\1/" \
	      "--regex=/[ \t]*let[ \t]+rec[ \t]+\([^ \t]+\)/\1/" \
	      "--regex=/[ \t]*and[ \t]+\([^ \t]+\)/\1/" \
	      "--regex=/[ \t]*type[ \t]+\([^ \t]+\)/\1/" \
	      "--regex=/[ \t]*exception[ \t]+\([^ \t]+\)/\1/" \
	      "--regex=/[ \t]*val[ \t]+\([^ \t]+\)/\1/" \
	      "--regex=/[ \t]*module[ \t]+\([^ \t]+\)/\1/"
endif

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

.PHONY: doc doc-distrib

# private targets, useful for recompiling the doc without dependencies
# (too long!)
.PHONY: doc-kernel doc-index plugins-doc doc-update doc-tgz

DOC_DEPEND=$(MODULES_TODOC) byte $(DOC_PLUGIN)
ifneq ($(ENABLE_GUI),no)
DOC_DEPEND+=bin/viewer.byte$(EXE)
endif

$(DOC_DIR)/docgen.cmo: $(DOC_DIR)/docgen.ml
	$(PRINT_OCAMLC) $@
François Bobot's avatar
François Bobot committed
1480
	$(OCAMLC) -c -I +ocamldoc -I +compiler-libs -I $(CONFIG_DIR) $(DOC_DIR)/docgen.ml
1481
1482
1483

$(DOC_DIR)/docgen.cmxs: $(DOC_DIR)/docgen.ml
	$(PRINT_PACKING) $@
François Bobot's avatar
François Bobot committed
1484
	$(OCAMLOPT) -o $@ -shared -I +ocamldoc -I +compiler-libs -I $(CONFIG_DIR) \
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
	  $(DOC_DIR)/docgen.ml

clean-doc::
	$(PRINT_RM) "documentation generator"
	$(RM) $(DOC_DIR)/docgen.cm*

DOC_NOT_FOR_DISTRIB=yes
plugins-doc:
	$(QUIET_MAKE) \
	 $(if $(DOC_NOT_FOR_DISTRIB),$(PLUGIN_DOC_LIST),\
	   $(filter \
	     $(addsuffix _DOC,$(PLUGIN_DISTRIBUTED_NAME_LIST)),\
	     $(PLUGIN_DOC_LIST)))

.PHONY: server-doc-md server-doc-html server-doc

server-doc-md: byte
	$(PRINT) 'Generating Markdown server documentation'
	@rm -fr doc/server
	@mkdir -p doc/server
	./bin/frama-c.byte -server-doc doc/server

server-doc-html: server-doc-md
	$(PRINT) 'Generating HTML server documentation'
	@find doc/server -name "*.md" -print -exec pandoc \
			--standalone --toc --toc-depth=2 --to html \
			--template doc/pandoc/template.html \
			--metadata-file {}.json \
			--lua-filter doc/pandoc/href.lua \
			{} -o {}.html \;
	@cp -f doc/pandoc/style.css doc/server/
	$(PRINT) 'HTML server documentation ready:'
	$(PRINT) '  open doc/server/readme.md.html'

server-doc: server-doc-html

# to make the documentation for one plugin only,
# the name of the plugin should begin with a capital letter :
# Example for the pdg doc : make Pdg_DOC
# While working on the documentation of a plugin, it can also be useful
# to use : make -o doc/code/kernel-doc.ocamldoc Plugin_DOC
# to avoid redoing the global documentation each time.

STDLIB_FILES:=\
	array \
	buffer \
        bytes \
	char \
	format \
	hashtbl \
	int64 \
	list \
	map \
	marshal \
	obj \
        parsing \
	printf \
	queue \
	scanf \
	set \
	stack \
	string \
	sys \
1548
1549
	weak \
	ephemeron
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679

STDLIB_FILES:=$(patsubst %,$(OCAMLLIB)/%.mli,$(STDLIB_FILES))

.PHONY: doc-kernel
doc-kernel: $(DOC_DIR)/kernel-doc.ocamldoc

$(DOC_DIR)/kernel-doc.ocamldoc: $(DOC_DEPEND)
	$(PRINT_DOC) Kernel Documentation
	$(MKDIR) $(DOC_DIR)/html
	$(RM) $(DOC_DIR)/html/*.html
	$(OCAMLDOC) $(DOC_FLAGS) \
	  $(addprefix -passopt -stdlib ,$(STDLIB_FILES)) \
	  -t "Frama-C Kernel" \
	  -sort -css-style ../style.css \
	  -g $(DOC_PLUGIN) \
	  -d $(DOC_DIR)/html -dump $@ \
	  $(MODULES_TODOC); \
	  RES=$$?; \
	  if test $$RES -ne 0; then \
	    $(RM) $@; \
	    exit $$RES; \
	  fi

DYN_MLI_DIR := src/plugins/print_api

.PHONY: doc-dynamic
doc-dynamic: doc-kernel
	$(RM) $(DYN_MLI_DIR)/dynamic_plugins.mli
	./bin/frama-c.byte \
		-print_api $(call winpath,$(FRAMAC_ROOT_SRCDIR)/$(DYN_MLI_DIR))
	$(PRINT_DOC) Dynamically registered plugins Documentation
	$(MKDIR) $(DOC_DIR)/dynamic_plugins
	$(RM) $(DOC_DIR)/dynamic_plugins/*.html
	$(OCAMLDOC) $(DOC_FLAGS) -I $(FRAMAC_LIB) -I $(OCAMLLIB) \
	  -passopt -docpath $(DOC_DIR)/html \
	  -sort -css-style ../style.css \
	  -load $(DOC_DIR)/kernel-doc.ocamldoc \
	  -t " Dynamically registered plugins" \
	  -g $(DOC_PLUGIN) \
	  -d $(DOC_DIR)/dynamic_plugins \
	  $(DYN_MLI_DIR)/dynamic_plugins.mli
	$(ECHO) '<li><a href="dynamic_plugins/Dynamic_plugins.html">Dynamically registered plugins</a </li>' > $(DOC_DIR)/dynamic_plugins.toc

doc-index: doc-kernel doc-dynamic plugins-doc
	$(PRINT_MAKING) doc/code/index.html
	$(CAT)  $(DOC_DIR)/toc_head.htm $(DOC_DIR)/*.toc \
		$(DOC_DIR)/toc_tail.htm > $(DOC_DIR)/index.html

doc-update: doc-kernel doc-dynamic plugins-doc doc-index

doc:: doc-kernel doc-dynamic plugins-doc doc-index

doc-kernel doc-dynamic plugins-doc doc-index: $(DOC_DEPEND)

doc-tgz:
	$(PRINT_MAKING) frama-c-api.tar.gz
	cd $(DOC_DIR); \
	  $(TAR) zcf tmp.tgz index.html *.txt \
	   $(notdir $(wildcard $(DOC_DIR)/*.css $(DOC_DIR)/*.png \
			       $(DOC_DIR)/dynamic_plugins*)) \
	   html \
	   $(foreach p,$(PLUGIN_DISTRIBUTED_NAME_LIST),\
	     $(notdir $($(p)_DOC_DIR)))
	$(MKDIR) frama-c-api
	$(RM) -r frama-c-api/*
	cd frama-c-api; $(TAR) zxf ../$(DOC_DIR)/tmp.tgz
	$(TAR) zcf frama-c-api.tar.gz frama-c-api
	$(RM) -r frama-c-api $(DOC_DIR)/tmp.tgz

doc-distrib:
	$(QUIET_MAKE) clean-doc
	$(QUIET_MAKE) doc DOC_NOT_FOR_DISTRIB=
	$(QUIET_MAKE) doc-tgz

#find src -name "*.ml[i]" -o -name "*.ml" -maxdepth 3 | sort -r | xargs
dots: $(ALL_CMO)
	$(PRINT_DOC) callgraph
	$(OCAMLDOC) $(DOC_FLAGS) $(INCLUDES) -o doc/call_graph.dot \
	  -dot -dot-include-all -dot-reduce $(MODULES_TODOC)
	$(QUIET_MAKE) doc/call_graph.svg
	$(QUIET_MAKE) doc/call_graph.ps

# pandoc is required to regenerate the manpage
man/frama-c.1: man/frama-c.1.header man/frama-c.1.md
	$(PRINT) 'generating $@'
	$(RM) $@
	pandoc -s -t man -H $^ | tail -n +5 > man/frama-c.1
	$(CHMOD_RO) $@

# Checking consistency with the current implementation
######################################################

DOC_DEV_DIR = doc/developer
CHECK_API_DIR=$(DOC_DEV_DIR)/check_api

$(CHECK_API_DIR)/check_code.cmo: $(CHECK_API_DIR)/check_code.ml
	$(PRINT_OCAMLC) $@
	$(OCAMLC) -c -I +ocamldoc str.cma $(CHECK_API_DIR)/check_code.ml

$(CHECK_API_DIR)/check_code.cmxs: $(CHECK_API_DIR)/check_code.ml
	$(PRINT_PACKING) $@
	$(OCAMLOPT) -o $@ -shared -I +ocamldoc \
		str.cmxa $(CHECK_API_DIR)/check_code.ml

CHECK_CODE=$(CHECK_API_DIR)/check_code.cmxs

.PHONY: check-devguide
check-devguide: $(CHECK_CODE) $(DOC_DEPEND) $(DOC_DIR)/kernel-doc.ocamldoc
	$(PRINT) 'Checking     developer guide consistency'
	$(MKDIR) $(CHECK_API_DIR)/html
	$(OCAMLDOC) $(DOC_FLAGS) -I $(OCAMLLIB) \
	  -g $(CHECK_CODE) \
	  -passopt -docdevpath -passopt "`pwd`/$(CHECK_API_DIR)" \
	  -load $(DOC_DIR)/kernel-doc.ocamldoc \
	  -d $(CHECK_API_DIR)/html
	$(RM) -r  $(CHECK_API_DIR)/html
	$(MAKE) --silent -C $(CHECK_API_DIR) main.idx
	$(MAKE) --silent -C $(CHECK_API_DIR) >$(CHECK_API_DIR)/summary.txt
	$(ECHO) see all the information displayed here \
		in $(CHECK_API_DIR)/summary.txt
	$(RM) code_file
################################
# Code prettyfication and lint #
################################

# We're interested by any .ml[i]? file in src, except for scripts in test
# directories, and generated files (in particular lexers and parsers)
# Note: the find command below is *very* ugly, but it should be POSIX-compliant.

ALL_ML_FILES:=$(shell find src -name '*.ml' -print -o -name '*.mli' -print -o -path '*/tests' -prune '!' -name '*')
1680
ALL_ML_FILES+=ptests/ptests.ml
1681
1682

ifeq ($(origin MANUAL_ML_FILES),undefined)
1683
MANUAL_ML_FILES:=$(ALL_ML_FILES)
1684
endif
1685

1686
1687
1688
MANUAL_ML_FILES:=\
  $(filter-out $(GENERATED) $(PLUGIN_GENERATED_LIST), $(MANUAL_ML_FILES))

1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
# Allow control of files to be linted/fixed by external sources
# (e.g. pre-commit hook that will concentrate on files which have changed)

sinclude .Makefile.lint

HAS_GIT_FILE:=$(wildcard .git/HEAD)

ifeq ("$(HAS_GIT_FILE)","")
LINT_OTHER_SOURCES:=
else
LINT_OTHER_SOURCES:=\
  $(filter-out \
    $(shell git ls-tree --name-only HEAD src/plugins/*), \
    $(wildcard src/plugins/*))
endif

$(foreach dir,$(LINT_OTHER_SOURCES),$(eval sinclude $(dir)/.Makefile.lint))

ML_LINT_MISSING:=$(filter-out $(MANUAL_ML_FILES), $(ML_LINT_KO))

# By default, also checks files with unknown status:
# this requires new files to pass lint checker from the beginning

ML_LINT_CHECK?=$(filter-out $(ML_LINT_KO), $(MANUAL_ML_FILES))

# this NEWLINE variable containing a literal newline character is used to avoid
# the error "argument list too long", in some instances of "foreach".
# For details, see https://stackoverflow.com/questions/7039811
define NEWLINE


endef

# pre-requisite intentionally left blank: this target should only be used
# if the file is not present to generate it once and forall,
# and be edited manually afterwards
# double colon here tells make not to attempt updating the .Makefile.lint
# if it does not exist, but just to ignore it.
.Makefile.lint::
	echo "ML_LINT_KO:=" >> $@
	$(foreach file,$(sort $(MANUAL_ML_FILES)), \
            if ! $(MAKE) ML_LINT_CHECK=$(file) lint; \
            then echo "ML_LINT_KO+=$(file)" >> $@; fi;$(NEWLINE) )

$(foreach dir,$(LINT_OTHER_SOURCES),\
  $(eval $(dir)/.Makefile.lint:: ; \
     $(foreach file, $(sort $(filter $(dir)/%, $(MANUAL_ML_FILES))), \
            if ! $$(MAKE) ML_LINT_CHECK=$(file) lint; \
            then echo "ML_LINT_KO+=$(file)" >> $$@; fi; )))

.PHONY: stats-lint
stats-lint:
	echo \
         "scale = 2; bad = $(words $(ML_LINT_MISSING)); \
          all = $(words $(sort $(MANUAL_ML_FILES))); \
	  fail = $(words $(ML_LINT_KO)); \
          \"lint coverage: \"; \
          ((all - fail) * 100) / all; " | bc
	echo "number of files supposed to pass lint: $(words $(ML_LINT_CHECK))"
	echo "number of files supposed to fail lint: $(words $(ML_LINT_KO))"
ifneq ($(strip $(ML_LINT_MISSING)),)
	echo "number of files missing from src/ : $(words $(ML_LINT_MISSING))"
	$(foreach file, $(ML_LINT_MISSING), echo $(file);)
	exit 1
endif

INDENT_TARGET= $(patsubst %,%.indent,$(ML_LINT_CHECK))

LINT_TARGET= $(patsubst %,%.lint,$(ML_LINT_CHECK))

FIX_SYNTAX_TARGET=$(patsubst %,%.fix-syntax,$(ML_LINT_CHECK))

.PHONY: $(INDENT_TARGET) $(LINT_TARGET) $(FIX_SYNTAX_TARGET) \
        indent lint fix-syntax

indent: $(INDENT_TARGET)

lint: $(LINT_TARGET)

1768
1769
check-ocp-indent-version:
	if command -v ocp-indent >/dev/null; then \
1770
1771
1772
1773
1774
1775
		if [ -z "$(shell ocp-indent --version)" ]; then echo "warning: ocp-indent returned an empty string, assuming it is the correct version"; \
		else \
			$(eval ocp_version_major := $(shell ocp-indent --version | $(SED) -E "s/^([0-9]+)\.[0-9]+\..*/\1/")) \
			$(eval ocp_version_minor := $(shell ocp-indent --version | $(SED) -E "s/^[0-9]+\.([0-9]+)\..*/\1/")) \
			if [ "$(ocp_version_major)" -lt 1 -o "$(ocp_version_minor)" -lt 7 ]; then \
				echo "error: ocp-indent 1.7.0 required for linting (got $(ocp_version_major).$(ocp_version_minor))"; \
1776
			exit 1; \
1777
			fi; \
1778
1779
1780
1781
1782
		fi; \
	else \
		exit 1; \
	fi;

1783
1784
fix-syntax: $(FIX_SYNTAX_TARGET)

1785
$(INDENT_TARGET): %.indent: % check-ocp-indent-version
1786
1787
	ocp-indent -i $<

1788
$(LINT_TARGET): %.lint: % check-ocp-indent-version
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
	# See SO 1825552 on mixing grep and \t (and cry)
	# For OK_NL, we have three cases:
	# - for empty files, the computation boils down to 0 - 0 == 0
	# - for non-empty files with a proper \n at the end, to 1 - 1 == 0
	# - for empty files without \n, to 1 - 0 == 1 that will be catched
	OK_TAB=$$(grep -c -e "$$(printf '^ *\t')" $<) ; \
        OK_SPACE=$$(grep -c -e '[[:blank:]]$$' $<) ; \
        OK_NL=$$(($$(tail -c -1 $< | wc -c) - $$(tail -n -1 $< | wc -l))) ; \
        OK_EMPTY=$$(tail -n -1 $< | grep -c -e '^[[:blank:]]*$$') ; \
        ERROR=$$(($$OK_TAB + $$OK_SPACE + $$OK_NL + $$OK_EMPTY)) ; \
        if test $$ERROR -gt 0; then \
          echo "File $< does not pass syntactic checks:"; \
          echo "$$OK_TAB lines indented with tabulation instead of spaces"; \
          echo "$$OK_SPACE lines with spaces at end of line"; \
          test $$OK_NL -eq 0 || echo "No newline at end of file"; \
          test $$OK_EMPTY -eq 0 || echo "Empty line(s) at end of file"; \
          echo "Please run make ML_LINT_CHECK=$< fix-syntax"; \
          exit 1 ; \
        fi
	ocp-indent $< > $<.tmp;
	if cmp -s $< $<.tmp; \
        then rm -f $<.tmp; \
        else \
          echo "File $< is not indented correctly."; \
          echo "Please run make ML_LINT_CHECK=$< indent";\
          rm $<.tmp; \
          exit 1; \
        fi

$(FIX_SYNTAX_TARGET): %.fix-syntax: %
	$(ISED) -e 's/^ *\t\+/ /' $<
	$(ISED) -e 's/\(.*[^[:blank:]]\)[[:blank:]]\+$$/\1/' $<
	$(ISED) -e 's/^[ \t]\+$$//' $<
	if test \( $$(tail -n -1 $< | wc -l) -eq 0 \) -a \( $$(wc -c $< | cut -d " " -f 1) -gt 0 \) ; then \
          echo "" >> $<; \
        else \
          while tail -n -1 $< | grep -l -e '^[ \t]*$$'; do \
            head -n -1 $< > $<.tmp; \
            mv $<.tmp $<; \
          done; \
        fi

# Avoid a UTF-8 locale at all cost: in such setting, sed does not work
# reliably if you happen to have latin-1 encoding somewhere,
# which is still unfortunately the case in some dark corners of the platform
%.fix-syntax: LC_ALL = C

################
# Installation #
################

#       line below does not work if INCLUDES contains twice the same directory
#       Do not attempt to copy gui interfaces if gui is disabled
#Byte
ALL_BATCH_CMO_FIXED=$(filter-out src/kernel_internals/runtime/gui_init.cmo,$(CMO) $(STARTUP_CMO))
LIB_BYTE_TO_INSTALL=\
	$(MLI_ONLY:.mli=.cmi) \
	$(ALL_BATCH_CMO_FIXED:.cmo=.cmi) \
	$(ALL_BATCH_CMO_FIXED) \
	$(filter-out %.o,$(GEN_BYTE_LIBS:.cmo=.cmi)) \
	$(GEN_BYTE_LIBS)

#Byte GUI
ifneq ("$(ENABLE_GUI)","no")
LIB_BYTE_TO_INSTALL+=$(SINGLE_GUI_CMI) $(SINGLE_GUI_CMO)
endif

#Opt
ifeq ("$(OCAMLBEST)","opt")
ALL_BATCH_CMX_FIXED= $(filter-out src/kernel_internals/runtime/gui_init.cmx,\
	$(CMX) $(STARTUP_CMX))
LIB_OPT_TO_INSTALL +=\
	$(ALL_BATCH_CMX) \
	$(filter %.a,$(ALL_BATCH_CMX_FIXED:.cmxa=.a)) \
	$(filter %.o,$(ALL_BATCH_CMX_FIXED:.cmx=.o)) \
	$(filter-out %.o,$(GEN_OPT_LIBS)) \
	$(filter-out $(GEN_BYTE_LIBS),$(filter %.o,$(GEN_OPT_LIBS:.cmx=.o)))

#Opt GUI
ifneq ("$(ENABLE_GUI)","no")
LIB_OPT_TO_INSTALL += $(SINGLE_GUI_CMX) $(SINGLE_GUI_CMX:.cmx=.o)
endif

endif

clean-install:
	$(PRINT_RM) "Installation directory"
	$(RM) -r $(FRAMAC_LIBDIR)

1878
install-lib-byte: clean-install
1879
1880
	$(PRINT_INSTALL) kernel API
	$(MKDIR) $(FRAMAC_LIBDIR)
1881
	$(CP) $(LIB_BYTE_TO_INSTALL) $(FRAMAC_LIBDIR)
1882
	$(CP) $(addprefix lib/fc/,dllframa-c$(DLLEXT) libframa-c.a frama-c.cma META.frama-c) $(FRAMAC_LIBDIR)
1883
1884
1885
1886

install-lib-opt: install-lib-byte
	$(CP) $(LIB_OPT_TO_INSTALL) $(FRAMAC_LIBDIR)
	$(CP) $(addprefix lib/fc/,frama-c.a frama-c.cmxa) $(FRAMAC_LIBDIR)
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897

install-doc-code:
	$(PRINT_INSTALL) API documentation
	$(MKDIR) $(FRAMAC_DATADIR)/doc/code
	(cd doc ; tar cf - --exclude='.svn' --exclude='*.toc' \
			--exclude='*.htm' --exclude='*.txt' \
			--exclude='*.ml' \
			code \
		| (cd $(FRAMAC_DATADIR)/doc ; tar xf -))

.PHONY: install
1898
install:: install-lib-$(OCAMLBEST)
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
	$(PRINT_MAKING) destination directories
	$(MKDIR) $(BINDIR)
	$(MKDIR) $(MANDIR)/man1
	$(MKDIR) $(FRAMAC_PLUGINDIR)/top
	$(MKDIR) $(FRAMAC_PLUGINDIR)/gui
	$(MKDIR) $(FRAMAC_DATADIR)/theme/default
	$(MKDIR) $(FRAMAC_DATADIR)/theme/colorblind
	$(MKDIR) $(FRAMAC_DATADIR)/theme/flat
	$(MKDIR) $(FRAMAC_DATADIR)/libc/sys
	$(MKDIR) $(FRAMAC_DATADIR)/libc/netinet
	$(MKDIR) $(FRAMAC_DATADIR)/libc/net
	$(MKDIR) $(FRAMAC_DATADIR)/libc/arpa
	$(PRINT_INSTALL) shared files
	$(CP) \
	  $(wildcard share/*.c share/*.h) \
	  share/Makefile.dynamic share/Makefile.plugin.template \
	  share/Makefile.config share/Makefile.common share/Makefile.generic \
	  share/configure.ac share/autocomplete_frama-c share/_frama-c \
	  $(FRAMAC_DATADIR)
	$(MKDIR) $(FRAMAC_DATADIR)/analysis-scripts
1919
1920
1921
	$(CP) \
	  share/analysis-scripts/analysis.mk \
	  share/analysis-scripts/benchmark_database.py \
1922
	  share/analysis-scripts/cmd-dep.sh \
1923
	  share/analysis-scripts/concat-csv.sh \
1924
	  share/analysis-scripts/clone.sh \
1925
	  share/analysis-scripts/creduce.sh \
1926
	  share/analysis-scripts/epilogue.mk \
1927
	  share/analysis-scripts/fc_stubs.c \
1928
	  share/analysis-scripts/find_fun.py \
1929
	  share/analysis-scripts/flamegraph.pl \
1930
	  share/analysis-scripts/frama_c_results.py \
1931
	  share/analysis-scripts/function_finder.py \
1932
1933
	  share/analysis-scripts/git_utils.py \
	  share/analysis-scripts/list_files.py \
1934
	  share/analysis-scripts/make_template.py \
1935
	  share/analysis-scripts/make_wrapper.py \
1936
	  share/analysis-scripts/normalize_jcdb.py \
1937
	  share/analysis-scripts/parse-coverage.sh \
1938
	  share/analysis-scripts/prologue.mk \
1939
	  share/analysis-scripts/README.md \
1940
1941
	  share/analysis-scripts/results_display.py \
	  share/analysis-scripts/summary.py \
1942
1943
	  share/analysis-scripts/template.mk \
	  $(FRAMAC_DATADIR)/analysis-scripts
1944
1945
1946
1947
1948
1949
	$(MKDIR) $(FRAMAC_DATADIR)/compliance
	$(CP) share/compliance/c11_functions.json \
	  share/compliance/glibc_functions.json \
	  share/compliance/nonstandard_identifiers.json \
	  share/compliance/posix_identifiers.json \
	  $(FRAMAC_DATADIR)/compliance
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
	$(MKDIR) $(FRAMAC_DATADIR)/emacs
	$(CP) $(wildcard share/emacs/*.el) $(FRAMAC_DATADIR)/emacs
	$(CP) share/frama-c.rc $(ICONS) $(FRAMAC_DATADIR)
	$(CP) $(THEME_ICONS_DEFAULT) $(FRAMAC_DATADIR)/theme/default
	$(CP) $(THEME_ICONS_COLORBLIND) $(FRAMAC_DATADIR)/theme/colorblind
	$(CP) $(THEME_ICONS_FLAT) $(FRAMAC_DATADIR)/theme/flat
	if [ -d $(EMACS_DATADIR) ]; then \
	  $(CP) $(wildcard share/emacs/*.el) $(EMACS_DATADIR); \
	fi
	$(CP) share/Makefile.dynamic_config.external \
	      $(FRAMAC_DATADIR)/Makefile.dynamic_config
	$(PRINT_INSTALL) C standard library
	$(CP) $(wildcard share/libc/*.c share/libc/*.i share/libc/*.h) \
	      $(FRAMAC_DATADIR)/libc
	$(CP) share/libc/sys/*.[ch] $(FRAMAC_DATADIR)/libc/sys
	$(CP) share/libc/arpa/*.[ch] $(FRAMAC_DATADIR)/libc/arpa
	$(CP) share/libc/net/*.[ch] $(FRAMAC_DATADIR)/libc/net
	$(CP) share/libc/netinet/*.[ch] $(FRAMAC_DATADIR)/libc/netinet
	$(PRINT_INSTALL) binaries
	$(CP) bin/toplevel.$(OCAMLBEST) $(BINDIR)/frama-c$(EXE)
	$(CP) bin/toplevel.byte$(EXE) $(BINDIR)/frama-c.byte$(EXE)
	if [ -x bin/toplevel.top ] ; then \
	  $(CP) bin/toplevel.top $(BINDIR)/frama-c.toplevel$(EXE); \
	fi
	if [ -x bin/viewer.$(OCAMLBEST) ] ; then \
	  $(CP) bin/viewer.$(OCAMLBEST) $(BINDIR)/frama-c-gui$(EXE);\
	fi
	if [ -x bin/viewer.byte$(EXE) ] ; then \
	  $(CP) bin/viewer.byte$(EXE) $(BINDIR)/frama-c-gui.byte$(EXE); \
	fi
1980
1981
	$(CP) bin/ptests.$(OCAMLBEST)$(EXE) \
	      $(BINDIR)/ptests.$(OCAMLBEST)$(EXE)
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
	if [ -x bin/fc-config$(EXE) ] ; then \
		$(CP) bin/fc-config$(EXE) $(BINDIR)/frama-c-config$(EXE); \
	fi
	if [ -x bin/frama-c-script ] ; then \
		$(CP) bin/frama-c-script $(BINDIR)/frama-c-script; \
	fi
	$(PRINT_INSTALL) config files
	$(CP) $(addprefix ptests/,$(PTESTS_FILES)) $(FRAMAC_LIBDIR)
	$(PRINT_INSTALL) API documentation
	$(MKDIR) $(FRAMAC_DATADIR)/doc/code
	$(CP) $(wildcard $(DOC_GEN_FILES)) $(FRAMAC_DATADIR)/doc/code
	$(PRINT_INSTALL) plug-ins
	if [ -d "$(FRAMAC_PLUGIN)" ]; then \
	  $(CP)  $(PLUGIN_DYN_CMI_LIST) $(PLUGIN_META_LIST) \
		 $(FRAMAC_PLUGINDIR); \
1997
1998
1999
2000
	  $(CP)  $(PLUGIN_DYN_CMO_LIST) $(FRAMAC_PLUGINDIR)/top; \
	  if [ "$(OCAMLBEST)" = "opt" ]; then \
	    $(CP) $(PLUGIN_DYN_CMX_LIST) $(FRAMAC_PLUGINDIR)/top; \
	  fi; \
2001
2002
2003
2004
2005
	fi
	$(PRINT_INSTALL) gui plug-ins
	if [ -d "$(FRAMAC_PLUGIN_GUI)" -a "$(PLUGIN_DYN_GUI_EXISTS)" = "yes" ]; \
	then \
	  $(CP) $(patsubst %.cma,%.cmi,$(PLUGIN_DYN_GUI_CMO_LIST:.cmo=.cmi)) \
2006
2007
2008
2009
		$(PLUGIN_DYN_GUI_CMO_LIST) $(FRAMAC_PLUGINDIR)/gui; \
	  if [ "$(OCAMLBEST)" = "opt" ]; then \
	    $(CP) $(PLUGIN_DYN_GUI_CMX_LIST) $(FRAMAC_PLUGINDIR)/gui; \
	  fi; \
2010
2011
2012
2013
2014
2015
2016
2017
	fi
	$(PRINT_INSTALL) man pages
	$(CP) man/frama-c.1 $(MANDIR)/man1/frama-c.1
	$(CP) man/frama-c.1 $(MANDIR)/man1/frama-c-gui.1

.PHONY: uninstall
uninstall::
	$(PRINT_RM) installed binaries
2018
	$(RM) $(BINDIR)/frama-c* $(BINDIR)/ptests.$(OCAMLBEST)$(EXE)
2019
2020
2021
2022
2023
2024
2025
2026
202