boilerplate.mk 2.89 KB
Newer Older
1

2 3 4 5 6 7 8 9 10 11 12
# XXX This whole file should disappear

# New build system:
# 	  include mk/newconfig.mk
#     default : all

# Old build system:
#     include mk/boilerplate.mk

default: all

Ian Lynagh's avatar
Ian Lynagh committed
13 14 15 16
HAVE_EVAL := NO
$(eval HAVE_EVAL := YES)

ifeq "$(HAVE_EVAL)" "NO"
17
$(error Your make does not support eval. You need GNU make >= 3.80)
Ian Lynagh's avatar
Ian Lynagh committed
18 19
endif

20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
define get-ghc-rts-field # $1 = rseult variable, $2 = field name
$1 := $$(shell $$(TEST_HC) +RTS --info | grep '^ .("$2",' | sed -e 's/.*", *"//' -e 's/")$$$$//')
endef

define get-ghc-field # $1 = rseult variable, $2 = field name
$1 := $$(shell $$(TEST_HC) --info | grep '^ .("$2",' | sed -e 's/.*", *"//' -e 's/")$$$$//')
endef

define get-ghc-feature-bool # $1 = rseult variable, $2 = field name
SHELL_RES := $$(shell $$(TEST_HC) --info | grep '^ .("$2",' | sed -e 's/.*", *"//' -e 's/")$$$$//')
$1 := $$(strip \
	  $$(if $$(SHELL_RES), \
         $$(if $$(subst YES,,$$(SHELL_RES)), \
            $$(if $$(subst NO,,$$(SHELL_RES)), \
               $$(warning ghc info field not YES or NO: $2: $$(SHELL_RES)), \
               NO), \
            YES), \
         $$(warning ghc info field not found: $2)))
endef

ifeq "$(TEST_HC)" ""

OLD_BUILD_SYSTEM_STAGE1_GHC := $(abspath $(TOP)/../ghc/stage1-inplace/ghc)
OLD_BUILD_SYSTEM_STAGE2_GHC := $(abspath $(TOP)/../ghc/stage2-inplace/ghc)
OLD_BUILD_SYSTEM_STAGE3_GHC := $(abspath $(TOP)/../ghc/stage3-inplace/ghc)
OLD_BUILD_SYSTEM_GHC_PKG    := $(abspath $(TOP)/../utils/ghc-pkg/install-inplace/bin/ghc-pkg)
OLD_BUILD_SYSTEM_HP2PS      := $(abspath $(TOP)/../utils/hp2ps/hp2ps)
ifneq "$(wildcard $(OLD_BUILD_SYSTEM_STAGE1_GHC))" ""

ifeq "$(stage)" "1"
TEST_HC := $(OLD_BUILD_SYSTEM_STAGE1_GHC)
else
ifeq "$(stage)" "3"
TEST_HC := $(OLD_BUILD_SYSTEM_STAGE3_GHC)
54
else
55 56 57
# use stage2 by default
TEST_HC := $(OLD_BUILD_SYSTEM_STAGE2_GHC)
endif
58
endif
59 60
GHC_PKG := $(OLD_BUILD_SYSTEM_GHC_PKG)
HP2PS_ABS := $(OLD_BUILD_SYSTEM_HP2PS)
61

62 63 64 65 66
else
NEW_BUILD_SYSTEM_STAGE1_GHC := $(abspath $(TOP)/../inplace/bin/ghc-stage1)
NEW_BUILD_SYSTEM_STAGE2_GHC := $(abspath $(TOP)/../inplace/bin/ghc-stage2)
NEW_BUILD_SYSTEM_STAGE3_GHC := $(abspath $(TOP)/../inplace/bin/ghc-stage3)
ifneq "$(wildcard $(NEW_BUILD_SYSTEM_STAGE1_GHC))" ""
67

68 69 70 71 72 73 74 75 76
ifeq "$(stage)" "1"
TEST_HC := $(NEW_BUILD_SYSTEM_STAGE1_GHC)
else
ifeq "$(stage)" "3"
TEST_HC := $(NEW_BUILD_SYSTEM_STAGE3_GHC)
else
# use stage2 by default
TEST_HC := $(NEW_BUILD_SYSTEM_STAGE2_GHC)
endif
77
endif
78

79 80 81 82 83 84
else
TEST_HC := $(shell which ghc)
endif

endif
endif
85

86 87 88
ifeq "$(GHC_PKG)" ""
GHC_PKG := $(dir $(TEST_HC))/ghc-pkg
endif
89

90 91 92 93
ifeq "$(HP2PS_ABS)" ""
HP2PS_ABS := $(dir $(TEST_HC))/hp2ps
endif

94
ifeq "$(wildcard $(TEST_HC) $(TEST_HC).exe)" ""
Ian Lynagh's avatar
Ian Lynagh committed
95
$(error Cannot find ghc: $(TEST_HC))
96
endif
97

98
ifeq "$(wildcard $(GHC_PKG) $(GHC_PKG).exe)" ""
Ian Lynagh's avatar
Ian Lynagh committed
99
$(error Cannot find ghc-pkg: $(GHC_PKG))
100
endif
101

102
ifeq "$(wildcard $(HP2PS_ABS) $(HP2PS_ABS).exe)" ""
Ian Lynagh's avatar
Ian Lynagh committed
103
$(error Cannot find hp2ps: $(HP2PS_ABS))
104 105
endif

106 107 108 109 110
$(eval $(call get-ghc-field,GhcRTSWays,RTS ways))

GS = gs
CP = cp
RM = rm -f
111
PYTHON = python
112