Merge pull request #7923 from haskell/mergify/bp/master/pr-7734
[cabal.git] / Makefile
blobda57dcc4e7d4b9cb5bf20834c30874f93786e6ad
1 .PHONY : all lexer sdpx lib exe doctest
2 .PHONY : phony
4 CABALBUILD := cabal v2-build
5 CABALRUN := cabal v2-run
7 # default rules
9 all : exe lib
11 lib : $(LEXER_HS)
12 $(CABALBUILD) Cabal:libs
14 exe : $(LEXER_HS)
15 $(CABALBUILD) cabal-install:exes
17 # Build library with oldest supported GHC
18 lib-ghc-7.6 :
19 $(CABALBUILD) --project-file=cabal.project.libonly --with-compiler=ghc-7.6.3 Cabal:libs
21 lib-ghc-7.8 :
22 $(CABALBUILD) --project-file=cabal.project.libonly --with-compiler=ghc-7.8.4 Cabal:libs
24 # source generation: Lexer
26 LEXER_HS:=Cabal/src/Distribution/Fields/Lexer.hs
28 lexer : $(LEXER_HS)
30 $(LEXER_HS) : templates/Lexer.x
31 alex --latin1 --ghc -o $@ $^
32 cat -s $@ > Lexer.tmp
33 mv Lexer.tmp $@
35 # source generation: SPDX
37 SPDX_LICENSE_HS:=Cabal/src/Distribution/SPDX/LicenseId.hs
38 SPDX_EXCEPTION_HS:=Cabal/src/Distribution/SPDX/LicenseExceptionId.hs
40 spdx : $(SPDX_LICENSE_HS) $(SPDX_EXCEPTION_HS)
42 SPDX_LICENSE_VERSIONS:=3.0 3.2 3.6 3.9 3.10
44 $(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
45 cabal v2-run --builddir=dist-newstyle-meta --project-file=cabal.project.meta gen-spdx -- templates/SPDX.LicenseId.template.hs $(SPDX_LICENSE_VERSIONS:%=license-list-data/licenses-%.json) $(SPDX_LICENSE_HS)
47 $(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
48 cabal v2-run --builddir=dist-newstyle-meta --project-file=cabal.project.meta gen-spdx-exc -- templates/SPDX.LicenseExceptionId.template.hs $(SPDX_LICENSE_VERSIONS:%=license-list-data/exceptions-%.json) $(SPDX_EXCEPTION_HS)
50 # source generation: templates
52 TEMPLATE_MACROS:=Cabal/src/Distribution/Simple/Build/Macros/Z.hs
53 TEMPLATE_PATHS:=Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs
55 templates : phony $(TEMPLATE_MACROS) $(TEMPLATE_PATHS)
57 $(TEMPLATE_MACROS) : templates/cabal_macros.template.h cabal-dev-scripts/src/GenCabalMacros.hs
58 cabal v2-run --builddir=dist-newstyle-meta --project-file=cabal.project.meta gen-cabal-macros -- $< $@
60 $(TEMPLATE_PATHS) : templates/Paths_pkg.template.hs cabal-dev-scripts/src/GenPathsModule.hs
61 cabal v2-run --builddir=dist-newstyle-meta --project-file=cabal.project.meta gen-paths-module -- $< $@
63 # generated docs
65 buildinfo-fields-reference : phony
66 cabal build --builddir=dist-newstyle-bi --project-file=cabal.project.buildinfo buildinfo-reference-generator
67 $$(cabal-plan list-bin --builddir=dist-newstyle-bi buildinfo-reference-generator) buildinfo-reference-generator/template.zinza | tee $@
69 # analyse-imports
70 analyse-imports : phony
71 find Cabal/src cabal-install/src -type f -name '*.hs' | xargs cabal v2-run --builddir=dist-newstyle-meta --project-file=cabal.project.meta analyse-imports --
73 # github actions
74 github-actions : .github/workflows/quick-jobs.yml
75 github-actions : .github/workflows/bootstrap.yml
76 github-actions : .github/workflows/linux.yml
77 github-actions : .github/workflows/macos.yml
78 github-actions : .github/workflows/windows.yml
80 .github/workflows/%.yml : templates/ci-%.template.yml cabal-dev-scripts/src/GenValidate.hs
81 cabal v2-run --builddir=dist-newstyle-meta --project-file=cabal.project.meta gen-validate -- $< $@
83 # ghcid
85 ghcid-lib :
86 ghcid -c 'cabal v2-repl Cabal'
88 ghcid-cli :
89 ghcid -c 'cabal v2-repl cabal-install'
91 # doctests (relies on .ghc.environment files)
93 doctest :
94 doctest --fast Cabal/src
96 # This is not run as part of validate.sh (we need hackage-security, which is tricky to get).
97 doctest-cli :
98 doctest -D__DOCTEST__ --fast cabal-install/src cabal-install-solver/src cabal-install-solver/src-assertion
100 # tests
102 check-tests :
103 $(CABALRUN) check-tests -- --cwd Cabal-tests ${TEST}
105 parser-tests :
106 $(CABALRUN) parser-tests -- --cwd Cabal-tests ${TEST}
108 parser-tests-accept :
109 $(CABALRUN) parser-tests -- --cwd Cabal-tests --accept ${TEST}
111 custom-setup-tests :
112 $(CABALRUN) custom-setup-tests --
114 hackage-parsec-tests :
115 $(CABALRUN) hackage-tests -- parsec +RTS -s -qg -I0 -A64M -N${THREADS} -RTS ${TEST}
117 hackage-roundtrip-tests :
118 $(CABALRUN) hackage-tests -- roundtrip +RTS -s -qg -I0 -A64M -N${THREADS} -RTS ${TEST}
120 cabal-install-test:
121 @which cabal-plan
122 $(CABALBUILD) -j3 cabal-tests cabal
123 rm -rf .ghc.environment.*
124 cd cabal-testsuite && `cabal-plan list-bin cabal-tests` --with-cabal=`cabal-plan list-bin cabal` --hide-successes -j3 ${TEST}
126 # hackage-benchmarks (solver)
128 hackage-benchmarks-run:
129 $(CABALBUILD) -j3 hackage-benchmark cabal
130 rm -rf .ghc.environment.*
131 $$(cabal-plan list-bin hackage-benchmark) --cabal1=cabal --cabal2=$$(cabal-plan list-bin cabal) --packages="hakyll servant-auth-server" --print-trials --concurrently
134 # This doesn't run build, as you first need to test with cabal-install-test :)
135 cabal-install-test-accept:
136 @which cabal-plan
137 rm -rf .ghc.environment.*
138 cd cabal-testsuite && `cabal-plan list-bin cabal-tests` --with-cabal=`cabal-plan list-bin cabal` --hide-successes -j3 --accept ${TEST}
140 # Docker validation
142 # Use this carefully, on big machine you can say
144 # make validate-via-docker-all -j4 -O
146 validate-via-docker-all : validate-via-docker-7.6.3
147 validate-via-docker-all : validate-via-docker-7.8.4
148 validate-via-docker-all : validate-via-docker-7.10.3
149 validate-via-docker-all : validate-via-docker-8.0.2
150 validate-via-docker-all : validate-via-docker-8.2.2
151 validate-via-docker-all : validate-via-docker-8.4.4
152 validate-via-docker-all : validate-via-docker-8.6.5
153 validate-via-docker-all : validate-via-docker-8.8.4
154 validate-via-docker-all : validate-via-docker-8.10.4
156 validate-dockerfiles : .docker/validate-8.10.4.dockerfile
157 validate-dockerfiles : .docker/validate-8.8.4.dockerfile
158 validate-dockerfiles : .docker/validate-8.6.5.dockerfile
159 validate-dockerfiles : .docker/validate-8.4.4.dockerfile
160 validate-dockerfiles : .docker/validate-8.2.2.dockerfile
161 validate-dockerfiles : .docker/validate-8.6.5.dockerfile
162 validate-dockerfiles : .docker/validate-7.10.3.dockerfile
163 validate-dockerfiles : .docker/validate-7.8.4.dockerfile
164 validate-dockerfiles : .docker/validate-7.6.3.dockerfile
166 .docker/validate-%.dockerfile : .docker/validate.dockerfile.zinza cabal-dev-scripts/src/GenValidateDockerfile.hs
167 cabal v2-run --builddir=dist-newstyle-meta --project-file=cabal.project.meta gen-validate-dockerfile -- $* $< $@
169 # This is good idea anyway
170 # and we have a test relying on this limit being sufficiently small
171 DOCKERARGS:=--ulimit nofile=1024:1024
173 validate-via-docker-7.6.3:
174 docker build $(DOCKERARGS) -t cabal-validate:7.6.3 -f .docker/validate-7.6.3.dockerfile .
176 validate-via-docker-7.8.4:
177 docker build $(DOCKERARGS) -t cabal-validate:7.8.4 -f .docker/validate-7.8.4.dockerfile .
179 validate-via-docker-7.10.3:
180 docker build $(DOCKERARGS) -t cabal-validate:7.10.3 -f .docker/validate-7.10.3.dockerfile .
182 validate-via-docker-8.0.2:
183 docker build $(DOCKERARGS) -t cabal-validate:8.0.2 -f .docker/validate-8.0.2.dockerfile .
185 validate-via-docker-8.2.2:
186 docker build $(DOCKERARGS) -t cabal-validate:8.2.2 -f .docker/validate-8.2.2.dockerfile .
188 validate-via-docker-8.4.4:
189 docker build $(DOCKERARGS) -t cabal-validate:8.4.4 -f .docker/validate-8.4.4.dockerfile .
191 validate-via-docker-8.6.5:
192 docker build $(DOCKERARGS) -t cabal-validate:8.6.5 -f .docker/validate-8.6.5.dockerfile .
194 validate-via-docker-8.8.4:
195 docker build $(DOCKERARGS) -t cabal-validate:8.8.4 -f .docker/validate-8.8.4.dockerfile .
197 validate-via-docker-8.10.4:
198 docker build $(DOCKERARGS) -t cabal-validate:8.10.4 -f .docker/validate-8.10.4.dockerfile .
200 validate-via-docker-old:
201 docker build $(DOCKERARGS) -t cabal-validate:older -f .docker/validate-old.dockerfile .
203 # Weeder
204 weeder :
205 cabal build all --project-file=cabal.project.weeder
206 weeder | less
208 # tags
209 .PHONY : tags
210 tags :
211 hasktags -b Cabal/src Cabal-described/src cabal-install/src cabal-testsuite/src
213 # boostrapping
214 ##############################################################################
216 bootstrap-plans-linux: phony
217 @if [ $$(uname) != "Linux" ]; then echo "Not Linux"; false; fi
218 cabal v2-build --project=cabal.project.release --with-compiler ghc-8.6.5 --dry-run cabal-install:exe:cabal
219 cp dist-newstyle/cache/plan.json bootstrap/linux-8.6.5.plan.json
220 cabal v2-build --project=cabal.project.release --with-compiler ghc-8.8.4 --dry-run cabal-install:exe:cabal
221 cp dist-newstyle/cache/plan.json bootstrap/linux-8.8.4.plan.json
222 cabal v2-build --project=cabal.project.release --with-compiler ghc-8.10.7 --dry-run cabal-install:exe:cabal
223 cp dist-newstyle/cache/plan.json bootstrap/linux-8.10.7.plan.json
225 bootstrap-jsons-linux: phony
226 @if [ $$(uname) != "Linux" ]; then echo "Not Linux"; false; fi
227 cabal v2-build --builddir=dist-newstyle-bootstrap --project=cabal.project.bootstrap cabal-bootstrap-gen
228 cabal v2-run -vnormal+stderr --builddir=dist-newstyle-bootstrap --project=cabal.project.bootstrap cabal-bootstrap-gen -- bootstrap/linux-8.6.5.plan.json | python3 -m json.tool | tee bootstrap/linux-8.6.5.json
229 cabal v2-run -vnormal+stderr --builddir=dist-newstyle-bootstrap --project=cabal.project.bootstrap cabal-bootstrap-gen -- bootstrap/linux-8.8.4.plan.json | python3 -m json.tool | tee bootstrap/linux-8.8.4.json
230 cabal v2-run -vnormal+stderr --builddir=dist-newstyle-bootstrap --project=cabal.project.bootstrap cabal-bootstrap-gen -- bootstrap/linux-8.10.7.plan.json | python3 -m json.tool | tee bootstrap/linux-8.10.7.json
232 # documentation
233 ##############################################################################
235 # TODO: when we have sphinx-build2 ?
236 SPHINXCMD:=sphinx-build
237 # Flag -n ("nitpick") warns about broken references
238 # Flag -W turns warnings into errors
239 # Flag --keep-going continues after errors
240 SPHINX_FLAGS:=-n -W --keep-going -E
241 SPHINX_HTML_OUTDIR:=dist-newstyle/doc/users-guide
242 USERGUIDE_STAMP:=$(SPHINX_HTML_OUTDIR)/index.html
244 # do pip install everytime so we have up to date requirements when we build
245 users-guide: .python-sphinx-virtualenv $(USERGUIDE_STAMP)
246 $(USERGUIDE_STAMP) : doc/*.rst
247 mkdir -p $(SPHINX_HTML_OUTDIR)
248 (. ./.python-sphinx-virtualenv/bin/activate && pip install -r doc/requirements.txt && $(SPHINXCMD) $(SPHINX_FLAGS) doc $(SPHINX_HTML_OUTDIR))
250 .python-sphinx-virtualenv:
251 python3 -m venv .python-sphinx-virtualenv
252 (. ./.python-sphinx-virtualenv/bin/activate)
254 # This goal is intended for manual invocation, always rebuilds.
255 .PHONY: users-guide-requirements
256 users-guide-requirements: doc/requirements.txt
258 .PHONY: doc/requirements.txt
259 doc/requirements.txt: .python-sphinx-virtualenv
260 . .python-sphinx-virtualenv/bin/activate \
261 && make -C doc build-and-check-requirements