Makefile.in 11.6 KB
Newer Older
1 2 3 4
##########################################################################
#                                                                        #
#  This file is part of WP plug-in of Frama-C.                           #
#                                                                        #
Andre Maroneze's avatar
Andre Maroneze committed
5
#  Copyright (C) 2007-2020                                               #
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
#    CEA (Commissariat a l'energie atomique et aux energies              #
#         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).            #
#                                                                        #
##########################################################################

# Do not use ?= to initialize both below variables
# (fixed efficiency issue, see GNU Make manual, Section 8.11)
ifndef FRAMAC_SHARE
FRAMAC_SHARE  :=$(shell frama-c-config -print-share-path)
endif
ifndef FRAMAC_LIBDIR
FRAMAC_LIBDIR :=$(shell frama-c-config -print-libpath)
endif
PLUGIN_DIR ?=.

ifneq ("$(FRAMAC_INTERNAL)","yes")
include $(FRAMAC_SHARE)/Makefile.config
endif

37
# Coq Resources Installation
38 39 40 41
include $(PLUGIN_DIR)/share/Makefile.resources

# Extension of the GUI for wp is compilable
# only if gnomecanvas is available
42
#ifeq ($(HAS_GNOMECANVAS),yes)
43 44 45 46 47 48 49 50 51 52 53 54
PLUGIN_GUI_CMO:= \
	GuiConfig \
	GuiList \
	GuiSequent \
	GuiProver \
	GuiTactic \
	GuiProof \
	GuiComposer \
	GuiGoal \
	GuiSource \
	GuiPanel \
	GuiNavigator
55
#endif
56

François Bobot's avatar
François Bobot committed
57 58
PLUGIN_REQUIRES:= why3

59 60 61 62 63 64
PLUGIN_ENABLE:=@ENABLE_WP@
PLUGIN_NAME:=Wp
PLUGIN_CMO:= \
	rformat wprop \
	wp_parameters wp_error \
	dyncall ctypes clabels \
65
	Why3Provers \
66
	Context Warning AssignsCompleteness MemoryContext wpContext \
67
	LogicUsage RefUsage \
68 69
	Layout Region \
	RegionAnnot RegionAccess RegionDump RegionAnalysis \
70
	cil2cfg normAtLabels wpPropId wpStrategy mcfg \
71
	Lang Repr Matrix Passive Splitter \
72
	LogicBuiltins Definitions \
73
	Cmath Cint Cfloat Vset Vlist Cstring Cvalues \
74 75 76 77 78 79 80
	Letify Cleaning \
	Sigs Mstate Conditions \
	Filtering \
	Plang Pcfg Pcond \
	CodeSemantics \
	LogicCompiler \
	LogicSemantics LogicAssigns  \
81
	Sigma MemLoader \
82
	MemEmpty MemZeroAlias MemVar \
83
	MemMemory MemTyped MemRegion \
84
	wpReached wpRTE wpAnnot wpTarget \
85 86 87
	CfgCompiler StmtSemantics \
	VCS script proof wpo wpReport \
	Footprint Tactical Strategy \
Loïc Correnson's avatar
Loïc Correnson committed
88
	TacSplit TacChoice TacRange TacInduction \
89 90 91
	TacArray TacCompound TacUnfold \
	TacHavoc TacInstance TacLemma \
	TacFilter TacCut WpTac TacNormalForm \
92
	TacRewrite TacBitwised TacBitrange TacBittest TacShift \
93 94
	TacCongruence TacOverflow Auto \
	ProofSession ProofScript ProofEngine \
95
	ProverTask ProverErgo ProverCoq \
96
	filter_axioms Cache ProverWhy3 \
97 98 99 100 101 102 103 104 105 106 107 108
	driver prover ProverSearch ProverScript \
	Generator Factory \
	calculus cfgDump cfgWP \
	register VC

PLUGIN_CMI:=

PLUGIN_GENERATED:= \
   $(PLUGIN_DIR)/script.ml \
   $(PLUGIN_DIR)/rformat.ml \
   $(PLUGIN_DIR)/driver.ml \
   $(PLUGIN_DIR)/Wp.mli
109

110 111 112 113 114 115 116 117 118 119 120 121 122 123
PLUGIN_DEPENDENCIES:= rtegen qed
PLUGIN_UNDOC+=
PLUGIN_INTRO:=$(PLUGIN_DIR)/intro_wp.txt
PLUGIN_DISTRIBUTED:=$(PLUGIN_ENABLE)
PLUGIN_DISTRIB_EXTERNAL:= \
	Changelog \
	Makefile.in \
        MakeAPI \
	configure.ac \
	configure \
	$(addprefix share/, $(ALL_CEA_RESOURCES) \
	                    $(ALL_UNMODIFIED_WHY3_RESOURCES) \
	                    $(ALL_MODIFIED_WHY3_RESOURCES))

