Makefile 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739
  1. # Top-level Makefile for Agda 2
  2. # Authors: Ulf Norell, Nils Anders Danielsson, Francesco Mazzoli, Liang-Ting Chen
  3. # Profiling verbosity for std-lib-test
  4. PROFVERB=7
  5. # Various paths and commands
  6. TOP=.
  7. # mk/path.mk uses TOP, so include after the definition of TOP.
  8. include ./mk/paths.mk
  9. include ./mk/cabal.mk
  10. include ./mk/stack.mk
  11. # mk/prtty.mk pretty prints information, depending on whether it is run on Travis on not
  12. include ./mk/pretty.mk
  13. # Run in interactive and parallel mode by default
  14. # You can use the PARALLEL_TESTS variable to control the number of parallel
  15. # tests. The default is one per processor. Invoke make like this:
  16. # make PARALLEL_TESTS=123 test
  17. # Or set it in ./mk/config.mk, which is .gitignored
  18. ifeq ($(PARALLEL_TESTS),)
  19. PARALLEL_TESTS := $(shell getconf _NPROCESSORS_ONLN)
  20. endif
  21. AGDA_BIN_SUFFIX = -$(VERSION)
  22. AGDA_TESTS_OPTIONS ?=-i -j$(PARALLEL_TESTS)
  23. # A cabal/stack dictionary
  24. CABAL_OPT_NO_DOCS = --disable-documentation
  25. STACK_OPT_NO_DOCS = --no-haddock
  26. CABAL_OPT_TESTS = --enable-tests
  27. STACK_OPT_TESTS = --test --no-run-tests
  28. CABAL_OPT_FAST = --ghc-options=-O0
  29. STACK_OPT_FAST = --fast
  30. CABAL_FLAG_ICU = -fenable-cluster-counting
  31. STACK_FLAG_ICU = --flag Agda:enable-cluster-counting
  32. CABAL_FLAG_OPTIM_HEAVY ?= -foptimise-heavily
  33. STACK_FLAG_OPTIM_HEAVY ?= --flag Agda:optimise-heavily
  34. CABAL_INSTALL_HELPER = $(CABAL) $(CABAL_INSTALL_CMD) $(CABAL_OPT_NO_DOCS)
  35. STACK_INSTALL_HELPER = $(STACK) build Agda $(STACK_OPT_NO_DOCS)
  36. # If running on Travis, use --system-ghc.
  37. # Developers running `make` will usually want to use the GHC version they've
  38. # specified in their stack.yaml. Otherwise they can put that option in
  39. # themselves.
  40. # Note that GitHub workflows currently do not use the Makefile, but instead
  41. # invoke `stack` directly. (See: .github/workflows/stack.yml)
  42. ifneq ($(TRAVIS),)
  43. STACK_INSTALL_HELPER += --system-ghc
  44. endif
  45. # 2016-07-15. We use a different build directory in the quick
  46. # installation for avoiding recompilation (see Issue #2083 and
  47. # https://github.com/haskell/cabal/issues/1893).
  48. # quicker install: -O0, no tests
  49. QUICK_CABAL_INSTALL = $(CABAL_INSTALL_HELPER) $(CABAL_OPT_FAST) --builddir=$(QUICK_BUILD_DIR)
  50. QUICK_STACK_INSTALL = $(STACK_INSTALL_HELPER) $(STACK_OPT_FAST) --work-dir=$(QUICK_STACK_BUILD_DIR)
  51. # fast install: -O0, but tests
  52. FAST_CABAL_INSTALL = $(CABAL_INSTALL_HELPER) $(CABAL_OPT_TESTS) $(CABAL_OPT_FAST) --builddir=$(FAST_BUILD_DIR)
  53. FAST_STACK_INSTALL = $(STACK_INSTALL_HELPER) $(STACK_OPT_TESTS) $(STACK_OPT_FAST) --work-dir=$(FAST_STACK_BUILD_DIR)
  54. # ordinary install: optimizations and tests
  55. SLOW_CABAL_INSTALL_OPTS = $(CABAL_OPT_TESTS) $(CABAL_FLAG_OPTIM_HEAVY) --builddir=$(BUILD_DIR)
  56. SLOW_STACK_INSTALL_OPTS = $(STACK_OPT_TESTS) $(STACK_FLAG_OPTIM_HEAVY)
  57. CABAL_INSTALL = $(CABAL_INSTALL_HELPER) $(SLOW_CABAL_INSTALL_OPTS)
  58. STACK_INSTALL = $(STACK_INSTALL_HELPER) $(SLOW_STACK_INSTALL_OPTS)
  59. # Depending on your machine and ghc version you might want to tweak the amount of memory
  60. # given to ghc to compile Agda. To do this set GHC_RTS_OPTS in mk/config.mk (gitignored).
  61. ifeq ($(GHC_RTS_OPTS),)
  62. #
  63. ifeq ("$(shell $(GHC) --info | grep 'target word size' | cut -d\" -f4)","4")
  64. GHC_RTS_OPTS := -M2.3G
  65. else ifeq ($(GHC_VERSION),9.0)
  66. GHC_RTS_OPTS := -M6G
  67. else ifeq ($(GHC_VERSION),8.10)
  68. GHC_RTS_OPTS := -M6G
  69. else
  70. GHC_RTS_OPTS := -M4G
  71. endif
  72. #
  73. endif
  74. GHC_OPTS = "+RTS $(GHC_RTS_OPTS) -RTS"
  75. # The following options are used in several invocations of cabal
  76. # install/configure below. They are always the last options given to
  77. # the command.
  78. CABAL_INSTALL_OPTS =
  79. STACK_INSTALL_OPTS =
  80. # Only enable cluster-counting by default for non-Windows, due to agda/agda#5012
  81. # The msys* and mingw* strings derived from: https://stackoverflow.com/a/18434831/141513
  82. ifeq ($(filter msys% mingw%,$(shell echo "$${OSTYPE:-unknown}")),)
  83. CABAL_INSTALL_OPTS += $(CABAL_FLAG_ICU)
  84. STACK_INSTALL_OPTS += $(STACK_FLAG_ICU)
  85. endif
  86. CABAL_INSTALL_OPTS += --ghc-options=$(GHC_OPTS) $(CABAL_OPTS)
  87. STACK_INSTALL_OPTS += --ghc-options $(GHC_OPTS) $(STACK_OPTS)
  88. # Options for building Agda's dependencies.
  89. CABAL_INSTALL_DEP_OPTS = --only-dependencies $(CABAL_INSTALL_OPTS)
  90. STACK_INSTALL_DEP_OPTS = --only-dependencies $(STACK_INSTALL_OPTS)
  91. # Options for building the Agda exectutable.
  92. # -j1 so that cabal will print built progress to stdout.
  93. CABAL_INSTALL_BIN_OPTS = -j1 --disable-library-profiling \
  94. $(CABAL_INSTALL_OPTS)
  95. STACK_INSTALL_BIN_OPTS = --no-library-profiling \
  96. $(STACK_INSTALL_OPTS)
  97. CABAL_CONFIGURE_OPTS = $(SLOW_CABAL_INSTALL_OPTS) \
  98. --disable-library-profiling \
  99. $(CABAL_INSTALL_OPTS)
  100. ##############################################################################
  101. ## Installation (via stack if stack.yaml is present)
  102. .PHONY: default
  103. default: install-bin
  104. .PHONY: install ## Install Agda, test suites, and Emacs mode
  105. install: install-bin compile-emacs-mode setup-emacs-mode
  106. .PHONY: ensure-hash-is-correct
  107. ensure-hash-is-correct:
  108. touch src/full/Agda/VersionCommit.hs
  109. .PHONY: copy-bins-with-suffix-% ## Copy binaries to local bin directory with suffix
  110. copy-bins-with-suffix-%:
  111. ifdef HAS_STACK
  112. mkdir -p $(shell $(STACK) path --local-bin)
  113. cp $(shell $(STACK) --work-dir=$(STACK_BUILD_DIR) path --dist-dir)/build/agda/agda $(shell $(STACK) path --local-bin)/agda-$*
  114. cp $(shell $(STACK) --work-dir=$(STACK_BUILD_DIR) path --dist-dir)/build/agda-mode/agda-mode $(shell $(STACK) path --local-bin)/agda-mode-$*
  115. endif
  116. .PHONY: install-deps ## Install Agda dependencies.
  117. install-deps:
  118. ifdef HAS_STACK
  119. @echo "===================== Installing dependencies using Stack ================"
  120. time $(STACK_INSTALL) $(STACK_INSTALL_DEP_OPTS)
  121. else
  122. @echo "========================= Installing dependencies using Cabal ============"
  123. time $(CABAL_INSTALL) $(CABAL_INSTALL_DEP_OPTS)
  124. endif
  125. .PHONY: install-bin ## Install Agda and test suites
  126. install-bin: install-deps ensure-hash-is-correct
  127. ifdef HAS_STACK
  128. @echo "===================== Installing using Stack with test suites ============"
  129. time $(STACK_INSTALL) $(STACK_INSTALL_BIN_OPTS)
  130. mkdir -p $(BUILD_DIR)/build/
  131. cp -r $(shell $(STACK) path --dist-dir)/build $(BUILD_DIR)
  132. $(MAKE) copy-bins-with-suffix$(AGDA_BIN_SUFFIX)
  133. else
  134. # `cabal new-install --enable-tests` emits the error message (bug?):
  135. # cabal: --enable-tests was specified, but tests can't be enabled in a remote package
  136. @echo "===================== Installing using Cabal with test suites ============"
  137. time $(CABAL_INSTALL) $(CABAL_INSTALL_BIN_OPTS) --program-suffix=$(AGDA_BIN_SUFFIX)
  138. endif
  139. .PHONY: v1-install ## Developer install goal without -foptimize-aggressively nor dependencies.
  140. # Alternative to 'install-bin'
  141. v1-install: ensure-hash-is-correct
  142. ifdef HAS_STACK
  143. @echo "===================== Installing using Stack with test suites ============"
  144. time $(STACK_INSTALL_HELPER) $(STACK_INSTALL_BIN_OPTS) $(STACK_OPT_TESTS)
  145. mkdir -p $(BUILD_DIR)/build/
  146. cp -r $(shell $(STACK) path --dist-dir)/build $(BUILD_DIR)
  147. $(MAKE) copy-bins-with-suffix$(AGDA_BIN_SUFFIX)
  148. else
  149. @echo "===================== Installing using Cabal with test suites ============"
  150. time $(CABAL_INSTALL_HELPER) $(CABAL_INSTALL_BIN_OPTS) $(CABAL_OPT_TESTS) --builddir=$(BUILD_DIR) --program-suffix=$(AGDA_BIN_SUFFIX)
  151. endif
  152. .PHONY: fast-install-bin ## Install Agda compiled with -O0 with tests
  153. fast-install-bin: install-deps fast-install-bin-no-deps
  154. .PHONY: fast-install-bin-no-deps ##
  155. fast-install-bin-no-deps:
  156. ifdef HAS_STACK
  157. @echo "============= Installing using Stack with -O0 and test suites ============"
  158. time $(FAST_STACK_INSTALL) $(STACK_INSTALL_BIN_OPTS)
  159. mkdir -p $(FAST_BUILD_DIR)/build/
  160. cp -r $(shell $(STACK) path --work-dir=$(FAST_STACK_BUILD_DIR) --dist-dir)/build $(FAST_BUILD_DIR)
  161. $(MAKE) copy-bins-with-suffix-fast STACK_BUILD_DIR=$(FAST_STACK_BUILD_DIR)
  162. else
  163. # `cabal new-install --enable-tests` emits the error message (bug?):
  164. # cabal: --enable-tests was specified, but tests can't be enabled in a remote package
  165. @echo "============= Installing using Cabal with -O0 and test suites ============"
  166. time $(FAST_CABAL_INSTALL) $(CABAL_INSTALL_BIN_OPTS) --program-suffix=-fast
  167. endif
  168. .PHONY: quicker-install-bin ## Install Agda compiled with -O0 without tests
  169. # Disabling optimizations leads to *much* quicker build times.
  170. # The performance loss is acceptable for running small tests.
  171. quicker-install-bin: install-deps quicker-install-bin-no-deps
  172. .PHONY: quicker-install-bin-no-deps ##
  173. quicker-install-bin-no-deps:
  174. ifdef HAS_STACK
  175. @echo "===================== Installing using Stack with -O0 ===================="
  176. time $(QUICK_STACK_INSTALL) $(STACK_INSTALL_BIN_OPTS)
  177. $(MAKE) copy-bins-with-suffix-quicker STACK_BUILD_DIR=$(QUICK_STACK_BUILD_DIR)
  178. else
  179. @echo "===================== Installing using Cabal with -O0 ===================="
  180. time $(QUICK_CABAL_INSTALL) $(CABAL_INSTALL_BIN_OPTS) --program-suffix=-quicker
  181. endif
  182. .PHONY: v2-type-check ## Type check the Agda source only (-fno-code) with v2-cabal.
  183. # Takes max 40s; can be quicker than make quicker-install-bin (max 5min).
  184. #
  185. # Might "fail" with errors like
  186. #
  187. # ar: ./dist-2.6.2-no-code/build/Agda/Auto/Auto.o: No such file or directory
  188. # ...
  189. #
  190. # Thus, ignore exit code.
  191. # Also prefixing it with `time` has no effect since it formally fails.
  192. v2-type-check:
  193. @echo "=============== Type checking using v2 Cabal with -fno-code =============="
  194. -$(CABAL) v2-build --project-file=cabal.project.tc --builddir=dist-no-code \
  195. 2>&1 \
  196. | $(SED) -e '/.*dist.*build.*: No such file or directory/d' \
  197. -e '/.*Warning: the following files would be used as linker inputs, but linking is not being done:.*/d'
  198. # Andreas, 2022-01-30:
  199. # According to my experiments, `make type-check-no-deps` on an
  200. # unchanged project runs slightly faster than `make v2-type-check`.
  201. # Thus keeping the `v1` style as the default.
  202. .PHONY: type-check ## Type check the Agda source only (-fno-code) with v1-cabal.
  203. # Takes max 40s; can be quicker than make quicker-install-bin (max 5min).
  204. #
  205. # Might "fail" with errors like
  206. #
  207. # ar: ./dist-2.6.2-no-code/build/Agda/Auto/Auto.o: No such file or directory
  208. # ...
  209. #
  210. # Thus, ignore exit code.
  211. # Also prefixing it with `time` has no effect since it formally fails.
  212. type-check: install-deps type-check-no-deps
  213. .PHONY: type-check-no-deps ##
  214. type-check-no-deps :
  215. @echo "=============== Type checking using v1 Cabal with -fno-code =============="
  216. -$(CABAL) $(CABAL_BUILD_CMD) --builddir=$(BUILD_DIR)-no-code \
  217. --ghc-options=-fno-code \
  218. --ghc-options=-fwrite-interface \
  219. 2>&1 \
  220. | $(SED) -e '/.*dist.*build.*: No such file or directory/d' \
  221. -e '/.*Warning: the following files would be used as linker inputs, but linking is not being done:.*/d'
  222. ## Andreas, 2021-10-14: This does not work, agda-tests is not type-checked.
  223. ## Maybe because cabal fails with an error after type-checking the library component.
  224. # .PHONY: type-check-with-tests ## Type check only, including tests
  225. # type-check-with-tests :
  226. # @echo "================= Type checking using Cabal with -fno-code ==============="
  227. # $(CABAL) $(CABAL_CONFIGURE_CMD) $(CABAL_CONFIGURE_OPTS) --builddir=$(BUILD_DIR)-no-code
  228. # -time $(CABAL) $(CABAL_BUILD_CMD) agda-tests --builddir=$(BUILD_DIR)-no-code \
  229. # --ghc-options=-fno-code \
  230. # --ghc-options=-fwrite-interface \
  231. # 2>&1 \
  232. # | $(SED) -e '/.*dist.*build.*: No such file or directory/d' \
  233. # -e '/.*Warning: the following files would be used as linker inputs, but linking is not being done:.*/d'
  234. .PHONY : install-prof-bin ## Install Agda with profiling enabled
  235. # --program-suffix is not for the executable name in
  236. # $(BUILD_DIR)/build/, only for installing it into .cabal/bin
  237. install-prof-bin : install-deps ensure-hash-is-correct
  238. $(CABAL_INSTALL) -j1 --enable-library-profiling --enable-profiling \
  239. --program-suffix=-prof $(CABAL_INSTALL_OPTS)
  240. .PHONY : install-debug ## Install Agda with debug enabled
  241. # A separate build directory is used. The suffix "-debug" is used for the binaries.
  242. install-debug : install-deps ensure-hash-is-correct
  243. $(CABAL_INSTALL) --disable-library-profiling \
  244. -fdebug --program-suffix=-debug --builddir=$(DEBUG_BUILD_DIR) \
  245. $(CABAL_INSTALL_BIN_OPTS)
  246. .PHONY : debug-install-quick ## Install Agda -O0 with debug enabled
  247. debug-install-quick : install-deps
  248. $(QUICK_CABAL_INSTALL) --disable-library-profiling \
  249. -fdebug --program-suffix=-debug-quick --builddir=$(QUICK_DEBUG_BUILD_DIR) \
  250. $(CABAL_INSTALL_BIN_OPTS) --ghc-options=-O0
  251. ##############################################################################
  252. ## Agda mode for Emacs
  253. .PHONY : compile-emacs-mode ## Compile Agda's Emacs mode using Emacs.
  254. compile-emacs-mode: install-bin
  255. $(AGDA_MODE) compile
  256. .PHONY : setup-emacs-mode ## Configure Agda's Emacs mode.
  257. setup-emacs-mode : install-bin
  258. @echo
  259. @echo "If the agda-mode command is not found, make sure that the directory"
  260. @echo "in which it was installed is located on your shell's search path."
  261. @echo
  262. $(AGDA_MODE) setup
  263. ##############################################################################
  264. ## Clean
  265. clean_helper = if [ -d $(1) ]; then $(CABAL) $(CABAL_CLEAN_CMD) --builddir=$(1); fi;
  266. clean : ## Clean all local builds
  267. $(call clean_helper,$(BUILD_DIR))
  268. $(call clean_helper,$(QUICK_BUILD_DIR))
  269. $(STACK) clean --full
  270. $(STACK) clean --full --work-dir=$(QUICK_STACK_BUILD_DIR)
  271. ##############################################################################
  272. ## Haddock
  273. .PHONY : haddock ##
  274. haddock :
  275. $(CABAL) $(CABAL_CONFIGURE_CMD) $(CABAL_CONFIGURE_OPTS)
  276. $(CABAL) $(CABAL_HADDOCK_CMD) --builddir=$(BUILD_DIR)
  277. ##############################################################################
  278. ## The user manual
  279. .PHONY : user-manual-html ## Make the user manual (HTML).
  280. user-manual-html :
  281. @$(call decorate, "User manual (HTML)", $(MAKE) -C doc/user-manual html)
  282. .PHONY : user-manual-pdf ## Make the user manual (PDF).
  283. user-manual-pdf :
  284. @$(call decorate, "User manual (PDF)", $(MAKE) -C doc/user-manual latexpdf)
  285. cp doc/user-manual/_build/latex/Agda.pdf doc/user-manual.pdf
  286. .PHONY: user-manual-linkcheck ##
  287. user-manual-linkcheck :
  288. @$(call decorate, "User manual (linkcheck)", $(MAKE) -C doc/user-manual linkcheck)
  289. cp doc/user-manual/_build/latex/Agda.pdf doc/user-manual.pdf
  290. ##############################################################################
  291. ## Create tag files
  292. .PHONY : tags ##
  293. tags : have-bin-hs-tags
  294. $(MAKE) -C $(FULL_SRC_DIR) tags
  295. .PHONY : TAGS ##
  296. TAGS : have-bin-hs-tags
  297. @$(call decorate, "TAGS", \
  298. $(MAKE) -C $(FULL_SRC_DIR) TAGS)
  299. ##############################################################################
  300. ## Standard library
  301. .PHONY : std-lib ## Update the standard library.
  302. std-lib :
  303. git submodule update --init std-lib
  304. .PHONY : up-to-date-std-lib ##
  305. up-to-date-std-lib : std-lib
  306. @($(MAKE) -C std-lib setup)
  307. .PHONY : fast-forward-std-lib ##
  308. fast-forward-std-lib :
  309. git submodule update --init --remote std-lib
  310. @($(MAKE) -C std-lib setup)
  311. ##############################################################################
  312. ## Cubical library
  313. .PHONY : cubical ## Update the cubical library.
  314. cubical :
  315. git submodule update --init cubical
  316. .PHONY : up-to-date-cubical ##
  317. up-to-date-cubical : cubical
  318. .PHONY : fast-forward-cubical ##
  319. fast-forward-cubical :
  320. git submodule update --init --remote cubical
  321. ##############################################################################
  322. ## Continuous Integration
  323. .PHONY : workflows ## Build the workflow configuration in .github/workflows.
  324. workflows :
  325. make -C .github/workflows
  326. ##############################################################################
  327. ## Testing
  328. .PHONY : test ## Run all test suites.
  329. test : check-whitespace \
  330. check-encoding \
  331. common \
  332. succeed \
  333. fail \
  334. bugs \
  335. interaction \
  336. examples \
  337. std-lib-test \
  338. cubical-test \
  339. interactive \
  340. latex-html-test \
  341. api-test \
  342. internal-tests \
  343. benchmark-without-logs \
  344. compiler-test \
  345. std-lib-compiler-test \
  346. std-lib-succeed \
  347. std-lib-interaction \
  348. user-manual-test \
  349. size-solver-test
  350. .PHONY : test-using-std-lib ## Run all tests which use the standard library.
  351. test-using-std-lib : std-lib-test \
  352. benchmark-without-logs \
  353. std-lib-compiler-test \
  354. std-lib-succeed \
  355. std-lib-interaction
  356. .PHONY : quicktest ## Run successful and failing tests.
  357. quicktest : common succeed fail
  358. .PHONY : check-encoding ## Make sure that Parser.y is ASCII. [Issue #5465]
  359. check-encoding :
  360. @$(call decorate, "Check that Parser.y is ASCII", \
  361. iconv -f ASCII src/full/Agda/Syntax/Parser/Parser.y > /dev/null)
  362. # Hint: if the encoding check fails, use
  363. #
  364. # pcregrep --color='auto' -n "[\x80-\xFF]" src/full/Agda/Syntax/Parser/Parser.y
  365. #
  366. # to find non-ASCII characters.
  367. .PHONY : bugs ##
  368. bugs :
  369. @$(call decorate, "Suite of tests for bugs", \
  370. AGDA_BIN=$(AGDA_BIN) $(AGDA_TESTS_BIN) $(AGDA_TESTS_OPTIONS) --regex-include all/Bugs)
  371. .PHONY : internal-tests ##
  372. internal-tests :
  373. @$(call decorate, "Internal test suite", \
  374. AGDA_BIN=$(AGDA_BIN) $(AGDA_TESTS_BIN) $(AGDA_TESTS_OPTIONS) --regex-include all/Internal )
  375. .PHONY : common ##
  376. common :
  377. @$(call decorate, "Suite of successful tests: mini-library Common", \
  378. $(MAKE) -C test/Common )
  379. .PHONY : succeed ##
  380. succeed :
  381. @$(call decorate, "Suite of successful tests", \
  382. echo $(shell which $(AGDA_BIN)) > test/Succeed/exec-tc/executables && \
  383. AGDA_BIN=$(AGDA_BIN) $(AGDA_TESTS_BIN) $(AGDA_TESTS_OPTIONS) --regex-include all/Succeed ; \
  384. rm test/Succeed/exec-tc/executables )
  385. .PHONY : fail ##
  386. fail :
  387. @$(call decorate, "Suite of failing tests", \
  388. AGDA_BIN=$(AGDA_BIN) $(AGDA_TESTS_BIN) $(AGDA_TESTS_OPTIONS) --regex-include all/Fail)
  389. .PHONY : interaction ##
  390. interaction :
  391. @$(call decorate, "Suite of interaction tests", \
  392. $(MAKE) -C test/interaction)
  393. .PHONY : interactive ##
  394. interactive :
  395. @$(call decorate, "Suite of interactive tests", \
  396. AGDA_BIN=$(AGDA_BIN) $(AGDA_TESTS_BIN) $(AGDA_TESTS_OPTIONS) --regex-include all/Interactive)
  397. .PHONY : examples ##
  398. examples :
  399. @$(call decorate, "Suite of examples", \
  400. $(MAKE) -C examples)
  401. .PHONY : latex-html-test ## Tests the LaTeX and HTML backends.
  402. latex-html-test :
  403. @$(call decorate, "Suite of tests for the LaTeX and HTML backends", \
  404. AGDA_BIN=$(AGDA_BIN) $(AGDA_TESTS_BIN) $(AGDA_TESTS_OPTIONS) --regex-include all/LaTeXAndHTML)
  405. .PHONY : html-test ##
  406. html-test :
  407. @$(call decorate, "Suite of tests for the HTML backend", \
  408. AGDA_BIN=$(AGDA_BIN) $(AGDA_TESTS_BIN) $(AGDA_TESTS_OPTIONS) --regex-include all/LaTeXAndHTML/HTML)
  409. .PHONY : latex-test ##
  410. latex-test :
  411. @$(call decorate, "Suite of tests for the LaTeX backend", \
  412. AGDA_BIN=$(AGDA_BIN) $(AGDA_TESTS_BIN) $(AGDA_TESTS_OPTIONS) --regex-include all/LaTeXAndHTML/LaTeX)
  413. .PHONY : quicklatex-test ##
  414. quicklatex-test :
  415. @$(call decorate, "Suite of tests for the QuickLaTeX backend", \
  416. AGDA_BIN=$(AGDA_BIN) $(AGDA_TESTS_BIN) $(AGDA_TESTS_OPTIONS) --regex-include all/LaTeXAndHTML/QuickLaTeX)
  417. .PHONY : std-lib-test ##
  418. std-lib-test :
  419. @$(call decorate, "Standard library test", \
  420. (cd std-lib && cabal run GenerateEverything && \
  421. time $(AGDA_BIN) $(AGDA_OPTS) --ignore-interfaces --no-default-libraries -v profile:$(PROFVERB) \
  422. -i. -isrc README.agda \
  423. +RTS -s))
  424. .PHONY : cubical-test ##
  425. cubical-test :
  426. -rm -rf cubical/_build
  427. @$(call decorate, "Cubical library test", \
  428. time $(MAKE) -C cubical \
  429. AGDA_EXEC=$(AGDA_BIN) RTS_OPTIONS=$(AGDA_OPTS))
  430. .PHONY : continue-std-lib-test ##
  431. continue-std-lib-test :
  432. @(cd std-lib && \
  433. time $(AGDA_BIN) -v profile:$(PROFVERB) --no-default-libraries -i. -isrc README.agda +RTS -s)
  434. .PHONY : std-lib-succeed ##
  435. std-lib-succeed :
  436. @$(call decorate, "Successful tests using the standard library", \
  437. find test/LibSucceed -type f -name '*.agdai' -delete ; \
  438. AGDA_BIN=$(AGDA_BIN) $(AGDA_TESTS_BIN) $(AGDA_TESTS_OPTIONS) --regex-include all/LibSucceed)
  439. .PHONY : std-lib-interaction ##
  440. std-lib-interaction :
  441. @$(call decorate, "Interaction tests using the standard library", \
  442. $(MAKE) -C test/lib-interaction)
  443. .PHONY : compiler-test ##
  444. compiler-test :
  445. @$(call decorate, "Compiler tests", \
  446. AGDA_BIN=$(AGDA_BIN) $(AGDA_TESTS_BIN) $(AGDA_TESTS_OPTIONS) --regex-include all/Compiler --regex-exclude AllStdLib)
  447. .PHONY : ghc-compiler-test ##
  448. ghc-compiler-test :
  449. @$(call decorate, "GHC Compiler tests", \
  450. AGDA_BIN=$(AGDA_BIN) $(AGDA_TESTS_BIN) $(AGDA_TESTS_OPTIONS) --regex-include all/Compiler/MAlonzo_Lazy --regex-exclude AllStdLib)
  451. .PHONY : js-compiler-test ##
  452. js-compiler-test :
  453. @$(call decorate, "JS Compiler tests", \
  454. AGDA_BIN=$(AGDA_BIN) $(AGDA_TESTS_BIN) $(AGDA_TESTS_OPTIONS) --regex-include all/Compiler/JS_MinifiedOptimized --regex-exclude AllStdLib)
  455. .PHONY : std-lib-compiler-test ##
  456. std-lib-compiler-test :
  457. @$(call decorate, "Standard library compiler tests", \
  458. AGDA_BIN=$(AGDA_BIN) $(AGDA_TESTS_BIN) $(AGDA_TESTS_OPTIONS) --regex-include AllStdLib)
  459. .PHONY : api-test ##
  460. api-test :
  461. @$(call decorate, "Successful tests using Agda as a Haskell library", \
  462. $(MAKE) -C test/api clean; $(MAKE) -C test/api)
  463. .PHONY : benchmark ##
  464. benchmark :
  465. @$(call decorate, "Benchmark suite", \
  466. $(MAKE) -C benchmark)
  467. .PHONY : benchmark-without-logs ##
  468. benchmark-without-logs :
  469. @$(call decorate, "Benchmark suite without creating logs", \
  470. $(MAKE) -C benchmark without-creating-logs)
  471. .PHONY : benchmark-summary ##
  472. benchmark-summary :
  473. @$(call decorate, "Benchmark summary", \
  474. $(MAKE) -C benchmark summary)
  475. .PHONY : user-manual-test ##
  476. user-manual-test :
  477. @$(call decorate, "User manual (test)", \
  478. find doc/user-manual -type f -name '*.agdai' -delete; \
  479. AGDA_BIN=$(AGDA_BIN) $(AGDA_TESTS_BIN) $(AGDA_TESTS_OPTIONS) --regex-include all/UserManual)
  480. .PHONY : testing-emacs-mode ##
  481. testing-emacs-mode:
  482. @$(call decorate, "Testing the Emacs mode", \
  483. $(AGDA_MODE) compile)
  484. ##############################################################################
  485. ## Size solver
  486. # NB. It is necessary to install the Agda library (i.e run `make install-bin`)
  487. # before installing the `size-solver` program.
  488. .PHONY : install-size-solver ## Install the size solver.
  489. install-size-solver :
  490. @$(call decorate, "Installing the size-solver program", \
  491. $(MAKE) -C src/size-solver STACK_INSTALL_OPTS='$(SLOW_STACK_INSTALL_OPTS) $(STACK_INSTALL_OPTS)' CABAL_INSTALL_OPTS='$(SLOW_CABAL_INSTALL_OPTS) $(CABAL_INSTALL_OPTS)' install-bin)
  492. .PHONY : size-solver-test ##
  493. size-solver-test : install-size-solver
  494. @$(call decorate, "Testing the size-solver program", \
  495. $(MAKE) -C src/size-solver test)
  496. ##############################################################################
  497. ## Development
  498. ## Setting the `stack.yaml` file ############################################
  499. # The variable `GHC_COMPILER` is to be defined as a command-line argument.
  500. # For example: `make set-default-stack-file GHC_COMPILER=8.10.2`
  501. set-default-stack-file : remove-default-stack-file ##
  502. ln -s stack-$(GHC_COMPILER).yaml stack.yaml
  503. cd $(FIXW_PATH) && ln -s stack-$(GHC_COMPILER).yaml stack.yaml
  504. remove-default-stack-file : ##
  505. rm -f stack.yaml
  506. cd $(FIXW_PATH) && rm -f stack.yaml
  507. # Installing binaries for developer services
  508. .PHONY : have-bin-%
  509. have-bin-% :
  510. @($* --help > /dev/null) || $(CABAL) $(CABAL_INSTALL_CMD) $*
  511. ## Whitespace-related #######################################################
  512. # Agda can fail to compile on Windows if files which are CPP-processed
  513. # don't end with a newline character (because we use -Werror).
  514. FIXW_BIN = fix-whitespace
  515. .PHONY : fix-whitespace ## Fix the whitespace issue.
  516. fix-whitespace : have-bin-$(FIXW_BIN)
  517. $(FIXW_BIN)
  518. .PHONY : check-whitespace ## Check the whitespace issue without fixing it.
  519. check-whitespace : have-bin-$(FIXW_BIN)
  520. $(FIXW_BIN) --check
  521. ## agda-bisect standalone program ############################################
  522. .PHONY : install-agda-bisect ## Install agda-bisect.
  523. install-agda-bisect :
  524. @$(call decorate, "Installing the agda-bisect program", \
  525. cd src/agda-bisect && $(CABAL) $(CABAL_INSTALL_CMD))
  526. ## HPC #######################################################################
  527. .PHONY: hpc-build ##
  528. hpc-build: ensure-hash-is-correct
  529. $(CABAL) $(CABAL_CLEAN_CMD) $(CABAL_OPTS)
  530. $(CABAL) $(CABAL_CONFIGURE_CMD) --enable-library-coverage $(CABAL_INSTALL_OPTS)
  531. $(CABAL) $(CABAL_BUILD_CMD) $(CABAL_OPTS)
  532. agda.tix: ./examples/agda.tix ./test/common/agda.tix ./test/Succeed/agda.tix ./test/compiler/agda.tix ./test/api/agda.tix ./test/interaction/agda.tix ./test/fail/agda.tix ./test/lib-succeed/agda.tix ./std-lib/agda.tix ##
  533. hpc sum --output=$@ $^
  534. .PHONY: hpc ## Generate a code coverage report
  535. hpc: hpc-build test agda.tix
  536. hpc report --hpcdir=$(BUILD_DIR)/hpc/mix/Agda-$(VERSION) agda.tix
  537. hpc markup --hpcdir=$(BUILD_DIR)/hpc/mix/Agda-$(VERSION) agda --destdir=hpc-report
  538. ## Lines of Code #############################################################
  539. agdalocfiles=$(shell find . \( \( -name '*.agda' -o -name '*.in' \) ! -name '.*' \) )
  540. agda-loc : ## Agda files (tests) in this project
  541. @wc $(agdalocfiles)
  542. loc : ## Source code of Agda
  543. $(MAKE) -C src/full loc
  544. ## Module dependency graph ###################################################
  545. mod-dep : module-dependency-graph.pdf ## Generate a module dependency graph (PDF).
  546. mod-dot : module-dependency-graph.dot ## Generate a module dependency graph (DOT).
  547. module-dependency-graph.pdf : %.pdf : %.dot
  548. dot -Tpdf $< > $@
  549. module-dependency-graph.dot :
  550. graphmod --no-cluster --prune-edges > $@
  551. ## HLint ####################################################################
  552. hlint : $(BUILD_DIR)/build/autogen/cabal_macros.h ##
  553. hlint --cpp-file=$< \
  554. --cpp-include=$(FULL_SRC_DIR) \
  555. --report=hlint-report.html \
  556. $(FULL_SRC_DIR)/Agda
  557. ##############################################################################
  558. ## Auxiliary targets
  559. help: ## Display this information.
  560. @echo "Available targets:"
  561. @$(SED) -n \
  562. -e 's/^\.PHONY[[:blank:]]*:[[:blank:]]*\([[:graph:]]*[[:blank:]]*##\)/\1/p' \
  563. -e 's/\([[:alnum:]_-]\{1,\}\)[[:blank:]]*:[[:blank:]]*[^#]*##[[:blank:]]*\([^\#]*\)$$/\1 ## \2/p' \
  564. -e 's/^\(#\{2,\}\)$$//p' \
  565. -e "s/^\(#\{2,\}[[:blank:]]*\)\([^#]\{1,\}\)$$/\2/p" \
  566. Makefile | \
  567. awk 'BEGIN {FS = "##"}; \
  568. NF == 0 { print }; \
  569. NF == 1 { print $$1 };\
  570. NF == 2 { printf " \033[36m%-26s\033[0m %s\n", $$1, $$2};'
  571. debug : ## Print debug information.
  572. @echo "AGDA_BIN = $(AGDA_BIN)"
  573. @echo "AGDA_BIN_SUFFIX = $(AGDA_BIN_SUFFIX)"
  574. @echo "AGDA_TESTS_BIN = $(AGDA_TESTS_BIN)"
  575. @echo "AGDA_TESTS_OPTIONS = $(AGDA_TESTS_OPTIONS)"
  576. @echo "BUILD_DIR = $(BUILD_DIR)"
  577. @echo "CABAL_BUILD_CMD = $(CABAL_BUILD_CMD)"
  578. @echo "CABAL_CLEAN_CMD = $(CABAL_CLEAN_CMD)"
  579. @echo "CABAL = $(CABAL)"
  580. @echo "CABAL_CONFIGURE_CMD = $(CABAL_CONFIGURE_CMD)"
  581. @echo "CABAL_CONFIGURE_OPTS = $(CABAL_CONFIGURE_OPTS)"
  582. @echo "CABAL_HADDOCK_CMD = $(CABAL_HADDOCK_CMD)"
  583. @echo "CABAL_INSTALL_CMD = $(CABAL_INSTALL_CMD)"
  584. @echo "CABAL_INSTALL_OPTS = $(CABAL_INSTALL_OPTS)"
  585. @echo "CABAL_OPTS = $(CABAL_OPTS)"
  586. @echo "GHC_VER = $(GHC_VER)"
  587. @echo "GHC_VERSION = $(GHC_VERSION)"
  588. @echo "PARALLEL_TESTS = $(PARALLEL_TESTS)"
  589. @echo "STACK = $(STACK)"
  590. @echo "STACK_INSTALL_OPTS = $(STACK_INSTALL_OPTS)"
  591. @echo
  592. @echo "Run \`make -pq\` to get a detailed report."
  593. @echo
  594. # EOF