Makefile.common 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028
  1. # -*- mode: makefile -*-
  2. # The first line sets the emacs major mode to Makefile
  3. # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
  4. # SPDX-License-Identifier: MIT-0
  5. CBMC_STARTER_KIT_VERSION = CBMC starter kit 2.11
  6. ################################################################
  7. # The CBMC Starter Kit depends on the files Makefile.common and
  8. # run-cbmc-proofs.py. They are installed by the setup script
  9. # cbmc-starter-kit-setup and updated to the latest version by the
  10. # update script cbmc-starter-kit-update. For more information about
  11. # the starter kit and these files and these scripts, see
  12. # https://model-checking.github.io/cbmc-starter-kit
  13. #
  14. # Makefile.common implements what we consider to be some best
  15. # practices for using cbmc for software verification.
  16. #
  17. # Section I gives default values for a large number of Makefile
  18. # variables that control
  19. # * how your code is built (include paths, etc),
  20. # * what program transformations are applied to your code (loop
  21. # unwinding, etc), and
  22. # * what properties cbmc checks for in your code (memory safety, etc).
  23. #
  24. # These variables are defined below with definitions of the form
  25. # VARIABLE ?= DEFAULT_VALUE
  26. # meaning VARIABLE is set to DEFAULT_VALUE if VARIABLE has not already
  27. # been given a value.
  28. #
  29. # For your project, you can override these default values with
  30. # project-specific definitions in Makefile-project-defines.
  31. #
  32. # For any individual proof, you can override these default values and
  33. # project-specific values with proof-specific definitions in the
  34. # Makefile for your proof.
  35. #
  36. # The definitions in the proof Makefile override definitions in the
  37. # project Makefile-project-defines which override definitions in this
  38. # Makefile.common.
  39. #
  40. # Section II uses the values defined in Section I to build your code, run
  41. # your proof, and build a report of your results. You should not need
  42. # to modify or override anything in Section II, but you may want to
  43. # read it to understand how the values defined in Section I control
  44. # things.
  45. #
  46. # To use Makefile.common, set variables as described above as needed,
  47. # and then for each proof,
  48. #
  49. # * Create a subdirectory <DIR>.
  50. # * Write a proof harness (a function) with the name <HARNESS_ENTRY>
  51. # in a file with the name <DIR>/<HARNESS_FILE>.c
  52. # * Write a makefile with the name <DIR>/Makefile that looks
  53. # something like
  54. #
  55. # HARNESS_FILE=<HARNESS_FILE>
  56. # HARNESS_ENTRY=<HARNESS_ENTRY>
  57. # PROOF_UID=<PROOF_UID>
  58. #
  59. # PROJECT_SOURCES += $(SRCDIR)/libraries/api_1.c
  60. # PROJECT_SOURCES += $(SRCDIR)/libraries/api_2.c
  61. #
  62. # PROOF_SOURCES += $(PROOFDIR)/harness.c
  63. # PROOF_SOURCES += $(SRCDIR)/cbmc/proofs/stub_a.c
  64. # PROOF_SOURCES += $(SRCDIR)/cbmc/proofs/stub_b.c
  65. #
  66. # UNWINDSET += foo.0:3
  67. # UNWINDSET += bar.1:6
  68. #
  69. # REMOVE_FUNCTION_BODY += api_stub_a
  70. # REMOVE_FUNCTION_BODY += api_stub_b
  71. #
  72. # DEFINES = -DDEBUG=0
  73. #
  74. # include ../Makefile.common
  75. #
  76. # * Change directory to <DIR> and run make
  77. #
  78. # The proof setup script cbmc-starter-kit-setup-proof from the CBMC
  79. # Starter Kit will do most of this for, creating a directory and
  80. # writing a basic Makefile and proof harness into it that you can edit
  81. # as described above.
  82. #
  83. # Warning: If you get results that are hard to explain, consider
  84. # running "make clean" or "make veryclean" before "make" if you get
  85. # results that are hard to explain. Dependency handling in this
  86. # Makefile.common may not be perfect.
  87. SHELL=/bin/bash
  88. default: report
  89. ################################################################
  90. ################################################################
  91. ## Section I: This section gives common variable definitions.
  92. ##
  93. ## Override these definitions in Makefile-project-defines or
  94. ## your proof Makefile.
  95. ##
  96. ## Remember that Makefile.common and Makefile-project-defines are
  97. ## included into the proof Makefile in your proof directory, so all
  98. ## relative pathnames defined there should be relative to your proof
  99. ## directory.
  100. ################################################################
  101. # Define the layout of the source tree and the proof subtree
  102. #
  103. # Generally speaking,
  104. #
  105. # SRCDIR = the root of the repository
  106. # CBMC_ROOT = /srcdir/cbmc
  107. # PROOF_ROOT = /srcdir/cbmc/proofs
  108. # PROOF_SOURCE = /srcdir/cbmc/sources
  109. # PROOF_INCLUDE = /srcdir/cbmc/include
  110. # PROOF_STUB = /srcdir/cbmc/stubs
  111. # PROOFDIR = the directory containing the Makefile for your proof
  112. #
  113. # The path /srcdir/cbmc used in the example above is determined by the
  114. # setup script cbmc-starter-kit-setup. Projects usually create a cbmc
  115. # directory somewhere in the source tree, and run the setup script in
  116. # that directory. The value of CBMC_ROOT becomes the absolute path to
  117. # that directory.
  118. #
  119. # The location of that cbmc directory in the source tree affects the
  120. # definition of SRCDIR, which is defined in terms of the relative path
  121. # from a proof directory to the repository root. The definition is
  122. # usually determined by the setup script cbmc-starter-kit-setup and
  123. # written to Makefile-template-defines, but you can override it for a
  124. # project in Makefile-project-defines and for a specific proof in the
  125. # Makefile for the proof.
  126. # Absolute path to the directory containing this Makefile.common
  127. # See https://ftp.gnu.org/old-gnu/Manuals/make-3.80/html_node/make_17.html
  128. #
  129. # Note: We compute the absolute paths to the makefiles in MAKEFILE_LIST
  130. # before we filter the list of makefiles for %/Makefile.common.
  131. # Otherwise an invocation of the form "make -f Makefile.common" will set
  132. # MAKEFILE_LIST to "Makefile.common" which will fail to match the
  133. # pattern %/Makefile.common.
  134. #
  135. MAKEFILE_PATHS = $(foreach makefile,$(MAKEFILE_LIST),$(abspath $(makefile)))
  136. PROOF_ROOT = $(dir $(filter %/Makefile.common,$(MAKEFILE_PATHS)))
  137. CBMC_ROOT = $(shell dirname $(PROOF_ROOT))
  138. PROOF_SOURCE = $(CBMC_ROOT)/sources
  139. PROOF_INCLUDE = $(CBMC_ROOT)/include
  140. PROOF_STUB = $(CBMC_ROOT)/stubs
  141. # Project-specific definitions to override default definitions below
  142. # * Makefile-project-defines will never be overwritten
  143. # * Makefile-template-defines may be overwritten when the starter
  144. # kit is updated
  145. sinclude $(PROOF_ROOT)/Makefile-project-defines
  146. sinclude $(PROOF_ROOT)/Makefile-template-defines
  147. # SRCDIR is the path to the root of the source tree
  148. # This is a default definition that is frequently overridden in
  149. # another Makefile, see the discussion of SRCDIR above.
  150. SRCDIR ?= $(abspath ../..)
  151. # PROOFDIR is the path to the directory containing the proof harness
  152. PROOFDIR ?= $(abspath .)
  153. ################################################################
  154. # Define how to run CBMC
  155. # Do property checking with the external SAT solver given by
  156. # EXTERNAL_SAT_SOLVER. Do coverage checking with the default solver,
  157. # since coverage checking requires the use of an incremental solver.
  158. # The EXTERNAL_SAT_SOLVER variable is typically set (if it is at all)
  159. # as an environment variable or as a makefile variable in
  160. # Makefile-project-defines.
  161. #
  162. # For a particular proof, if the default solver is faster, do property
  163. # checking with the default solver by including this definition in the
  164. # proof Makefile:
  165. # USE_EXTERNAL_SAT_SOLVER =
  166. #
  167. ifneq ($(strip $(EXTERNAL_SAT_SOLVER)),)
  168. USE_EXTERNAL_SAT_SOLVER ?= --external-sat-solver $(EXTERNAL_SAT_SOLVER)
  169. endif
  170. CHECKFLAGS += $(USE_EXTERNAL_SAT_SOLVER)
  171. # Job pools
  172. # For version of Litani that are new enough (where `litani print-capabilities`
  173. # prints "pools"), proofs for which `EXPENSIVE = true` is set can be added to a
  174. # "job pool" that restricts how many expensive proofs are run at a time. All
  175. # other proofs will be built in parallel as usual.
  176. #
  177. # In more detail: all compilation, instrumentation, and report jobs are run with
  178. # full parallelism as usual, even for expensive proofs. The CBMC jobs for
  179. # non-expensive proofs are also run in parallel. The only difference is that the
  180. # CBMC safety checks and coverage checks for expensive proofs are run with a
  181. # restricted parallelism level. At any one time, only N of these jobs are run at
  182. # once, amongst all the proofs.
  183. #
  184. # To configure N, Litani needs to be initialized with a pool called "expensive".
  185. # For example, to only run two CBMC safety/coverage jobs at a time from amongst
  186. # all the proofs, you would initialize litani like
  187. # litani init --pools expensive:2
  188. # The run-cbmc-proofs.py script takes care of this initialization through the
  189. # --expensive-jobs-parallelism flag.
  190. #
  191. # To enable this feature, set
  192. # the ENABLE_POOLS variable when running Make, like
  193. # `make ENABLE_POOLS=true report`
  194. # The run-cbmc-proofs.py script takes care of this through the
  195. # --restrict-expensive-jobs flag.
  196. ifeq ($(strip $(ENABLE_POOLS)),)
  197. POOL =
  198. INIT_POOLS =
  199. else ifeq ($(strip $(EXPENSIVE)),)
  200. POOL =
  201. INIT_POOLS =
  202. else
  203. POOL = --pool expensive
  204. INIT_POOLS = --pools expensive:1
  205. endif
  206. # Similar to the pool feature above. If Litani is new enough, enable
  207. # profiling CBMC's memory use.
  208. ifeq ($(strip $(ENABLE_MEMORY_PROFILING)),)
  209. MEMORY_PROFILING =
  210. else
  211. MEMORY_PROFILING = --profile-memory
  212. endif
  213. # Property checking flags
  214. #
  215. # Each variable below controls a specific property checking flag
  216. # within CBMC. If desired, a property flag can be disabled within
  217. # a particular proof by nulling the corresponding variable when CBMC's default
  218. # is not to perform such checks, or setting to --no-<CHECK>-check when CBMC's
  219. # default is to perform such checks. For instance, the following lines:
  220. #
  221. # CBMC_FLAG_POINTER_CHECK = --no-pointer-check
  222. # CBMC_FLAG_UNSIGNED_OVERFLOW_CHECK =
  223. #
  224. # would disable pointer checks and unsigned overflow checks with CBMC flag
  225. # within:
  226. # * an entire project when added to Makefile-project-defines
  227. # * a specific proof when added to the harness Makefile
  228. CBMC_FLAG_MALLOC_MAY_FAIL ?= # set to --no-malloc-may-fail to disable
  229. CBMC_FLAG_BOUNDS_CHECK ?= # set to --no-bounds-check to disable
  230. CBMC_FLAG_CONVERSION_CHECK ?= --conversion-check
  231. CBMC_FLAG_DIV_BY_ZERO_CHECK ?= # set to --no-div-by-zero-check to disable
  232. CBMC_FLAG_FLOAT_OVERFLOW_CHECK ?= --float-overflow-check
  233. CBMC_FLAG_NAN_CHECK ?= --nan-check
  234. CBMC_FLAG_POINTER_CHECK ?= #set to --no-pointer-check to disable
  235. CBMC_FLAG_POINTER_OVERFLOW_CHECK ?= --pointer-overflow-check
  236. CBMC_FLAG_POINTER_PRIMITIVE_CHECK ?= # set to --no-pointer-primitive-check to disable
  237. CBMC_FLAG_SIGNED_OVERFLOW_CHECK ?= # set to --no-signed-overflow-check to disable
  238. CBMC_FLAG_UNDEFINED_SHIFT_CHECK ?= # set to --no-undefined-shift-check to disable
  239. CBMC_FLAG_UNSIGNED_OVERFLOW_CHECK ?= --unsigned-overflow-check
  240. CBMC_FLAG_UNWINDING_ASSERTIONS ?= # set to --no-unwinding-assertions to disable
  241. CBMC_DEFAULT_UNWIND ?= --unwind 1
  242. CBMC_FLAG_FLUSH ?= --flush
  243. # CBMC flags used for property checking and coverage checking
  244. CBMCFLAGS += $(CBMC_FLAG_FLUSH)
  245. # CBMC 6.0.0 enables all standard checks by default, which can make coverage analysis
  246. # very slow. See https://github.com/diffblue/cbmc/issues/8389
  247. # For now, we disable these checks when generating coverage info.
  248. COVERFLAGS ?= --no-standard-checks --malloc-may-fail --malloc-fail-null
  249. # CBMC flags used for property checking
  250. CHECKFLAGS += $(CBMC_FLAG_BOUNDS_CHECK)
  251. CHECKFLAGS += $(CBMC_FLAG_CONVERSION_CHECK)
  252. CHECKFLAGS += $(CBMC_FLAG_DIV_BY_ZERO_CHECK)
  253. CHECKFLAGS += $(CBMC_FLAG_FLOAT_OVERFLOW_CHECK)
  254. CHECKFLAGS += $(CBMC_FLAG_NAN_CHECK)
  255. CHECKFLAGS += $(CBMC_FLAG_POINTER_CHECK)
  256. CHECKFLAGS += $(CBMC_FLAG_POINTER_OVERFLOW_CHECK)
  257. CHECKFLAGS += $(CBMC_FLAG_POINTER_PRIMITIVE_CHECK)
  258. CHECKFLAGS += $(CBMC_FLAG_SIGNED_OVERFLOW_CHECK)
  259. CHECKFLAGS += $(CBMC_FLAG_UNDEFINED_SHIFT_CHECK)
  260. CHECKFLAGS += $(CBMC_FLAG_UNSIGNED_OVERFLOW_CHECK)
  261. # Additional CBMC flag to CBMC control verbosity.
  262. #
  263. # Meaningful values are
  264. # 0 none
  265. # 1 only errors
  266. # 2 + warnings
  267. # 4 + results
  268. # 6 + status/phase information
  269. # 8 + statistical information
  270. # 9 + progress information
  271. # 10 + debug info
  272. #
  273. # Uncomment the following line or set in Makefile-project-defines
  274. # CBMC_VERBOSITY ?= --verbosity 4
  275. # Additional CBMC flag to control how CBMC treats static variables.
  276. #
  277. # NONDET_STATIC is a list of flags of the form --nondet-static
  278. # and --nondet-static-exclude VAR. The --nondet-static flag causes
  279. # CBMC to initialize static variables with unconstrained value
  280. # (ignoring initializers and default zero-initialization). The
  281. # --nondet-static-exclude VAR excludes VAR for the variables
  282. # initialized with unconstrained values.
  283. NONDET_STATIC ?=
  284. # Flags to pass to goto-cc for compilation and linking
  285. COMPILE_FLAGS ?= -Wall -Werror
  286. LINK_FLAGS ?= -Wall -Werror
  287. EXPORT_FILE_LOCAL_SYMBOLS ?= --export-file-local-symbols
  288. # During instrumentation, it adds models of C library functions
  289. ADD_LIBRARY_FLAG := --add-library
  290. # Preprocessor include paths -I...
  291. INCLUDES ?=
  292. # Preprocessor definitions -D...
  293. DEFINES ?=
  294. # CBMC object model
  295. #
  296. # CBMC_OBJECT_BITS is the number of bits in a pointer CBMC uses for
  297. # the id of the object to which a pointer is pointing. CBMC uses 8
  298. # bits for the object id by default. The remaining bits in the pointer
  299. # are used for offset into the object. This limits the size of the
  300. # objects that CBMC can model. This Makefile defines this bound on
  301. # object size to be CBMC_MAX_OBJECT_SIZE. You are likely to get
  302. # unexpected results if you try to malloc an object larger than this
  303. # bound.
  304. CBMC_OBJECT_BITS ?= 8
  305. # CBMC loop unwinding (Normally set in the proof Makefile)
  306. #
  307. # UNWINDSET is a list of pairs of the form foo.1:4 meaning that
  308. # CBMC should unwind loop 1 in function foo no more than 4 times.
  309. # For historical reasons, the number 4 is one more than the number
  310. # of times CBMC actually unwinds the loop.
  311. UNWINDSET ?=
  312. # CBMC early loop unwinding (Normally set in the proof Makefile)
  313. #
  314. # Most users can ignore this variable.
  315. #
  316. # This variable exists to support the use of loop and function
  317. # contracts, two features under development for CBMC. Checking the
  318. # assigns clause for function contracts and loop invariants currently
  319. # assumes loop-free bodies for loops and functions with contracts
  320. # (possibly after replacing nested loops with their own loop
  321. # contracts). To satisfy this requirement, it may be necessary to
  322. # unwind some loops before the function contract and loop invariant
  323. # transformations are applied to the goto program. This variable
  324. # CPROVER_LIBRARY_UNWINDSET is identical to UNWINDSET, and we assume that the
  325. # loops mentioned in CPROVER_LIBRARY_UNWINDSET and UNWINDSET are disjoint.
  326. CPROVER_LIBRARY_UNWINDSET ?=
  327. # CBMC function removal (Normally set set in the proof Makefile)
  328. #
  329. # REMOVE_FUNCTION_BODY is a list of function names. CBMC will "undefine"
  330. # the function, and CBMC will treat the function as having no side effects
  331. # and returning an unconstrained value of the appropriate return type.
  332. # The list should include the names of functions being stubbed out.
  333. REMOVE_FUNCTION_BODY ?=
  334. # CBMC function pointer restriction (Normally set in the proof Makefile)
  335. #
  336. # RESTRICT_FUNCTION_POINTER is a list of function pointer restriction
  337. # instructions of the form:
  338. #
  339. # <fun_id>.function_pointer_call.<N>/<fun_id>[,<fun_id>]*
  340. #
  341. # The function pointer call number <N> in the specified function gets
  342. # rewritten to a case switch over a finite list of functions.
  343. # If some possible target functions are omitted from the list a counter
  344. # example trace will be found by CBMC, i.e. the transformation is sound.
  345. # If the target functions are file-local symbols, then mangled names must
  346. # be used.
  347. RESTRICT_FUNCTION_POINTER ?=
  348. # The project source files (Normally set set in the proof Makefile)
  349. #
  350. # PROJECT_SOURCES is the list of project source files to compile,
  351. # including the source file defining the function under test.
  352. PROJECT_SOURCES ?=
  353. # The proof source files (Normally set in the proof Makefile)
  354. #
  355. # PROOF_SOURCES is the list of proof source files to compile, including
  356. # the proof harness, and including any function stubs being used.
  357. PROOF_SOURCES ?=
  358. # The number of seconds that CBMC should be allowed to run for before
  359. # being forcefully terminated. Currently, this is set to be less than
  360. # the time limit for a CodeBuild job, which is eight hours. If a proof
  361. # run takes longer than the time limit of the CI environment, the
  362. # environment will halt the proof run without updating the Litani
  363. # report, making the proof run appear to "hang".
  364. CBMC_TIMEOUT ?= 21600
  365. # CBMC string abstraction
  366. #
  367. # Replace all uses of char * by a struct that carries that string,
  368. # and also the underlying allocation and the C string length.
  369. STRING_ABSTRACTION ?=
  370. ifdef STRING_ABSTRACTION
  371. ifneq ($(strip $(STRING_ABSTRACTION)),)
  372. CBMC_STRING_ABSTRACTION := --string-abstraction
  373. endif
  374. endif
  375. # Optional configuration library flags
  376. OPT_CONFIG_LIBRARY ?=
  377. CBMC_OPT_CONFIG_LIBRARY := $(CBMC_FLAG_MALLOC_MAY_FAIL) $(CBMC_STRING_ABSTRACTION)
  378. # Proof writers could add function contracts in their source code.
  379. # These contracts are ignored by default, but may be enabled in two distinct
  380. # contexts using the following two variables:
  381. # 1. To check whether one or more function contracts are sound with respect to
  382. # the function implementation, CHECK_FUNCTION_CONTRACTS should be a list of
  383. # function names. Use CHECK_FUNCTION_CONTRACTS_REC to check contracts on
  384. # recursive functions.
  385. # 2. To replace calls to certain functions with their correspondent function
  386. # contracts, USE_FUNCTION_CONTRACTS should be a list of function names.
  387. # One must check separately whether a function contract is sound before
  388. # replacing it in calling contexts.
  389. CHECK_FUNCTION_CONTRACTS ?=
  390. CBMC_CHECK_FUNCTION_CONTRACTS := $(patsubst %,--enforce-contract %, $(CHECK_FUNCTION_CONTRACTS))
  391. CHECK_FUNCTION_CONTRACTS_REC ?=
  392. CBMC_CHECK_FUNCTION_CONTRACTS_REC := $(patsubst %,--enforce-contract-rec %, $(CHECK_FUNCTION_CONTRACTS_REC))
  393. USE_FUNCTION_CONTRACTS ?=
  394. CBMC_USE_FUNCTION_CONTRACTS := $(patsubst %,--replace-call-with-contract %, $(USE_FUNCTION_CONTRACTS))
  395. CODE_CONTRACTS := $(CHECK_FUNCTION_CONTRACTS)$(USE_FUNCTION_CONTRACTS)$(APPLY_LOOP_CONTRACTS)
  396. # Proof writers may also apply function contracts using the Dynamic Frame
  397. # Condition Checking (DFCC) mode. For more information on DFCC,
  398. # please see https://diffblue.github.io/cbmc/contracts-dev-spec-dfcc.html.
  399. USE_DYNAMIC_FRAMES ?=
  400. ifdef USE_DYNAMIC_FRAMES
  401. ifneq ($(strip $(USE_DYNAMIC_FRAMES)),)
  402. CBMC_USE_DYNAMIC_FRAMES := $(CBMC_OPT_CONFIG_LIBRARY) --dfcc $(HARNESS_ENTRY) $(CBMC_CHECK_FUNCTION_CONTRACTS_REC)
  403. endif
  404. endif
  405. # Similarly, proof writers could also add loop contracts in their source code
  406. # to obtain unbounded correctness proofs. Unlike function contracts, loop
  407. # contracts are not reusable and thus are checked and used simultaneously.
  408. # These contracts are also ignored by default, but may be enabled by setting
  409. # the APPLY_LOOP_CONTRACTS variable.
  410. APPLY_LOOP_CONTRACTS ?=
  411. ifdef APPLY_LOOP_CONTRACTS
  412. ifneq ($(strip $(APPLY_LOOP_CONTRACTS)),)
  413. CBMC_APPLY_LOOP_CONTRACTS := --apply-loop-contracts
  414. endif
  415. endif
  416. # The default unwind should only be used in DFCC mode without loop contracts.
  417. # When loop contracts are applied, we only unwind specified loops.
  418. # If any loops remain after loop contracts have been applied, CBMC might try
  419. # to unwind the program indefinitely, because we do not pass default unwind
  420. # (i.e., --unwind 1) to CBMC when in DFCC mode.
  421. # We must not use a default unwind command in DFCC mode, because contract instrumentation
  422. # introduces loops encoding write set inclusion checks that must be dynamically unwound during
  423. # symex.
  424. ifneq ($(strip $(USE_DYNAMIC_FRAMES)),)
  425. ifneq ($(strip $(APPLY_LOOP_CONTRACTS)),)
  426. UNWIND_0500_FLAGS=$(CBMC_UNWINDSET) $(CBMC_CPROVER_LIBRARY_UNWINDSET) $(CBMC_FLAG_UNWINDING_ASSERTIONS)
  427. UNWIND_0500_DESC="$(PROOF_UID): unwinding specified subset of loops"
  428. else
  429. UNWIND_0500_FLAGS=$(CBMC_UNWINDSET) $(CBMC_CPROVER_LIBRARY_UNWINDSET) $(CBMC_DEFAULT_UNWIND) $(CBMC_FLAG_UNWINDING_ASSERTIONS)
  430. UNWIND_0500_DESC="$(PROOF_UID): unwinding all loops"
  431. endif
  432. endif
  433. # Silence makefile output (eg, long litani commands) unless VERBOSE is set.
  434. ifndef VERBOSE
  435. MAKEFLAGS := $(MAKEFLAGS) -s
  436. endif
  437. ################################################################
  438. ################################################################
  439. ## Section II: This section defines the process of running a proof
  440. ##
  441. ## There should be no reason to edit anything below this line.
  442. ################################################################
  443. # Paths
  444. CBMC ?= cbmc
  445. GOTO_ANALYZER ?= goto-analyzer
  446. GOTO_CC ?= goto-cc
  447. GOTO_INSTRUMENT ?= goto-instrument
  448. CRANGLER ?= crangler
  449. VIEWER ?= cbmc-viewer
  450. VIEWER2 ?= cbmc-viewer
  451. CMAKE ?= cmake
  452. GOTODIR ?= $(PROOFDIR)/gotos
  453. LOGDIR ?= $(PROOFDIR)/logs
  454. PROJECT ?= project
  455. PROOF ?= proof
  456. HARNESS_GOTO ?= $(GOTODIR)/$(HARNESS_FILE)
  457. PROJECT_GOTO ?= $(GOTODIR)/$(PROJECT)
  458. PROOF_GOTO ?= $(GOTODIR)/$(PROOF)
  459. ################################################################
  460. # Useful macros for values that are hard to reference
  461. SPACE :=$() $()
  462. COMMA :=,
  463. ################################################################
  464. # Set C compiler defines
  465. CBMCFLAGS += --object-bits $(CBMC_OBJECT_BITS)
  466. DEFINES += -DCBMC=1
  467. DEFINES += -DCBMC_OBJECT_BITS=$(CBMC_OBJECT_BITS)
  468. DEFINES += -DCBMC_MAX_OBJECT_SIZE="(SIZE_MAX>>(CBMC_OBJECT_BITS+1))"
  469. # CI currently assumes cbmc invocation has at most one --unwindset
  470. # UNWINDSET is designed for user code (i.e., proof and project code)
  471. ifdef UNWINDSET
  472. ifneq ($(strip $(UNWINDSET)),)
  473. CBMC_UNWINDSET := --unwindset $(subst $(SPACE),$(COMMA),$(strip $(UNWINDSET)))
  474. endif
  475. endif
  476. # CPROVER_LIBRARY_UNWINDSET is designed for CPROVER library functions
  477. ifdef CPROVER_LIBRARY_UNWINDSET
  478. ifneq ($(strip $(CPROVER_LIBRARY_UNWINDSET)),)
  479. CBMC_CPROVER_LIBRARY_UNWINDSET := --unwindset $(subst $(SPACE),$(COMMA),$(strip $(CPROVER_LIBRARY_UNWINDSET)))
  480. endif
  481. endif
  482. CBMC_REMOVE_FUNCTION_BODY := $(patsubst %,--remove-function-body %, $(REMOVE_FUNCTION_BODY))
  483. ifdef RESTRICT_FUNCTION_POINTER
  484. ifneq ($(strip $(RESTRICT_FUNCTION_POINTER)),)
  485. CBMC_RESTRICT_FUNCTION_POINTER := $(patsubst %,--restrict-function-pointer %, $(RESTRICT_FUNCTION_POINTER))
  486. endif
  487. endif
  488. ################################################################
  489. # Targets for rewriting source files with crangler
  490. # Construct crangler configuration files
  491. #
  492. # REWRITTEN_SOURCES is a list of crangler output files source.i.
  493. # This target assumes that for each source.i
  494. # * source.i_SOURCE is the path to a source file,
  495. # * source.i_FUNCTIONS is a list of functions (may be empty)
  496. # * source.i_OBJECTS is a list of variables (may be empty)
  497. # This target constructs the crangler configuration file source.i.json
  498. # of the form
  499. # {
  500. # "sources": [ "/proj/code.c" ],
  501. # "includes": [ "/proj/include" ],
  502. # "defines": [ "VAR=1" ],
  503. # "functions": [ {"function_name": ["remove static"]} ],
  504. # "objects": [ {"variable_name": ["remove static"]} ],
  505. # "output": "source.i"
  506. # }
  507. # to remove the static attribute from function_name and variable_name
  508. # in the source file source.c and write the result to source.i.
  509. #
  510. # This target assumes that filenames include no spaces and that
  511. # the INCLUDES and DEFINES variables include no spaces after -I
  512. # and -D. For example, use "-DVAR=1" and not "-D VAR=1".
  513. #
  514. # Define *_SOURCE, *_FUNCTIONS, and *_OBJECTS in the proof Makefile.
  515. # The string source.i is usually an absolute path $(PROOFDIR)/code.i
  516. # to a file in the proof directory that contains the proof Makefile.
  517. # The proof Makefile usually includes the definitions
  518. # $(PROOFDIR)/code.i_SOURCE = /proj/code.c
  519. # $(PROOFDIR)/code.i_FUNCTIONS = function_name
  520. # $(PROOFDIR)/code.i_OBJECTS = variable_name
  521. # Because these definitions refer to PROOFDIR that is defined in this
  522. # Makefile.common, these definitions must appear after the inclusion
  523. # of Makefile.common in the proof Makefile.
  524. #
  525. $(foreach rs,$(REWRITTEN_SOURCES),$(eval $(rs).json: $($(rs)_SOURCE)))
  526. $(foreach rs,$(REWRITTEN_SOURCES),$(rs).json):
  527. echo '{'\
  528. '"sources": ['\
  529. '"$($(@:.json=)_SOURCE)"'\
  530. '],'\
  531. '"includes": ['\
  532. '$(subst $(SPACE),$(COMMA),$(patsubst -I%,"%",$(strip $(INCLUDES))))' \
  533. '],'\
  534. '"defines": ['\
  535. '$(subst $(SPACE),$(COMMA),$(patsubst -D%,"%",$(subst ",\",$(strip $(DEFINES)))))' \
  536. '],'\
  537. '"functions": ['\
  538. '{'\
  539. '$(subst ~, ,$(subst $(SPACE),$(COMMA),$(patsubst %,"%":["remove~static"],$($(@:.json=)_FUNCTIONS))))' \
  540. '}'\
  541. '],'\
  542. '"objects": ['\
  543. '{'\
  544. '$(subst ~, ,$(subst $(SPACE),$(COMMA),$(patsubst %,"%":["remove~static"],$($(@:.json=)_OBJECTS))))' \
  545. '}'\
  546. '],'\
  547. '"output": "$(@:.json=)"'\
  548. '}' > $@
  549. # Rewrite source files with crangler
  550. #
  551. $(foreach rs,$(REWRITTEN_SOURCES),$(eval $(rs): $(rs).json))
  552. $(REWRITTEN_SOURCES):
  553. $(LITANI) add-job \
  554. --command \
  555. '$(CRANGLER) $@.json' \
  556. --inputs $($@_SOURCE) \
  557. --outputs $@ \
  558. --stdout-file $(LOGDIR)/crangler-$(subst /,_,$(subst .,_,$@))-log.txt \
  559. --interleave-stdout-stderr \
  560. --pipeline-name "$(PROOF_UID)" \
  561. --ci-stage build \
  562. --description "$(PROOF_UID): removing static"
  563. ################################################################
  564. # Build targets that make the relevant .goto files
  565. # Compile project sources
  566. $(PROJECT_GOTO)0100.goto: $(PROJECT_SOURCES) $(REWRITTEN_SOURCES)
  567. $(LITANI) add-job \
  568. --command \
  569. '$(GOTO_CC) $(CBMC_VERBOSITY) $(COMPILE_FLAGS) $(EXPORT_FILE_LOCAL_SYMBOLS) $(INCLUDES) $(DEFINES) $^ -o $@' \
  570. --inputs $^ \
  571. --outputs $@ \
  572. --stdout-file $(LOGDIR)/project_sources-log.txt \
  573. --pipeline-name "$(PROOF_UID)" \
  574. --ci-stage build \
  575. --description "$(PROOF_UID): building project binary"
  576. # Compile proof sources
  577. $(PROOF_GOTO)0100.goto: $(PROOF_SOURCES)
  578. $(LITANI) add-job \
  579. --command \
  580. '$(GOTO_CC) $(CBMC_VERBOSITY) $(COMPILE_FLAGS) $(EXPORT_FILE_LOCAL_SYMBOLS) $(INCLUDES) $(DEFINES) $^ -o $@' \
  581. --inputs $^ \
  582. --outputs $@ \
  583. --stdout-file $(LOGDIR)/proof_sources-log.txt \
  584. --pipeline-name "$(PROOF_UID)" \
  585. --ci-stage build \
  586. --description "$(PROOF_UID): building proof binary"
  587. # Remove function bodies from project sources
  588. $(PROJECT_GOTO)0200.goto: $(PROJECT_GOTO)0100.goto
  589. $(LITANI) add-job \
  590. --command \
  591. '$(GOTO_INSTRUMENT) $(CBMC_VERBOSITY) $(CBMC_REMOVE_FUNCTION_BODY) $^ $@' \
  592. --inputs $^ \
  593. --outputs $@ \
  594. --stdout-file $(LOGDIR)/remove_function_body-log.txt \
  595. --pipeline-name "$(PROOF_UID)" \
  596. --ci-stage build \
  597. --description "$(PROOF_UID): removing function bodies from project sources"
  598. # Link project and proof sources into the proof harness
  599. $(HARNESS_GOTO)0100.goto: $(PROOF_GOTO)0100.goto $(PROJECT_GOTO)0200.goto
  600. $(LITANI) add-job \
  601. --command '$(GOTO_CC) $(CBMC_VERBOSITY) --function $(HARNESS_ENTRY) $^ $(LINK_FLAGS) -o $@' \
  602. --inputs $^ \
  603. --outputs $@ \
  604. --stdout-file $(LOGDIR)/link_proof_project-log.txt \
  605. --pipeline-name "$(PROOF_UID)" \
  606. --ci-stage build \
  607. --description "$(PROOF_UID): linking project to proof"
  608. # Restrict function pointers
  609. $(HARNESS_GOTO)0200.goto: $(HARNESS_GOTO)0100.goto
  610. $(LITANI) add-job \
  611. --command \
  612. '$(GOTO_INSTRUMENT) $(CBMC_VERBOSITY) $(CBMC_RESTRICT_FUNCTION_POINTER) --remove-function-pointers $^ $@' \
  613. --inputs $^ \
  614. --outputs $@ \
  615. --stdout-file $(LOGDIR)/restrict_function_pointer-log.txt \
  616. --pipeline-name "$(PROOF_UID)" \
  617. --ci-stage build \
  618. --description "$(PROOF_UID): restricting function pointers in project sources"
  619. # Fill static variable with unconstrained values
  620. $(HARNESS_GOTO)0300.goto: $(HARNESS_GOTO)0200.goto
  621. ifneq ($(strip $(CODE_CONTRACTS)),)
  622. $(LITANI) add-job \
  623. --command 'cp $^ $@' \
  624. --inputs $^ \
  625. --outputs $@ \
  626. --stdout-file $(LOGDIR)/nondet_static-log.txt \
  627. --pipeline-name "$(PROOF_UID)" \
  628. --ci-stage build \
  629. --description "$(PROOF_UID): not setting static variables to nondet (will do during contract instrumentation)"
  630. else
  631. $(LITANI) add-job \
  632. --command \
  633. '$(GOTO_INSTRUMENT) $(CBMC_VERBOSITY) $(NONDET_STATIC) $^ $@' \
  634. --inputs $^ \
  635. --outputs $@ \
  636. --stdout-file $(LOGDIR)/nondet_static-log.txt \
  637. --pipeline-name "$(PROOF_UID)" \
  638. --ci-stage build \
  639. --description "$(PROOF_UID): setting static variables to nondet"
  640. endif
  641. # Link CPROVER library if DFCC mode is on
  642. $(HARNESS_GOTO)0400.goto: $(HARNESS_GOTO)0300.goto
  643. ifneq ($(strip $(USE_DYNAMIC_FRAMES)),)
  644. $(LITANI) add-job \
  645. --command \
  646. '$(GOTO_INSTRUMENT) $(CBMC_VERBOSITY) $(ADD_LIBRARY_FLAG) $(CBMC_OPT_CONFIG_LIBRARY) $^ $@' \
  647. --inputs $^ \
  648. --outputs $@ \
  649. --stdout-file $(LOGDIR)/linking-library-models-log.txt \
  650. --pipeline-name "$(PROOF_UID)" \
  651. --ci-stage build \
  652. --description "$(PROOF_UID): linking CPROVER library"
  653. else
  654. $(LITANI) add-job \
  655. --command 'cp $^ $@' \
  656. --inputs $^ \
  657. --outputs $@ \
  658. --stdout-file $(LOGDIR)/linking-library-models-log.txt \
  659. --pipeline-name "$(PROOF_UID)" \
  660. --ci-stage build \
  661. --description "$(PROOF_UID): not linking CPROVER library"
  662. endif
  663. # Early unwind all loops on DFCC mode; otherwise, only unwind loops in proof and project code
  664. $(HARNESS_GOTO)0500.goto: $(HARNESS_GOTO)0400.goto
  665. ifneq ($(strip $(USE_DYNAMIC_FRAMES)),)
  666. $(LITANI) add-job \
  667. --command \
  668. '$(GOTO_INSTRUMENT) $(CBMC_VERBOSITY) $(UNWIND_0500_FLAGS) $^ $@' \
  669. --inputs $^ \
  670. --outputs $@ \
  671. --stdout-file $(LOGDIR)/unwind_loops-log.txt \
  672. --pipeline-name "$(PROOF_UID)" \
  673. --ci-stage build \
  674. --description $(UNWIND_0500_DESC)
  675. else ifneq ($(strip $(CODE_CONTRACTS)),)
  676. $(LITANI) add-job \
  677. --command \
  678. '$(GOTO_INSTRUMENT) $(CBMC_VERBOSITY) $(CBMC_UNWINDSET) $(CBMC_FLAG_UNWINDING_ASSERTIONS) $^ $@' \
  679. --inputs $^ \
  680. --outputs $@ \
  681. --stdout-file $(LOGDIR)/unwind_loops-log.txt \
  682. --pipeline-name "$(PROOF_UID)" \
  683. --ci-stage build \
  684. --description "$(PROOF_UID): unwinding loops in proof and project code"
  685. else
  686. $(LITANI) add-job \
  687. --command 'cp $^ $@' \
  688. --inputs $^ \
  689. --outputs $@ \
  690. --stdout-file $(LOGDIR)/unwind_loops-log.txt \
  691. --pipeline-name "$(PROOF_UID)" \
  692. --ci-stage build \
  693. --description "$(PROOF_UID): not unwinding loops"
  694. endif
  695. # Replace function contracts, check function contracts, instrument for loop contracts
  696. $(HARNESS_GOTO)0600.goto: $(HARNESS_GOTO)0500.goto
  697. $(LITANI) add-job \
  698. --command \
  699. '$(GOTO_INSTRUMENT) $(CBMC_USE_DYNAMIC_FRAMES) $(NONDET_STATIC) $(CBMC_VERBOSITY) $(CBMC_CHECK_FUNCTION_CONTRACTS) $(CBMC_USE_FUNCTION_CONTRACTS) $(CBMC_APPLY_LOOP_CONTRACTS) $^ $@' \
  700. --inputs $^ \
  701. --outputs $@ \
  702. --stdout-file $(LOGDIR)/check_function_contracts-log.txt \
  703. --pipeline-name "$(PROOF_UID)" \
  704. --ci-stage build \
  705. --description "$(PROOF_UID): checking function contracts"
  706. # Omit initialization of unused global variables (reduces problem size)
  707. $(HARNESS_GOTO)0700.goto: $(HARNESS_GOTO)0600.goto
  708. $(LITANI) add-job \
  709. --command \
  710. '$(GOTO_INSTRUMENT) $(CBMC_VERBOSITY) --slice-global-inits $^ $@' \
  711. --inputs $^ \
  712. --outputs $@ \
  713. --stdout-file $(LOGDIR)/slice_global_inits-log.txt \
  714. --pipeline-name "$(PROOF_UID)" \
  715. --ci-stage build \
  716. --description "$(PROOF_UID): slicing global initializations"
  717. # Omit unused functions (sharpens coverage calculations)
  718. $(HARNESS_GOTO)0800.goto: $(HARNESS_GOTO)0700.goto
  719. $(LITANI) add-job \
  720. --command \
  721. '$(GOTO_INSTRUMENT) $(CBMC_VERBOSITY) --drop-unused-functions $^ $@' \
  722. --inputs $^ \
  723. --outputs $@ \
  724. --stdout-file $(LOGDIR)/drop_unused_functions-log.txt \
  725. --pipeline-name "$(PROOF_UID)" \
  726. --ci-stage build \
  727. --description "$(PROOF_UID): dropping unused functions"
  728. # Final name for proof harness
  729. $(HARNESS_GOTO).goto: $(HARNESS_GOTO)0800.goto
  730. $(LITANI) add-job \
  731. --command 'cp $< $@' \
  732. --inputs $^ \
  733. --outputs $@ \
  734. --pipeline-name "$(PROOF_UID)" \
  735. --ci-stage build \
  736. --description "$(PROOF_UID): copying final goto-binary"
  737. ################################################################
  738. # Targets to run the analysis commands
  739. ifdef CBMCFLAGS
  740. ifeq ($(strip $(CODE_CONTRACTS)),)
  741. CBMCFLAGS += $(CBMC_UNWINDSET) $(CBMC_CPROVER_LIBRARY_UNWINDSET) $(CBMC_DEFAULT_UNWIND) $(CBMC_OPT_CONFIG_LIBRARY)
  742. else ifeq ($(strip $(USE_DYNAMIC_FRAMES)),)
  743. CBMCFLAGS += $(CBMC_CPROVER_LIBRARY_UNWINDSET) $(CBMC_OPT_CONFIG_LIBRARY)
  744. endif
  745. endif
  746. $(LOGDIR)/result.xml: $(HARNESS_GOTO).goto
  747. $(LITANI) add-job \
  748. $(POOL) \
  749. --command \
  750. '$(CBMC) $(CBMC_VERBOSITY) $(CBMCFLAGS) $(CBMC_FLAG_UNWINDING_ASSERTIONS) $(CHECKFLAGS) --trace --xml-ui $<' \
  751. --inputs $^ \
  752. --outputs $@ \
  753. --ci-stage test \
  754. --stdout-file $@ \
  755. $(MEMORY_PROFILING) \
  756. --ignore-returns 10 \
  757. --timeout $(CBMC_TIMEOUT) \
  758. --pipeline-name "$(PROOF_UID)" \
  759. --tags "stats-group:safety checks" \
  760. --stderr-file $(LOGDIR)/result-err-log.txt \
  761. --description "$(PROOF_UID): checking safety properties"
  762. $(LOGDIR)/result.txt: $(HARNESS_GOTO).goto
  763. $(LITANI) add-job \
  764. $(POOL) \
  765. --command \
  766. '$(CBMC) $(CBMC_VERBOSITY) $(CBMCFLAGS) $(CBMC_FLAG_UNWINDING_ASSERTIONS) $(CHECKFLAGS) --trace $<' \
  767. --inputs $^ \
  768. --outputs $@ \
  769. --ci-stage test \
  770. --stdout-file $@ \
  771. $(MEMORY_PROFILING) \
  772. --ignore-returns 10 \
  773. --timeout $(CBMC_TIMEOUT) \
  774. --pipeline-name "$(PROOF_UID)" \
  775. --tags "stats-group:safety checks" \
  776. --stderr-file $(LOGDIR)/result-err-log.txt \
  777. --description "$(PROOF_UID): checking safety properties"
  778. $(LOGDIR)/property.xml: $(HARNESS_GOTO).goto
  779. $(LITANI) add-job \
  780. --command \
  781. '$(CBMC) $(CBMC_VERBOSITY) $(CBMCFLAGS) $(CBMC_FLAG_UNWINDING_ASSERTIONS) $(CHECKFLAGS) --show-properties --xml-ui $<' \
  782. --inputs $^ \
  783. --outputs $@ \
  784. --ci-stage test \
  785. --stdout-file $@ \
  786. --ignore-returns 10 \
  787. --pipeline-name "$(PROOF_UID)" \
  788. --stderr-file $(LOGDIR)/property-err-log.txt \
  789. --description "$(PROOF_UID): printing safety properties"
  790. $(LOGDIR)/coverage.xml: $(HARNESS_GOTO).goto
  791. $(LITANI) add-job \
  792. $(POOL) \
  793. --command \
  794. '$(CBMC) $(CBMC_VERBOSITY) $(CBMCFLAGS) $(COVERFLAGS) --cover location --xml-ui $<' \
  795. --inputs $^ \
  796. --outputs $@ \
  797. --ci-stage test \
  798. --stdout-file $@ \
  799. $(MEMORY_PROFILING) \
  800. --ignore-returns 10 \
  801. --timeout $(CBMC_TIMEOUT) \
  802. --pipeline-name "$(PROOF_UID)" \
  803. --tags "stats-group:coverage computation" \
  804. --stderr-file $(LOGDIR)/coverage-err-log.txt \
  805. --description "$(PROOF_UID): calculating coverage"
  806. COVERAGE ?= $(LOGDIR)/coverage.xml
  807. VIEWER_COVERAGE_FLAG ?= --coverage $(COVERAGE)
  808. $(PROOFDIR)/report: $(LOGDIR)/result.xml $(LOGDIR)/property.xml $(COVERAGE)
  809. $(LITANI) add-job \
  810. --command " $(VIEWER) \
  811. --result $(LOGDIR)/result.xml \
  812. $(VIEWER_COVERAGE_FLAG) \
  813. --property $(LOGDIR)/property.xml \
  814. --srcdir $(SRCDIR) \
  815. --goto $(HARNESS_GOTO).goto \
  816. --reportdir $(PROOFDIR)/report \
  817. --config $(PROOFDIR)/cbmc-viewer.json" \
  818. --inputs $^ \
  819. --outputs $(PROOFDIR)/report \
  820. --pipeline-name "$(PROOF_UID)" \
  821. --stdout-file $(LOGDIR)/viewer-log.txt \
  822. --ci-stage report \
  823. --description "$(PROOF_UID): generating report"
  824. litani-path:
  825. @echo $(LITANI)
  826. # ##############################################################
  827. # Phony Rules
  828. #
  829. # These rules provide a convenient way to run a single proof up to a
  830. # certain stage. Users can browse into a proof directory and run
  831. # "make -Bj 3 report" to generate a report for just that proof, or
  832. # "make goto" to build the goto binary. Under the hood, this runs litani
  833. # for just that proof.
  834. _goto: $(HARNESS_GOTO).goto
  835. goto:
  836. @ echo Running 'litani init'
  837. $(LITANI) init $(INIT_POOLS) --project $(PROJECT_NAME)
  838. @ echo Running 'litani add-job'
  839. $(MAKE) -B _goto
  840. @ echo Running 'litani build'
  841. $(LITANI) run-build
  842. _result: $(LOGDIR)/result.txt
  843. result:
  844. @ echo Running 'litani init'
  845. $(LITANI) init $(INIT_POOLS) --project $(PROJECT_NAME)
  846. @ echo Running 'litani add-job'
  847. $(MAKE) -B _result
  848. @ echo Running 'litani build'
  849. $(LITANI) run-build
  850. _property: $(LOGDIR)/property.xml
  851. property:
  852. @ echo Running 'litani init'
  853. $(LITANI) init $(INIT_POOLS) --project $(PROJECT_NAME)
  854. @ echo Running 'litani add-job'
  855. $(MAKE) -B _property
  856. @ echo Running 'litani build'
  857. $(LITANI) run-build
  858. _coverage: $(LOGDIR)/coverage.xml
  859. coverage:
  860. @ echo Running 'litani init'
  861. $(LITANI) init $(INIT_POOLS) --project $(PROJECT_NAME)
  862. @ echo Running 'litani add-job'
  863. $(MAKE) -B _coverage
  864. @ echo Running 'litani build'
  865. $(LITANI) run-build
  866. _report: $(PROOFDIR)/report
  867. report:
  868. @ echo Running 'litani init'
  869. $(LITANI) init $(INIT_POOLS) --project $(PROJECT_NAME)
  870. @ echo Running 'litani add-job'
  871. $(MAKE) -B _report
  872. @ echo Running 'litani build'
  873. $(LITANI) run-build
  874. _report_no_coverage:
  875. $(MAKE) COVERAGE="" VIEWER_COVERAGE_FLAG="" _report
  876. report-no-coverage:
  877. $(MAKE) COVERAGE="" VIEWER_COVERAGE_FLAG=" " report
  878. ################################################################
  879. # Targets to clean up after ourselves
  880. clean:
  881. -$(RM) $(DEPENDENT_GOTOS)
  882. -$(RM) TAGS*
  883. -$(RM) *~ \#*
  884. -$(RM) $(REWRITTEN_SOURCES) $(foreach rs,$(REWRITTEN_SOURCES),$(rs).json)
  885. veryclean: clean
  886. -$(RM) -r report
  887. -$(RM) -r $(LOGDIR) $(GOTODIR)
  888. .PHONY: \
  889. _coverage \
  890. _goto \
  891. _property \
  892. _report \
  893. _report_no_coverage \
  894. clean \
  895. coverage \
  896. goto \
  897. litani-path \
  898. property \
  899. report \
  900. report-no-coverage \
  901. result \
  902. setup_dependencies \
  903. testdeps \
  904. veryclean \
  905. #
  906. ################################################################
  907. # Run "make echo-proof-uid" to print the proof ID of a proof. This can be
  908. # used by scripts to ensure that every proof has an ID, that there are
  909. # no duplicates, etc.
  910. .PHONY: echo-proof-uid
  911. echo-proof-uid:
  912. @echo $(PROOF_UID)
  913. .PHONY: echo-project-name
  914. echo-project-name:
  915. @echo $(PROJECT_NAME)
  916. ################################################################
  917. # Project-specific targets requiring values defined above
  918. sinclude $(PROOF_ROOT)/Makefile-project-targets
  919. # CI-specific targets to drive cbmc in CI
  920. sinclude $(PROOF_ROOT)/Makefile-project-testing
  921. ################################################################