124
CEA_WP_GENEREATED= script.ml rformat.ml driver.ml
François Bobot's avatar
François Bobot committed
125

126 127 128 129 130 131 132
# --------------------------------------------------------------------------
# --- Tests                                                              ---
# --------------------------------------------------------------------------

PLUGIN_TESTS_DIRS:= \
  wp wp_plugin wp_acsl wp_bts \
  wp_store wp_hoare wp_typed wp_usage \
133 134
  wp_gallery wp_manual wp_tip \
  wp_region
135 136

ifeq ($(FRAMAC_INTERNAL),yes)
137
Wp_DEFAULT_TESTS: create_share_link
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
endif

# --------------------------------------------------------------------------
# --- Dynamic Plugin                                                     ---
# --------------------------------------------------------------------------

include $(FRAMAC_SHARE)/Makefile.dynamic

# Regenerating the Makefile on need

ifeq ("$(FRAMAC_INTERNAL)","yes")
CONFIG_STATUS_DIR=$(FRAMAC_SRC)
else
CONFIG_STATUS_DIR=.
endif

154 155 156 157 158 159 160
WP_CONFIGURE_MAKEFILE= \
	$(Wp_DIR)/Makefile.in \
	$(Wp_DIR)/share/Makefile.coqwp \
	$(Wp_DIR)/share/Makefile.resources \
	$(CONFIG_STATUS_DIR)/config.status

$(Wp_DIR)/Makefile: $(WP_CONFIGURE_MAKEFILE)
161 162
	@cd $(CONFIG_STATUS_DIR) && ./config.status --file $@

Loïc Correnson's avatar
Loïc Correnson committed
163 164 165 166
# --------------------------------------------------------------------------
# --- Qualif Tests                                                       ---
# --------------------------------------------------------------------------

Loïc Correnson's avatar
Loïc Correnson committed
167
.PHONY: wp-qualif wp-qualif-update wp-qualif-upgrade wp-qualif-push wp-qualif-status
Loïc Correnson's avatar
Loïc Correnson committed
168

169
WP_QUALIF_CACHE?=$(abspath $(Wp_DIR)/../wp-cache)
170
WP_QUALIF_ENTRIES=git -C $(WP_QUALIF_CACHE) ls-files --others --exclude-standard | wc -l
Loïc Correnson's avatar
Loïc Correnson committed
171

172 173 174 175
WP_CHECKOUT_CACHE=\
	echo "[CACHE] repo: $(WP_QUALIF_CACHE)" && \
	git -C $(WP_QUALIF_CACHE) checkout master

Loïc Correnson's avatar
Loïc Correnson committed
176
wp-qualif: ./bin/toplevel.opt ./bin/ptests.opt $(WP_QUALIF_CACHE)
177
	$(WP_CHECKOUT_CACHE)
Loïc Correnson's avatar
Loïc Correnson committed
178 179 180 181
	FRAMAC_WP_CACHE=replay \
	FRAMAC_WP_CACHEDIR=$(WP_QUALIF_CACHE) \
	  ./bin/ptests.opt src/plugins/wp/tests -config qualif -error-code

182 183 184
WP_PULL_CACHE=\
	echo "[CACHE] pull cache" && \
	$(WP_CHECKOUT_CACHE) && \
Loïc Correnson's avatar
Loïc Correnson committed
185
	git -C $(WP_QUALIF_CACHE) pull --rebase --prune
186 187 188

wp-qualif-update: ./bin/toplevel.opt ./bin/ptests.opt $(WP_QUALIF_CACHE)
	$(WP_PULL_CACHE)
Loïc Correnson's avatar
Loïc Correnson committed
189
	@echo "[TESTS] updating wp-qualif"
Loïc Correnson's avatar
Loïc Correnson committed
190
	FRAMAC_WP_CACHE=update \
Loïc Correnson's avatar
Loïc Correnson committed
191
	FRAMAC_WP_CACHEDIR=$(WP_QUALIF_CACHE) \
192
	  ./bin/ptests.opt src/plugins/wp/tests -config qualif
Loïc Correnson's avatar
Loïc Correnson committed
193 194
	@echo "[CACHE] cache status"
	git -C $(WP_QUALIF_CACHE) status -s -b -u no
195
	@echo "New entries: `$(WP_QUALIF_ENTRIES)`"
Loïc Correnson's avatar
Loïc Correnson committed
196 197

wp-qualif-upgrade: ./bin/toplevel.opt ./bin/ptests.opt
198
	$(WP_PULL_CACHE)
Loïc Correnson's avatar
Loïc Correnson committed
199
	@echo "[TESTS] upgrading wp-qualif (cache & scripts)"
Loïc Correnson's avatar
Loïc Correnson committed
200 201
	FRAMAC_WP_CACHE=update \
	FRAMAC_WP_SCRIPT=update \
Loïc Correnson's avatar
Loïc Correnson committed
202
	FRAMAC_WP_CACHEDIR=$(WP_QUALIF_CACHE) \
203
	  ./bin/ptests.opt src/plugins/wp/tests -config qualif
Loïc Correnson's avatar
Loïc Correnson committed
204 205
	@echo "[CACHE] cache status"
	git -C $(WP_QUALIF_CACHE) status -s -b -u no
206
	@echo "New entries: `$(WP_QUALIF_ENTRIES)`"
Loïc Correnson's avatar
Loïc Correnson committed
207 208

wp-qualif-push:
Loïc Correnson's avatar
Loïc Correnson committed
209
	@echo "[CACHE] pushing updates"
210
	$(WP_CHECKOUT_CACHE)
Loïc Correnson's avatar
Loïc Correnson committed
211 212 213 214 215
	git -C $(WP_QUALIF_CACHE) add -A
	git -C $(WP_QUALIF_CACHE) commit -m "[wp] cache updates"
	git -C $(WP_QUALIF_CACHE) push -f

wp-qualif-status:
216
	@echo "[CACHE] status"
217
	$(WP_CHECKOUT_CACHE)
Loïc Correnson's avatar
Loïc Correnson committed
218
	git -C $(WP_QUALIF_CACHE) status -s -b -u no
219
	@echo "New entries: `$(WP_QUALIF_ENTRIES)`"
Loïc Correnson's avatar
Loïc Correnson committed
220 221

$(WP_QUALIF_CACHE):
222 223
	@echo "[CACHE] cloning wp global at $(WP_QUALIF_CACHE)..."
	@echo "Use env. variable WP_QUALIF_CACHE to change this location."
Loïc Correnson's avatar
Loïc Correnson committed
224
	@git clone "git@git.frama-c.com:frama-c/wp-cache.git" $(WP_QUALIF_CACHE)
Loïc Correnson's avatar
Loïc Correnson committed
225

226 227 228 229 230 231 232 233 234 235 236
# --------------------------------------------------------------------------
# --- WP API                                                             ---
# --------------------------------------------------------------------------

WP_API_BASE= \
	wp_parameters.mli \
	ctypes.mli clabels.mli \
	MemoryContext.mli \
	LogicUsage.mli RefUsage.mli \
	normAtLabels.mli \
	wpPropId.mli mcfg.ml \
237
	Context.mli Warning.mli AssignsCompleteness.mli wpContext.mli \
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282
	Lang.mli Repr.mli Passive.mli Splitter.mli \
	LogicBuiltins.mli Definitions.mli \
	Cint.mli Cfloat.mli Vset.mli Cstring.mli \
	Sigs.ml Mstate.mli Conditions.mli Filtering.mli \
	Plang.mli Pcfg.mli Pcond.mli \
	CodeSemantics.mli \
	LogicCompiler.mli LogicSemantics.mli \
	Sigma.mli MemVar.mli MemTyped.mli \
	CfgCompiler.mli StmtSemantics.mli \
	Factory.mli driver.mli VCS.mli Tactical.mli Strategy.mli Auto.mli \
	VC.mli wpo.mli ProverTask.mli prover.mli

define WP_capitalize
$(shell printf "%s%s" \
    $$($(ECHO) $(1) | cut -c 1 | tr '[:lower:]' '[:upper:]')
    $$($(ECHO) $(1) | cut -c 2-))
endef

define WP_export
$(ECHO) "module $(call WP_capitalize, $(basename $(notdir $(1)))) : sig" >> $(2);
$(ECHO) '# 1 "$(1)"' >> $(2);
$(CAT) $(1) >> $(2);
$(ECHO) "end" >> $(2);
endef

WP_MLI=$(addprefix $(Wp_DIR)/, $(WP_API_BASE))

