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
{}
44 # source generation: SPDX
46 SPDX_LICENSE_HS
:=Cabal-syntax
/src
/Distribution
/SPDX
/LicenseId.hs
47 SPDX_EXCEPTION_HS
:=Cabal-syntax
/src
/Distribution
/SPDX
/LicenseExceptionId.hs
49 # Note: the 'spdx' goal is used in .github/workflows/quick-jobs.yml.
50 # Any changes to this goal need to be reconciled with this workflow.
53 spdx
: $(SPDX_LICENSE_HS
) $(SPDX_EXCEPTION_HS
)
55 SPDX_LICENSE_VERSIONS
:=3.0 3.2 3.6 3.9 3.10 3.16 3.23
57 $(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
58 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
)
60 $(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
61 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
)
63 # source generation: templates
65 TEMPLATE_MACROS
:=Cabal
/src
/Distribution
/Simple
/Build
/Macros
/Z.hs
66 TEMPLATE_PATHS
:=Cabal
/src
/Distribution
/Simple
/Build
/PathsModule
/Z.hs
68 # Note: the 'templates' goal is used in .github/workflows/quick-jobs.yml.
69 # Any changes to this goal need to be reconciled with this workflow.
72 templates
: $(TEMPLATE_MACROS
) $(TEMPLATE_PATHS
)
74 $(TEMPLATE_MACROS
) : templates
/cabal_macros.template.h cabal-dev-scripts
/src
/GenCabalMacros.hs
75 cabal run
--builddir
=dist-newstyle-meta
--project-file
=cabal.meta.project gen-cabal-macros
-- $< $@
77 $(TEMPLATE_PATHS
) : templates
/Paths_pkg.template.hs cabal-dev-scripts
/src
/GenPathsModule.hs
78 cabal run
--builddir
=dist-newstyle-meta
--project-file
=cabal.meta.project gen-paths-module
-- $< $@
81 # Use cabal build before cabal run to avoid output of the build on stdout when running
82 doc
/buildinfo-fields-reference.rst
: \
83 $(wildcard Cabal-syntax
/src
/*/*.hs Cabal-syntax
/src
/*/*/*.hs Cabal-syntax
/src
/*/*/*/*.hs
) \
84 $(wildcard Cabal-described
/src
/Distribution
/Described.hs Cabal-described
/src
/Distribution
/Utils
/*.hs
) \
85 buildinfo-reference-generator
/src
/Main.hs \
86 buildinfo-reference-generator
/template.zinza
87 cabal build buildinfo-reference-generator
88 cabal run buildinfo-reference-generator buildinfo-reference-generator
/template.zinza | tee
$@
89 git diff
--exit-code
$@
91 .PHONY
: analyse-imports
93 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
--
99 ghcid
-c
'cabal repl Cabal'
103 ghcid
-c
'cabal repl cabal-install'
107 cd Cabal-syntax
&& $(DOCTEST
)
108 cd Cabal-described
&& $(DOCTEST
)
109 cd Cabal
&& $(DOCTEST
)
110 cd cabal-install-solver
&& $(DOCTEST
)
111 cd cabal-install
&& $(DOCTEST
)
113 # This is not run as part of validate.sh (we need hackage-security, which is tricky to get).
116 doctest
-D__DOCTEST__
--fast cabal-install
/src cabal-install-solver
/src cabal-install-solver
/src-assertion
118 .PHONY
: doctest-install
120 cabal
install doctest
--overwrite-policy
=always
--ignore-project
--flag cabal-doctest
126 $(CABALRUN
) check-tests
-- --cwd Cabal-tests
${TEST}
130 $(CABALRUN
) parser-tests
-- --cwd Cabal-tests
${TEST}
132 .PHONY
: parser-tests-accept
133 parser-tests-accept
:
134 $(CABALRUN
) parser-tests
-- --cwd Cabal-tests
--accept
${TEST}
136 .PHONY
: custom-setup-tests
138 $(CABALRUN
) custom-setup-tests
--
140 .PHONY
: hackage-parsec-tests
141 hackage-parsec-tests
:
142 $(CABALRUN
) hackage-tests
-- parsec
+RTS
-s
-qg
-I0
-A64M
-N
${THREADS} -RTS
${TEST}
144 .PHONY
: hackage-rountrip-tests
145 hackage-roundtrip-tests
:
146 $(CABALRUN
) hackage-tests
-- roundtrip
+RTS
-s
-qg
-I0
-A64M
-N
${THREADS} -RTS
${TEST}
148 .PHONY
: cabal-install-test
150 $(CABALBUILD
) -j3 cabal-tests cabal
151 rm -rf .ghc.environment.
*
152 cd cabal-testsuite
&& `cabal list-bin cabal-tests` --with-cabal
=`cabal list-bin cabal` --hide-successes
-j3
${TEST}
154 # hackage-benchmarks (solver)
156 .PHONY
: hackage-benchmarks-run
157 hackage-benchmarks-run
:
158 $(CABALBUILD
) -j3 hackage-benchmark cabal
159 rm -rf .ghc.environment.
*
160 $$(cabal list-bin hackage-benchmark
) --cabal1
=cabal
--cabal2
=$$(cabal list-bin cabal
) --packages
="hakyll servant-auth-server" --print-trials
--concurrently
163 # This doesn't run build, as you first need to test with cabal-install-test :)
164 .PHONY
: cabal-install-test-accept
165 cabal-install-test-accept
:
166 rm -rf .ghc.environment.
*
167 cd cabal-testsuite
&& `cabal list-bin cabal-tests` --with-cabal
=`cabal list-bin cabal` --hide-successes
-j3
--accept
${TEST}
171 # Use this carefully, on big machine you can say
173 # make validate-via-docker-all -j4 -O
175 .PHONY
: validate-via-docker-all
176 validate-via-docker-all
: validate-via-docker-8.2
.2
177 validate-via-docker-all
: validate-via-docker-8.4
.4
178 validate-via-docker-all
: validate-via-docker-8.8
.4
179 validate-via-docker-all
: validate-via-docker-8.10
.4
181 .PHONY
: validate-dockerfiles
182 validate-dockerfiles
: .docker
/validate-8.10
.4.dockerfile
183 validate-dockerfiles
: .docker
/validate-8.8
.4.dockerfile
184 validate-dockerfiles
: .docker
/validate-8.4
.4.dockerfile
185 validate-dockerfiles
: .docker
/validate-8.2
.2.dockerfile
187 .docker
/validate-
%.dockerfile
: .docker
/validate.dockerfile.zinza cabal-dev-scripts
/src
/GenValidateDockerfile.hs
188 cabal run
--builddir
=dist-newstyle-meta
--project-file
=cabal.meta.project gen-validate-dockerfile
-- $* $< $@
190 # This is good idea anyway
191 # and we have a test relying on this limit being sufficiently small
192 DOCKERARGS
:=--ulimit nofile
=1024:1024
194 .PHONY
: validate-via-docker-8.2
.2
195 validate-via-docker-8.2
.2:
196 docker build
$(DOCKERARGS
) -t cabal-validate
:8.2.2 -f .docker
/validate-8.2
.2.dockerfile .
198 .PHONY
: validate-via-docker-8.4
.4
199 validate-via-docker-8.4
.4:
200 docker build
$(DOCKERARGS
) -t cabal-validate
:8.4.4 -f .docker
/validate-8.4
.4.dockerfile .
202 .PHONY
: validate-via-docker-8.8
.4
203 validate-via-docker-8.8
.4:
204 docker build
$(DOCKERARGS
) -t cabal-validate
:8.8.4 -f .docker
/validate-8.8
.4.dockerfile .
206 .PHONY
: validate-via-docker-8.10
.4
207 validate-via-docker-8.10
.4:
208 docker build
$(DOCKERARGS
) -t cabal-validate
:8.10.4 -f .docker
/validate-8.10
.4.dockerfile .
210 .PHONY
: validate-via-docker-old
211 validate-via-docker-old
:
212 docker build
$(DOCKERARGS
) -t cabal-validate
:older
-f .docker
/validate-old.dockerfile .
217 hasktags
-b Cabal-syntax
/src Cabal
/src Cabal-described
/src cabal-install
/src cabal-testsuite
/src
220 ##############################################################################
222 bootstrap-json-
%: phony
223 cabal build
--project-file
=cabal.bootstrap.project
--with-compiler
=ghc-
$* --dry-run cabal-install
:exe
:cabal
224 cp dist-newstyle
/cache
/plan.json bootstrap
/linux-
$*.plan.json
225 @
# -v0 to avoid build output on stdout
226 cd bootstrap
&& cabal run
-v0 cabal-bootstrap-gen
-- linux-
$*.plan.json \
227 | python3
-m json.tool
> linux-
$*.json
229 BOOTSTRAP_GHC_VERSIONS
:= 9.0.2 9.2.8 9.4.8 9.6.4 9.8.2
231 .PHONY
: bootstrap-jsons
232 bootstrap-jsons
: $(BOOTSTRAP_GHC_VERSIONS
:%=bootstrap-json-
%)
235 ##############################################################################
239 $(MAKE
) -C doc users-guide
241 .PHONY
: users-guide-requirements
242 users-guide-requirements
:
243 $(MAKE
) -C doc users-guide-requirements
245 ifeq ($(shell uname
), Darwin
)
246 PROCS
:= $(shell sysctl
-n hw.logicalcpu
)
248 PROCS
:= $(shell nproc
)