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
8 # We have to avoid allow-newer.
9 # SEE: https://github.com/haskell/cabal/issues/6859
10 DOCTEST
:= cabal doctest
--allow-newer
=False
19 $(CABALBUILD
) Cabal
:libs
23 $(CABALBUILD
) cabal-install
:exes
26 init
: ## Set up git hooks and ignored revisions
27 @git config core.hooksPath .githooks
31 style
: ## Run the code styler
32 @fourmolu
-q
-i Cabal Cabal-syntax cabal-install
34 .PHONY
: style-modified
35 style-modified
: ## Run the code styler on modified files
36 @git ls-files
--modified Cabal Cabal-syntax cabal-install \
37 | grep
'.hs$$' | xargs
-P
$(PROCS
) -I
{} fourmolu
-q
-i
{}
40 style-commit
: ## Run the code styler on the previous commit
41 @git diff
--name-only HEAD
$(COMMIT
) Cabal Cabal-syntax cabal-install \
42 | grep
'.hs$$' | xargs
-P
$(PROCS
) -I
{} fourmolu
-q
-i
{}
45 whitespace
: ## Run fix-whitespace in check mode
46 fix-whitespace
--check --verbose
48 .PHONY
: fix-whitespace
49 fix-whitespace
: ## Run fix-whitespace in fix mode
50 fix-whitespace
--verbose
52 # source generation: SPDX
54 SPDX_LICENSE_HS
:=Cabal-syntax
/src
/Distribution
/SPDX
/LicenseId.hs
55 SPDX_EXCEPTION_HS
:=Cabal-syntax
/src
/Distribution
/SPDX
/LicenseExceptionId.hs
57 # Note: the 'spdx' goal is used in .github/workflows/quick-jobs.yml.
58 # Any changes to this goal need to be reconciled with this workflow.
61 spdx
: $(SPDX_LICENSE_HS
) $(SPDX_EXCEPTION_HS
)
63 SPDX_LICENSE_VERSIONS
:=3.0 3.2 3.6 3.9 3.10 3.16 3.23 3.25
65 $(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
66 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
)
68 $(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
69 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
)
71 # source generation: templates
73 TEMPLATE_MACROS
:=Cabal
/src
/Distribution
/Simple
/Build
/Macros
/Z.hs
74 TEMPLATE_PATHS
:=Cabal
/src
/Distribution
/Simple
/Build
/PathsModule
/Z.hs
76 # Note: the 'templates' goal is used in .github/workflows/quick-jobs.yml.
77 # Any changes to this goal need to be reconciled with this workflow.
80 templates
: $(TEMPLATE_MACROS
) $(TEMPLATE_PATHS
)
82 $(TEMPLATE_MACROS
) : templates
/cabal_macros.template.h cabal-dev-scripts
/src
/GenCabalMacros.hs
83 cabal run
--builddir
=dist-newstyle-meta
--project-file
=cabal.meta.project gen-cabal-macros
-- $< $@
85 $(TEMPLATE_PATHS
) : templates
/Paths_pkg.template.hs cabal-dev-scripts
/src
/GenPathsModule.hs
86 cabal run
--builddir
=dist-newstyle-meta
--project-file
=cabal.meta.project gen-paths-module
-- $< $@
89 # Use cabal build before cabal run to avoid output of the build on stdout when running
90 doc
/buildinfo-fields-reference.rst
: \
91 $(wildcard Cabal-syntax
/src
/*/*.hs Cabal-syntax
/src
/*/*/*.hs Cabal-syntax
/src
/*/*/*/*.hs
) \
92 $(wildcard Cabal-described
/src
/Distribution
/Described.hs Cabal-described
/src
/Distribution
/Utils
/*.hs
) \
93 buildinfo-reference-generator
/src
/Main.hs \
94 buildinfo-reference-generator
/template.zinza
95 cabal build buildinfo-reference-generator
96 cabal run buildinfo-reference-generator buildinfo-reference-generator
/template.zinza | tee
$@
97 git diff
--exit-code
$@
99 .PHONY
: analyse-imports
101 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
--
107 ghcid
-c
'cabal repl Cabal'
111 ghcid
-c
'cabal repl cabal-install'
115 cd Cabal-syntax
&& $(DOCTEST
)
116 cd Cabal-described
&& $(DOCTEST
)
117 cd Cabal
&& $(DOCTEST
)
118 cd cabal-install-solver
&& $(DOCTEST
)
119 cd cabal-install
&& $(DOCTEST
)
121 # This is not run as part of validate.sh (we need hackage-security, which is tricky to get).
124 doctest
-D__DOCTEST__
--fast cabal-install
/src cabal-install-solver
/src cabal-install-solver
/src-assertion
126 .PHONY
: doctest-install
128 cabal
install doctest
--overwrite-policy
=always
--ignore-project
--flag cabal-doctest
134 $(CABALRUN
) check-tests
-- --cwd Cabal-tests
${TEST}
138 $(CABALRUN
) parser-tests
-- --cwd Cabal-tests
${TEST}
140 .PHONY
: parser-tests-accept
141 parser-tests-accept
:
142 $(CABALRUN
) parser-tests
-- --cwd Cabal-tests
--accept
${TEST}
144 .PHONY
: custom-setup-tests
146 $(CABALRUN
) custom-setup-tests
--
148 .PHONY
: hackage-parsec-tests
149 hackage-parsec-tests
:
150 $(CABALRUN
) hackage-tests
-- parsec
+RTS
-s
-qg
-I0
-A64M
-N
${THREADS} -RTS
${TEST}
152 .PHONY
: hackage-rountrip-tests
153 hackage-roundtrip-tests
:
154 $(CABALRUN
) hackage-tests
-- roundtrip
+RTS
-s
-qg
-I0
-A64M
-N
${THREADS} -RTS
${TEST}
156 .PHONY
: cabal-install-test
158 $(CABALBUILD
) -j3 cabal-tests cabal
159 rm -rf .ghc.environment.
*
160 cd cabal-testsuite
&& `cabal list-bin cabal-tests` --with-cabal
=`cabal list-bin cabal` --hide-successes
-j3
${TEST}
162 # hackage-benchmarks (solver)
164 .PHONY
: hackage-benchmarks-run
165 hackage-benchmarks-run
:
166 $(CABALBUILD
) -j3 hackage-benchmark cabal
167 rm -rf .ghc.environment.
*
168 $$(cabal list-bin hackage-benchmark
) --cabal1
=cabal
--cabal2
=$$(cabal list-bin cabal
) --packages
="hakyll servant-auth-server" --print-trials
--concurrently
171 # This doesn't run build, as you first need to test with cabal-install-test :)
172 .PHONY
: cabal-install-test-accept
173 cabal-install-test-accept
:
174 rm -rf .ghc.environment.
*
175 cd cabal-testsuite
&& `cabal list-bin cabal-tests` --with-cabal
=`cabal list-bin cabal` --hide-successes
-j3
--accept
${TEST}
179 # Use this carefully, on big machine you can say
181 # make validate-via-docker-all -j4 -O
183 .PHONY
: validate-via-docker-all
184 validate-via-docker-all
: validate-via-docker-8.2
.2
185 validate-via-docker-all
: validate-via-docker-8.4
.4
186 validate-via-docker-all
: validate-via-docker-8.8
.4
187 validate-via-docker-all
: validate-via-docker-8.10
.4
189 .PHONY
: validate-dockerfiles
190 validate-dockerfiles
: .docker
/validate-8.10
.4.dockerfile
191 validate-dockerfiles
: .docker
/validate-8.8
.4.dockerfile
192 validate-dockerfiles
: .docker
/validate-8.4
.4.dockerfile
193 validate-dockerfiles
: .docker
/validate-8.2
.2.dockerfile
195 .docker
/validate-
%.dockerfile
: .docker
/validate.dockerfile.zinza cabal-dev-scripts
/src
/GenValidateDockerfile.hs
196 cabal run
--builddir
=dist-newstyle-meta
--project-file
=cabal.meta.project gen-validate-dockerfile
-- $* $< $@
198 # This is good idea anyway
199 # and we have a test relying on this limit being sufficiently small
200 DOCKERARGS
:=--ulimit nofile
=1024:1024
202 .PHONY
: validate-via-docker-8.2
.2
203 validate-via-docker-8.2
.2:
204 docker build
$(DOCKERARGS
) -t cabal-validate
:8.2.2 -f .docker
/validate-8.2
.2.dockerfile .
206 .PHONY
: validate-via-docker-8.4
.4
207 validate-via-docker-8.4
.4:
208 docker build
$(DOCKERARGS
) -t cabal-validate
:8.4.4 -f .docker
/validate-8.4
.4.dockerfile .
210 .PHONY
: validate-via-docker-8.8
.4
211 validate-via-docker-8.8
.4:
212 docker build
$(DOCKERARGS
) -t cabal-validate
:8.8.4 -f .docker
/validate-8.8
.4.dockerfile .
214 .PHONY
: validate-via-docker-8.10
.4
215 validate-via-docker-8.10
.4:
216 docker build
$(DOCKERARGS
) -t cabal-validate
:8.10.4 -f .docker
/validate-8.10
.4.dockerfile .
218 .PHONY
: validate-via-docker-old
219 validate-via-docker-old
:
220 docker build
$(DOCKERARGS
) -t cabal-validate
:older
-f .docker
/validate-old.dockerfile .
225 hasktags
-b Cabal-syntax
/src Cabal
/src Cabal-described
/src cabal-install
/src cabal-testsuite
/src
228 ##############################################################################
230 bootstrap-json-
%: phony
231 cabal build
--project-file
=cabal.bootstrap.project
--with-compiler
=ghc-
$* --dry-run cabal-install
:exe
:cabal
232 cp dist-newstyle
/cache
/plan.json bootstrap
/linux-
$*.plan.json
233 @
# -v0 to avoid build output on stdout
234 cd bootstrap
&& cabal run
-v0 cabal-bootstrap-gen
-- linux-
$*.plan.json \
235 | python3
-m json.tool
> linux-
$*.json
237 BOOTSTRAP_GHC_VERSIONS
:= 9.0.2 9.2.8 9.4.8 9.6.6 9.8.2
239 .PHONY
: bootstrap-jsons
240 bootstrap-jsons
: $(BOOTSTRAP_GHC_VERSIONS
:%=bootstrap-json-
%)
243 ##############################################################################
247 $(MAKE
) -C doc users-guide
249 .PHONY
: users-guide-requirements
250 users-guide-requirements
:
251 $(MAKE
) -C doc users-guide-requirements
253 ifeq ($(shell uname
), Darwin
)
254 PROCS
:= $(shell sysctl
-n hw.logicalcpu
)
256 PROCS
:= $(shell nproc
)