Debian Codegraph @

share/Makefile.plugin.template

raw
1 ##########################################################################
2 # #
3 # This file is part of Frama-C. #
4 # #
5 # Copyright (C) 2007-2022 #
6 # CEA (Commissariat à l'énergie atomique et aux énergies #
7 # alternatives) #
8 # #
9 # you can redistribute it and/or modify it under the terms of the GNU #
10 # Lesser General Public License as published by the Free Software #
11 # Foundation, version 2.1. #
12 # #
13 # It is distributed in the hope that it will be useful, #
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
16 # GNU Lesser General Public License for more details. #
17 # #
18 # See the GNU Lesser General Public License version 2.1 #
19 # for more details (enclosed in the file licenses/LGPLv2.1). #
20 # #
21 ##########################################################################
22
23 ###############################################################################
24 #
25 # Generic makefile used to build plug-ins.
26 # Setup the following required variables before including this makefile:
27 #
28 # Warning: You should not use these variables inside of your Makefile,
29 # use the namespaced version (@PLUGIN_NAME@_*) at the end of this list.
30 #
31 # Usual information
32 # -----------------
33 ifndef PLUGIN_NAME # The ML module name of the plugin
34 $(error PLUGIN_NAME is not set)
35 endif
36 ifndef PLUGIN_DIR # The directory containing the source files
37 $(error PLUGIN_DIR is not set)
38 endif
39 PLUGIN_DIR?=
40 PLUGIN_ENABLE?= # Whether the plugin is enabled
41 PLUGIN_DEPENDS?= # Deprecated (static plug-in dependencies, Frama-C only)
42
43 # META file
44 # ---------
45 # The META for the plug-in is automatically generated, unless variable
46 # PLUGIN_HAS_META is set to "yes". The following optional variables can
47 # be set accordingly:
48 #
49 PLUGIN_HAS_META?= # defaults to empty
50
51 # When setting PLUGIN_HAS_META to "yes", the next variables are not taken into
52 # account. Instead, your are responsible for providing a full featured META
53 # file in the PLUGIN_DIR source directory, which will be copied and installed
54 # with the plug-in object files.
55
56 PLUGIN_DESCRIPTION?= # if empty then defaults to "Frama-C NAME plug-in"
57 PLUGIN_VERSION?= # if empty then defaults to current Frama-C version
58 PLUGIN_REQUIRES?= # package(s) the plug-in depends on (defaults to empty)
59 PLUGIN_DEPENDENCIES?= # plugins(s) the plug-in depends on (defaults to empty)
60
61 # Remarks:
62 # - the package name for "MyPlugin" is defined to be "frama-c-myplugin"
63 # - PLUGIN_DEPENDENCIES <pkg> is a shortcut for PLUGIN_REQUIRES <frama-c-pkg>
64 # - the makefile adds a proper "directory" directive to both provided or
65 # generated META files
66
67
68 # Source files
69 # ------------
70 PLUGIN_CMO?= # The .cmo files (do not add the plugin path and the
71 # extension)
72 PLUGIN_CMI?= # The .cmi files (only if there is no corresponding .cmo)
73 PLUGIN_TYPES_CMO?= # The .cmo files containing the types definitions
74 PLUGIN_GUI_CMI?= # The .cmi files for the GUI
75 # (only if there is no corresponding .cmi)
76 PLUGIN_GUI_CMO?= # The .cmo files to be linked with the graphical interface
77 PLUGIN_GENERATED?= # source files generated by the plugins, typically parsers
78
79 # Compilation flags
80 # -----------------
81 PLUGIN_BFLAGS?= # Additional options for the bytecode compiler
82 PLUGIN_OFLAGS?= # Additional options for the native compiler
83 PLUGIN_EXTRA_BYTE?= # Additional bytecode files to link against
84 PLUGIN_EXTRA_OPT?= # Additional native files to link against
85 PLUGIN_EXTRA_DIRS?= # Additional directories (relative to the root of the
86 # plugin) containing some of the source files of the
87 # plugin
88 PLUGIN_LINK_BFLAGS?= # Additional options for the bytecode linker
89 PLUGIN_LINK_OFLAGS?= # Additional options for the native linker
90 PLUGIN_LINK_GUI_BFLAGS?= # Additional options for the bytecode gui linker
91 PLUGIN_LINK_GUI_OFLAGS?= # Additional options for the native gui linker
92
93
94 # Dependencies
95 # ------------
96 PLUGIN_DEPFLAGS?= # Additional options for ocamldep
97
98 # Documentation
99 # -------------
100 PLUGIN_DOCFLAGS?= # Additional options for ocamldoc
101 PLUGIN_UNDOC?= # Do not document this source files (do not add the
102 # plugin path)
103 PLUGIN_TYPES_TODOC?= # Do document this source files containing the types
104 # definition
105 PLUGIN_INTRO?= # Add this text file to the introduction of the
106 # documentation
107 PLUGIN_HAS_EXT_DOC?= # (yes/no) Plugin has a pdf manual
108
109
110 # Testing
111 # -------
112 PLUGIN_NO_TEST?= # Set it to a non-empty value if there is no specific
113 # test directory for this plugin
114 PLUGIN_TESTS_DIRS?= # Test directories of the plugin.
115 # Default is tests/$(PLUGIN_DIR)
116 PLUGIN_TESTS_DIRS_DEFAULTS?= # Tests directories that should be run by default
117 # Defaults to $(PLUGIN_TESTS_DIRS)
118 PLUGIN_TESTS_LIB?= # Additional source (.ml) files used by tests.
119 PLUGIN_NO_DEFAULT_TEST?= # Set it to a non-empty value if you don't want the
120 # tests of your plugin to be executed systematically
121 # by make tests
122 PLUGIN_INTERNAL_TEST?= # Set it to a non-empty value if the tests of the plugin
123 # are in Frama-C's tests directory and not a tests
124 # subdirectory of the plugin (internal use only,
125 # obsolete and not recommended way to handle tests)
126
127 # Distribution
128 # ------------
129 PLUGIN_DISTRIBUTED?= # should the plugin be included in the distribution
130 # (yes/no)
131 PLUGIN_DISTRIB_EXTERNAL?= # list of files that should be distributed within the
132 # source distribution for this plug-in. They will be
133 # put at their proper place in the frama-c-$(VERSION)
134 # directory for a release.
135 PLUGIN_DISTRIB_TESTS?= # list of files that should be also distributed without
136 # headers checking.
137 PLUGIN_HEADER_SPEC?=$(DEFAULT_HEADER_SPEC) # list of files containing header
138 # specifications.
139 PLUGIN_HEADER_DIRS?=$(DEFAULT_HEADER_DIRS) # list of directories containing
140 # open/close-source header files.
141 PLUGIN_HEADER_EXCEPTIONS?=$(DEFAULT_HEADER_EXCEPTIONS) # list of distributed files allowed
142 # to have no entry into the
143 # PLUGIN_HEADER_SPEC files
144 PLUGIN_CEA_PROPRIETARY_FILES?=$(DEFAULT_CEA_PROPRIETARY_FILES) # list of files that cannot be
145 # part of an OPEN_SOURCE distribution
146 PLUGIN_CEA_PROPRIETARY_HEADERS?= # list of licenses that cannot
147 # be part of an OPEN_SOURCE distribution.
148
149 # Kernel developers only
150 # ----------------------
151 PLUGIN_RESET?=yes # Set it to no in order to NOT reset plug-in variable.
152
153
154 # Except for their initialization, all these variables should not be used
155 # outside of this Makefile.
156 #
157 # Instead, you can safely use the corresponding following variables.
158 # Warning:
159 # - They contain the extensions and the plugin path unlike the originals
160 # - except @PLUGIN_NAME@_DIR, they are undefined before
161 # Makefile.plugin.generated is created
162 #
163 # @PLUGIN_NAME@_DIR
164 # @PLUGIN_NAME@_CMO
165 # @PLUGIN_NAME@_CMX
166 # @PLUGIN_NAME@_CMI
167 # @PLUGIN_NAME@_TYPES_CMO
168 # @PLUGIN_NAME@_TYPES_CMX
169 # @PLUGIN_NAME@_TYPES_TODOC
170 # @PLUGIN_NAME@_BFLAGS
171 # @PLUGIN_NAME@_OFLAGS
172 # @PLUGIN_NAME@_DEPFLAGS
173 # @PLUGIN_NAME@_DOCFLAGS
174 # @PLUGIN_NAME@_GENERATED
175 # @PLUGIN_NAME@_TESTS_DIRS
176 # @PLUGIN_NAME@_TESTS_LIB
177 #
178 ###############################################################################
179 #
180 # Note for the Makefile.plugin developers:
181 # If you add a new option to communicate with the main Makefile,
182 # don't forget to reset it at the end of this file.
183 #
184 ###############################################################################
185
186
187 DEPEND_PKG := $(addprefix frama-c-, $(shell echo $(PLUGIN_DEPENDENCIES) | tr '[:upper:]' '[:lower:]'))
188
189 # Where the other plug-ins to load are already installed
190 ifeq ($(FRAMAC_INTERNAL),yes)
191 INSTALLED_PLUGIN_DIR:=$(FRAMAC_ROOT_SRCDIR)/lib/plugins
192 # Also inform the main Makefile that there's another plug-in to be
193 # considered
194 PLUGIN_LIST+=$(PLUGIN_DIR)/@PLUGIN_NAME@
195 PLUGIN_PACKAGES:=$(PLUGIN_REQUIRES)
196
197 else
198
199 INSTALLED_PLUGIN_DIR:=$(PLUGIN_INSTALL_DIR)
200 PLUGIN_PACKAGES:=$(PLUGIN_REQUIRES) $(DEPEND_PKG)
201
202 endif
203
204 PLUGIN_REQUIRES += $(DEPEND_PKG)
205
206 # The plugin types .cm* files
207 PLUGIN_TYPES_CMO:=$(addsuffix .cmo,$(PLUGIN_TYPES_CMO))
208 PLUGIN_TYPES_CMX:=$(PLUGIN_TYPES_CMO:.cmo=.cmx)
209 @PLUGIN_NAME@_TYPES_CMO:=$(PLUGIN_TYPES_CMO)
210 @PLUGIN_NAME@_TYPES_CMX:=$(PLUGIN_TYPES_CMX)
211 @PLUGIN_NAME@_TYPES_TODOC:=$(PLUGIN_TYPES_TODOC)
212
213 PLUGIN_TYPES_CMO_LIST += $(PLUGIN_TYPES_CMO)
214 PLUGIN_TYPES_CMX_LIST += $(PLUGIN_TYPES_CMX)
215
216 # [VP] don't exactly know why, but make has a tendency to add a
217 # spurious space at the beginning of PLUGIN_BASE. Fortunately, $(strip )
218 # is behaving correctly.
219 PLUGIN_BASE:=$(strip $(if $(notdir $(PLUGIN_DIR)),$(notdir $(PLUGIN_DIR)),\
220 $(notdir $(patsubst %/,%,$(PLUGIN_DIR)))))
221
222 PLUGIN_DEPENDS:=$(PLUGIN_DEPENDS) $(PLUGIN_DEPENDENCIES)
223
224
225
226 ################
227 # ml sources #
228 ################
229
230 PLUGIN_SRC:= $(PLUGIN_DIR)/@[email protected] \
231 $(patsubst %,$(PLUGIN_DIR)/%.ml*,$(PLUGIN_CMO)) \
232 $(patsubst %,$(PLUGIN_DIR)/%.mli,$(PLUGIN_CMI)) \
233 $(patsubst %.cmo,%.ml*,$(PLUGIN_TYPES_CMO))
234 ifneq ($(ENABLE_GUI),no)
235 PLUGIN_SRC:= $(PLUGIN_SRC) $(patsubst %,$(PLUGIN_DIR)/%.ml*,$(PLUGIN_GUI_CMO))
236 endif
237
238 @PLUGIN_NAME@_SRC:=$(PLUGIN_SRC)
239
240 PLUGIN_ML_SRC:=$(patsubst %.ml*,%.ml,$(PLUGIN_SRC)) \
241 $(patsubst %.ml*,%.mli,$(filter %.ml*,$(PLUGIN_SRC)))
242 @PLUGIN_NAME@_ML_SRC:=$(PLUGIN_ML_SRC)
243
244 ################
245 # distribution #
246 ################
247
248
249 ifneq ($(PLUGIN_ENABLE),no)
250
251 # for `check-header` target even if the plugin is not distributed
252 ifneq ("$(strip $(PLUGIN_HEADER_SPEC))","")
253 # Don't remove the '/./' because it is used as separator:
254 # i.e. filenames contained into the spec file 'src/plugins/MY-PLUGIN/./headers/header_spec.txt'
255 # are considered being relative from 'src/plugins/MY-PLUGIN/'.
256 # The wildcard is used in order to add only existing files.
257 PLUGIN_HEADER_SPEC_LIST +=$(strip $(wildcard $(PLUGIN_DIR)/./$(PLUGIN_HEADER_SPEC)))
258 endif
259
260 ifneq ("$(strip $(PLUGIN_HEADER_DIRS))","")
261 # The wildcard is used in order to add only existing directory.
262 PLUGIN_HEADER_DIRS_LIST +=$(wildcard $(addprefix $(PLUGIN_DIR)/,$(PLUGIN_HEADER_DIRS)))
263 endif
264
265 ifneq ("$(strip $(PLUGIN_HEADER_EXCEPTIONS))","")
266 PLUGIN_HEADER_EXCEPTIONS_LIST +=$(addprefix $(PLUGIN_DIR)/,$(PLUGIN_HEADER_EXCEPTIONS))
267 endif
268
269 ifneq ("$(strip $(PLUGIN_CEA_PROPRIETARY_HEADERS))","")
270 PLUGIN_CEA_PROPRIETARY_HEADERS_LIST +=$(PLUGIN_CEA_PROPRIETARY_HEADERS)
271 endif
272
273 ifneq ("$(strip $(PLUGIN_CEA_PROPRIETARY_FILES))","")
274 # Files that cannot be part of an OPEN_SOURCE distribution.
275 # The wildcard is used in order to add only existing files.
276 PLUGIN_CEA_PROPRIETARY_FILE_LIST +=$(wildcard $(addprefix $(PLUGIN_DIR)/,$(PLUGIN_CEA_PROPRIETARY_FILES)))
277 endif
278
279 ifneq ($(PLUGIN_DISTRIBUTED),no)
280 PLUGIN_DISTRIBUTED_LIST += $(PLUGIN_SRC)
281 ifeq ($(ENABLE_GUI),no)
282 # Also include GUI files to be distributed, even if not currently used
283 PLUGIN_DISTRIBUTED_LIST += \
284 $(patsubst %,$(PLUGIN_DIR)/%.ml*,$(PLUGIN_GUI_CMO)) \
285 $(patsubst %,$(PLUGIN_DIR)/%.mli,$(PLUGIN_GUI_CMI))
286 endif
287
288 # VP: this needs to be adapted for external plugins.
289 ifeq ($(PLUGIN_HAS_EXT_DOC),yes)
290 PLUGIN_EXT_DOC_DIR:=doc/$(PLUGIN_BASE)
291 PLUGIN_DIST_DOC_LIST += doc/plugins/$(PLUGIN_BASE).pdf
292 $(PLUGIN_EXT_DOC_DIR)/$(PLUGIN_BASE).pdf:
293 $(PRINT_MAKING) $@
294 $(MAKE) -C $(dir $@)
295
296 doc/plugins/$(PLUGIN_BASE).pdf: \
297 $(PLUGIN_EXT_DOC_DIR)/$(PLUGIN_BASE).pdf
298 $(PRINT_CP) $<
299 $(MKDIR) doc/plugins
300 $(CP) $< $@
301 endif
302 ifneq ("$(strip $(PLUGIN_DISTRIB_EXTERNAL))","")
303 PLUGIN_DIST_EXTERNAL_LIST += \
304 $(addprefix $(PLUGIN_DIR)/,$(PLUGIN_DISTRIB_EXTERNAL))
305 endif
306 ifneq ("$(strip $(PLUGIN_DISTRIB_TESTS))","")
307 PLUGIN_DIST_TESTS_LIST += \
308 $(addprefix $(PLUGIN_DIR)/,$(PLUGIN_DISTRIB_TESTS))
309 endif
310 endif #PLUGIN_DISTRIBUTED
311 endif #PLUGIN_ENABLE
312
313 PLUGIN_OPT:=`echo "@PLUGIN_NAME@" | tr 'A-Z' 'a-z' `
314
315 # Export some variables which can be safely used outside/inside Makefile.plugin
316 # even if the plug-in is not enabled
317 ifneq ("$(PLUGIN_ENABLE)","no")
318
319 # The .cm* files list
320 PLUGIN_CMO:= $(patsubst %,$(PLUGIN_DIR)/%.cmo,$(PLUGIN_CMO))
321 PLUGIN_CMX:= $(PLUGIN_CMO:.cmo=.cmx)
322 PLUGIN_CMI_ONLY:=$(patsubst %,$(PLUGIN_DIR)/%.cmi,$(PLUGIN_CMI))
323 PLUGIN_CMI:= $(PLUGIN_CMI_ONLY) $(PLUGIN_CMO:.cmo=.cmi)
324 PLUGIN_INFERRED_MLI:= $(PLUGIN_CMO:.cmo=.inferred.mli)
325
326 @PLUGIN_NAME@_CMO:=$(PLUGIN_CMO)
327 @PLUGIN_NAME@_CMX:=$(PLUGIN_CMX)
328 @PLUGIN_NAME@_CMI_ONLY:=$(PLUGIN_CMI_ONLY)
329 @PLUGIN_NAME@_CMI:=$(PLUGIN_CMI)
330 @PLUGIN_NAME@_INFERRED_MLI:=$(PLUGIN_INFERRED_MLI)
331
332 HAS_GUI:=no
333 ifneq ($(ENABLE_GUI),no)
334 ifneq ("$(PLUGIN_GUI_CMO)","")
335 # The .cm* gui files list
336 PLUGIN_GUI_CMO:= $(PLUGIN_CMO) \
337 $(patsubst %,$(PLUGIN_DIR)/%.cmo,$(PLUGIN_GUI_CMO))
338 PLUGIN_GUI_CMX:= $(PLUGIN_GUI_CMO:.cmo=.cmx)
339 PLUGIN_GUI_CMI_ONLY:=$(PLUGIN_CMI_ONLY) $(PLUGIN_GUI_CMI)
340 PLUGIN_GUI_CMI:= $(PLUGIN_CMI_ONLY) $(PLUGIN_GUI_CMO:.cmo=.cmi)
341 HAS_GUI:=yes
342 endif
343 endif
344
345 @PLUGIN_NAME@_GUI_CMO:=$(PLUGIN_GUI_CMO)
346 @PLUGIN_NAME@_GUI_CMX:=$(PLUGIN_GUI_CMX)
347 @PLUGIN_NAME@_GUI_CMI:=$(PLUGIN_GUI_CMI)
348
349 # Interface for the the packed plugins
350 TARGET_MLI:= $(PLUGIN_LIB_DIR)/@[email protected]
351 TARGET_CMI:= $(TARGET_MLI:.mli=.cmi)
352
353 # The packed files for toplevel mode (in directory 'top')
354 TARGET_TOP_MLI:= $(PLUGIN_LIB_DIR)/top/@[email protected]
355 TARGET_TOP_CMI:= $(TARGET_TOP_MLI:.mli=.cmi)
356 TARGET_TOP_CMO:= $(TARGET_TOP_MLI:.mli=.cmo)
357 ifdef PLUGIN_EXTRA_BYTE
358 TARGET_TOP_CMA:= $(TARGET_TOP_CMO:.cmo=.cma)
359 else
360 TARGET_TOP_CMA:=
361 endif
362
363 TARGET_TOP_CMX:= $(TARGET_TOP_CMO:.cmo=.cmx)
364
365 TARGET_TOP_CMXS:= $(TARGET_TOP_CMX:.cmx=.cmxs)
366
367 # The packed files for GUI mode (in directory 'gui')
368 ifeq ($(HAS_GUI),yes)
369 TARGET_GUI_MLI:=$(PLUGIN_LIB_DIR)/gui/@[email protected]
370 TARGET_GUI_CMO:= $(PLUGIN_LIB_DIR)/gui/@[email protected]
371 TARGET_GUI_CMI:= $(TARGET_GUI_CMO:.cmo=.cmi)
372 TARGET_GUI_CMX:= $(TARGET_GUI_CMO:.cmo=.cmx)
373 TARGET_GUI_CMA:= $(TARGET_GUI_CMO:.cmo=.cma)
374 TARGET_GUI_CMXS:= $(TARGET_GUI_CMO:.cmo=.cmxs)
375 else
376 TARGET_GUI_MLI:=
377 TARGET_GUI_CMO:=
378 TARGET_GUI_CMI:=
379 TARGET_GUI_CMX:=
380 TARGET_GUI_CMA:=
381 endif
382
383 # Meta-variables for the targets:
384 @PLUGIN_NAME@_TARGET_MLI:=$(TARGET_MLI)
385 @PLUGIN_NAME@_TARGET_CMI:=$(TARGET_CMI)
386 @PLUGIN_NAME@_TARGET_TOP_MLI:=$(TARGET_TOP_MLI)
387 @PLUGIN_NAME@_TARGET_TOP_CMI:=$(TARGET_TOP_CMI)
388 @PLUGIN_NAME@_TARGET_TOP_CMO:=$(TARGET_TOP_CMO)
389 @PLUGIN_NAME@_TARGET_TOP_CMA:=$(TARGET_TOP_CMA)
390 @PLUGIN_NAME@_TARGET_TOP_CMX:=$(TARGET_TOP_CMX)
391 @PLUGIN_NAME@_TARGET_TOP_CMXS:=$(TARGET_TOP_CMXS)
392 @PLUGIN_NAME@_TARGET_GUI_MLI:=$(TARGET_GUI_MLI)
393 @PLUGIN_NAME@_TARGET_GUI_CMI:=$(TARGET_GUI_CMI)
394 @PLUGIN_NAME@_TARGET_GUI_CMO:=$(TARGET_GUI_CMO)
395 @PLUGIN_NAME@_TARGET_GUI_CMA:=$(TARGET_GUI_CMA)
396 @PLUGIN_NAME@_TARGET_GUI_CMX:=$(TARGET_GUI_CMX)
397 @PLUGIN_NAME@_TARGET_GUI_CMXS:=$(TARGET_GUI_CMXS)
398
399 # Some meta-variables for compilation flags
400 NAME_BFLAGS :=@PLUGIN_NAME@_BFLAGS
401 NAME_OFLAGS :=@PLUGIN_NAME@_OFLAGS
402 NAME_TEST_BFLAGS :=@PLUGIN_NAME@_TEST_BFLAGS
403 NAME_TEST_OFLAGS :=@PLUGIN_NAME@_TEST_OFLAGS
404 TARGET_OFLAGS :=@PLUGIN_NAME@_TARGET_OFLAGS
405 TARGET_BFLAGS :=@PLUGIN_NAME@_TARGET_BFLAGS
406 ifeq ($(HAS_GUI),yes)
407 NAME_GUI_BFLAGS :=@PLUGIN_NAME@_GUI_BFLAGS
408 NAME_GUI_OFLAGS :=@PLUGIN_NAME@_GUI_OFLAGS
409 TARGET_GUI_OFLAGS:=@PLUGIN_NAME@_GUI_TARGET_OFLAGS
410 TARGET_GUI_BFLAGS:=@PLUGIN_NAME@_GUI_TARGET_BFLAGS
411 endif
412 NAME_DEPFLAGS :=@PLUGIN_NAME@_DEPFLAGS
413 NAME_DOCFLAGS :=@PLUGIN_NAME@_DOCFLAGS
414
415 # Export some variables which can be safely used outside/inside Makefile.plugin
416 @PLUGIN_NAME@_CMO:=$(PLUGIN_CMO)
417 @PLUGIN_NAME@_CMX:=$(PLUGIN_CMX)
418 @PLUGIN_NAME@_CMI:=$(PLUGIN_CMI)
419 @PLUGIN_NAME@_GENERATED:=$(PLUGIN_GENERATED)
420 @PLUGIN_NAME@_TARGET_BFLAGS:=$(PLUGIN_LINK_BFLAGS)
421 @PLUGIN_NAME@_TARGET_OFLAGS:=$(PLUGIN_LINK_OFLAGS)
422 @PLUGIN_NAME@_EXTRA_BYTE:=$(PLUGIN_EXTRA_BYTE)
423 @PLUGIN_NAME@_EXTRA_OPT:=$(PLUGIN_EXTRA_OPT)
424 @PLUGIN_NAME@_EXTRA_DIRS:=$(PLUGIN_EXTRA_DIRS)
425
426 ifeq ($(HAS_GUI),yes)
427 # gui variable
428 @PLUGIN_NAME@_GUI_CMO:=$(PLUGIN_GUI_CMO)
429 @PLUGIN_NAME@_GUI_CMX:=$(PLUGIN_GUI_CMX)
430 @PLUGIN_NAME@_GUI_CMI:=$(PLUGIN_GUI_CMI)
431 @PLUGIN_NAME@_GUI_CMI_ONLY:=$(PLUGIN_GUI_CMI_ONLY)
432 @PLUGIN_NAME@_GUI_TARGET_BFLAGS:=$(PLUGIN_LINK_GUI_BFLAGS)
433 @PLUGIN_NAME@_GUI_TARGET_OFLAGS:=$(PLUGIN_LINK_GUI_OFLAGS)
434 endif
435
436 PLUGIN_EXTRA_DIRS_INC:=$(patsubst %,-I $(PLUGIN_DIR)/% ,$(PLUGIN_EXTRA_DIRS))
437
438 # Set the compilation flags for the plugin
439 INCLUDE_EXT_FLAGS:=-I $(INSTALLED_PLUGIN_DIR) \
440 $(addprefix -package ,$(PLUGIN_PACKAGES) $(LIBRARY_NAMES))
441 INCLUDE_FLAGS:=-I $(PLUGIN_DIR) $(PLUGIN_EXTRA_DIRS_INC) $(INCLUDE_EXT_FLAGS)
442 $(NAME_BFLAGS):=$(BFLAGS) $(INCLUDE_FLAGS) $(PLUGIN_BFLAGS)
443 $(NAME_OFLAGS):=$(OFLAGS) $(INCLUDE_FLAGS) $(PLUGIN_OFLAGS)
444 # DO NOT include the plugin's own directory as search path for compiling
445 # ml test scripts: they will be loaded in a separate phase, and will only see
446 # the plugin through its static API
447 $(NAME_TEST_BFLAGS):= $(BFLAGS) $(INCLUDE_EXT_FLAGS) $(PLUGIN_BFLAGS) -w -70
448 $(NAME_TEST_OFLAGS):= $(OFLAGS) $(INCLUDE_EXT_FLAGS) $(PLUGIN_OFLAGS)
449
450 $(TARGET_BFLAGS):= $(PLUGIN_LINK_BFLAGS)
451 $(TARGET_OFLAGS):= $(PLUGIN_LINK_OFLAGS)
452 $(NAME_DOCFLAGS):= $(DOC_FLAGS) $(PLUGIN_DOCFLAGS) \
453 -I $(PLUGIN_DIR) \
454 $(PLUGIN_EXTRA_DIRS_INC) \
455 -I $(PLUGIN_LIB_DIR) \
456 $(addprefix -package ,$(PLUGIN_REQUIRES) $(LIBRARY_NAMES))
457
458 ifeq ($(HAS_GUI),yes)
459 $(NAME_GUI_BFLAGS):=$($(NAME_BFLAGS)) $(THREAD) $(addprefix -package ,$(LIBRARY_NAMES_GUI))
460 $(NAME_GUI_OFLAGS):=$($(NAME_OFLAGS)) $(THREAD) $(addprefix -package ,$(LIBRARY_NAMES_GUI))
461 $(TARGET_GUI_BFLAGS):= $(PLUGIN_LINK_GUI_BFLAGS)
462 $(TARGET_GUI_OFLAGS):= $(PLUGIN_LINK_GUI_OFLAGS)
463 $(NAME_DOCFLAGS) := $($(NAME_DOCFLAGS)) $(addprefix -package ,$(LIBRARY_NAMES_GUI))
464 endif
465 $(NAME_DEPFLAGS):= -I $(PLUGIN_DIR) $(PLUGIN_DEPFLAGS) $(PLUGIN_EXTRA_DIRS_INC)
466
467 # Add the flags to the compilation line of the plugin source files
468 $(PLUGIN_CMO) $(PLUGIN_CMI) $(PLUGIN_INFERRED_MLI): BFLAGS:=$($(NAME_BFLAGS))
469 $(PLUGIN_CMX): OFLAGS:=$($(NAME_OFLAGS)) -for-pack @PLUGIN_NAME@
470
471 ifeq ($(HAS_GUI),yes)
472 $(PLUGIN_GUI_CMO) $(PLUGIN_GUI_CMI): BFLAGS:=$($(NAME_GUI_BFLAGS))
473 $(PLUGIN_GUI_CMX): OFLAGS:=$($(NAME_GUI_OFLAGS)) -for-pack @PLUGIN_NAME@
474 endif
475
476 # META file
477 PLUGIN_PKG :=$(shell echo frama-c-@PLUGIN_NAME@ | tr '[:upper:]' '[:lower:]')
478 TARGET_META :=$(PLUGIN_LIB_DIR)/META.$(PLUGIN_PKG)
479 PLUGIN_GENERATED+= $(TARGET_META)
480
481 ifneq ($(PLUGIN_HAS_META),yes)
482 # generated META
483 ifeq ($(PLUGIN_DESCRIPTION),)
484 PLUGIN_DESCRIPTION :="Frama-C @PLUGIN_NAME@ plug-in"
485 endif
486 ifeq ($(PLUGIN_VERSION),)
487 ifeq ($(FRAMAC_INTERNAL),yes)
488 ifeq ($(FRAMAC_ROOT_SRCDIR),)
489 PLUGIN_VERSION :=$(shell cat VERSION)
490 else
491 # To remove "cat: VERSION: No such file or directory" in EXECNOW target performing make commands under a plugin directory
492 PLUGIN_VERSION :=$(shell cat $(FRAMAC_ROOT_SRCDIR)/VERSION)
493 endif
494 else
495 PLUGIN_VERSION :=$(shell frama-c-config -print-version)
496 endif
497 endif
498 # registering package description for later use
499 META.$(PLUGIN_PKG).DESCRIPTION :=$(PLUGIN_DESCRIPTION)
500 META.$(PLUGIN_PKG).VERSION :=$(PLUGIN_VERSION)
501 META.$(PLUGIN_PKG).REQUIRES :=$(PLUGIN_REQUIRES)
502 ifdef PLUGIN_EXTRA_BYTE
503 META.$(PLUGIN_PKG).BYTE :=@[email protected]
504 else
505 META.$(PLUGIN_PKG).BYTE :=@[email protected]
506 endif
507 META.$(PLUGIN_PKG).NATIVE :=@[email protected]
508 META.$(PLUGIN_PKG).PLUGIN :=@[email protected]
509
510 ifeq ($(FRAMAC_INTERNAL),yes)
511 # In internal mode, we depend on the main Makefile for plugins that do not
512 # have their own Makefile. To detect that, we check whether there is a
513 # plugin-specific Makefile in the include stack.
514 ifeq ($(filter $(PLUGIN_DIR)/Makefile,$(MAKEFILE_LIST)),)
515 $(TARGET_META): Makefile
516 else
517 $(TARGET_META): $(PLUGIN_DIR)/Makefile
518 endif # PLUGIN_DIR/Makefile
519 else
520 $(TARGET_META): $(PLUGIN_DIR)/Makefile
521 endif # FRAMAC_INTERNAL
522
523 $(TARGET_META):
524 $(PRINT_MAKING) $(notdir $@)
525 $(RM) $@
526 $(MKDIR) $(dir $@)
527 $(ECHO) "description = \"$($(notdir $@).DESCRIPTION)\"" >> $@
528 $(ECHO) "version = \"$($(notdir $@).VERSION)\"" >> $@
529 $(ECHO) "requires = \"frama-c.kernel $($(notdir $@).REQUIRES)\"" >> $@
530 $(ECHO) "archive(byte) = \"top/$($(notdir $@).BYTE)\"" >> $@
531 $(ECHO) "archive(native) = \"top/$($(notdir $@).NATIVE)\"" >> $@
532 $(ECHO) "plugin(native) = \"top/$($(notdir $@).PLUGIN)\"" >> $@
533 $(ECHO) "plugin(byte) = \"top/$($(notdir $@).BYTE)\"" >> $@
534 ifeq ($(HAS_GUI),yes)
535 $(ECHO) "archive(byte,gui) = \"gui/$($(notdir $@).BYTE)\"" >> $@
536 $(ECHO) "archive(native,gui) = \"gui/$($(notdir $@).NATIVE)\"" >> $@
537 $(ECHO) "plugin(native,gui) = \"gui/$($(notdir $@).PLUGIN)\"" >> $@
538 $(ECHO) "plugin(byte,gui) = \"gui/$($(notdir $@).BYTE)\"" >> $@
539 endif
540 $(ECHO) "directory = \"\"" >> $@
541
542 else # PLUGIN_HAS_META
543 # user-defined META
544 $(TARGET_META): $(PLUGIN_DIR)/META
545 $(PRINT_CP) $(notdir $@)
546 $(CP) $< $@
547 $(ECHO) "directory = \"\"" >> $@
548 endif # PLUGIN_HAS_META
549
550 # Now build the targets
551 #######################
552
553 @PLUGIN_NAME@_PLUGIN_MLI:= $(PLUGIN_DIR)/@[email protected]
554 @PLUGIN_NAME@_CHECK_PLUGIN_MLI:=$(PLUGIN_DIR)/@[email protected]_mli_exists
555
556 $(TARGET_CMI): BFLAGS:=$($(NAME_BFLAGS)) -opaque
557
558 $(TARGET_CMI): $(PLUGIN_CMO)
559
560
561 ifneq ($(TARGET_MLI),$(@PLUGIN_NAME@_PLUGIN_MLI))
562 # Copy the plugin interface in the plugins directory
563 $(TARGET_MLI): $(@PLUGIN_NAME@_CHECK_PLUGIN_MLI)
564 $(PRINT_MAKING) $@
565 $(MKDIR) $(PLUGIN_LIB_DIR)
566 $(RM) $@
567 $(ECHO) "(* This module was generated automatically by code in Makefile and $(@PLUGIN_NAME@_PLUGIN_MLI) *)" > $@
568 $(ECHO) "#1 \"$(@PLUGIN_NAME@_PLUGIN_MLI)\"" >> $@
569 $(CAT) $(@PLUGIN_NAME@_PLUGIN_MLI) >> $@
570 $(CHMOD_RO) $@
571
572 $(INSTALLED_PLUGIN_DIR)/.placeholders_ready: $(TARGET_MLI)
573
574 PLUGIN_GENERATED+= $(TARGET_MLI)
575 endif
576
577 $(TARGET_TOP_MLI): $(@PLUGIN_NAME@_CHECK_PLUGIN_MLI) $(TARGET_MLI)
578 $(PRINT_MAKING) $@
579 $(MKDIR) $(PLUGIN_LIB_DIR)/top
580 $(RM) $@
581 $(CP) $(@PLUGIN_NAME@_TARGET_MLI) $@
582
583 PLUGIN_GENERATED+= $(TARGET_TOP_MLI)
584
585 @PLUGIN_NAME@_MLI:=$(TARGET_MLI)
586
587 $(TARGET_TOP_CMI): $(TARGET_CMI)
588 $(PRINT_MAKING) $@
589 $(MKDIR) $(PLUGIN_LIB_DIR)/top
590 $(RM) $@
591 $(CP) $< $@
592
593
594 $(TARGET_TOP_CMO): $(PLUGIN_CMO) \
595 $(TARGET_CMI) $(TARGET_TOP_CMI)
596 $(PRINT_PACKING) $@
597 $(OCAMLC) -o $(call winpath,$@) $(@PLUGIN_NAME@_BFLAGS) -pack \
598 $(@PLUGIN_NAME@_TARGET_BFLAGS) \
599 $(@PLUGIN_NAME@_CMI_ONLY) $(@PLUGIN_NAME@_CMO)
600
601 $(TARGET_TOP_CMX): $(PLUGIN_CMX) \
602 $(TARGET_CMI) $(TARGET_TOP_CMI)
603 $(PRINT_PACKING) $@
604 $(OCAMLOPT) -o $(call winpath,$@) $(@PLUGIN_NAME@_OFLAGS) -pack \
605 $(@PLUGIN_NAME@_TARGET_OFLAGS) \
606 $(@PLUGIN_NAME@_CMI_ONLY) $(@PLUGIN_NAME@_CMX)
607
608 $(TARGET_TOP_CMXS): $(TARGET_TOP_CMX) $(PLUGIN_EXTRA_OPT)
609 $(PRINT_PACKING) $@
610 $(OCAMLOPT) -o $(call winpath,$@) -shared \
611 $(@PLUGIN_NAME@_OFLAGS) \
612 $(@PLUGIN_NAME@_EXTRA_OPT) \
613 $(@:.cmxs=.cmx)
614
615 ifdef PLUGIN_EXTRA_BYTE
616 $(TARGET_TOP_CMA): $(PLUGIN_EXTRA_BYTE) $(TARGET_TOP_CMO)
617 $(PRINT_PACKING) $@
618 $(OCAMLC) -o $(call winpath,$@) $(@PLUGIN_NAME@_BFLAGS) \
619 $(@PLUGIN_NAME@_TARGET_BFLAGS) \
620 -a $(@PLUGIN_NAME@_EXTRA_BYTE) $(@:.cma=.cmo)
621 endif
622
623 ifeq ($(HAS_GUI),yes)
624 # packing gui files
625 ###################
626
627 $(TARGET_GUI_CMI): $(TARGET_CMI)
628 $(PRINT_MAKING) $@
629 $(MKDIR) $(PLUGIN_LIB_DIR)/gui
630 $(RM) $@
631 $(CP) $< $@
632
633 PLUGIN_GENERATED+= $(TARGET_GUI_MLI)
634
635 $(TARGET_GUI_MLI): $(@PLUGIN_NAME@_CHECK_PLUGIN_MLI) $(TARGET_MLI)
636 $(PRINT_MAKING) $@
637 $(MKDIR) $(PLUGIN_LIB_DIR)/gui
638 $(RM) $@
639 $(CP) $(@PLUGIN_NAME@_TARGET_MLI) $@
640
641 $(TARGET_GUI_CMO): $(PLUGIN_GUI_CMO) $(TARGET_CMI) $(TARGET_GUI_CMI)
642 $(PRINT_PACKING) $@
643 $(MKDIR) $(PLUGIN_LIB_DIR)/gui
644 $(OCAMLC) -o $(call winpath,$@) $(@PLUGIN_NAME@_GUI_BFLAGS) -pack \
645 $(@PLUGIN_NAME@_GUI_TARGET_BFLAGS) \
646 $(@PLUGIN_NAME@_GUI_CMI_ONLY) \
647 $(@PLUGIN_NAME@_GUI_CMO)
648
649 $(TARGET_GUI_CMX): $(PLUGIN_GUI_CMX) $(TARGET_CMI) $(TARGET_GUI_CMI)
650 $(PRINT_PACKING) $@
651 $(MKDIR) $(PLUGIN_LIB_DIR)/gui
652 $(OCAMLOPT) -o $(call winpath,$@) $(@PLUGIN_NAME@_GUI_OFLAGS) -pack \
653 $(@PLUGIN_NAME@_GUI_TARGET_OFLAGS) \
654 $(@PLUGIN_NAME@_GUI_CMI_ONLY) \
655 $(@PLUGIN_NAME@_GUI_CMX)
656
657 $(TARGET_GUI_CMXS): $(TARGET_GUI_CMX)
658 $(PRINT_PACKING) $@
659 $(MKDIR) $(PLUGIN_LIB_DIR)/gui
660 $(OCAMLOPT) -o $(call winpath,$@) -shared \
661 $(@PLUGIN_NAME@_GUI_OFLAGS) \
662 $(@PLUGIN_NAME@_GUI_TARGET_OFLAGS) \
663 $(@PLUGIN_NAME@_EXTRA_OPT) \
664 $^
665
666 ifdef PLUGIN_EXTRA_BYTE
667 $(TARGET_GUI_CMA): $(PLUGIN_EXTRA_BYTE) $(TARGET_GUI_CMO)
668 $(PRINT_PACKING) $@
669 $(OCAMLC) -o $(call winpath,$@) $(@PLUGIN_NAME@_GUI_BFLAGS) \
670 $(@PLUGIN_NAME@_GUI_TARGET_BFLAGS) \
671 -a $(@PLUGIN_NAME@_EXTRA_BYTE) $(@:.cma=.cmo)
672 endif
673
674 else
675 # No specific gui items
676 TARGET_GUI_MLI:=
677 TARGET_GUI_CMI:=
678 endif # HAS_GUI
679
680 #########
681
682 # The following rules used some plugin info (name and path) in their names
683 # in order to used them in the command:
684 # it is not possible to use $(PLUGIN_*) in commands due to the evaluation rules
685 # of make
686
687 ##########################
688 # Internal documentation #
689 ##########################
690
691 MODULES_TODOC+= $(PLUGIN_TYPES_TODOC)
692
693 PLUGIN_UNDOC := $(addprefix $(PLUGIN_DIR)/,$(PLUGIN_UNDOC))
694
695 PLUGIN_DOC_SRC:=$(filter-out $(PLUGIN_UNDOC),$(PLUGIN_ML_SRC))
696 @PLUGIN_NAME@_DOC_SRC:=$(PLUGIN_DOC_SRC)
697
698 ifndef PLUGIN_DOC_DIR
699 PLUGIN_DOC_DIR := $(DOC_DIR)/$(PLUGIN_BASE)
700 endif
701
702 @PLUGIN_NAME@_DOC_DIR:= $(PLUGIN_DOC_DIR)
703
704 @PLUGIN_NAME@_INTRO:=$(PLUGIN_INTRO)
705 ifdef PLUGIN_INTRO
706 @PLUGIN_NAME@_CAT_INTRO:= cp -f $(PLUGIN_INTRO) $(PLUGIN_DOC_DIR)/@[email protected]
707 ifeq ($(PLUGIN_DISTRIBUTED),yes)
708 PLUGIN_DIST_EXTERNAL_LIST+= $(PLUGIN_INTRO)
709 endif
710 else
711 @PLUGIN_NAME@_CAT_INTRO:= echo "" > $(PLUGIN_DOC_DIR)/@[email protected]
712 endif
713
714 ifeq ($(FRAMAC_INTERNAL),yes)
715 DOC_INTRO:= $(DOC_DIR)/intro_kernel_plugin.txt \
716 $(DOC_DIR)/intro_plugin.txt \
717 $(DOC_DIR)/intro_plugin_D_and_S.txt \
718 $(DOC_DIR)/intro_plugin_default.txt
719 else
720 DOC_INTRO:=
721 endif
722
723 $(@PLUGIN_NAME@_DOC_DIR)/@[email protected]: $(DOC_INTRO) $(@PLUGIN_NAME@_INTRO)
724 $(PRINT_MAKING) "$@"
725 $(MKDIR) $(dir $@)
726 $(@PLUGIN_NAME@_CAT_INTRO)
727 if [ -f "$(DOC_DIR)/html/Db.@[email protected]" ] ; then \
728 if [ -f "$(DOC_DIR)/dynamic_plugins/Dynamic_plugins.@[email protected]" ] ; then \
729 cat $(DOC_DIR)/intro_plugin_D_and_S.txt >> $@ ; \
730 else \
731 cat $(DOC_DIR)/intro_kernel_plugin.txt >> $@ ; \
732 fi ; \
733 elif [ -f "$(DOC_DIR)/dynamic_plugins/Dynamic_plugins.@[email protected]" ] ; then \
734 cat $(DOC_DIR)/intro_plugin.txt >> $@ ; \
735 else \
736 cat $(DOC_DIR)/intro_plugin_default.txt >> $@ ; \
737 fi
738 $(ISED) -e "s/_PluginName_/@PLUGIN_NAME@/g" \
739 -e "/^#\*/d" $@
740
741 ifeq ($(FRAMAC_INTERNAL),yes)
742 OCAMLDOC_GEN:=$(DOC_PLUGIN)
743 OCAMLDOC_GEN+=$(DOC_DIR)/kernel-doc.ocamldoc
744
745 else
746 OCAMLDOC_GEN:=
747
748 # not doing kernel documentation if just compiling plugin's one
749
750 $(DOC_DIR)/docgen.cmo: $(DOC_DIR)/docgen.ml
751 $(PRINT_OCAMLC) $@
752 $(OCAMLC) -c -I +ocamldoc $(call winpath,$(DOC_DIR))/docgen.ml
753
754 $(DOC_DIR)/docgen.cmxs: $(DOC_DIR)/docgen.ml
755 $(PRINT_PACKING) $@
756 $(OCAMLOPT) -o $(call winpath,$@) -shared -I +ocamldoc \
757 $(call winpath,$(DOC_DIR))/docgen.ml
758 endif
759
760 OCAMLDOC_DEPEND:= $(PLUGIN_CMO)
761 ifneq ($(ENABLE_GUI),no)
762 OCAMLDOC_DEPEND:= $(OCAMLDOC_DEPEND) $(PLUGIN_GUI_CMO)
763 endif
764
765 .PHONY: @PLUGIN_NAME@_DOC
766 @PLUGIN_NAME@_DOC: $(OCAMLDOC_DEPEND) \
767 $(OCAMLDOC_GEN) \
768 $(@PLUGIN_NAME@_DOC_DIR)/@[email protected] \
769 $(@PLUGIN_NAME@_DOC_DIR)/modules.svg \
770 $(DOC_PLUGIN)
771 $(PRINT_DOC) @PLUGIN_NAME@
772 $(MKDIR) $(@PLUGIN_NAME@_DOC_DIR)
773 $(RM) $(@PLUGIN_NAME@_DOC_DIR)/*.html
774 # Only generate toc for kernel's documentation if we are in Frama-C's main
775 # Makefile
776 ifeq ($(FRAMAC_INTERNAL),yes)
777 $(ECHO) '<li><a href="$(subst $(DOC_DIR)/,,$(@PLUGIN_NAME@_DOC_DIR))/index.html">$(subst _, ,@PLUGIN_NAME@)</a></li>' > $(DOC_DIR)/@[email protected]
778 endif
779 $(OCAMLDOC) $(@PLUGIN_NAME@_DOCFLAGS) \
780 -t "@PLUGIN_NAME@ plugin" \
781 -css-style ../style.css \
782 -d $(@PLUGIN_NAME@_DOC_DIR) -g $(DOC_PLUGIN) -passopt -docpath $(DOC_DIR)/html \
783 $(addprefix -load ,$(wildcard $(DOC_DIR)/kernel-doc.ocamldoc)) \
784 $(wildcard $(@PLUGIN_NAME@_DOC_SRC))
785 # [rb+js] 20090619
786 # pwd is required to avoid "bad directory" message on OpenBSD
787 # don't know why
788 cd `pwd`/$(@PLUGIN_NAME@_DOC_DIR); \
789 for f in $(foreach f,$(@PLUGIN_NAME@_TYPES_TODOC),\
790 $(basename $(notdir $f))); do \
791 for g in \
792 $(wildcard ../html/$(shell $(ECHO) $(f) | $(SED) 's/^./\u&/')); \
793 do \
794 ln -sf $$g; \
795 done; \
796 done; \
797 for f in *.html; do \
798 $(ISED) -e 's|\(doc/code/html\)|../../../\1|g' $$f ; \
799 done
800
801
802 # removed dependencies:
803 # $(PLUGIN_DOC_DIR)/modules.ps \
804 # $(PLUGIN_DOC_DIR)/modules-all.ps \
805 # $(PLUGIN_DOC_DIR)/types.ps
806 $(PLUGIN_DOC_DIR)/modules.dot: DOC_FLAGS:=$($(NAME_DOCFLAGS))
807 $(PLUGIN_DOC_DIR)/modules.dot: $(wildcard $(PLUGIN_DOC_SRC))
808 $(PRINT_DOC) $@
809 $(MKDIR) $(dir $@)
810 $(OCAMLDOC) $(DOC_FLAGS) -o $@ -dot $^ \
811 || { $(RM) $@; exit 2; } # in case of error, ocamldoc still generates
812 # something
813 $(ISED) -e "s/rotate=90;//" \
814 -e 's/digraph G/digraph "Plugin architecture ($(subst /,,$(subst doc/code,,$(dir $@))))"/' \
815 $@
816
817 $(PLUGIN_DOC_DIR)/modules-all.dot: DOC_FLAGS:=$($(NAME_DOCFLAGS))
818 $(PLUGIN_DOC_DIR)/modules-all.dot: $(wildcard $(PLUGIN_DOC_SRC))
819 $(PRINT_DOC) $@
820 $(MKDIR) $(dir $@)
821 $(OCAMLDOC) $(DOC_FLAGS) $($(dir $@)FLAGS) -o $@ -dot \
822 -dot-include-all $^
823 $(ISED) -e "s/rotate=90;//" $@
824
825 $(PLUGIN_DOC_DIR)/types.dot: DOC_FLAGS:=$($(NAME_DOCFLAGS))
826 $(PLUGIN_DOC_DIR)/types.dot: $(wildcard $(PLUGIN_DOC_SRC))
827 $(PRINT_DOC) $@
828 $(MKDIR) $(dir $@)
829 $(OCAMLDOC) $(DOC_FLAGS) $($(dir $@)FLAGS) -o $@ -dot -dot-types $^
830 $(ISED) -e "s/rotate=90;//" $@
831
832 .PHONY: @PLUGIN_NAME@_metrics
833 @PLUGIN_NAME@_metrics : $(PLUGIN_DOC_DIR)/metrics.html
834 $(PLUGIN_DOC_DIR)/metrics.html : $(wildcard $(PLUGIN_DOC_SRC))
835 $(PRINT_DOC) $@
836 ocamlmetrics $^ > $@
837
838 ############
839 # Tests #
840 ############
841
842 ifneq ("$(PLUGIN_ENABLE)","no")
843 ifndef PLUGIN_NO_TEST
844 ifndef PLUGIN_TESTS_DIRS
845 PLUGIN_TESTS_DIRS:=$(PLUGIN_BASE)
846 endif
847 endif
848
849 ifndef PLUGIN_TESTS_DIRS_DEFAULT
850 PLUGIN_TESTS_DIRS_DEFAULT:=$(PLUGIN_TESTS_DIRS)
851 endif
852
853 ifndef PLUGIN_NO_DEFAULT_TEST
854 ifdef PLUGIN_INTERNAL_TEST
855 PLUGIN_TESTS_LIST += $(PLUGIN_TESTS_DIRS_DEFAULT)
856 endif
857 endif
858
859 @PLUGIN_NAME@_TESTS_DIRS:=$(PLUGIN_TESTS_DIRS)
860
861 @PLUGIN_NAME@_TESTS_LIB_DIR:=$(sort $(dir $(PLUGIN_TESTS_LIB)))
862 @PLUGIN_NAME@_TESTS_LIB_DIR_INCLUDE:=$(foreach d,$(@PLUGIN_NAME@_TESTS_LIB_DIR),-I $d )
863 @PLUGIN_NAME@_EXTRA_DIRS:=$(@PLUGIN_NAME@_EXTRA_DIRS) $(@PLUGIN_NAME@_TESTS_LIB_DIR)
864 @PLUGIN_NAME@_TESTS_LIB_OPT:=$(PLUGIN_TESTS_LIB:%.ml=%.cmx)
865 @PLUGIN_NAME@_TESTS_LIB_OPT_DYN:=$(PLUGIN_TESTS_LIB:%.ml=%.cmxs)
866 @PLUGIN_NAME@_TESTS_LIB_BYTE:=$(PLUGIN_TESTS_LIB:%.ml=%.cmo)
867
868 $(@PLUGIN_NAME@_TESTS_LIB_OPT): OFLAGS:=$($(NAME_TEST_OFLAGS)) $(@PLUGIN_NAME@_TESTS_LIB_DIR_INCLUDE)
869 $(@PLUGIN_NAME@_TESTS_LIB_OPT_DYN): OFLAGS:=$($(NAME_TEST_OFLAGS)) $(@PLUGIN_NAME@_TESTS_LIB_DIR_INCLUDE)
870 $(@PLUGIN_NAME@_TESTS_LIB_BYTE): BFLAGS:=$($(NAME_TEST_BFLAGS)) $(@PLUGIN_NAME@_TESTS_LIB_DIR_INCLUDE)
871
872 # [JS 2009/03/18] both .PRECIOUS are required in order to prevent 'make'
873 # deletion of intermediate generated files. Such a deletion forces 'make' to
874 # unnecessarily recompile those files.
875 .PRECIOUS: $(@PLUGIN_NAME@_TESTS_LIB_OPT) \
876 $(@PLUGIN_NAME@_TESTS_LIB_OPT_DYN) \
877 $(@PLUGIN_NAME@_TESTS_LIB_BYTE) \
878 $(@PLUGIN_NAME@_TESTS_LIB_BYTE:%.cmo=%.cmi)
879 endif # PLUGIN_ENABLE
880
881 ##########
882 # Depend #
883 ##########
884
885 # for reasons known to themselves, ocamldep and make are confused by ./file.ml
886 # hence (one of) the patsubst below in case PLUGIN_DIR is .
887
888 # If you explicitly do "make depend" it is
889 # $(PLUGIN_DIR)/@PLUGIN_NAME@_DEP_REDO. it forces the computation of
890 # dependencies. Otherwise usual dependency for $(PLUGIN_DIR)/.depend.
891 .PHONY: $(@PLUGIN_NAME@_DIR)/@PLUGIN_NAME@_DEP_REDO
892 $(@PLUGIN_NAME@_DIR)/@PLUGIN_NAME@_DEP_REDO $(@PLUGIN_NAME@_DIR)/.depend: \
893 $(PLUGIN_GENERATED)
894 $(PRINT_DEP) $(@PLUGIN_NAME@_DIR)/.depend
895 $(RM) $(@PLUGIN_NAME@_DIR)/.depend
896 $(OCAMLDEP) $(INCLUDES) \
897 $(@PLUGIN_NAME@_DEPFLAGS) \
898 $(patsubst ./%,%,\
899 $(@PLUGIN_NAME@_ML_SRC) \
900 $(@PLUGIN_NAME@_MLI) \
901 $(@PLUGIN_NAME@_GUI_MLI)) \
902 $(foreach d,$(wildcard $(@PLUGIN_NAME@_TESTS_LIB_DIR)),\
903 -I $d $d*.ml $d*.mli) \
904 > $(@PLUGIN_NAME@_DIR)/.depend
905 $(CHMOD_RO) $(@PLUGIN_NAME@_DIR)/.depend
906
907 depend:: $(@PLUGIN_NAME@_DIR)/@PLUGIN_NAME@_DEP_REDO
908
909 #Just for backward compatibility (19/10/2015)
910 $(@PLUGIN_NAME@_DIR)/@PLUGIN_NAME@_DEP: $(@PLUGIN_NAME@_DIR)/.depend
911 $(TOUCH) $@
912
913 #In internal mode wait for lib/plugins to be populated by .mli.
914 ifeq ($(FRAMAC_INTERNAL),yes)
915 $(@PLUGIN_NAME@_DIR)/@PLUGIN_NAME@_DEP_REDO $(@PLUGIN_NAME@_DIR)/.depend: $(INSTALLED_PLUGIN_DIR)/.placeholders_ready
916 endif
917
918 # MAKECMDGOALS contains the targets passed to make. We set it to non-empty
919 # (if needed) to silence warnings about undefined variables.
920 MAKECMDGOALS ?=
921
922 ifneq ($(MAKECMDGOALS),clean)
923 ifneq ($(MAKECMDGOALS),distclean)
924 ifneq ($(MAKECMDGOALS),smartclean)
925 sinclude $(PLUGIN_DIR)/.depend
926 endif
927 endif
928 endif
929
930 ############
931 # Cleaning #
932 ############
933
934 .PHONY: $(PLUGIN_DIR)/@PLUGIN_NAME@_CLEAN
935 $(PLUGIN_DIR)/@PLUGIN_NAME@_CLEAN:
936 $(PRINT_RM) $(patsubst %_CLEAN,%,$(notdir $@))
937 if test "$(FRAMAC_INTERNAL)" = "yes"; then \
938 $(RM) $(dir $@).depend; \
939 fi
940 $(RM) $(PLUGIN_GENERATED)
941 $(RM) $(@:%CLEAN=%DEP) $(@:%CLEAN=%DEP_REDO)
942 $(RM) $(patsubst %.cmo,%.cm*,$($(patsubst %_CLEAN,%_CMO,$(notdir $@))))
943 $(RM) $(patsubst %.cmi,%.cm*,$($(patsubst %_CLEAN,%_CMI,$(notdir $@))))
944 $(RM) $(patsubst %.cmo,%.annot,\
945 $($(patsubst %_CLEAN,%_CMO,$(notdir $@))))
946 $(RM) $(patsubst %.cmo,%.o,$($(patsubst %_CLEAN,%_CMO,$(notdir $@))))
947 $(RM) $(patsubst %.cmo,%.cm*,\
948 $($(patsubst %_CLEAN,%_GUI_CMO,$(notdir $@))))
949 $(RM) $(patsubst %.cmi,%.cm*,\
950 $($(patsubst %_CLEAN,%_GUI_CMI,$(notdir $@))))
951 $(RM) $(patsubst %.cmo,%.annot,\
952 $($(patsubst %_CLEAN,%_GUI_CMO,$(notdir $@))))
953 $(RM) $(patsubst %.cmo,%.o,\
954 $($(patsubst %_CLEAN,%_GUI_CMO,$(notdir $@))))
955 $(RM) $(dir $@)*~ $(dir $@)*.cm* $(dir $@)*.o $(dir $@)*.annot
956 $(RM) $(foreach d,$(@:%CLEAN=%TESTS_LIB_OPT),\
957 $(foreach f,$($(notdir $d)),\
958 $f $(f:.cmx=.cm*) $(f:.cmx=.opt) $(f:.cmx=.byte) $(f:.cmx=.o)))
959 $(RM) -f $(@PLUGIN_NAME@_CHECK_PLUGIN_MLI)
960
961
962 .PHONY: $(PLUGIN_DIR)/@PLUGIN_NAME@_DIST_CLEAN
963 $(PLUGIN_DIR)/@PLUGIN_NAME@_DIST_CLEAN:
964 $(RM) $(dir $@)/tests/ptests_config
965
966 .PHONY: $(PLUGIN_DIR)/@PLUGIN_NAME@_CLEAN_DOC $(@PLUGIN_NAME@_DOC_DIR)
967 $(PLUGIN_DIR)/@PLUGIN_NAME@_CLEAN_DOC: $(@PLUGIN_NAME@_DOC_DIR)
968 $(PRINT_RM) documentation of $(patsubst %_CLEAN_DOC,%,$(notdir $@))
969 $(RM) -r $<
970 $(RM) $(DOC_DIR)/$(notdir $(patsubst %_CLEAN_DOC,%,$@).toc)
971
972 # Global lists seen in Makefile
973
974 PLUGIN_GENERATED_LIST += $(PLUGIN_GENERATED)
975
976 PLUGIN_META_LIST += $(TARGET_META)
977 PLUGIN_DYN_CMI_LIST += $(TARGET_CMI)
978 ifdef PLUGIN_EXTRA_BYTE
979 .PRECIOUS: $(TARGET_TOP_CMO)
980 PLUGIN_DYN_CMO_LIST += $(TARGET_TOP_CMA)
981 else
982 PLUGIN_DYN_CMO_LIST += $(TARGET_TOP_CMO)
983 endif
984 PLUGIN_DYN_DEP_GUI_CMO_LIST += $(PLUGIN_GUI_CMO)
985 ifeq ($(HAS_GUI),yes)
986 PLUGIN_DYN_GUI_EXISTS:=yes
987 ifdef PLUGIN_EXTRA_BYTE
988 PLUGIN_DYN_GUI_CMO_LIST += $(TARGET_GUI_CMA)
989 else
990 PLUGIN_DYN_GUI_CMO_LIST += $(TARGET_GUI_CMO)
991 endif #EXTRA_BYTE
992 endif #HAS_GUI
993
994 PLUGIN_DYN_DEP_GUI_CMX_LIST += $(PLUGIN_GUI_CMX)
995 PLUGIN_DYN_CMX_LIST += $(TARGET_TOP_CMXS) $(TARGET_TOP_CMX) $(TARGET_TOP_O)
996 # If P1 depends on P2, then dynamically link P1.cmxs requires to have
997 # compiled P1's sources wrt the P2's .cmx.
998 ifeq ($(HAS_GUI),yes)
999 PLUGIN_DYN_GUI_CMX_LIST += $(TARGET_GUI_CMXS)
1000 endif # HAS_GUI
1001
1002 PLUGIN_INTERNAL_CMO_LIST += $(PLUGIN_CMO)
1003 PLUGIN_INTERNAL_CMX_LIST += $(PLUGIN_CMX)
1004 PLUGIN_DOC_LIST += @PLUGIN_NAME@_DOC
1005 PLUGIN_DOC_DIRS += $(PLUGIN_BASE)
1006
1007 ifeq ($(PLUGIN_DISTRIBUTED),yes)
1008 PLUGIN_DISTRIBUTED_NAME_LIST += @PLUGIN_NAME@
1009 PLUGIN_DISTRIBUTED_DIR_LIST += @PLUGIN_NAME@
1010 endif
1011
1012 else
1013 $(PLUGIN_DIR)/@PLUGIN_NAME@_DEP_REDO:
1014 $(PLUGIN_DIR)/@PLUGIN_NAME@_DEP:
1015 $(PLUGIN_DIR)/@PLUGIN_NAME@_CLEAN:
1016 $(PLUGIN_DIR)/@PLUGIN_NAME@_CLEAN_DOC:
1017 $(PLUGIN_DIR)/@PLUGIN_NAME@_DIST_CLEAN:
1018 endif
1019
1020 # Reset each "local" plugin variable
1021
1022 ifneq ($(PLUGIN_RESET),no)
1023 PLUGIN_RESET:=
1024 PLUGIN_NAME:=
1025 PLUGIN_DIR:=
1026 PLUGIN_DESCRIPTION:=
1027 PLUGIN_VERSION:=
1028 PLUGIN_REQUIRES:=
1029 PLUGIN_HAS_META:=
1030 PLUGIN_CMI:=
1031 PLUGIN_CMO:=
1032 PLUGIN_BFLAGS:=
1033 PLUGIN_OFLAGS:=
1034 PLUGIN_DEPFLAGS:=
1035 PLUGIN_DOCFLAGS:=
1036 PLUGIN_GENERATED:=
1037 PLUGIN_TYPES_CMO:=
1038 PLUGIN_GUI_CMO:=
1039 PLUGIN_GUI_CMX:=
1040 PLUGIN_GUI_CMI:=
1041 PLUGIN_GUI_MLI:=
1042 PLUGIN_UNDOC:=
1043 PLUGIN_TYPES_TODOC:=
1044 PLUGIN_INTRO:=
1045 PLUGIN_ENABLE:=
1046 PLUGIN_NO_TEST:=
1047 PLUGIN_TESTS_LIB:=
1048 PLUGIN_TESTS_DIRS:=
1049 PLUGIN_DEPENDS:=
1050 PLUGIN_DEPENDENCIES:=
1051 PLUGIN_DISTRIBUTED:=
1052 PLUGIN_DISTRIB_EXTERNAL:=
1053 PLUGIN_DISTRIB_TESTS:=
1054 PLUGIN_HAS_EXT_DOC:=
1055 PLUGIN_NO_DEFAULT_TEST:=
1056 PLUGIN_TESTS_DIRS_DEFAULT:=
1057 PLUGIN_LINK_GUI_BFLAGS:=
1058 PLUGIN_LINK_GUI_OFLAGS:=
1059 PLUGIN_LINK_BFLAGS:=
1060 PLUGIN_LINK_OFLAGS:=
1061 PLUGIN_EXTRA_BYTE:=
1062 PLUGIN_EXTRA_OPT:=
1063 PLUGIN_EXTRA_DIRS:=
1064 PLUGIN_INTERNAL_TEST:=
1065 PLUGIN_DOC_DIR:=
1066 PLUGIN_HEADER_SPEC:=$(DEFAULT_HEADER_SPEC)
1067 PLUGIN_HEADER_DIRS:=$(DEFAULT_HEADER_DIRS)
1068 PLUGIN_HEADER_EXCEPTIONS:=$(DEFAULT_HEADER_EXCEPTIONS)
1069 PLUGIN_CEA_PROPRIETARY_FILES:=$(DEFAULT_CEA_PROPRIETARY_FILES)
1070 PLUGIN_CEA_PROPRIETARY_HEADERS:=
1071 endif
1072
1073 ###############################################################################
1074 # Local Variables:
1075 # mode: makefile
1076 # End: