Makefile 3.68 KB
Newer Older
1 2 3 4 5 6 7
# -----------------------------------------------------------------------------
#
# (c) 2009 The University of Glasgow
#
# This file is part of the GHC build system.
#
# To understand how the build system works and how to modify it, see
8 9
#      http://ghc.haskell.org/trac/ghc/wiki/Building/Architecture
#      http://ghc.haskell.org/trac/ghc/wiki/Building/Modifying
10 11
#
# -----------------------------------------------------------------------------
12

Ian Lynagh's avatar
Ian Lynagh committed
13
ifeq "$(wildcard distrib/)" ""
14

Ian Lynagh's avatar
Ian Lynagh committed
15
# We're in a bindist
16

Ian Lynagh's avatar
Ian Lynagh committed
17 18 19 20
.PHONY: default
default:
	@echo 'Run "make install" to install'
	@false
21

Ian Lynagh's avatar
Ian Lynagh committed
22 23 24
.PHONY: install show
install show:
	$(MAKE) -r --no-print-directory -f ghc.mk $@ BINDIST=YES NO_INCLUDE_DEPS=YES
25

26
else
27

28
.PHONY: default
Ian Lynagh's avatar
Ian Lynagh committed
29 30
default : all
	@:
31

32 33
# For help, type 'make help'
.PHONY: help
Kyle J. Van Berendonck's avatar
Kyle J. Van Berendonck committed
34
help:
Austin Seipp's avatar
Austin Seipp committed
35
	@cat MAKEHELP.md
36

37
ifneq "$(filter maintainer-clean distclean clean help,$(MAKECMDGOALS))" ""
38 39
-include mk/config.mk
else
40 41 42 43
include mk/config.mk
ifeq "$(ProjectVersion)" ""
$(error Please run ./configure first)
endif
44
endif
45 46 47

include mk/custom-settings.mk

48 49 50 51 52 53 54
# Verify that stage 0 LLVM backend isn't affected by Bug #9439 if needed
ifeq "$(GHC_LLVM_AFFECTED_BY_9439)" "1"
ifneq "$(findstring -fllvm,$(GhcHcOpts) $(GhcStage1HcOpts))" ""
$(error Stage 0 compiler is affected by Bug #9439. Refusing to bootstrap with -fllvm)
endif
endif

Ian Lynagh's avatar
Ian Lynagh committed
55
# No need to update makefiles for these targets:
56
REALGOALS=$(filter-out binary-dist binary-dist-prep bootstrapping-files framework-pkg clean clean_% distclean maintainer-clean show echo help test fulltest fast fasttest,$(MAKECMDGOALS))
57

58 59 60 61
# configure touches certain files even if they haven't changed.  This
# can mean a lot of unnecessary recompilation after a re-configure, so
# here we cache the old versions of these files so we can restore the
# timestamps.
kili's avatar
kili committed
62
%.old:  %
63
	@set -x && test -f $@ && cmp -s $< $@ || cp -p $< $@
kili's avatar
kili committed
64 65
	touch -r $@ $<

66

Ian Lynagh's avatar
Ian Lynagh committed
67 68
# NB. not the same as saying '%: ...', which doesn't do the right thing:
# it does nothing if we specify a target that already exists.
69
.PHONY: $(REALGOALS) all
kili's avatar
kili committed
70
$(REALGOALS) all: mk/config.mk.old mk/project.mk.old compiler/ghc.cabal.old
71
ifneq "$(OMIT_PHASE_0)" "YES"
Ian Lynagh's avatar
Ian Lynagh committed
72
	@echo "===--- building phase 0"
73
	$(MAKE) -r --no-print-directory -f ghc.mk phase=0 phase_0_builds
74
endif
75
ifneq "$(OMIT_PHASE_1)" "YES"
Ian Lynagh's avatar
Ian Lynagh committed
76
	@echo "===--- building phase 1"
77
	$(MAKE) -r --no-print-directory -f ghc.mk phase=1 phase_1_builds
Ian Lynagh's avatar
Ian Lynagh committed
78 79
endif
	@echo "===--- building final phase"
80
	$(MAKE) -r --no-print-directory -f ghc.mk phase=final $@
81

82
.PHONY: binary-dist
Ian Lynagh's avatar
Ian Lynagh committed
83
binary-dist: binary-dist-prep
84
	mv bindistprep/*.tar.$(TAR_COMP_EXT) .
Ian Lynagh's avatar
Ian Lynagh committed
85

86
.PHONY: binary-dist-prep
Ian Lynagh's avatar
Ian Lynagh committed
87 88 89
binary-dist-prep:
ifeq "$(mingw32_TARGET_OS)" "1"
	$(MAKE) -r --no-print-directory -f ghc.mk windows-binary-dist-prep
90
else
Ian Lynagh's avatar
Ian Lynagh committed
91 92
	rm -f bindist-list
	$(MAKE) -r --no-print-directory -f ghc.mk bindist BINDIST=YES
Ian Lynagh's avatar
Ian Lynagh committed
93
	$(MAKE) -r --no-print-directory -f ghc.mk unix-binary-dist-prep
94
endif
95

96
.PHONY: clean distclean maintainer-clean
97 98
clean distclean maintainer-clean:
	$(MAKE) -r --no-print-directory -f ghc.mk $@ CLEANING=YES
Ian Lynagh's avatar
Ian Lynagh committed
99
	test ! -d testsuite || $(MAKE) -C testsuite $@
Ian Lynagh's avatar
Ian Lynagh committed
100

101
.PHONY: $(filter clean_%,$(MAKECMDGOALS))
102
$(filter clean_%, $(MAKECMDGOALS)) : clean_% :
103
	$(MAKE) -r --no-print-directory -f ghc.mk $@ CLEANING=YES
104

105
.PHONY: bootstrapping-files show echo
106
bootstrapping-files show echo:
Ian Lynagh's avatar
Ian Lynagh committed
107
	$(MAKE) -r --no-print-directory -f ghc.mk $@
sof's avatar
sof committed
108

109
ifeq "$(darwin_TARGET_OS)" "1"
110
.PHONY: framework-pkg
111 112 113 114
framework-pkg:
	$(MAKE) -C distrib/MacOS $@
endif

Ian Lynagh's avatar
Ian Lynagh committed
115 116 117
# If the user says 'make A B', then we don't want to invoke two
# instances of the rule above in parallel:
.NOTPARALLEL:
118

Ian Lynagh's avatar
Ian Lynagh committed
119
endif
120

121 122
.PHONY: fasttest fast
fasttest fast:
123
	$(MAKE) -C testsuite/tests CLEANUP=1 OUTPUT_SUMMARY=../../testsuite_summary.txt fast
124

125 126
.PHONY: fulltest test
fulltest test:
127
	$(MAKE) -C testsuite/tests CLEANUP=1 OUTPUT_SUMMARY=../../testsuite_summary.txt