Makefile 3.44 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

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

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

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

include mk/custom-settings.mk

47 48 49 50 51 52 53
# 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
54
# No need to update makefiles for these targets:
55
REALGOALS=$(filter-out binary-dist binary-dist-prep bootstrapping-files framework-pkg clean clean_% distclean maintainer-clean show echo help test fulltest,$(MAKECMDGOALS))
56

57 58 59 60
# 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
61
%.old:  %
62
	@set -x && test -f $@ && cmp -s $< $@ || cp -p $< $@
kili's avatar
kili committed
63 64
	touch -r $@ $<

65

Ian Lynagh's avatar
Ian Lynagh committed
66 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.
.PHONY: $(REALGOALS)
kili's avatar
kili committed
69
$(REALGOALS) all: mk/config.mk.old mk/project.mk.old compiler/ghc.cabal.old
70
ifneq "$(OMIT_PHASE_0)" "YES"
Ian Lynagh's avatar
Ian Lynagh committed
71
	@echo "===--- building phase 0"
72
	$(MAKE) -r --no-print-directory -f ghc.mk phase=0 phase_0_builds
73
endif
74
ifneq "$(OMIT_PHASE_1)" "YES"
Ian Lynagh's avatar
Ian Lynagh committed
75
	@echo "===--- building phase 1"
76
	$(MAKE) -r --no-print-directory -f ghc.mk phase=1 phase_1_builds
Ian Lynagh's avatar
Ian Lynagh committed
77 78
endif
	@echo "===--- building final phase"
79
	$(MAKE) -r --no-print-directory -f ghc.mk phase=final $@
80

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

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

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

97
$(filter clean_%, $(MAKECMDGOALS)) : clean_% :
98
	$(MAKE) -r --no-print-directory -f ghc.mk $@ CLEANING=YES
99

100
bootstrapping-files show echo:
Ian Lynagh's avatar
Ian Lynagh committed
101
	$(MAKE) -r --no-print-directory -f ghc.mk $@
sof's avatar
sof committed
102

103 104 105 106 107
ifeq "$(darwin_TARGET_OS)" "1"
framework-pkg:
	$(MAKE) -C distrib/MacOS $@
endif

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

Ian Lynagh's avatar
Ian Lynagh committed
112
endif
113 114 115

.PHONY: test
test:
116
	$(MAKE) -C testsuite/tests CLEANUP=1 OUTPUT_SUMMARY=../../testsuite_summary.txt fast
117 118 119

.PHONY: fulltest
fulltest:
120
	$(MAKE) -C testsuite/tests CLEANUP=1 OUTPUT_SUMMARY=../../testsuite_summary.txt
121