Merge pull request #9701 from cabalism/doc/compare-source-repos-9665
[cabal.git] / Makefile
blobd305ca16353acb60bb75d3d8cf83f7e2d1893a6e
1 .PHONY: phony
2 # Adding dependency "phony" is like declaring a target as ".PHONY":
3 # See https://www.gnu.org/software/make/manual/html_node/Force-Targets.html
5 CABALBUILD := cabal build
6 CABALRUN := cabal run
8 # The newer and prefered way to call the doctest tool is:
9 # $ cabal repl --with-ghc=doctest
10 # SEE: https://github.com/haskell/cabal/issues/8504
11 # There is but one caveat, we have to avoid allow-newer.
12 # SEE: https://github.com/haskell/cabal/issues/6859
13 DOCTEST := cabal repl --with-ghc=doctest --repl-options="-w" --ghc-options="-Wwarn" --allow-newer=False
15 # default rules
17 .PHONY: all
18 all : exe lib
20 .PHONY: lib
21 lib :
22 $(CABALBUILD) Cabal:libs
24 .PHONY: exe
25 exe :
26 $(CABALBUILD) cabal-install:exes
28 .PHONY: init
29 init: ## Set up git hooks and ignored revisions
30 @git config core.hooksPath .githooks
31 ## TODO
33 .PHONY: style
34 style: ## Run the code styler
35 @fourmolu -q -i Cabal Cabal-syntax cabal-install
37 .PHONY: style-modified
38 style-modified: ## Run the code styler on modified files
39 @git ls-files --modified Cabal Cabal-syntax cabal-install \
40 | grep '.hs$$' | xargs -P $(PROCS) -I {} fourmolu -q -i {}
42 .PHONY: style-commit
43 style-commit: ## Run the code styler on the previous commit
44 @git diff --name-only HEAD $(COMMIT) Cabal Cabal-syntax cabal-install \
45 | grep '.hs$$' | xargs -P $(PROCS) -I {} fourmolu -q -i {}
47 # source generation: SPDX
49 SPDX_LICENSE_HS:=Cabal-syntax/src/Distribution/SPDX/LicenseId.hs
50 SPDX_EXCEPTION_HS:=Cabal-syntax/src/Distribution/SPDX/LicenseExceptionId.hs
52 # Note: the 'spdx' goal is used in .github/workflows/quick-jobs.yml.
53 # Any changes to this goal need to be reconciled with this workflow.
55 .PHONY: spdx
56 spdx : $(SPDX_LICENSE_HS) $(SPDX_EXCEPTION_HS)
58 SPDX_LICENSE_VERSIONS:=3.0 3.2 3.6 3.9 3.10 3.16 3.23
60 $(SPDX_LICENSE_HS) : templates/SPDX.LicenseId.template.hs cabal-dev-scripts/src/GenUtils.hs cabal-dev-scripts/src/GenSPDX.hs license-list-data/licenses-3.0.json license-list-data/licenses-3.2.json
61 cabal run --builddir=dist-newstyle-meta --project-file=cabal.meta.project gen-spdx -- templates/SPDX.LicenseId.template.hs $(SPDX_LICENSE_VERSIONS:%=license-list-data/licenses-%.json) $(SPDX_LICENSE_HS)
63 $(SPDX_EXCEPTION_HS) : templates/SPDX.LicenseExceptionId.template.hs cabal-dev-scripts/src/GenUtils.hs cabal-dev-scripts/src/GenSPDXExc.hs license-list-data/exceptions-3.0.json license-list-data/exceptions-3.2.json
64 cabal run --builddir=dist-newstyle-meta --project-file=cabal.meta.project gen-spdx-exc -- templates/SPDX.LicenseExceptionId.template.hs $(SPDX_LICENSE_VERSIONS:%=license-list-data/exceptions-%.json) $(SPDX_EXCEPTION_HS)
66 # source generation: templates
68 TEMPLATE_MACROS:=Cabal/src/Distribution/Simple/Build/Macros/Z.hs
69 TEMPLATE_PATHS:=Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs
71 # Note: the 'templates' goal is used in .github/workflows/quick-jobs.yml.
72 # Any changes to this goal need to be reconciled with this workflow.
74 .PHONY: templates
75 templates : $(TEMPLATE_MACROS) $(TEMPLATE_PATHS)
77 $(TEMPLATE_MACROS) : templates/cabal_macros.template.h cabal-dev-scripts/src/GenCabalMacros.hs
78 cabal run --builddir=dist-newstyle-meta --project-file=cabal.meta.project gen-cabal-macros -- $< $@
80 $(TEMPLATE_PATHS) : templates/Paths_pkg.template.hs cabal-dev-scripts/src/GenPathsModule.hs
81 cabal run --builddir=dist-newstyle-meta --project-file=cabal.meta.project gen-paths-module -- $< $@
83 # generated docs
84 # Use cabal build before cabal run to avoid output of the build on stdout when running
85 doc/buildinfo-fields-reference.rst : \
86 $(wildcard Cabal-syntax/src/*/*.hs Cabal-syntax/src/*/*/*.hs Cabal-syntax/src/*/*/*/*.hs) \
87 $(wildcard Cabal-described/src/Distribution/Described.hs Cabal-described/src/Distribution/Utils/*.hs) \
88 buildinfo-reference-generator/src/Main.hs \
89 buildinfo-reference-generator/template.zinza
90 cabal build buildinfo-reference-generator
91 cabal run buildinfo-reference-generator buildinfo-reference-generator/template.zinza | tee $@
92 git diff --exit-code $@
94 .PHONY: analyse-imports
95 analyse-imports :
96 find Cabal-syntax/src Cabal/src cabal-install/src -type f -name '*.hs' | xargs cabal run --builddir=dist-newstyle-meta --project-file=cabal.meta.project analyse-imports --
98 # ghcid
100 .PHONY: ghcid-lib
101 ghcid-lib :
102 ghcid -c 'cabal repl Cabal'
104 .PHONY: ghcid-cli
105 ghcid-cli :
106 ghcid -c 'cabal repl cabal-install'
108 .PHONY: doctest
109 doctest :
110 $(DOCTEST) Cabal-syntax
111 $(DOCTEST) Cabal-described
112 $(DOCTEST) --build-depends=QuickCheck Cabal
113 $(DOCTEST) cabal-install-solver
114 $(DOCTEST) cabal-install
116 # This is not run as part of validate.sh (we need hackage-security, which is tricky to get).
117 .PHONY: doctest-cli
118 doctest-cli :
119 doctest -D__DOCTEST__ --fast cabal-install/src cabal-install-solver/src cabal-install-solver/src-assertion
121 .PHONY: doctest-install
122 doctest-install:
123 cabal install doctest --overwrite-policy=always --ignore-project
125 # tests
127 .PHONY: check-tests
128 check-tests :
129 $(CABALRUN) check-tests -- --cwd Cabal-tests ${TEST}
131 .PHONY: parser-tests
132 parser-tests :
133 $(CABALRUN) parser-tests -- --cwd Cabal-tests ${TEST}
135 .PHONY: parser-tests-accept
136 parser-tests-accept :
137 $(CABALRUN) parser-tests -- --cwd Cabal-tests --accept ${TEST}
139 .PHONY: custom-setup-tests
140 custom-setup-tests :
141 $(CABALRUN) custom-setup-tests --
143 .PHONY: hackage-parsec-tests
144 hackage-parsec-tests :
145 $(CABALRUN) hackage-tests -- parsec +RTS -s -qg -I0 -A64M -N${THREADS} -RTS ${TEST}
147 .PHONY: hackage-rountrip-tests
148 hackage-roundtrip-tests :
149 $(CABALRUN) hackage-tests -- roundtrip +RTS -s -qg -I0 -A64M -N${THREADS} -RTS ${TEST}
151 .PHONY: cabal-install-test
152 cabal-install-test:
153 $(CABALBUILD) -j3 cabal-tests cabal
154 rm -rf .ghc.environment.*
155 cd cabal-testsuite && `cabal list-bin cabal-tests` --with-cabal=`cabal list-bin cabal` --hide-successes -j3 ${TEST}
157 # hackage-benchmarks (solver)
159 .PHONY: hackage-benchmarks-run
160 hackage-benchmarks-run:
161 $(CABALBUILD) -j3 hackage-benchmark cabal
162 rm -rf .ghc.environment.*
163 $$(cabal list-bin hackage-benchmark) --cabal1=cabal --cabal2=$$(cabal list-bin cabal) --packages="hakyll servant-auth-server" --print-trials --concurrently
166 # This doesn't run build, as you first need to test with cabal-install-test :)
167 .PHONY: cabal-install-test-accept
168 cabal-install-test-accept:
169 rm -rf .ghc.environment.*
170 cd cabal-testsuite && `cabal list-bin cabal-tests` --with-cabal=`cabal list-bin cabal` --hide-successes -j3 --accept ${TEST}
172 # Docker validation
174 # Use this carefully, on big machine you can say
176 # make validate-via-docker-all -j4 -O
178 .PHONY: validate-via-docker-all
179 validate-via-docker-all : validate-via-docker-8.2.2
180 validate-via-docker-all : validate-via-docker-8.4.4
181 validate-via-docker-all : validate-via-docker-8.6.5
182 validate-via-docker-all : validate-via-docker-8.8.4
183 validate-via-docker-all : validate-via-docker-8.10.4
185 .PHONY: validate-dockerfiles
186 validate-dockerfiles : .docker/validate-8.10.4.dockerfile
187 validate-dockerfiles : .docker/validate-8.8.4.dockerfile
188 validate-dockerfiles : .docker/validate-8.6.5.dockerfile
189 validate-dockerfiles : .docker/validate-8.4.4.dockerfile
190 validate-dockerfiles : .docker/validate-8.2.2.dockerfile
192 .docker/validate-%.dockerfile : .docker/validate.dockerfile.zinza cabal-dev-scripts/src/GenValidateDockerfile.hs
193 cabal run --builddir=dist-newstyle-meta --project-file=cabal.meta.project gen-validate-dockerfile -- $* $< $@
195 # This is good idea anyway
196 # and we have a test relying on this limit being sufficiently small
197 DOCKERARGS:=--ulimit nofile=1024:1024
199 .PHONY: validate-via-docker-8.2.2
200 validate-via-docker-8.2.2:
201 docker build $(DOCKERARGS) -t cabal-validate:8.2.2 -f .docker/validate-8.2.2.dockerfile .
203 .PHONY: validate-via-docker-8.4.4
204 validate-via-docker-8.4.4:
205 docker build $(DOCKERARGS) -t cabal-validate:8.4.4 -f .docker/validate-8.4.4.dockerfile .
207 .PHONY: validate-via-docker-8.6.5
208 validate-via-docker-8.6.5:
209 docker build $(DOCKERARGS) -t cabal-validate:8.6.5 -f .docker/validate-8.6.5.dockerfile .
211 .PHONY: validate-via-docker-8.8.4
212 validate-via-docker-8.8.4:
213 docker build $(DOCKERARGS) -t cabal-validate:8.8.4 -f .docker/validate-8.8.4.dockerfile .
215 .PHONY: validate-via-docker-8.10.4
216 validate-via-docker-8.10.4:
217 docker build $(DOCKERARGS) -t cabal-validate:8.10.4 -f .docker/validate-8.10.4.dockerfile .
219 .PHONY: validate-via-docker-old
220 validate-via-docker-old:
221 docker build $(DOCKERARGS) -t cabal-validate:older -f .docker/validate-old.dockerfile .
223 # tags
224 .PHONY : tags
225 tags :
226 hasktags -b Cabal-syntax/src Cabal/src Cabal-described/src cabal-install/src cabal-testsuite/src
228 # bootstrapping
229 ##############################################################################
231 bootstrap-json-%: phony
232 cabal build --project-file=cabal.bootstrap.project --with-compiler=ghc-$* --dry-run cabal-install:exe:cabal
233 cp dist-newstyle/cache/plan.json bootstrap/linux-$*.plan.json
234 @# -v0 to avoid build output on stdout
235 cd bootstrap && cabal run -v0 cabal-bootstrap-gen -- linux-$*.plan.json \
236 | python3 -m json.tool > linux-$*.json
238 BOOTSTRAP_GHC_VERSIONS := 8.10.7 9.0.2 9.2.8 9.4.8 9.6.4 9.8.2
240 .PHONY: bootstrap-jsons
241 bootstrap-jsons: $(BOOTSTRAP_GHC_VERSIONS:%=bootstrap-json-%)
243 # documentation
244 ##############################################################################
246 .PHONY: users-guide
247 users-guide:
248 $(MAKE) -C doc users-guide
250 .PHONY: users-guide-requirements
251 users-guide-requirements:
252 $(MAKE) -C doc users-guide-requirements
254 ifeq ($(shell uname), Darwin)
255 PROCS := $(shell sysctl -n hw.logicalcpu)
256 else
257 PROCS := $(shell nproc)
258 endif