$(Wp_DIR)/Wp.mli: $(Wp_DIR)/Makefile $(WP_MLI)
	$(PRINT_MAKING) $@
	$(RM) $@ $@.tmp
	$(ECHO) "(* This file is generated. Do not edit. *)" > $@.tmp
	$(ECHO) "(** {b WP Public API} *)" > $@.tmp
	$(foreach file,$(WP_MLI),$(call WP_export,$(file),$@.tmp))
	$(CHMOD_RO) $@.tmp
	$(MV) $@.tmp $@

.PHONY: wp-doc-api

wp-doc-api:
	$(ECHO) "Generating WP documentation"
	@mkdir -p $(Wp_DIR)/doc/html
	$(RM) -fr $(Wp_DIR)/doc/html/*
	$(CP) $(Wp_DIR)/doc/ocamldoc.css $(Wp_DIR)/doc/html/style.css
	$(OCAMLDOC) \
		-package zarith \
Loïc Correnson's avatar
Loïc Correnson committed
283
		-package why3 \
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300
		-I lib/fc -I lib/plugins -I $(Wp_DIR) -stars \
		-html -d $(Wp_DIR)/doc/html -charset utf-8 \
		-t "Frama-C/WP API Documentation" \
		-intro $(Wp_DIR)/doc/wp-api.odoc \
		-colorize-code -short-functors $(Wp_DIR)/Wp.mli
	$(ECHO) "Generating $(Wp_DIR)/doc/html/index.html"

clean::
	$(RM) $(Wp_DIR)/Wp.mli
	$(RM) -fr $(Wp_DIR)/doc/html

# --------------------------------------------------------------------------
# --- Installation Resources
# --------------------------------------------------------------------------

## All relative to share/

301
ALL_COQ_SOURCES= $(addprefix coqwp/, $(COQ_LIBS_CEA) $(COQ_LIBS_INRIA))
302 303
ALL_COQ_BINARIES= $(addsuffix o, $(ALL_COQ_SOURCES))
ALL_ERGO_SOURCES= $(addprefix ergo/, $(ERGO_LIBS_CEA) $(ERGO_LIBS_INRIA))
François Bobot's avatar
François Bobot committed
304
ALL_WHY3_SOURCES= $(addprefix why3/frama_c_wp/, $(WHY3_LIBS_CEA))
305 306 307 308 309

ALL_RESOURCES= \
	wp.driver \
	$(ALL_COQ_SOURCES) \
	$(ALL_ERGO_SOURCES) \
310
	$(ALL_WHY3_SOURCES)
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329

INSTALL_OPT?=
INSTALL_SHARE=@$(Wp_DIR)/share/instwp $(INSTALL_OPT)

byte:: $(Wp_DIR)/share/instwp
opt:: $(Wp_DIR)/share/instwp
clean::
	rm -f $(Wp_DIR)/share/instwp
	rm -f $(Wp_DIR)/share/install.cm*

$(Wp_DIR)/share/instwp: $(Wp_DIR)/share/install.ml
	$(OCAMLC) $(WARNINGS) -o $@ unix.cma $^

# --------------------------------------------------------------------------
# --- Pre-Compiled Coq Libraries                                         ---
# --------------------------------------------------------------------------

WP_COQC_ENABLED=@COQC@

330
ifeq ($(WP_COQC_ENABLED),yes)
331

332
include $(Wp_DIR)/share/Makefile.coqwp
333

334 335 336
byte:: coqwpcompile
opt:: coqwpcompile
clean:: wp-coq-clean
337

338
endif #($(WP_COQC_ENABLED),yes)
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

# --------------------------------------------------------------------------
# --- Installation                                                       ---
# --------------------------------------------------------------------------

install:: clean-install
	$(PRINT_INSTALL) WP shared files
	$(MKDIR) $(FRAMAC_DATADIR)/wp
	$(INSTALL_SHARE) -p \
		-i $(Wp_DIR)/share \
		-d $(FRAMAC_DATADIR)/wp \
		$(ALL_RESOURCES) -f -b $(ALL_COQ_BINARIES)

uninstall::
	$(PRINT_RM) WP shared files
	$(RM) -r $(FRAMAC_DATADIR)/wp

# --------------------------------------------------------------------------
# --- WP Release Stuff (CEA-LIST Only)
# --------------------------------------------------------------------------
sinclude MakeDistrib
# --------------------------------------------------------------------------

$(Wp_DIR)/.depend: $(Wp_DIR)/driver.mll
$(Wp_DIR)/driver.mll: $(Wp_DIR)/Makefile