diff options
Diffstat (limited to 'rules')
39 files changed, 0 insertions, 2835 deletions
diff --git a/rules/add-dependency.mk b/rules/add-dependency.mk deleted file mode 100644 index 1b5a666e86..0000000000 --- a/rules/add-dependency.mk +++ /dev/null @@ -1,15 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (c) 2010 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 -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - -define add-dependency -$1: $2 -endef diff --git a/rules/all-target.mk b/rules/all-target.mk deleted file mode 100644 index 52fbc02b1e..0000000000 --- a/rules/all-target.mk +++ /dev/null @@ -1,18 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (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 -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - -define all-target # args: $1 = dir, $2 = deps -all : all_$1 -.PHONY: all_$1 -all_$1 : $2 -endef - diff --git a/rules/bindist.mk b/rules/bindist.mk deleted file mode 100644 index af3b144222..0000000000 --- a/rules/bindist.mk +++ /dev/null @@ -1,32 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (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 -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - - -# Add files to the bindist-list. Invoke like this: -# -# $(eval $(call bindist-list,utils/genapply,ghc.mk)) - -define bindist-list -# $1 = name -# $2 = files - -.PHONY: bindist-list_$1 -bindist-list: bindist-list_$1 - -bindist-list_$1: - $(foreach i,$2,\ - $(call make-command,\ - for f in $i; do echo $(BIN_DIST_NAME)/$$$$f >> bindist-list; done \ - ) \ - ) -endef - diff --git a/rules/build-dependencies.mk b/rules/build-dependencies.mk deleted file mode 100644 index cc438c80eb..0000000000 --- a/rules/build-dependencies.mk +++ /dev/null @@ -1,161 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (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 -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - -define build-dependencies -$(call trace, build-dependencies($1,$2,$3)) -$(call profStart, build-dependencies($1,$2,$3)) -# $1 = dir -# $2 = distdir -# $3 = GHC stage to use (0 == bootstrapping compiler) - -$1_$2_depfile_haskell = $$($1_$2_depfile_base).haskell -$1_$2_depfile_c_asm = $$($1_$2_depfile_base).c_asm - -$1_$2_C_FILES_DEPS = $$(filter-out $$($1_$2_C_FILES_NODEPS),$$($1_$2_C_FILES)) -$1_$2_CXX_FILES_DEPS = $$(filter-out $$($1_$2_CXX_FILES_NODEPS),$$($1_$2_CXX_FILES)) - -$1_$2_MKDEPENDHS_FLAGS = -dep-makefile $$($1_$2_depfile_haskell).tmp $$(foreach way,$$($1_$2_WAYS),-dep-suffix "$$(patsubst %o,%,$$($$(way)_osuf))") -$1_$2_MKDEPENDHS_FLAGS += -include-pkg-deps -$1_$2_MKDEPENDHS_FLAGS += $(addprefix -I,$($1_INCLUDE_DIRS)) - -ifneq "$$(NO_GENERATED_MAKEFILE_RULES)" "YES" - -# Some of the Haskell files (e.g. utils/hsc2hs/Main.hs) (directly or -# indirectly) include the generated includes files. -$$($1_$2_depfile_haskell) : $$(includes_$3_H_CONFIG) $$(includes_$3_H_PLATFORM) - -$$($1_$2_depfile_haskell) : $$($1_$2_HS_SRCS) $$($1_$2_HS_BOOT_SRCS) $$$$($1_$2_HC_MK_DEPEND_DEP) | $$$$(dir $$$$@)/. - $$(call removeFiles,$$@.tmp) -ifneq "$$($1_$2_HS_SRCS)" "" - "$$($1_$2_HC_MK_DEPEND)" -M \ - $$($1_$2_$$(firstword $$($1_$2_WAYS))_MOST_DIR_HC_OPTS) \ - $$($1_$2_MKDEPENDHS_FLAGS) \ - $$($1_$2_HS_SRCS) -endif - echo "$1_$2_depfile_haskell_EXISTS = YES" >> $$@.tmp -ifneq "$$($1_$2_SLASH_MODS)" "" - for dir in $$(sort $$(foreach mod,$$($1_$2_SLASH_MODS),$1/$2/build/$$(dir $$(mod)))); do \ - if test ! -d $$$$dir; then mkdir -p $$$$dir; fi \ - done -endif -# Some packages are from the bootstrapping compiler, so are not -# within the build tree. On Windows this causes a problem as they look -# like bad rules, due to the two colons, so we filter them out. - grep -v ' : [a-zA-Z]:/' $$@.tmp > $$@.tmp2 -# Insert the calls to hi-rule. Basically, we look for the -# Foo.dyn_o Foo.o : Foo.hs -# lines, and create corresponding hi-rule lines -# <dollar>(eval <dollar>(call hi-rule,Foo.dyn_hi Foo.hi : %hi: %o Foo.hs)) - sed -e '/hs$$$$/ p' -e '/hs$$$$/ s/o /hi /g' \ - -e '/hs$$$$/ s/:/ : %hi: %o /' \ - -e '/hs$$$$/ s/^/$$$$(eval $$$$(call hi-rule,/' \ - -e '/hs$$$$/ s/$$$$/))/' \ - -e '/hs-boot$$$$/ p' -e '/hs-boot$$$$/ s/o-boot /hi-boot /g' \ - -e '/hs-boot$$$$/ s/:/ : %hi-boot: %o-boot /' \ - -e '/hs-boot$$$$/ s/^/$$$$(eval $$$$(call hi-rule,/' \ - -e '/hs-boot$$$$/ s/$$$$/))/' \ - $$@.tmp2 > $$@ -# Some of the C files (directly or indirectly) include the generated -# includes files. -$$($1_$2_depfile_c_asm) : $$(includes_$3_H_CONFIG) $$(includes_$3_H_PLATFORM) - -$$($1_$2_depfile_c_asm) : $$($1_$2_C_FILES_DEPS) $$($1_$2_CXX_FILES_DEPS) $$($1_$2_S_FILES) $$($1_$2_CMM_FILES) | $$$$(dir $$$$@)/. - $$(call removeFiles,$$@.tmp) -ifneq "$$(strip $$($1_$2_C_FILES_DEPS) $$($1_$2_CXX_FILES_DEPS) $$($1_$2_S_FILES)) $$($1_$2_CMM_FILES))" "" -# We ought to actually do this for each way in $$($1_$2_WAYS), but then -# it takes a long time to make the C deps for the RTS (30 seconds rather -# than 3), so instead we just pass the list of ways in and let addCFileDeps -# copy the deps for each way on the assumption that they are the same - $$(foreach f,$$($1_$2_C_FILES_DEPS) $$($1_$2_S_FILES) $$($1_$2_CMM_FILES), \ - $$(call addCFileDeps,$1,$2,$$($1_$2_depfile_c_asm),$$f,$$($1_$2_WAYS),"c")) - $$(foreach f,$$($1_$2_CXX_FILES_DEPS), \ - $$(call addCFileDeps,$1,$2,$$($1_$2_depfile_c_asm),$$f,$$($1_$2_WAYS),"c++")) - $$(call removeFiles,$$@.bit) -endif - echo "$1_$2_depfile_c_asm_EXISTS = YES" >> $$@.tmp - mv $$@.tmp $$@ - -endif # NO_GENERATED_MAKEFILE_RULES - -# Note sed magic above: mkdependC can't do -odir stuff, so we have to -# munge the dependencies it generates to refer to the correct targets. - -$(call profEnd, build-dependencies($1,$2,$3)) -endef - -# This comment is outside the "define addCFileDeps" as that definition -# is a list of command lines, and if it is inside it then we pass this -# comment to the shell every time we call the definition. -# $1 = dir -# $2 = distdir -# $3 = depfile -# $4 = file -# $5 = ways -# $6 = lang (c or c++) -# -# The formatting of this definition (e.g. the blank line above) is -# important, in order to get make to generate the right makefile code. -# -# 's|\\|/|g' -# We first normalise all slashes to be forward slashes. Note that -# $(TOP) also uses forward slashes. -# 's| /$$| \\|' -# But now we need to fix the line continuation characters that we -# just broke. -# "1s|\.o|\.$($w_osuf)|" -# We will have dependencies for .o files, so we need to fix them up -# for the right object suffix for the way we're doing -# "1s|^|$(dir $4)|" -# We always get deps for just foo.o when the file we're making is -# a/b/c/foo.o, so we need to prepend the directory of the source file -# "1s|$1/|$1/$2/build/|" -# Well, almost. We actually need to insert e.g. "dist/build" in the -# middle of that directory -# "1s|$2/build/$2/build|$2/build|g" -# But some source files, e.g. sm/Evac_thr.c, are also inside the -# "dist/build" directory, so now we've just made -# "dist/build/dist/build", so we need to remove the duplication -# again -# "s|$(TOP)/||g$(CASE_INSENSITIVE_SED)" -# Finally, when making deps for packages like ghc stage2, we have -# some include paths for packages registered in the in-tree package -# database. These include paths are full (i.e. not relative) paths, -# which means that the "cpp -MM" output uses full paths in some cases. -# This causes 2 problems: -# * they don't match up with the rules to rebuild the files, where -# appropriate. -# * on Windows, make interprets the colon in c:/foo/bar.h as make -# syntax. -# So we sed off $(TOP). Unfortunately, on Windows, the case for the -# drive letter is sometimes different in what $(TOP) starts with, and -# what the path in the package database starts with. We therefore -# need to do the substitution case-insensitively on Windows. But -# the s///i modifier isn't portable, so we set CASE_INSENSITIVE_SED -# to "i" on Windows and "" on any other platform. - -# We use this not only for .c files, but also for .S and .cmm files. -# As gcc doesn't know what a .cmm file is, it treats it as a linker -# input and ignores it. We therefore tell gcc that all files are C -# files with "-x c" so that it actually processes them all. - -define addCFileDeps - - $(CPP) $($1_$2_MKDEPENDC_OPTS) $($1_$2_$(firstword $($1_$2_WAYS))_ALL_CC_OPTS) $($(basename $4)_CC_OPTS) -MM -x $6 $4 -MF $3.bit - $(foreach w,$5,sed -e 's|\\|/|g' -e 's| /$$| \\|' -e "1s|\.o|\.$($w_osuf)|" -e "1s|^|$(dir $4)|" -e "1s|$1/|$1/$2/build/|" -e "1s|$2/build/$2/build|$2/build|g" -e "s|^$(TOP)/||g$(CASE_INSENSITIVE_SED)" $3.bit >> $3.tmp &&) true -endef - -ifeq "$(Windows_Host)" "YES" -CASE_INSENSITIVE_SED = i -else -CASE_INSENSITIVE_SED = -endif - diff --git a/rules/build-package-data.mk b/rules/build-package-data.mk deleted file mode 100644 index a8c9c12823..0000000000 --- a/rules/build-package-data.mk +++ /dev/null @@ -1,145 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (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 -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - -define build-package-data -$(call trace, build-package-data($1,$2,$3)) -$(call profStart, build-package-data($1,$2,$3)) -# args: -# $1 = dir -# $2 = distdir -# $3 = GHC stage to use (0 == bootstrapping compiler) - -ifeq "$(V)" "0" -$1_$2_CONFIGURE_OPTS += -v0 --configure-option=--quiet - -# Cabal always passes --with-compiler and --with-gcc to library configure -# scripts, resulting in the following useless (for us) warning in the logs: -# "configure: WARNING: unrecognized options: --with-compiler, --with-gcc" -$1_$2_CONFIGURE_OPTS += --configure-option=--disable-option-checking - -$1_$2_GHC_PKG_OPTS += -v0 -endif - -$1_$2_CONFIGURE_OPTS += --disable-library-for-ghci -ifeq "$$(filter v,$$($1_$2_WAYS))" "v" -$1_$2_CONFIGURE_OPTS += --enable-library-vanilla -# Build the GHCi lib even if GHCi is dynamic (and therefore won't use -# these by default), because they will be used by -# (a) ghci -fexternal-interpreter -# (b) statically-linked binaries that use the GHC package -ifeq "$$(GhcWithInterpreter)" "YES" -$1_$2_CONFIGURE_OPTS += --enable-library-for-ghci -endif -else -$1_$2_CONFIGURE_OPTS += --disable-library-vanilla -endif - -ifeq "$$(filter p,$$($1_$2_WAYS))" "p" -$1_$2_CONFIGURE_OPTS += --enable-library-profiling -else -$1_$2_CONFIGURE_OPTS += --disable-library-profiling -endif - -ifeq "$$(filter dyn,$$($1_$2_WAYS))" "dyn" -$1_$2_CONFIGURE_OPTS += --enable-shared -else -$1_$2_CONFIGURE_OPTS += --disable-shared -endif - -ifeq "$$(HSCOLOUR_SRCS)" "YES" -$1_$2_CONFIGURE_OPTS += --with-hscolour="$$(HSCOLOUR_CMD)" -endif - -# We filter out -Werror from SRC_CC_OPTS, because when configure tests -# for a feature it may not generate warning-free C code, and thus may -# think that the feature doesn't exist if -Werror is on. -# -# Do `-iquote $(TOP)/$1` so package configure scripts can access their own source. -$1_$2_CONFIGURE_CFLAGS = $$(filter-out -Werror,$$(SRC_CC_OPTS)) $$(CONF_CC_OPTS_STAGE$3) $$($1_CC_OPTS) $$($1_$2_CC_OPTS) $$(SRC_CC_WARNING_OPTS) -iquote $(TOP)/$1 -$1_$2_CONFIGURE_LDFLAGS = $$(SRC_LD_OPTS) $$($1_LD_OPTS) $$($1_$2_LD_OPTS) -$1_$2_CONFIGURE_CPPFLAGS = $$(SRC_CPP_OPTS) $$(CONF_CPP_OPTS_STAGE$3) $$($1_CPP_OPTS) $$($1_$2_CPP_OPTS) - -$1_$2_CONFIGURE_OPTS += --configure-option=CFLAGS="$$($1_$2_CONFIGURE_CFLAGS)" -$1_$2_CONFIGURE_OPTS += --configure-option=LDFLAGS="$$($1_$2_CONFIGURE_LDFLAGS)" -$1_$2_CONFIGURE_OPTS += --configure-option=CPPFLAGS="$$($1_$2_CONFIGURE_CPPFLAGS)" - -# Also pass these as gcc-options, because Cabal uses them to check for -# the existence of foreign libraries. -$1_$2_CONFIGURE_OPTS += --gcc-options="$$($1_$2_CONFIGURE_CFLAGS) $$($1_$2_CONFIGURE_LDFLAGS)" - -ifneq "$$(ICONV_INCLUDE_DIRS)" "" -$1_$2_CONFIGURE_OPTS += --configure-option=--with-iconv-includes="$$(ICONV_INCLUDE_DIRS)" -endif - -ifneq "$$(ICONV_LIB_DIRS)" "" -$1_$2_CONFIGURE_OPTS += --configure-option=--with-iconv-libraries="$$(ICONV_LIB_DIRS)" -endif - -ifneq "$$(GMP_INCLUDE_DIRS)" "" -$1_$2_CONFIGURE_OPTS += --configure-option=--with-gmp-includes="$$(GMP_INCLUDE_DIRS)" -endif - -ifneq "$$(GMP_LIB_DIRS)" "" -$1_$2_CONFIGURE_OPTS += --configure-option=--with-gmp-libraries="$$(GMP_LIB_DIRS)" -endif - -ifeq "$$(GMP_PREFER_FRAMEWORK)" "YES" -$1_$2_CONFIGURE_OPTS += --configure-option=--with-gmp-framework-preferred -endif - -ifeq "$$(GMP_FORCE_INTREE)" "YES" -$1_$2_CONFIGURE_OPTS += --configure-option=--with-intree-gmp -endif - -ifeq "$$(GMP_ENABLED)" "YES" -$1_$2_CONFIGURE_OPTS += --configure-option=--with-gmp -endif - - -ifneq "$$(CURSES_LIB_DIRS)" "" -$1_$2_CONFIGURE_OPTS += --configure-option=--with-curses-libraries="$$(CURSES_LIB_DIRS)" -endif - -$1_$2_CONFIGURE_OPTS += --configure-option=--host=$(TargetPlatformFull) - -ifeq "$3" "0" -$1_$2_CONFIGURE_OPTS += $$(BOOT_PKG_CONSTRAINTS) -endif - -$1_$2_CONFIGURE_OPTS += --with-gcc="$$(CC_STAGE$3)" -$1_$2_CONFIGURE_OPTS += --with-ld="$$(LD_STAGE$3)" -$1_$2_CONFIGURE_OPTS += --with-ar="$$(AR_STAGE$3)" -$1_$2_CONFIGURE_OPTS += $$(if $$(ALEX),--with-alex="$$(ALEX)") -$1_$2_CONFIGURE_OPTS += $$(if $$(HAPPY),--with-happy="$$(HAPPY)") - -$1_$2_PKGDATA = $1/$2/package-data.mk - -ifneq "$$(BINDIST)" "YES" -ifneq "$$(NO_GENERATED_MAKEFILE_RULES)" "YES" -$1/$2/inplace-pkg-config : $$($1_$2_PKGDATA) -$1/$2/build/$$(or $$($1_EXECUTABLE),$$($1_$2_PROGNAME),.)/autogen/cabal_macros.h : $$($1_$2_PKGDATA) - -# This rule configures the package, generates the package-data.mk file -# for our build system, and registers the package for use in-place in -# the build tree. -$$($1_$2_PKGDATA) : $$$$(ghc-cabal_INPLACE) $$($1_$2_GHC_PKG_DEP) $1/$$($1_PACKAGE).cabal $$(wildcard $1/configure) $$(LAX_DEPS_FOLLOW) $$$$($1_$2_HC_CONFIG_DEP) - "$$(ghc-cabal_INPLACE)" configure $1 $2 --with-ghc="$$($1_$2_HC_CONFIG)" --with-ghc-pkg="$$($1_$2_GHC_PKG)" $$($1_CONFIGURE_OPTS) $$($1_$2_CONFIGURE_OPTS) -ifeq "$$($1_$2_PROG)" "" - $$(call cmd,$1_$2_GHC_PKG) update -v0 --force $$($1_$2_GHC_PKG_OPTS) $1/$2/inplace-pkg-config -endif -endif # NO_GENERATED_MAKEFILE_RULES -endif # BINDIST - -PACKAGE_DATA_MKS += $$($1_$2_PKGDATA) - -$(call profEnd, build-package-data($1,$2,$3)) -endef diff --git a/rules/build-package-way.mk b/rules/build-package-way.mk deleted file mode 100644 index 2f7af28ecb..0000000000 --- a/rules/build-package-way.mk +++ /dev/null @@ -1,151 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (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 -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - - -define build-package-way # $1 = dir, $2 = distdir, $3 = way, $4 = stage -$(call trace, build-package-way($1,$2,$3)) -$(call profStart, build-package-way($1,$2,$3)) - -$(call distdir-way-opts,$1,$2,$3,$4) -$(call hs-suffix-way-rules,$1,$2,$3) - -$(call hs-objs,$1,$2,$3) - -# The .a/.so library file, indexed by two different sets of vars: -# the first is indexed by the dir, distdir and way -# the second is indexed by the package id, distdir and way -$1_$2_$3_LIB_FILE = libHS$$($1_$2_COMPONENT_ID)$(subst .,%,$$($3_libsuf)) -$1_$2_$3_LIB = $1/$2/build/$$($1_$2_$3_LIB_FILE) -$$($1_$2_COMPONENT_ID)_$2_$3_LIB = $$($1_$2_$3_LIB) - -# Note [inconsistent distdirs] -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# hack: the DEPS_LIBS mechanism assumes that the distdirs for packages -# that depend on each other are the same, but that is not the case for -# ghc where we use stage1/stage2 rather than dist/dist-install. -# Really we should use a consistent scheme for distdirs, but in the -# meantime we work around it by defining ghc-<ver>_dist-install_way_LIB: -# -# A similar hack is applied to the PROGRAM_DEP_LIB mechanism in -# rules/build-package.mk. -ifeq "$$($1_PACKAGE) $2" "ghc stage2" -$$($1_$2_COMPONENT_ID)_dist-install_$3_LIB = $$($1_$2_$3_LIB) -endif - -# All the .a/.so library file dependencies for this library. -# -# The $(subst stage2,dist-install,..) is needed due to Note -# [inconsistent distdirs]. -# -# NB: Use DEP_COMPONENT_IDS for the /directory/ parameter. -$1_$2_$3_DEPS_LIBS=$$(foreach dep,$$($1_$2_DEP_COMPONENT_IDS),$$($$(dep)_$(subst stage2,dist-install,$2)_$3_LIB)) - -$1_$2_$3_NON_HS_OBJS = $$($1_$2_$3_CMM_OBJS) $$($1_$2_$3_C_OBJS) $$($1_$2_$3_CXX_OBJS) $$($1_$2_$3_S_OBJS) $$($1_$2_EXTRA_OBJS) -$1_$2_$3_ALL_OBJS = $$($1_$2_$3_HS_OBJS) $$($1_$2_$3_NON_HS_OBJS) - -ifeq "$3" "dyn" - -# Link a dynamic library -# On windows we have to supply the extra libs this one links to when building it. -ifeq "$$(TargetOS_CPP)" "mingw32" -$$($1_$2_$3_LIB) : $$($1_$2_$3_ALL_OBJS) $$(ALL_RTS_LIBS) $$($1_$2_$3_DEPS_LIBS) - $$(call build-dll,$1,$2,$3,-L$1/$2/build,,$$($1_$2_$3_HS_OBJS) $$($1_$2_$3_NON_HS_OBJS),"$$@","NO","$$($1_PACKAGE)","$$($1_$2_VERSION)") - -else # ifneq "$$(TargetOS_CPP)" "mingw32" -$$($1_$2_$3_LIB) : $$($1_$2_$3_ALL_OBJS) $$(ALL_RTS_LIBS) $$($1_$2_$3_DEPS_LIBS) - $$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) $$($1_$2_$3_GHC_LD_OPTS) $$($1_$2_$3_ALL_OBJS) \ - -shared -dynamic -dynload deploy \ - $$(addprefix -l,$$($1_$2_EXTRA_LIBRARIES)) $$(addprefix -L,$$($1_$2_EXTRA_LIBDIRS)) \ - -no-auto-link-packages \ - -o $$@ -endif # "$$(TargetOS_CPP)" "mingw32" - -else # ifneq "$3" "dyn" - -# Build the ordinary .a library -$$($1_$2_$3_LIB) : $$($1_$2_$3_ALL_OBJS) - $$(call removeFiles,$$@ $$@.contents) - echo $$($1_$2_$3_ALL_OBJS) >> $$@.contents -ifeq "$$($1_$2_ArSupportsAtFile)" "YES" - $$(call cmd,$1_$2_AR) $$($1_$2_AR_OPTS) $$($1_$2_EXTRA_AR_ARGS) $$@ @$$@.contents -else - "$$(XARGS)" $$(XARGS_OPTS) "$$($1_$2_AR)" $$($1_$2_AR_OPTS) $$($1_$2_EXTRA_AR_ARGS) $$@ < $$@.contents -endif - $$(call removeFiles,$$@.contents) - -endif # "$3" "dyn" - -$(call all-target,$1_$2,all_$1_$2_$3) -$(call all-target,$1_$2_$3,$$($1_$2_$3_LIB)) - -# Don't put bootstrapping packages in the bindist -ifneq "$4" "0" -BINDIST_HI += $$($1_$2_$3_HI) -BINDIST_LIBS += $$($1_$2_$3_LIB) -# Need to put the split libs and import libraries here -endif - -ifeq "$$($1_$2_SplitSections)" "YES" -ifeq "$(LdIsGNULd)" "YES" -ifeq "$$(HostOS_CPP)" "mingw32" -$1_$2_LD_SCRIPT_CMD = -$1_$2_LD_SCRIPT = driver/utils/merge_sections_pe.ld -else -$1_$2_LD_SCRIPT_CMD = -T -$1_$2_LD_SCRIPT = driver/utils/merge_sections.ld -endif -endif -endif - -# Build the GHCi library -# See Note [Merging object files for GHCi] in GHC.Driver.Pipeline. -ifneq "$(filter $3, v p)" "" -$1_$2_$3_GHCI_LIB = $1/$2/build/HS$$($1_$2_COMPONENT_ID).$$($3_osuf) -ifeq "$$($1_$2_BUILD_GHCI_LIB)" "YES" -# Don't put bootstrapping packages in the bindist -ifneq "$4" "0" -BINDIST_LIBS += $$($1_$2_$3_GHCI_LIB) -endif -endif -$$($1_$2_$3_GHCI_LIB) : $$($1_$2_$3_HS_OBJS) $$($1_$2_$3_CMM_OBJS) $$($1_$2_$3_C_OBJS) $$($1_$2_$3_CXX_OBJS) $$($1_$2_$3_S_OBJS) $$($1_$2_EXTRA_OBJS) $$($1_$2_LD_SCRIPT) - $$(call cmd,MERGE_OBJS_STAGE$4) $(MERGE_OBJS_STAGE$4_FLAGS) $$(if $$($1_$2_LD_SCRIPT),$$($1_$2_LD_SCRIPT_CMD) $$($1_$2_LD_SCRIPT)) -o $$@ $$(EXTRA_LD_LINKER_OPTS) $$($1_$2_$3_HS_OBJS) $$($1_$2_$3_CMM_OBJS) $$($1_$2_$3_C_OBJS) $$($1_$2_$3_CXX_OBJS) $$($1_$2_$3_S_OBJS) $$($1_$2_EXTRA_OBJS) -ifeq "$$($1_$2_BUILD_GHCI_LIB)" "YES" -# Don't bother making ghci libs for bootstrapping packages -ifneq "$4" "0" -$(call all-target,$1_$2,$$($1_$2_$3_GHCI_LIB)) -endif -endif # "$$($1_$2_BUILD_GHCI_LIB)" "YES" -endif # "$(filter $3, v p)" "" - -$(call profEnd, build-package-way($1,$2,$3)) -endef # build-package-way - -define build-dll -# Call out to the shell script to decide how to build the util dll. -# 1 = dir -# 2 = distdir -# 3 = way -# 4 = extra flags -# 5 = extra libraries to link -# 6 = object files to link -# 7 = output filename -# 8 = link command -# 9 = create delay load import lib -# 10 = SxS Name -# 11 = SxS Version -$(gen-dll_INPLACE) link "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$(call cmd,$1_$2_HC) $(subst -no-hs-main,,$($1_$2_$3_ALL_HC_OPTS) $($1_$2_$3_GHC_LD_OPTS)) \ - -shared -dynamic -dynload deploy \ - $(addprefix -l,$($1_$2_EXTRA_LIBRARIES)) \ - -no-auto-link-packages" "$8" \ - "$9" "${10}" -endef - diff --git a/rules/build-package.mk b/rules/build-package.mk deleted file mode 100644 index 12381d8892..0000000000 --- a/rules/build-package.mk +++ /dev/null @@ -1,171 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (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 -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - - -# Build a package with the stage-1 compiler, multiple ways. A typical -# libraries/foo/ghc.mk will look like this: -# -# $(eval $(call build-package,libraries/base,dist-install)) -# -# The package metadata is generated from the .cabal file and placed in -# package-data.mk. It will look something like this: -# -# libraries/base_dist_MODULES = GHC.Base Data.Tuple ... -# libraries/base_dist_PACKAGE = base -# libraries/base_dist_VERSION = 4.0.0.0 -# libraries/base_dist_HC_OPTS = -package ghc-prim-0.1.0.0 -XRank2Types ... -# libraries/base_dist_C_SRCS = cbits/PrelIOUtils.c ... -# libraries/base_dist_S_SRCS = cbits/foo.S ... -# libraries/base_dist_CC_OPTS = -Iinclude ... -# libraries/base_dist_LD_OPTS = -package ghc-prim-0.1.0.0 - -define build-package -$(call trace, build-package($1,$2,$3)) -$(call profStart, build-package($1,$2,$3)) -# $1 = dir -# $2 = distdir -# $3 = GHC stage to use (0 == bootstrapping compiler) - -ifeq "$$(findstring $3,0 1 2)" "" -$$(error $1/$2: stage argument to build-package should be 0, 1, or 2) -endif - -$(call clean-target,$1,$2,$1/$2) - -distclean : clean_$1_$2_config - -.PHONY: clean_$1_$2_config -clean_$1_$2_config: - $$(call removeFiles,$1/config.log $1/config.status $(wildcard $1/include/Hs*Config.h)) - $$(call removeTrees,$1/autom4te.cache) - -ifneq "$$($1_$2_NOT_NEEDED)" "YES" -$$(eval $$(call build-package-helper,$1,$2,$3)) -endif -$(call profEnd, build-package($1,$2,$3)) -endef - - -define build-package-helper -# $1 = dir -# $2 = distdir -# $3 = GHC stage to use (0 == bootstrapping compiler) - -# --- CONFIGURATION - -$(call package-config,$1,$2,$3) - -ifeq "$3" "1" -$$($1_PACKAGE)_INSTALL_INFO = $1_$2 -endif - -# Bootstrapping libs are only built one way -ifeq "$3" "0" -$1_$2_WAYS = v -else -$1_$2_WAYS = $$(filter-out $$($1_$2_EXCLUDED_WAYS),$$(GhcLibWays)) -endif - -$1_$2_DYNAMIC_TOO = NO -ifneq "$$(DYNAMIC_TOO)" "NO" -ifneq "$$(filter v,$$($1_$2_WAYS))" "" -ifneq "$$(filter dyn,$$($1_$2_WAYS))" "" -$1_$2_DYNAMIC_TOO = YES -endif -endif -endif - -# We must use a different dependency file if $(GhcLibWays) changes, so -# encode the ways into the name of the file. -$1_$2_WAYS_DASHED = $$(subst $$(space),,$$(patsubst %,-%,$$(strip $$($1_$2_WAYS)))) -$1_$2_depfile_base = $1/$2/build/.depend$$($1_$2_WAYS_DASHED) - -$(call build-package-data,$1,$2,$3) -ifneq "$$(NO_INCLUDE_PKGDATA)" "YES" -ifeq "$3" "0" -include $1/$2/package-data.mk -else ifeq "$(phase)" "final" -include $1/$2/package-data.mk -endif -# Each Haskell compilation in this package will depend on the -# package-data.mk file because e.g. if the version of the package -# changes we need to recompile everything in it. -$1_$2_PKGDATA_DEP = $$($1_$2_PKGDATA) -endif - -$(call hs-sources,$1,$2) -$(call c-sources,$1,$2) -$(call includes-sources,$1,$2) -$(call distdir-opts,$1,$2,$3) - -$(call dependencies,$1,$2,$3) - -# Now generate all the build rules for each way in this directory: -$$(foreach way,$$($1_$2_WAYS),$$(eval \ - $$(call c-objs,$1,$2,$$(way)) \ - $$(call c-suffix-rules,$1,$2,$$(way),YES) \ - $$(call cxx-suffix-rules,$1,$2,$$(way),YES) \ - $$(call cmm-objs,$1,$2,$$(way)) \ - $$(call cmm-suffix-rules,$1,$2,$$(way)) \ - $$(call build-package-way,$1,$2,$$(way),$3) \ - )) - -# Programs will need to depend on either the vanilla lib (if -static -# is the default) or the dyn lib (if -dynamic is the default). We -# conservatively make them depend on both, to keep things simple. -# If dyn libs are not being built then $$($1_$2_dyn_LIB) will just -# expand to the empty string, and be ignored. -$1_$2_PROGRAM_DEP_LIB = $$($1_$2_v_LIB) $$($1_$2_dyn_LIB) -$$($1_$2_COMPONENT_ID)_$2_PROGRAM_DEP_LIB = $$($1_$2_PROGRAM_DEP_LIB) - -# See Note [inconsistent distdirs] in rules/build-package-way.mk. -ifeq "$$($1_PACKAGE) $2" "ghc stage1" -$$($1_$2_COMPONENT_ID)_dist-boot_PROGRAM_DEP_LIB = $$($1_$2_PROGRAM_DEP_LIB) -endif -ifeq "$$($1_PACKAGE) $2" "ghc stage2" -$$($1_$2_COMPONENT_ID)_dist-install_PROGRAM_DEP_LIB = $$($1_$2_PROGRAM_DEP_LIB) -endif - -# C and S files are possibly built the "dyn" way. -ifeq "$$(BuildSharedLibs)" "YES" -$(call c-objs,$1,$2,dyn) -$(call c-suffix-rules,$1,$2,dyn,YES) -$(call cxx-suffix-rules,$1,$2,dyn,YES) -$(call cmm-objs,$1,$2,dyn) -$(call cmm-suffix-rules,$1,$2,dyn,YES) -endif -$$(foreach dir,$$($1_$2_HS_SRC_DIRS),\ - $$(eval $$(call hs-suffix-rules-srcdir,$1,$2,$$(dir)))) - -$(call all-target,$1,all_$1_$2) -# This give us things like -# all_libraries: all_libraries/base_dist-install -ifneq "$$($1_$2_GROUP)" "" -all_$$($1_$2_GROUP): all_$1_$2 -endif - -ifneq "$3" "0" -$(call haddock,$1,$2) -endif - -# Don't put bootstrapping packages in the bindist -# -# See Note [inconsistent distdirs] in rules/build-package-way.mk for why -# we hard-code dist-install; GHC will use stage2/stage3 here so we -# cannot use the distdir parameter. -ifneq "$3" "0" -BINDIST_EXTRAS += $1/*.cabal $$(wildcard $1/*.buildinfo) $$(wildcard $1/dist-install/build/*.buildinfo) $1/$2/setup-config $1/LICENSE -BINDIST_EXTRAS += $$($1_$2_INSTALL_INCLUDES_SRCS) -endif - -endef - diff --git a/rules/build-prog.mk b/rules/build-prog.mk deleted file mode 100644 index 8d2bcd25c5..0000000000 --- a/rules/build-prog.mk +++ /dev/null @@ -1,336 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (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 -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - - -# Build a program. -# -# $(eval $(call build-prog,utils/genapply,dist-install,1)) - -define build-prog -$(call trace, build-prog($1,$2,$3)) -$(call profStart, build-prog($1,$2,$3)) -# $1 = dir -# $2 = distdir -# $3 = GHC stage to use (0 == bootstrapping compiler) - -ifeq "$$($1_$2_PROGNAME)" "" -$$(error $1_$2_PROGNAME is not set) -endif -ifneq "$$($1_$2_PROG)" "" -$$(error $1_$2_PROG is set) -endif -$1_$2_PROG = $$($1_$2_PROGNAME)$$(exeext$3) - -ifeq "$$(findstring $3,0 1 2)" "" -$$(error $1/$2: stage argument to build-prog should be 0, 1, or 2) -endif - -$(call clean-target,$1,$2,$1/$2) - -$$(eval $$(call build-prog-vars,$1,$2,$3)) - -ifneq "$$($1_$2_NOT_NEEDED)" "YES" -$$(eval $$(call build-prog-helper,$1,$2,$3)) -endif -$(call profEnd, build-prog($1,$2,$3)) -endef - - - - - -define build-prog-vars -# $1 = dir -# $2 = distdir -# $3 = GHC stage to use (0 == bootstrapping compiler) - -ifeq "$$($1_USES_CABAL)" "YES" -$1_$2_USES_CABAL = YES -endif - -ifeq "$$(Windows_Host)" "YES" -$1_$2_WANT_INPLACE_WRAPPER = NO -else ifneq "$$($1_$2_INSTALL_INPLACE)" "YES" -$1_$2_WANT_INPLACE_WRAPPER = NO -else ifeq "$$($1_$2_SHELL_WRAPPER)" "YES" -$1_$2_WANT_INPLACE_WRAPPER = YES -else ifeq "$$(DYNAMIC_GHC_PROGRAMS)" "YES" -$1_$2_WANT_INPLACE_WRAPPER = YES -else -$1_$2_WANT_INPLACE_WRAPPER = NO -endif - -ifeq "$$(Windows_Host)" "YES" -$1_$2_WANT_INSTALLED_WRAPPER = NO -else ifneq "$$($1_$2_INSTALL)" "YES" -$1_$2_WANT_INSTALLED_WRAPPER = NO -else ifeq "$$($1_$2_SHELL_WRAPPER)" "YES" -$1_$2_WANT_INSTALLED_WRAPPER = YES -else -$1_$2_WANT_INSTALLED_WRAPPER = NO -endif - -$1_$2_depfile_base = $1/$2/build/.depend - -ifeq "$$($1_$2_INSTALL_INPLACE)" "NO" -ifneq "$$(CLEANING)" "YES" -$1_$2_INPLACE = $$(error $1_$2 should not be installed inplace, but INPLACE var evaluated) -else -$1_$2_INPLACE = -endif -else -ifneq "$$($$($1_$2_PROGNAME)_INPLACE)" "" -$$(error $$($1_$2_PROGNAME)_INPLACE defined twice) -endif -# -# Where do we install the wrapper and the binary? -# $$($1_$2_PROGNAME)_INPLACE The thing we run (script or binary) -# $1_$2_INPLACE The binary -# -ifeq "$$($1_$2_TOPDIR)" "YES" -$$($1_$2_PROGNAME)_INPLACE = $$(INPLACE_LIB)/bin/$$($1_$2_PROG) -ifeq "$$($1_$2_WANT_INPLACE_WRAPPER)" "YES" -$1_$2_INPLACE = $$(INPLACE_LIB)/bin/$$($1_$2_PROG).bin -else -$1_$2_INPLACE = $$(INPLACE_LIB)/bin/$$($1_$2_PROG) -endif -else -$$($1_$2_PROGNAME)_INPLACE = $$(INPLACE_BIN)/$$($1_$2_PROG) -ifeq "$$($1_$2_WANT_INPLACE_WRAPPER)" "YES" -$1_$2_INPLACE = $$(INPLACE_LIB)/bin/$$($1_$2_PROG) -else -$1_$2_INPLACE = $$($$($1_$2_PROGNAME)_INPLACE) -endif -endif -endif - -endef - - - - - -define build-prog-helper -# $1 = dir -# $2 = distdir -# $3 = GHC stage to use (0 == bootstrapping compiler) - -$(call package-config,$1,$2,$3) - -ifeq "$$($1_$2_USES_CABAL)" "YES" -$(call build-package-data,$1,$2,$3) -ifneq "$$(NO_INCLUDE_PKGDATA)" "YES" -ifeq "$3" "0" -include $1/$2/package-data.mk -else ifeq "$(phase)" "final" -include $1/$2/package-data.mk -endif -endif -endif - -$(call all-target,$1,all_$1_$2) -$(call all-target,$1_$2,$1/$2/build/tmp/$$($1_$2_PROG)) - -$(call shell-wrapper,$1,$2) - -ifeq "$$($1_$2_PROGRAM_WAY)" "" -ifeq "$3" "0" -$1_$2_PROGRAM_WAY = v -else ifeq "$$(DYNAMIC_GHC_PROGRAMS)" "YES" -$1_$2_PROGRAM_WAY = dyn -else -$1_$2_PROGRAM_WAY = v -endif -endif - -$1_$2_WAYS = $$($1_$2_PROGRAM_WAY) - -$1_$2_DYNAMIC_TOO = NO - -$(call hs-sources,$1,$2) -$(call c-sources,$1,$2) - -# --- IMPLICIT RULES - -$(call distdir-opts,$1,$2,$3) -$(call distdir-way-opts,$1,$2,$$($1_$2_PROGRAM_WAY),$3) - -ifeq "$3" "0" -# For stage 0, we use GHC to compile C sources so that we don't have to -# worry about where the RTS header files are -$(call c-suffix-rules,$1,$2,$$($1_$2_PROGRAM_WAY),YES) -else -ifeq "$$($1_$2_UseGhcForCC)" "YES" -$(call c-suffix-rules,$1,$2,$$($1_$2_PROGRAM_WAY),YES) -else -$(call c-suffix-rules,$1,$2,$$($1_$2_PROGRAM_WAY),NO) -endif -endif - -$$(foreach dir,$$($1_$2_HS_SRC_DIRS),\ - $$(eval $$(call hs-suffix-rules-srcdir,$1,$2,$$(dir)))) -$(call hs-suffix-way-rules,$1,$2,$$($1_$2_PROGRAM_WAY)) - -$(call c-objs,$1,$2,$$($1_$2_PROGRAM_WAY)) -$(call hs-objs,$1,$2,$$($1_$2_PROGRAM_WAY)) - -$1_$2_LINK_WITH_GCC = NO - -ifeq "$$($1_$2_$$($1_$2_PROGRAM_WAY)_HS_OBJS)" "" -# We don't want to link the GHC RTS into C-only programs. There's no -# point, and it confuses the test that all GHC-compiled programs -# were compiled with the right GHC. -$1_$2_$$($1_$2_PROGRAM_WAY)_GHC_LD_OPTS += -no-auto-link-packages -no-hs-main -endif - -ifneq "$$(BINDIST)" "YES" - -# The quadrupled $'s here are because the _<way>_LIB variables aren't -# necessarily set when this part of the makefile is read -# -# See Note [inconsistent distdirs] in rules/build-package-way.mk for why -# we are computing the dist-dir from the GHC stage and not just using -# the distdir parameter. -$1/$2/build/tmp/$$($1_$2_PROG) $1/$2/build/tmp/$$($1_$2_PROG).dll : \ - $$(foreach dep,$$($1_$2_TRANSITIVE_DEP_COMPONENT_IDS),\ - $$$$($$(dep)_dist-$(if $(filter 0,$3),boot,install)_PROGRAM_DEP_LIB)) -# Workaround: We use TRANSITIVE_DEP_COMPONENT_IDS here as a workaround for -# #12078. - -$1_$2_PROG_NEEDS_C_WRAPPER = NO -$1_$2_PROG_INPLACE = $$($1_$2_PROG) -ifeq "$$(Windows_Host) $$($1_$2_PROGRAM_WAY)" "YES dyn" -ifneq "$$($1_$2_HS_SRCS)" "" -$1_$2_PROG_NEEDS_C_WRAPPER = YES -$1_$2_PROG_INPLACE = inplace-$$($1_$2_PROG) -endif -endif - -ifeq "$$($1_$2_PROG_NEEDS_C_WRAPPER)" "YES" - -$1_$2_RTS_OPTS_FLAG = $$(lastword $$(filter -rtsopts -rtsopts=all -rtsopts=some -rtsopts=none -no-rtsopts,$$($1_$2_$$($1_$2_PROGRAM_WAY)_ALL_HC_OPTS))) -ifeq "$$($1_$2_RTS_OPTS_FLAG)" "-rtsopts" -$1_$2_RTS_OPTS = RtsOptsAll -else ifeq "$$($1_$2_RTS_OPTS_FLAG)" "-rtsopts=all" -$1_$2_RTS_OPTS = RtsOptsAll -else ifeq "$$($1_$2_RTS_OPTS_FLAG)" "-rtsopts=some" -$1_$2_RTS_OPTS = RtsOptsSafeOnly -else ifeq "$$($1_$2_RTS_OPTS_FLAG)" "-rtsopts=none" -$1_$2_RTS_OPTS = RtsOptsNone -else ifeq "$$($1_$2_RTS_OPTS_FLAG)" "-no-rtsopts" -$1_$2_RTS_OPTS = RtsOptsNone -else -$1_$2_RTS_OPTS = RtsOptsSafeOnly -endif - -$1/$2/build/tmp/$$($1_$2_PROG)-inplace-wrapper.c: driver/utils/dynwrapper.c | $$$$(dir $$$$@)/. - $$(call removeFiles,$$@) - echo '#include <windows.h>' >> $$@ - echo '#include "Rts.h"' >> $$@ - echo 'LPTSTR path_dirs[] = {' >> $$@ - $$(foreach d,$$($1_$2_DEP_LIB_REL_DIRS),$$(call make-command,echo ' TEXT("/../../$$d")$$(comma)' >> $$@)) - echo ' TEXT("/../../$1/$2/build/tmp/"),' >> $$@ - echo ' NULL};' >> $$@ - echo 'LPTSTR progDll = TEXT("../../$1/$2/build/tmp/$$($1_$2_PROG).dll");' >> $$@ - echo 'LPTSTR rtsDll = TEXT("$$($$(WINDOWS_DYN_PROG_RTS))");' >> $$@ - echo 'int rtsOpts = $$($1_$2_RTS_OPTS);' >> $$@ - cat driver/utils/dynwrapper.c >> $$@ - -$1/$2/build/tmp/$$($1_$2_PROG)-wrapper.c: driver/utils/dynwrapper.c | $$$$(dir $$$$@)/. - $$(call removeFiles,$$@) - echo '#include <windows.h>' >> $$@ - echo '#include "Rts.h"' >> $$@ - echo 'LPTSTR path_dirs[] = {' >> $$@ - $$(foreach p,$$($1_$2_TRANSITIVE_DEP_COMPONENT_IDS),$$(call make-command,echo ' TEXT("/../lib/$$p")$$(comma)' >> $$@)) - echo ' TEXT("/../lib/"),' >> $$@ - echo ' NULL};' >> $$@ - echo 'LPTSTR progDll = TEXT("../lib/$$($1_$2_PROG).dll");' >> $$@ - echo 'LPTSTR rtsDll = TEXT("$$($$(WINDOWS_DYN_PROG_RTS))");' >> $$@ - echo 'int rtsOpts = $$($1_$2_RTS_OPTS);' >> $$@ - cat driver/utils/dynwrapper.c >> $$@ - -$1/$2/build/tmp/$$($1_$2_PROG_INPLACE) : $1/$2/build/tmp/$$($1_$2_PROG)-inplace-wrapper.c $1/$2/build/tmp/$$($1_$2_PROG).dll | $$$$(dir $$$$@)/. - $$(call cmd,$1_$2_HC) -no-hs-main -no-auto-link-packages -optc-g -optc-O0 $$< -o $$@ - -$1/$2/build/tmp/$$($1_$2_PROG) : $1/$2/build/tmp/$$($1_$2_PROG)-wrapper.c $1/$2/build/tmp/$$($1_$2_PROG).dll | $$$$(dir $$$$@)/. - $$(call cmd,$1_$2_HC) -no-hs-main -no-auto-link-packages -optc-g -optc-O0 $$< -o $$@ - -$1/$2/build/tmp/$$($1_$2_PROG).dll : $$($1_$2_$$($1_$2_PROGRAM_WAY)_HS_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_C_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_CXX_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_S_OBJS) $$($1_$2_OTHER_OBJS) | $$$$(dir $$$$@)/. - $$(call build-dll,$1,$2,$$($1_$2_PROGRAM_WAY),,$$($1_$2_$$($1_$2_PROGRAM_WAY)_HS_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_C_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_CXX_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_S_OBJS) $$($1_$2_OTHER_OBJS),$$@) -else # $1_$2_PROG_NEEDS_C_WRAPPER=NO -ifeq "$$($1_$2_LINK_WITH_GCC)" "NO" -$1/$2/build/tmp/$$($1_$2_PROG) : $$($1_$2_$$($1_$2_PROGRAM_WAY)_HS_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_C_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_CXX_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_S_OBJS) $$($1_$2_OTHER_OBJS) | $$$$(dir $$$$@)/. - $$(call cmd,$1_$2_HC) -o $$@ $$($1_$2_$$($1_$2_PROGRAM_WAY)_ALL_HC_OPTS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_GHC_LD_OPTS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_HS_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_C_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_CXX_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_S_OBJS) $$($1_$2_OTHER_OBJS) $$(addprefix -l,$$($1_$2_EXTRA_LIBRARIES)) - -else -$1/$2/build/tmp/$$($1_$2_PROG) : $$($1_$2_$$($1_$2_PROGRAM_WAY)_HS_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_C_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_CXX_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_S_OBJS) $$($1_$2_OTHER_OBJS) | $$$$(dir $$$$@)/. - $$(call cmd,$1_$2_CC) -o $$@ $$($1_$2_$$($1_$2_PROGRAM_WAY)_ALL_CC_OPTS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_ALL_LD_OPTS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_HS_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_C_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_CXX_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_S_OBJS) $$($1_$2_OTHER_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_EXTRA_CC_OPTS) $$(addprefix -l,$$($1_$2_EXTRA_LIBRARIES)) -endif -endif # $1_$2_PROG_NEEDS_C_WRAPPER - -# Note [lib-depends] -# ~~~~~~~~~~~~~~~~~~ -# If this program is built with stage1 or greater, we -# need to depend on the libraries too. NB. since $(ALL_STAGE1_LIBS) and -# $(ALL_RTS_LIBS) are not defined until after libraries/*/ghc.mk have -# been included, this introduces an ordering dependency. -ifneq "$$(CLEANING)" "YES" -ifneq "$3" "0" -ifneq "$$($1_$2_HS_SRCS)" "" -ifeq "$$(strip $$(ALL_STAGE1_$$($1_$2_PROGRAM_WAY)_LIBS))" "" -$$(error ordering failure in $1 ($2): ALL_STAGE1_$$($1_$2_PROGRAM_WAY)_LIBS is empty) -endif -$1/$2/build/tmp/$$($1_$2_PROG) : $$(ALL_STAGE1_$$($1_$2_PROGRAM_WAY)_LIBS) $$(ALL_RTS_LIBS) -endif -endif -endif - -ifeq "$$($1_$2_INSTALL_INPLACE)" "YES" -$$($1_$2_INPLACE) : $1/$2/build/tmp/$$($1_$2_PROG_INPLACE) | $$$$(dir $$$$@)/. - $$(INSTALL) -m 755 $$< $$@ -endif - -endif # BINDIST - -ifneq "$$($1_$2_INSTALL_INPLACE)" "NO" -$(call all-target,$1_$2,$$($1_$2_INPLACE)) -endif -$(call clean-target,$1,$2_inplace,$$($1_$2_INPLACE)) - -ifeq "$$($1_$2_INSTALL)" "YES" -ifeq "$$($1_$2_PROG_NEEDS_C_WRAPPER)" "YES" -INSTALL_LIBS += $1/$2/build/tmp/$$($1_$2_PROG).dll -endif -ifeq "$$($1_$2_WANT_INSTALLED_WRAPPER)" "YES" -INSTALL_LIBEXECS += $1/$2/build/tmp/$$($1_$2_PROG) -else ifeq "$$($1_$2_TOPDIR)" "YES" -INSTALL_LIBEXECS += $1/$2/build/tmp/$$($1_$2_PROG) -else -INSTALL_BINS += $1/$2/build/tmp/$$($1_$2_PROG) -endif -endif - -$(call dependencies,$1,$2,$3) - -# The Main module of a program implicitly depends on GHC.TopHandler -# so we need to add a dependency for that. As we don't know which -# module contains Main, we just make all modules in the program -# depend on it. -# -# See Note [inconsistent distdirs] in rules/build-package-way.mk for why -# we hard-code dist-install; GHC will use stage2/stage3 here so we -# cannot use the distdir parameter. -ifneq "$3" "0" -$$(foreach o,$$($1_$2_$$($1_$2_PROGRAM_WAY)_HS_OBJS),$$(eval $$(call add-dependency,$$o,libraries/base/dist-install/build/GHC/TopHandler.$$($$($1_$2_PROGRAM_WAY)_osuf)))) -endif - -endef diff --git a/rules/c-objs.mk b/rules/c-objs.mk deleted file mode 100644 index 6b43fb54cd..0000000000 --- a/rules/c-objs.mk +++ /dev/null @@ -1,18 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (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 -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - -define c-objs # args: $1 = dir, $2 = distdir, $3 = way -# C, C++, and S files are usually only built for way "v", but sometimes "dyn" too -$1_$2_$3_C_OBJS = $$(patsubst %.c,$1/$2/build/%.$$($3_osuf),$$($1_$2_C_SRCS)) -$1_$2_$3_CXX_OBJS = $$(patsubst %.cpp,$1/$2/build/%.$$($3_osuf),$$($1_$2_CXX_SRCS)) -$1_$2_$3_S_OBJS = $$(patsubst %.S,$1/$2/build/%.$$($3_osuf),$$($1_$2_S_SRCS)) -endef diff --git a/rules/c-sources.mk b/rules/c-sources.mk deleted file mode 100644 index edc0cdbf04..0000000000 --- a/rules/c-sources.mk +++ /dev/null @@ -1,18 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (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 -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - -define c-sources # args: $1 = dir, $2 = distdir -$1_$2_C_FILES = $$(patsubst %,$1/%,$$($1_$2_C_SRCS)) -$1_$2_CXX_FILES = $$(patsubst %,$1/%,$$($1_$2_CXX_SRCS)) -$1_$2_S_FILES = $$(patsubst %,$1/%,$$($1_$2_S_SRCS)) -$1_$2_CMM_FILES = $$(patsubst %,$1/%,$$($1_$2_CMM_SRCS)) -endef diff --git a/rules/c-suffix-rules.mk b/rules/c-suffix-rules.mk deleted file mode 100644 index d405d155c0..0000000000 --- a/rules/c-suffix-rules.mk +++ /dev/null @@ -1,64 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (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 -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - - -define c-suffix-rules -# $1 = dir -# $2 = distdir -# $3 = way -# $4 = use GHC (YES/NO) - -ifneq "$$(BINDIST)" "YES" - -ifeq "$4" "YES" - -$1/$2/build/%.$$($3_osuf) : $1/%.c $$(LAX_DEPS_FOLLOW) $$$$($1_$2_HC_DEP) | $$$$(dir $$$$@)/. - $$(call cmd,$1_$2_HC) $$($1_$2_$3_GHC_CC_OPTS) -c $$< -o $$@ - -$1/$2/build/%.$$($3_osuf) : $1/$2/build/%.c $$(LAX_DEPS_FOLLOW) $$$$($1_$2_HC_DEP) - $$(call cmd,$1_$2_HC) $$($1_$2_$3_GHC_CC_OPTS) -c $$< -o $$@ - -$1/$2/build/%.$$($3_osuf) : $1/$2/build/%.$$($3_ssuf) $$(LAX_DEPS_FOLLOW) $$$$($1_$2_HC_DEP) - $$(call cmd,$1_$2_HC) $$($1_$2_$3_GHC_CC_OPTS) -c $$< -o $$@ - -$1/$2/build/%.$$($3_osuf) : $1/%.S $$(LAX_DEPS_FOLLOW) $$$$($1_$2_HC_DEP) | $$$$(dir $$$$@)/. - $$(call cmd,$1_$2_HC) $$($1_$2_$3_GHC_CC_OPTS) -c $$< -o $$@ - -$1/$2/build/%.$$($3_ssuf) : $1/$2/build/%.c $$(LAX_DEPS_FOLLOW) $$$$($1_$2_HC_DEP) - $$(call cmd,$1_$2_HC) $$($1_$2_$3_GHC_CC_OPTS) -S $$< -o $$@ - -$1/$2/build/%.$$($3_ssuf) : $1/%.c $$(LAX_DEPS_FOLLOW) $$$$($1_$2_HC_DEP) - $$(call cmd,$1_$2_HC) $$($1_$2_$3_GHC_CC_OPTS) -S $$< -o $$@ - -else - -$1/$2/build/%.$$($3_osuf) : $1/%.c | $$$$(dir $$$$@)/. - $$(call cmd,$1_$2_CC) $$($1_$2_$3_ALL_CC_OPTS) -c $$< -o $$@ - -$1/$2/build/%.$$($3_osuf) : $1/$2/build/%.c - $$(call cmd,$1_$2_CC) $$($1_$2_$3_ALL_CC_OPTS) -c $$< -o $$@ - -$1/$2/build/%.$$($3_osuf) : $1/$2/build/%.$$($3_ssuf) - $$(call cmd,$1_$2_AS) $$($1_$2_$3_ALL_AS_OPTS) -o $$@ $$< - -$1/$2/build/%.$$($3_osuf) : $1/%.S | $$$$(dir $$$$@)/. - $$(call cmd,$1_$2_CC) $$($1_$2_$3_ALL_CC_OPTS) -c $$< -o $$@ - -$1/$2/build/%.$$($3_ssuf) : $1/$2/build/%.c - $$(call cmd,$1_$2_CC) $$($1_$2_$3_ALL_CC_OPTS) -S $$< -o $$@ - -endif - -endif - -endef - diff --git a/rules/clean-target.mk b/rules/clean-target.mk deleted file mode 100644 index 8b37624af7..0000000000 --- a/rules/clean-target.mk +++ /dev/null @@ -1,21 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (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 -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - - -define clean-target # args: $1 = dir, $2 = key, $3 = files/dirs to clean -clean : clean_$1 -.PHONY: clean_$1 -clean_$1 : clean_$1_$2 -.PHONY: clean_$1_$2 -clean_$1_$2: - $$(call removeTrees,$3) -endef diff --git a/rules/cmm-objs.mk b/rules/cmm-objs.mk deleted file mode 100644 index dc517cbf34..0000000000 --- a/rules/cmm-objs.mk +++ /dev/null @@ -1,16 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (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 -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - -define cmm-objs # args: $1 = dir, $2 = distdir, $3 = way - -$1_$2_$3_CMM_OBJS = $$(patsubst %.cmm,$1/$2/build/%.$$($3_osuf),$$($1_$2_CMM_SRCS)) -endef diff --git a/rules/cmm-suffix-rules.mk b/rules/cmm-suffix-rules.mk deleted file mode 100644 index bb7acce06f..0000000000 --- a/rules/cmm-suffix-rules.mk +++ /dev/null @@ -1,52 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (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 -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - - -define cmm-suffix-rules -# $1 = dir -# $2 = distdir -# $3 = way - -# .cmm files depend on all the .h files, to a first approximation. - -ifneq "$$(CLEANING)" "YES" - -$1/$2/build/%.$$($3_osuf) : $1/%.cmm $$(rts_H_FILES) $$(includes_$2_H_FILES) $$(LAX_DEPS_FOLLOW) $$$$($1_$2_HC_DEP) | $$$$(dir $$$$@)/. - $$(call cmd,$1_$2_HC) $$($1_$2_$3_MOST_HC_OPTS) -c $$< -o $$@ - -$1/$2/build/%.$$($3_osuf) : $1/$2/build/%.cmm $$(rts_H_FILES) $$(includes_$2_H_FILES) $$(LAX_DEPS_FOLLOW) $$$$($1_$2_HC_DEP) | $$$$(dir $$$$@)/. - $$(call cmd,$1_$2_HC) $$($1_$2_$3_MOST_HC_OPTS) -c $$< -o $$@ - -$1/$2/build/%.$$($3_hcsuf) : $1/%.cmm $$(rts_H_FILES) $$(includes_$2_H_FILES) $$(LAX_DEPS_FOLLOW) $$$$($1_$2_HC_DEP) | $$$$(dir $$$$@)/. - $$(call cmd,$1_$2_HC) $$($1_$2_$3_MOST_HC_OPTS) -C $$< -o $$@ - -$1/$2/build/%.$$($3_hcsuf) : $1/$2/build/%.cmm $$(rts_H_FILES) $$(includes_$2_H_FILES) $$(LAX_DEPS_FOLLOW) $$$$($1_$2_HC_DEP) | $$$$(dir $$$$@)/. - $$(call cmd,$1_$2_HC) $$($1_$2_$3_MOST_HC_OPTS) -C $$< -o $$@ - -# XXX -# When we started using "| $$$$(dir $$$$@)/." for directory deps, these -# rules started getting used when object splitting is enabled for some -# reason. But they fail with -# **splitmangle**: openBinaryFile: does not exist (No such file or directory) -# so for now they're commented out. They aren't needed, as we can always -# go directly to .o files. -# -# $1/$2/build/%.$$($3_ssuf) : $1/%.cmm $$(rts_H_FILES) $$(includes_$2_H_FILES) $$(LAX_DEPS_FOLLOW) $$$$($1_$2_HC_DEP) | $$$$(dir $$$$@)/. -# $$(call cmd,$1_$2_HC) $$($1_$2_$3_MOST_HC_OPTS) -S $$< -o $$@ -# -# $1/$2/build/%.$$($3_ssuf) : $1/$2/build/%.cmm $$(rts_H_FILES) $$(includes_$2_H_FILES) $$(LAX_DEPS_FOLLOW) $$$$($1_$2_HC_DEP) | $$$$(dir $$$$@)/. -# $$(call cmd,$1_$2_HC) $$($1_$2_$3_MOST_HC_OPTS) -S $$< -o $$@ - -endif - -endef - diff --git a/rules/cxx-suffix-rules.mk b/rules/cxx-suffix-rules.mk deleted file mode 100644 index 25b3d5212c..0000000000 --- a/rules/cxx-suffix-rules.mk +++ /dev/null @@ -1,44 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (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 -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - - -define cxx-suffix-rules -# $1 = dir -# $2 = distdir -# $3 = way -# $4 = use GHC (YES/NO) - -ifneq "$$(BINDIST)" "YES" - -ifeq "$4" "YES" - -$1/$2/build/%.$$($3_osuf) : $1/%.cpp $$(LAX_DEPS_FOLLOW) $$$$($1_$2_HC_DEP) | $$$$(dir $$$$@)/. - $$(call cmd,$1_$2_HC) $$($1_$2_$3_GHC_CC_OPTS) -c $$< -o $$@ - -$1/$2/build/%.$$($3_osuf) : $1/$2/build/%.cpp $$(LAX_DEPS_FOLLOW) $$$$($1_$2_HC_DEP) - $$(call cmd,$1_$2_HC) $$($1_$2_$3_GHC_CC_OPTS) -c $$< -o $$@ - - -else - -$1/$2/build/%.$$($3_osuf) : $1/%.cpp | $$$$(dir $$$$@)/. - $$(call cmd,$1_$2_CC) $$($1_$2_$3_ALL_CC_OPTS) -c $$< -o $$@ - -$1/$2/build/%.$$($3_osuf) : $1/$2/build/%.cpp - $$(call cmd,$1_$2_CC) $$($1_$2_$3_ALL_CC_OPTS) -c $$< -o $$@ - -endif - -endif - -endef - diff --git a/rules/dependencies.mk b/rules/dependencies.mk deleted file mode 100644 index 4aae78e4e3..0000000000 --- a/rules/dependencies.mk +++ /dev/null @@ -1,38 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (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 -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - -define dependencies -$(call trace, dependencies($1,$2,$3)) -$(call profStart, dependencies($1,$2,$3)) -# $1 = dir -# $2 = distdir -# $3 = GHC stage to use (0 == bootstrapping compiler) - -# We always have the dependency rules available, as we need to know -# how to build hsc2hs's dependency file in phase 0 -$(call build-dependencies,$1,$2,$3) - -ifneq "$(phase)" "0" -# From phase 1 we actually include the dependency files for the -# bootstrapping stuff -ifeq "$3" "0" -$(call include-dependencies,$1,$2,$3) -else ifeq "$(phase)" "final" -# In the final phase, we also include the dependency files for -# everything else -$(call include-dependencies,$1,$2,$3) -endif -endif - -$(call profEnd, dependencies($1,$2,$3)) -endef - diff --git a/rules/distdir-opts.mk b/rules/distdir-opts.mk deleted file mode 100644 index ebe56c1fd5..0000000000 --- a/rules/distdir-opts.mk +++ /dev/null @@ -1,111 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (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 -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - - -# Set compilation flags that do not depend on a particular way - -define distdir-opts # args: $1 = dir, $2 = distdir, $3 = stage - -ifeq "$3" "" -$$(error Stage not given for distdir-opts $1 $2) -endif - -ifneq ($$(strip $$($1_$2_DEP_INCLUDE_DIRS_SINGLE_QUOTED)),) -$1_$2_CC_INC_FLAGS := $$(subst $$(space)',$$(space)-I',$$(space)$$($1_$2_DEP_INCLUDE_DIRS_SINGLE_QUOTED)) -endif - -# The CONF_CC_OPTS_STAGE$3 options are what we use to get gcc to -# behave correctly, but they are specific to the gcc that we are using. -# If GHC is compiling C code then it will take care of that for us, -# and in the case of the stage 0 compiler it may be using a different -# gcc, so we don't want to use our gcc-specific options. -$1_$2_DIST_GCC_CC_OPTS = \ - $$(CONF_CC_OPTS_STAGE$3) \ - $$($1_$2_DIST_CC_OPTS) - -$1_$2_DIST_INCLUDE_DIRS = \ - $$($1_$2_INCLUDE_DIRS) \ - $$($1_INCLUDE_DIRS) - -$1_$2_DIST_CPP_OPTS = \ - $$(foreach dir,$$(filter-out /%,$$($1_$2_DIST_INCLUDE_DIRS)),-I$1/$$(dir)) \ - $$(foreach dir,$$(filter /%,$$($1_$2_DIST_INCLUDE_DIRS)),-I$$(dir)) \ - $$($1_$2_CPP_OPTS) \ - $$($1_CPP_OPTS) - -$1_$2_DIST_CC_OPTS = \ - $$(SRC_CC_OPTS) \ - $$($1_CC_OPTS) \ - -I$1/$2/build/$$(or $$($1_EXECUTABLE),$$($1_$2_PROGNAME),.)/autogen \ - $$($1_$2_DIST_CPP_OPTS) \ - $$($1_$2_CC_OPTS) \ - $$($1_$2_CC_INC_FLAGS) \ - $$($1_$2_DEP_CC_OPTS) \ - $$(SRC_CC_WARNING_OPTS) - -$1_$2_DIST_LD_OPTS = \ - $$(SRC_LD_OPTS) \ - $$($1_LD_OPTS) \ - $$($1_$2_LD_OPTS) \ - $$($1_$2_DIST_LD_LIB_DIRS) \ - $$($1_$2_DEP_LD_OPTS) - -# c.f. Cabal's Distribution.Simple.PreProcess.ppHsc2hs -# We use '' around cflags and lflags to handle paths with backslashes in -# on Windows -ifneq ($$(strip $$($1_$2_DIST_GCC_CC_OPTS)),) -$1_$2_HSC2HS_CC_OPTS:=$$(shell for i in $$($1_$2_DIST_GCC_CC_OPTS); do echo \'--cflag=$$$$i\'; done) -endif -ifneq ($$(strip $$($1_$2_DIST_LD_OPTS)),) -$1_$2_HSC2HS_LD_OPTS:=$$(shell for i in $$($1_$2_DIST_LD_OPTS); do echo \'--lflag=$$$$i\'; done) -endif - -$1_$2_ALL_HSC2HS_OPTS = \ - '--cc=$$(CC_STAGE$3)' \ - '--ld=$$(CC_STAGE$3)' \ - $$(CONF_HSC2HS_OPTS) \ - $$(SRC_HSC2HS_OPTS) \ - $$(SRC_HSC2HS_OPTS_STAGE$3) \ - --cflag=-D__GLASGOW_HASKELL__=$$(if $$(filter 0,$3),$$(GhcCanonVersion),$$(ProjectVersionInt)) \ - $$($1_$2_HSC2HS_CC_OPTS) \ - $$($1_$2_HSC2HS_LD_OPTS) \ - --cflag=-I$1/$2/build/$$(or $$($1_EXECUTABLE),$$($1_$2_PROGNAME),.)/autogen \ - $$(if $$($1_PACKAGE),--cflag=-include --cflag=$1/$2/build/$$(or $$($1_EXECUTABLE),$$($1_$2_PROGNAME),.)/autogen/cabal_macros.h) \ - $$($$(basename $$<)_HSC2HS_OPTS) \ - $$(EXTRA_HSC2HS_OPTS) - -$1_$2_ALL_ALEX_OPTS = \ - $$(CONF_ALEX_OPTS) \ - $$(SRC_ALEX_OPTS) \ - $$($1_ALEX_OPTS) \ - $$($1_$2_ALEX_OPTS) \ - $$(EXTRA_ALEX_OPTS) - -$1_$2_ALL_HAPPY_OPTS = \ - $$(CONF_HAPPY_OPTS) \ - $$(SRC_HAPPY_OPTS) \ - $$($1_HAPPY_OPTS) \ - $$($1_$2_HAPPY_OPTS) \ - $$(EXTRA_HAPPY_OPTS) - -# Disable split sections when building with stage0, it won't be supported yet -# and it's probably not very relevant anyway (smaller stage1 ghc?). -ifeq "$$($1_$2_SplitSections)" "" -ifeq "$3" "1" -$1_$2_SplitSections = $(SplitSections) -else -$1_$2_SplitSections = NO -endif -endif - -endef - diff --git a/rules/distdir-way-opts.mk b/rules/distdir-way-opts.mk deleted file mode 100644 index 098af4f8da..0000000000 --- a/rules/distdir-way-opts.mk +++ /dev/null @@ -1,220 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (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 -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - - -# Set compilation flags that additionally depend on a particular way - -define distdir-way-opts # args: $1 = dir, $2 = distdir, $3 = way, $4 = stage - -# Here is how the command line for a Haskell compilation is constructed. -# $1 is the directory we're building in -# $2 is the distdir (e.g. "dist", "dist-install" etc.) -# $3 is the way (e.g. "v", "p", etc.) -# $4 is the stage ("0", "1", "2") that the options are passed to -# See Note [Stage number in build variables] -# in mk/config.mk.in. -# -# ----------------------------- -# The variables affecting Haskell compilations are as follows, including -# the places in the build system that may define them. -# -# Variable Purpose Defined by -# -------------- ------------------------------ -------------- -# $1_PACKAGE Package name for this dir, $1/$2/ghc.mk -# if it is a package -# -# CONF_HC_OPTS GHC options from ./configure mk/config.mk.in -# -# CONF_CPP_OPTS_STAGE$4 CPP options from ./configure mk/config.mk.in -# -# CONF_CC_OPTS_STAGE$4 C compiler options from mk/config.mk.in -# ./configure -# -# CONF_HC_OPTS_STAGE$4 GHC options from ./configure mk/config.mk.in -# specific to stage $4 -# -# CONF_LD_LINKER_OPTS_STAGE$4 -# GHC options from ./configure mk/config.mk.in -# specific to stage $4 -# -# WAY_$3_HC_OPTS GHC options specific to way $3 mk/ways.mk -# -# SRC_HC_OPTS source-tree-wide GHC options mk/config.mk.in -# mk/build.mk -# mk/validate.mk -# mk/warnings.mk -# -# SRC_HC_OPTS_STAGE$4 source-tree-wide GHC options, mk/config.mk.in -# supplied to the stage $4 mk/build.mk -# compiler only mk/validate.mk -# mk/warnings.mk -# -# SRC_HC_WARNING_OPTS source-tree-wide GHC warning mk/config.mk.in -# options mk/build.mk -# mk/validate.mk -# mk/warnings.mk -# -# SRC_HC_WARNING_OPTS_STAGE$4 mk/config.mk.in -# source-tree-wide GHC warning mk/build.mk -# options, supplied to the mk/validate.mk -# stage $4 compiler only mk/warnings.mk -# -# EXTRA_HC_OPTS for supplying extra options on make EXTRA_HC_OPTS=... -# the command line -# -# $1_HC_OPTS GHC options specific to this $1/$2/package-data.mk -# dir -# -# $1_$2_HC_OPTS GHC options specific to this $1/$2/package-data.mk -# dir and distdir -# -# $1_$2_$3_HC_OPTS GHC options specific to this $1/$2/package-data.mk -# dir, distdir and way -# -# $1_$2_MORE_HC_OPTS GHC options for this dir/distdir ??? -# -# $1_$2_EXTRA_HC_OPTS GHC options for this dir/distdir mk/build.mk -# mk/warnings.mk -# -# $1_$2_HC_PKGCONF -package-db flag if necessary rules/package-config.mk -# -# $1_$2_HS_SRC_DIRS dirs relative to $1 containing $1/$2/package-data.mk -# source files -# -# $1_$2_CPP_OPTS CPP options $1/$2/package-data.mk -# -# <file>_HC_OPTS GHC options for this source $1/$2/ghc.mk -# file (without the extension) - -# ----------------------------- - -# The actual options passed to a Haskell compilation are defined -# below. Note that in general, more specific sets of options come -# after the less specific, so that we can override global options -# on a per-directory or per-way basis, for example. - -# $1_$2_$3_MOST_HC_OPTS is also passed to C compilations when we use -# GHC as the C compiler. - -$1_$2_$4_DEP_OPTS = \ - $$(foreach pkg,$$($1_$2_DEP_IPIDS),-package-id $$(pkg)) - -$4_THIS_UNIT_ID = -this-unit-id - -$1_$2_$3_MOST_HC_OPTS = \ - $$(WAY_$3_HC_OPTS) \ - $$(CONF_HC_OPTS) \ - $$(SRC_HC_OPTS) \ - $$(SRC_HC_OPTS_STAGE$4) \ - $$($1_HC_OPTS) \ - $$($1_$2_HC_PKGCONF) \ - $$(if $$($1_$2_PROG),, \ - $$(if $$($1_PACKAGE),$$($4_THIS_UNIT_ID) $$($1_$2_COMPONENT_ID))) \ - $$(if $$($1_PACKAGE),-hide-all-packages) \ - -package-env - \ - -i $$(if $$($1_$2_HS_SRC_DIRS),$$(foreach dir,$$($1_$2_HS_SRC_DIRS),-i$1/$$(dir)),-i$1) \ - -i$1/$2/build \ - -I$1/$2/build \ - -i$1/$2/build/$$(or $$($1_EXECUTABLE),$$($1_$2_PROGNAME),.)/autogen \ - -I$1/$2/build/$$(or $$($1_EXECUTABLE),$$($1_$2_PROGNAME),.)/autogen \ - $$(foreach dir,$$(filter -I%,$$($1_$2_DIST_CPP_OPTS)),$$(dir)) \ - $$(foreach opt,$$(filter-out -I%,$$($1_$2_DIST_CPP_OPTS)),-optP$$(opt)) \ - $$(if $$($1_PACKAGE),-optP-include \ - -optP$1/$2/build/$$(or $$($1_EXECUTABLE),$$($1_$2_PROGNAME),.)/autogen/cabal_macros.h) \ - $$($1_$2_$4_DEP_OPTS) \ - $$($1_$2_HC_OPTS) \ - $$(CONF_HC_OPTS_STAGE$4) \ - $$($1_$2_MORE_HC_OPTS) \ - $$($1_EXTRA_HC_OPTS) \ - $$($1_$2_EXTRA_HC_OPTS) \ - $$($1_$2_$3_HC_OPTS) \ - $$($$(basename $$(subst ./,,$$<))_HC_OPTS) \ - $$(SRC_HC_WARNING_OPTS) \ - $$(SRC_HC_WARNING_OPTS_STAGE$4) \ - $$(EXTRA_HC_OPTS) - -# What is going on with $1_EXECUTABLE? Recent version of Cabal -# place the cabal_macros.h for executables in build/exename/autogen -# rather than the traditional build/autogen. This is Right(TM) -# thing to do, but we have to accommodate it. Usually, it suffices -# to look in the PROGNAME, but for ghc the PROGNAME is ghc-stage1 -# while Cabal puts it in 'ghc', so we $1_EXECUTABLE is for that -# case. - -$1_$2_$3_MOST_DIR_HC_OPTS = \ - $$($1_$2_$3_MOST_HC_OPTS) \ - -outputdir $1/$2/build - -# NB. CONF_HC_OPTS_STAGE$4 has to be late enough to override $1_$2_HC_OPTS, so -# that -O0 is effective (see #5484) - -# $1_$2_$3_ALL_HC_OPTS: this is all the options we will pass to GHC -# for a given ($1,$2,$3). -$1_$2_$3_ALL_HC_OPTS = \ - -hisuf $$($3_hisuf) -osuf $$($3_osuf) -hcsuf $$($3_hcsuf) \ - $$($1_$2_$3_MOST_DIR_HC_OPTS) \ - $$(if $$(findstring YES,$$($1_$2_SplitSections)),$$(if $$(findstring dyn,$3),,-split-sections),) \ - $$(if $$(findstring YES,$$($1_$2_DYNAMIC_TOO)),$$(if $$(findstring v,$3),-dynamic-too)) - -$1_$2_$3_ALL_CC_OPTS = \ - $$(WAY_$3_CC_OPTS) \ - $$($1_$2_DIST_GCC_CC_OPTS) \ - $$($1_$2_$3_CC_OPTS) \ - $$($$(basename $$<)_CC_OPTS) \ - $$($1_$2_EXTRA_CC_OPTS) \ - $$(EXTRA_CC_OPTS) \ - $$(if $$(findstring YES,$$($1_$2_SplitSections)),-ffunction-sections -fdata-sections) - -$1_$2_$3_GHC_CC_OPTS = \ - $$(addprefix -optc, $$($1_$2_$3_ALL_CC_OPTS)) \ - $$($1_$2_$3_MOST_HC_OPTS) - -# Options for passing to gcc for linking -$1_$2_$3_ALL_LD_OPTS = \ - $$(WAY_$3_LD_OPTS) \ - $$($1_$2_DIST_LD_OPTS) \ - $$($1_$2_$3_LD_OPTS) \ - $$($1_$2_EXTRA_LD_OPTS) \ - $$(EXTRA_LD_OPTS) \ - $$(foreach o,$$(EXTRA_LD_LINKER_OPTS),-Wl$$(comma)$$o) \ - $$(foreach o,$$(CONF_LD_LINKER_OPTS_STAGE$4),-Wl$$(comma)$$o) - -# Options for passing to GHC when we use it for linking -$1_$2_$3_GHC_LD_OPTS = \ - $$(addprefix -optl, $$($1_$2_$3_ALL_LD_OPTS)) \ - $$($1_$2_$3_MOST_HC_OPTS) - -$1_$2_$3_ALL_AS_OPTS = \ - $$(CONF_AS_OPTS) \ - $$(SRC_AS_OPTS) \ - $$(WAY_$3_AS_OPTS) \ - $$($1_AS_OPTS) \ - $$($1_$2_AS_OPTS) \ - $$($1_$2_$3_AS_OPTS) \ - $$(EXTRA_AS_OPTS) - -ifeq "$3" "dyn" -ifneq "$4" "0" -ifeq "$$(TargetElf)" "YES" -$1_$2_$3_GHC_LD_OPTS += \ - -fno-use-rpaths \ - $$(foreach d,$$($1_$2_TRANSITIVE_DEP_COMPONENT_IDS),-optl-Wl$$(comma)-rpath -optl-Wl$$(comma)'$$$$ORIGIN/../$$d') -optl-Wl,-zorigin -else ifeq "$$(TargetOS_CPP)" "darwin" -$1_$2_$3_GHC_LD_OPTS += \ - -fno-use-rpaths \ - $$(foreach d,$$($1_$2_TRANSITIVE_DEP_COMPONENT_IDS),-optl-Wl$$(comma)-rpath -optl-Wl$$(comma)'@loader_path/../$$d') -endif -endif -endif - -endef - diff --git a/rules/foreachLibrary.mk b/rules/foreachLibrary.mk deleted file mode 100644 index 60dd0d3a82..0000000000 --- a/rules/foreachLibrary.mk +++ /dev/null @@ -1,59 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (c) 2010 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 -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - -# For each line in $(TOP)/packages: -# libraries/foo tag ... -# this calls -# $(call $1,foo,tag) -# -# Except! If there's a libraries/foo/ghc-packages then it calls -# $(call $1,foo/bar,tag) -# for each word 'bar' in libraries/foo/ghc-packages. -# - -# We use an FEL_ prefix for the variable names, to avoid trampling on -# other variables, as make has no concept of local variables. - -# We need to handle the following packages specially, as those don't -# have an entry in the packages file, since they don't live in -# repositories of their own: -# -# - base -# - ghc-boot -# - ghc-boot-th -# - ghc-prim -# - integer-gmp -# - ghc-bignum -# - template-haskell - -define foreachLibrary -# $1 = function to call for each library -# We will give it the package path and the tag as arguments -$$(foreach hashline,libraries/ghc-boot-th#-#no-remote-repo#no-vcs \ - libraries/ghc-boot#-#no-remote-repo#no-vcs \ - libraries/ghci#-#no-remote-repo#no-vcs \ - libraries/base#-#no-remote-repo#no-vcs \ - libraries/ghc-prim#-#no-remote-repo#no-vcs \ - libraries/integer-gmp#-#no-remote-repo#no-vcs \ - libraries/ghc-bignum#-#no-remote-repo#no-vcs \ - libraries/template-haskell#-#no-remote-repo#no-vcs \ - $$(shell grep '^libraries/' packages | sed 's/ */#/g'),\ - $$(eval FEL_line := $$(subst #,$$(space),$$(hashline))) \ - $$(eval FEL_libdir := $$(word 1,$$(FEL_line))) \ - $$(eval FEL_tag := $$(word 2,$$(FEL_line))) \ - $$(eval FEL_libroot := $$(patsubst libraries/%,%,$$(FEL_libdir))) \ - $$(if $$(wildcard $$(FEL_libdir)/ghc-packages), \ - $$(foreach lib,$$(shell cat $$(FEL_libdir)/ghc-packages), \ - $$(eval $$(call $1,$$(FEL_libroot)/$$(lib),$$(FEL_tag)))), \ - $$(if $$(wildcard $$(FEL_libdir)/), \ - $$(eval $$(call $1,$$(FEL_libroot),$$(FEL_tag)))))) -endef diff --git a/rules/haddock.mk b/rules/haddock.mk deleted file mode 100644 index b6d8e97051..0000000000 --- a/rules/haddock.mk +++ /dev/null @@ -1,93 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (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 -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - -ifneq "$(BINDIST)" "YES" -HADDOCK_VER := $(shell grep "^version:" utils/haddock/haddock.cabal | sed "s/version: *//") -HADDOCK_MAJOR_VER := $(shell echo $(HADDOCK_VER) | sed 's/\([0-9]\{1,\}\)\.\([0-9]\{1,\}\)\.\([0-9]\{1,\}\)/\1/') -HADDOCK_MINOR_VER := $(shell echo $(HADDOCK_VER) | sed 's/\([0-9]\{1,\}\)\.\([0-9]\{1,\}\)\.\([0-9]\{1,\}\)/\2/') -HADDOCK_PATCH_VER := $(shell echo $(HADDOCK_VER) | sed 's/\([0-9]\{1,\}\)\.\([0-9]\{1,\}\)\.\([0-9]\{1,\}\)/\3/') -HADDOCK_VERSION_STRING := $(shell echo $$(($(HADDOCK_MAJOR_VER) * 1000 + $(HADDOCK_MINOR_VER) * 10 + $(HADDOCK_PATCH_VER)))) -endif - -define haddock # args: $1 = dir, $2 = distdir -$(call trace, haddock($1,$2)) -$(call profStart, haddock($1,$2)) - -ifeq "$$($1_$2_DO_HADDOCK)" "YES" - -ifeq "$$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE)" "" -$$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE = $1/$2/doc/html/$$($1_PACKAGE)/$$($1_PACKAGE).haddock -ALL_HADDOCK_FILES += $$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE) -else -$$(error Already got a haddock file for $$($1_PACKAGE)) -endif - -haddock: html_$1 - -ifeq "$$(HADDOCK_DOCS)" "YES" -$(call all-target,$1_$2_haddock,html_$1) -endif - -.PHONY: html_$1 -html_$1 : $$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE) - -# See Note [inconsistent distdirs] in rules/build-package-way.mk for why -# we hard-code dist-install; GHC will use stage2/stage3 here so we -# cannot use the distdir parameter. -$$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_DEPS = $$(foreach n,$$($1_$2_DEPS),$$($$n_HADDOCK_FILE) $$($$n_dist-install_$$(HADDOCK_WAY)_LIB)) - -# We don't pass -dcore-lint to haddock because it caused a performance regression in #13789 -$1_$2_HADDOCK_GHC_OPTS = $$(foreach opt, $$(filter-out -dcore-lint,$$($1_$2_$$(HADDOCK_WAY)_ALL_HC_OPTS)),--optghc=$$(opt)) - -ifeq "$$(HSCOLOUR_SRCS)" "YES" -$1_$2_HADDOCK_FLAGS += --source-module=src/%{MODULE/./-}.html --source-entity=src/%{MODULE/./-}.html\#%{NAME} -endif - -ifneq "$$(BINDIST)" "YES" - -# We need the quadruple dollars for the dependencies, as it isn't -# guaranteed that we are processing the packages in dependency order, -# so we don't want to expand it yet. -$$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE) : $$$$(haddock_INPLACE) $$$$(ghc-cabal_INPLACE) $$($1_$2_HS_SRCS) $$$$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_DEPS) | $$$$(dir $$$$@)/. -ifeq "$$(HSCOLOUR_SRCS)" "YES" - "$$(ghc-cabal_INPLACE)" hscolour $1 $2 -endif - # N.B. in a source tree from tarball the testsuite/ directory may not exist - mkdir -p $$(TOP)/testsuite/tests/perf/haddock - "$$(TOP)/$$(INPLACE_BIN)/haddock" \ - --verbosity=0 \ - --odir="$1/$2/doc/html/$$($1_PACKAGE)" \ - --dump-interface=$$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE) \ - --html \ - --hoogle \ - --quickjump \ - --title="$$($1_PACKAGE)-$$($1_$2_VERSION)$$(if $$(strip $$($1_$2_SYNOPSIS)),: $$(strip $$($1_$2_SYNOPSIS)),)" \ - --prologue="$1/$2/haddock-prologue.txt" \ - --optghc="-D__HADDOCK_VERSION__=$$(HADDOCK_VERSION_STRING)" \ - $$(foreach mod,$$($1_$2_HIDDEN_MODULES),--hide=$$(mod)) \ - $$(foreach pkg,$$($1_$2_DEPS),$$(if $$($$(pkg)_HADDOCK_FILE),--read-interface=../$$(pkg)$$(comma)../$$(pkg)/src/%{MODULE/./-}.html\#%{NAME}$$(comma)$$($$(pkg)_HADDOCK_FILE))) \ - $$($1_$2_HADDOCK_GHC_OPTS) \ - $$($1_$2_HADDOCK_FLAGS) $$($1_$2_HADDOCK_OPTS) \ - $$($1_$2_HS_SRCS) \ - $$($1_$2_EXTRA_HADDOCK_SRCS) \ - $$(EXTRA_HADDOCK_OPTS) \ - +RTS -t"$$(TOP)/testsuite/tests/perf/haddock/$$($1_PACKAGE).t" --machine-readable - -# Make the haddocking depend on the library .a file, to ensure -# that we wait until the library is fully built before we haddock it -$$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE) : $$($1_$2_$$(HADDOCK_WAY)_LIB) -endif - -endif # $1_$2_DO_HADDOCK - -$(call profEnd, haddock($1,$2)) -endef diff --git a/rules/hi-rule.mk b/rules/hi-rule.mk deleted file mode 100644 index be4a460abe..0000000000 --- a/rules/hi-rule.mk +++ /dev/null @@ -1,110 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (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 -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - - -# Here's an interesting rule! - -# The .hi file may or may not change when we compile the corresponding -# .hs file. If GHC figures out that the .hi file has not changed, it -# doesn't touch it. This is a useful optimisation, because it means -# some modules may not get recompiled if the .hi files of the modules -# they depend on have not changed. -# -# See: -# https://gitlab.haskell.org/ghc/ghc/wikis/commentary/compiler/recompilation-avoidance -# -# So how do we express this dependency to make? The exact form of -# this rule is quite fragile. Here are some versions that don't work -# very well: -# -# %.hi : %.o -# @if [ ! -f $@ ] ; then \ -# echo Panic! $< exists, but $@ does not.; \ -# exit 1; \ -# fi -# -# This version adds a useful sanity check, and is a good solution, -# except that it means spawning a shell. This can be expensive, -# especially on Windows where spawning a shell takes about 0.3s. -# We'd like to avoid the shell if necessary. This also hides the -# message "nothing to be done for 'all'", since make thinks it has -# actually done something. Therefore we only use this version -# if ExtraMakefileSanityChecks is enabled. -# -# %.hi : %.o -# -# This version doesn't work: GNU make knows it has't done anything to -# update the .hi file, so even if the .o file has been updated, it -# won't rebuild anything that depends on the .hi file. So you might -# think a more correct way is to change the .hs rule: -# -# %.hi %.o : %.hs -# $(HC) ... -# -# this says "compiling %.hs updates both %.hi and %.o", but that's not -# true, since compiling the .hs file might not update the .hi file, if -# the .hi file didn't change. And if we use this version, then make -# will keep trying to rebuild %.hi if it is out of date with respect -# to %.hs. -# -# Using this form seems to be the best compromise: -# -# %.hi : %.o ; -# -# the ';' at the end signifies an "empty command" (see the GNU make -# documentation). An empty command is enough to get GNU make to think -# it has updated %.hi, but without actually spawning a shell to do so. -# -# However, given that rule, make thinks that it can make .hi files -# for any object file, even if the object file was created from e.g. -# a C source file. We therefore also add a dependency on the .hs/.lhs -# source file, which means we end up with rules like: -# -# a/%.hi : a/%.o b/%.hs ; -# -# But! If a file is not explicitly mentioned in a makefile, then if -# make needs to build it using such a %-rule then it treats it as an -# 'intermediate file', and deletes it when it is finished. Most .hi -# files are mentioned in .depend* files, as some other module depends on -# them, but there are some library modules that aren't imported by -# anything in the tree. -# -# We could stop make from deleting the .hi files by declaring -# ".SECONDARY:", but if we do that then make takes a pathologically long -# time with our build system. So we now generate (by calling hi-rule -# from .depend* files) rules that look like -# -# a/B.hi a/B.dyn_hi : %hi : %o x/B.hs -# -# Now all the .hi files are explicitly mentioned in the makefiles, so -# make doesn't think they are merely intermediate files, and doesn't -# delete them. - -ifeq "$(ExtraMakefileSanityChecks)" "NO" - -define hi-rule # $1 = rule header -$1 ; -endef - -else - -define hi-rule # $1 = rule header -$1 - @if [ ! -f $$@ ] ; then \ - echo "Panic! $$< exists, but $$@ does not."; \ - exit 1; \ - fi - -endef - -endif - diff --git a/rules/hs-objs.mk b/rules/hs-objs.mk deleted file mode 100644 index f46e527343..0000000000 --- a/rules/hs-objs.mk +++ /dev/null @@ -1,17 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (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 -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - - -define hs-objs # args: $1 = dir, $2 = distdir, $3 = way -$1_$2_$3_HS_OBJS = $$(patsubst %,$1/$2/build/%.$$($3_osuf),$$($1_$2_SLASH_MODS)) -$1_$2_$3_HI = $$(patsubst %,$1/$2/build/%.$$($3_hisuf),$$($1_$2_SLASH_MODS)) -endef diff --git a/rules/hs-sources.mk b/rules/hs-sources.mk deleted file mode 100644 index 1df4ed7a89..0000000000 --- a/rules/hs-sources.mk +++ /dev/null @@ -1,58 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (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 -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - - -define hs-sources # args: $1 = dir, $2 = distdir - -ifeq "$$($1_$2_HS_SRC_DIRS)" "" -$1_$2_HS_SRC_DIRS = . -endif - -# Here we collect all the .hs/.lhs source files that we can find. If -# we can't find a Haskell source file for a given module, then presumably -# it can be generated by preprocessing something (.hsc, .y, .x etc.), so -# we depend on dist/build/Foo.hs in anticipation that the implicit rules -# will put the preprocessed source file there. -# -# NB. use :=, we only want this thing evaluated once. -# -$1_$2_HS_SRCS := $$(foreach file,$$($1_$2_SLASH_MODS),\ - $$(firstword \ - $$(wildcard \ - $$(foreach dir,$$($1_$2_HS_SRC_DIRS) $2/build/$$(or $$($1_EXECUTABLE),$$($1_$2_PROGNAME),.)/autogen,\ - $1/$$(dir)/$$(file).hs $1/$$(dir)/$$(file).lhs)) \ - $1/$2/build/$$(file).hs)) - -# .hs-boot files must be in the same place as the .hs file they go -# with (GHC assumes this). When we preprocess a source file, and -# that module has a .hs-boot or .lhs-boot file, we must arrange to -# copy the file into the distdir so that it ends up alongside the -# preprocessed .hs file. This complicated macro figures out for which -# files we need to do this, so we can add them as dependencies of the -# .depend file rule. -# -# for each .hs file in the build dir, -# if there is a .hs-boot or .lhs-boot file for it in a source dir, -# we want that file in the build dir. -# -# NB. use :=, we only want this thing evaluated once. -# -$1_$2_HS_BOOT_SRCS := $$(foreach dir,$$($1_$2_HS_SRC_DIRS),\ - $$(subst $1/$$(dir),$1/$2/build,\ - $$(wildcard \ - $$(subst $1/$2/build,$1/$$(dir),\ - $$(foreach file,\ - $$(filter $1/$2/build%,$$($1_$2_HS_SRCS)),\ - $$(patsubst %.hs,%.hs-boot,$$(file)) \ - $$(patsubst %.hs,%.lhs-boot,$$(file))))))) - -endef diff --git a/rules/hs-suffix-rules-srcdir.mk b/rules/hs-suffix-rules-srcdir.mk deleted file mode 100644 index 1798bfb0b1..0000000000 --- a/rules/hs-suffix-rules-srcdir.mk +++ /dev/null @@ -1,50 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (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 -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - - -define hs-suffix-rules-srcdir -# args: $1 = dir, $2 = distdir, $3 = srcdir - -# Preprocessing Haskell source - -ifneq "$$(BINDIST)" "YES" - -$1/$2/build/%.hs : $1/$3/%.ly | $$$$(dir $$$$@)/. - $$(call cmd,HAPPY) $$($1_$2_ALL_HAPPY_OPTS) $$< -o $$@ - -$1/$2/build/%.hs : $1/$3/%.y | $$$$(dir $$$$@)/. - $$(call cmd,HAPPY) $$($1_$2_ALL_HAPPY_OPTS) $$< -o $$@ - -$1/$2/build/%.hs : $1/$2/build/%.ly | $$$$(dir $$$$@)/. - $$(call cmd,HAPPY) $$($1_$2_ALL_HAPPY_OPTS) $$< -o $$@ - -$1/$2/build/%.hs : $1/$2/build/%.y | $$$$(dir $$$$@)/. - $$(call cmd,HAPPY) $$($1_$2_ALL_HAPPY_OPTS) $$< -o $$@ - -$1/$2/build/%.hs : $1/$3/%.x | $$$$(dir $$$$@)/. - $$(call cmd,ALEX) $$($1_$2_ALL_ALEX_OPTS) $$< -o $$@ - -$1/$2/build/%_hsc.c $1/$2/build/%_hsc.h $1/$2/build/%.hs : $1/$3/%.hsc $$$$(hsc2hs_INPLACE) | $$$$(dir $$$$@)/. - $$(call cmd,hsc2hs_INPLACE) $$($1_$2_ALL_HSC2HS_OPTS) $$< -o $$@ - -# Now the rules for hs-boot files. - -$1/$2/build/%.hs-boot : $1/$3/%.hs-boot | $$$$(dir $$$$@)/. - "$$(CP)" $$< $$@ - -$1/$2/build/%.lhs-boot : $1/$3/%.lhs-boot | $$$$(dir $$$$@)/. - "$$(CP)" $$< $$@ - -endif - -endef - diff --git a/rules/hs-suffix-way-rules-srcdir.mk b/rules/hs-suffix-way-rules-srcdir.mk deleted file mode 100644 index 7223b553ba..0000000000 --- a/rules/hs-suffix-way-rules-srcdir.mk +++ /dev/null @@ -1,94 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (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 -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - - -define hs-suffix-way-rules-srcdir -# args: $1 = dir, $2 = distdir, $3 = way, $4 = srcdir - -ifneq "$$(BINDIST)" "YES" - -# Compiling Haskell source - -$1/$2/build/%.$$($3_osuf) : $1/$4/%.hs $$(LAX_DEPS_FOLLOW) $$$$($1_$2_HC_DEP) $$($1_$2_PKGDATA_DEP) - $$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@ $$(if $$(findstring YES,$$($1_$2_DYNAMIC_TOO)),-dyno $$(addsuffix .$$(dyn_osuf),$$(basename $$@))) - $$(call ohi-sanity-check,$1,$2,$3,$1/$2/build/$$*) - -$1/$2/build/%.$$($3_osuf) : $1/$4/%.lhs $$(LAX_DEPS_FOLLOW) $$$$($1_$2_HC_DEP) $$($1_$2_PKGDATA_DEP) - $$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@ $$(if $$(findstring YES,$$($1_$2_DYNAMIC_TOO)),-dyno $$(addsuffix .$$(dyn_osuf),$$(basename $$@))) - $$(call ohi-sanity-check,$1,$2,$3,$1/$2/build/$$*) - -$1/$2/build/%.$$($3_hcsuf) : $1/$4/%.hs $$(LAX_DEPS_FOLLOW) $$$$($1_$2_HC_DEP) $$($1_$2_PKGDATA_DEP) - $$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -C $$< -o $$@ - -$1/$2/build/%.$$($3_hcsuf) : $1/$4/%.lhs $$(LAX_DEPS_FOLLOW) $$$$($1_$2_HC_DEP) $$($1_$2_PKGDATA_DEP) - $$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -C $$< -o $$@ - -# XXX: for some reason these get used in preference to the direct -# .hs->.o rule, I don't know why --SDM - -$1/$2/build/%.$$($3_osuf) : $1/$4/%.hc | $$$$(dir $$$$@)/. - $$(call cmd,$1_$2_CC) \ - $$($1_$2_$3_ALL_CC_OPTS) \ - -x c -c $$< -o $$@ \ - $$(if $$(findstring YES,$$($1_$2_DYNAMIC_TOO)),-dyno $$(addsuffix .$$(dyn_osuf),$$(basename $$@))) - -$1/$2/build/%.$$($3_osuf) : $1/$2/build/%.hc - $$(call cmd,$1_$2_CC) \ - $$($1_$2_$3_ALL_CC_OPTS) \ - -x c -c $$< -o $$@ \ - $$(if $$(findstring YES,$$($1_$2_DYNAMIC_TOO)),-dyno $$(addsuffix .$$(dyn_osuf),$$(basename $$@))) - -# $1/$2/build/%.$$($3_osuf) : $1/$2/build/%.$$($3_hcsuf) -# $$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@ -# -# $1/$2/build/%.$$($3_osuf) : $1/$2/build/%.hc -# $$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@ -# -# $1/$2/build/%.$$($3_ssuf) : $1/$2/build/%.$$($3_hcsuf) -# $$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -S $$< -o $$@ - -# Now the rules for hs-boot files. - -$1/$2/build/%.$$($3_o-bootsuf) : $1/$4/%.hs-boot $$(LAX_DEPS_FOLLOW) $$$$($1_$2_HC_DEP) $$($1_$2_PKGDATA_DEP) - $$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@ $$(if $$(findstring YES,$$($1_$2_DYNAMIC_TOO)),-dyno $$(addsuffix .$$(dyn_osuf)-boot,$$(basename $$@))) - -$1/$2/build/%.$$($3_o-bootsuf) : $1/$4/%.lhs-boot $$(LAX_DEPS_FOLLOW) $$$$($1_$2_HC_DEP) $$($1_$2_PKGDATA_DEP) - $$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@ $$(if $$(findstring YES,$$($1_$2_DYNAMIC_TOO)),-dyno $$(addsuffix .$$(dyn_osuf)-boot,$$(basename $$@))) - -# stubs are automatically generated and compiled by GHC - -$1/$2/build/%_stub.$$($3_osuf): $1/$2/build/%.$$($3_osuf) - @: - -endif - -endef - -ifeq "$(ExtraMakefileSanityChecks)" "NO" -ohi-sanity-check = -else -# We don't look for the .hi file if this is for a program, as if the -# Main module is in foo.hs then we get foo.o but Main.hi -define ohi-sanity-check - @for f in $4.$($3_osuf) \ - $(if $($1_$2_PROG),,$4.$($3_hisuf)) \ - $(if $(findstring v,$3), \ - $(if $(findstring YES,$($1_$2_DYNAMIC_TOO)), \ - $4.$(dyn_osuf) $4.$(dyn_hisuf))); do \ - if [ ! -f $$f ]; then \ - echo "Panic! $$f not created."; \ - exit 1; \ - fi; \ - done -endef -endif - diff --git a/rules/hs-suffix-way-rules.mk b/rules/hs-suffix-way-rules.mk deleted file mode 100644 index e75d7b458e..0000000000 --- a/rules/hs-suffix-way-rules.mk +++ /dev/null @@ -1,132 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (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 -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - - -define hs-suffix-way-rules # args: $1 = dir, $2 = distdir, $3 = way - -ifeq "$3 $$($1_$2_DYNAMIC_TOO)" "dyn YES" -# We only want this rule to be used for Haskell sources, not for -# e.g. C sources, so we depend on the v_hisuf rather than v_osuf. -$1/$2/build/%.$$(dyn_osuf): $1/$2/build/%.$$(v_hisuf) - @if [ ! -f $$@ ] ; then \ - echo "Panic! $$< exists, but $$@ does not."; \ - exit 1; \ - fi - -$1/$2/build/%.$$(dyn_osuf)-boot: $1/$2/build/%.$$(v_hisuf)-boot - @if [ ! -f $$@ ] ; then \ - echo "Panic! $$< exists, but $$@ does not."; \ - exit 1; \ - fi -else - -# Note [Implicit rule search algorithm] -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# The order in which implicit rules are defined can influence a build. -# -# Case study: genprimops/Lexer.hs -# -# We have two implicit rules for creating .o files, which after instantiating -# with a specific directory ($1=utils/genprimops) and distdir ($2=dist) look -# like this: -# -# utils/genprimops/dist/build/%.o : utils/genprimops/dist/build/%.hs -# <recipe1> -# utils/genprimops/dist/build/%.o : utils/genprimops/./%.hs -# <recipe2> -# -# The first rule is defined in hs-suffix-way-rules.mk (this file), the other -# in hs-suffix-way-rules-srcdir.mk. -# -# Assume for rest of this story that %=Lexer. -# -# In a normal repository checkout, neither Lexer.hs exists, but we have a rule -# to generate the one in the build directory by running alex on Lexer.x (the -# rule for that operation is defined in hs-suffix-rules-srcdir.mk). Since make -# needs to make a choice which of the above two implicit rules to follow (it -# never runs 2 recipes for the same target, unless double colon rules are -# used, which we don't), logically it will choose the first rule: Lexer.o will -# depend on Lexer.hs in the build directory, that file will be built, and then -# Lexer.o can be built. -# -# In an sdist however, Lexer.hs is present in the source directory. It was -# copied there during the creation of the sdist by a rule in -# sdist-ghc-file.mk. And this time we *don't* know how to generate the -# Lexer.hs in the build directory, because 1) alex is not installed when -# building from sdist and 2) the sdist creation process renamed Lexer.x to -# Lexer.x.source. So normally make would now choose the second rule: Lexer.o -# will depend on Lexer.hs in the source directory, for which nothing needs to -# be done, and then Lexer.o can be built. -# -# There is however another actor in play, a rule in sdist-ghc-file.mk, which -# after after instantiating with the same directory ($1=utils/genprimops) and -# distdir ($2=dist) looks like this: -# -# sdist_utils/genprimops_dist_Lexer : utils/genprimops/dist/build/Lexer.hs -# -# Note that this is not an implicit rule, there aren't any %'s. This rule -# *explicitly* depends on Lexer.hs in the build directory. What follows is the -# following: -# -# * make thinks Lexer.hs in the build directory "ought to exist" [1], -# because it is an explicit dependency of /some/ target. -# -# * this puts our two implicit rules on equal footing: one depends on a -# file that exists, the other on a file that ought to exist. Make's -# implicit rule search algorithm doesn't distinguish between these two -# cases [1]. -# -# * to break the tie, make chooses the rule that is defined first. Lexer.o -# will depend on Lexer.hs in the build directory, which doesn't exist, -# and which make doesn't know how to build, causing a build failure. -# -# To prevent this from happening we define rules for haskell source files in -# the source directory before those in the distdir. -# -# Alternative solutions: -# -# * Don't include the explicit rule above when not creating an sdist, as -# that is the only time when it is needed. -# -# * Merge the two implicit rules, with help from $1_$2_HS_SRCS from -# hs-sources.mk, which is sdist aware. -# -# * Require alex and happy to be installed when building from an sdist, -# simplifying all this drastically. -# -# [1] https://www.gnu.org/software/make/manual/make.html#Implicit-Rule-Search - -$$(foreach dir,$$($1_$2_HS_SRC_DIRS),\ - $$(eval $$(call hs-suffix-way-rules-srcdir,$1,$2,$3,$$(dir)))) - - -ifneq "$$(BINDIST)" "YES" - -$1/$2/build/%.$$($3_hcsuf) : $1/$2/build/%.hs $$(LAX_DEPS_FOLLOW) $$$$($1_$2_HC_DEP) - $$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -C $$< -o $$@ - -$1/$2/build/%.$$($3_osuf) : $1/$2/build/%.hs $$(LAX_DEPS_FOLLOW) $$$$($1_$2_HC_DEP) - $$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@ $$(if $$(findstring YES,$$($1_$2_DYNAMIC_TOO)),-dyno $$(addsuffix .$$(dyn_osuf),$$(basename $$@))) - -$1/$2/build/%.$$($3_hcsuf) : $1/$2/build/$$(or $$($1_EXECUTABLE),$$($1_$2_PROGNAME),.)/autogen/%.hs $$(LAX_DEPS_FOLLOW) $$$$($1_$2_HC_DEP) - $$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -C $$< -o $$@ - -$1/$2/build/%.$$($3_osuf) : $1/$2/build/$$(or $$($1_EXECUTABLE),$$($1_$2_PROGNAME),.)/autogen/%.hs $$(LAX_DEPS_FOLLOW) $$$$($1_$2_HC_DEP) - $$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@ $$(if $$(findstring YES,$$($1_$2_DYNAMIC_TOO)),-dyno $$(addsuffix .$$(dyn_osuf),$$(basename $$@))) - -endif - - -endif - -endef # hs-suffix-way-rules - diff --git a/rules/include-dependencies.mk b/rules/include-dependencies.mk deleted file mode 100644 index 7d4c38b73b..0000000000 --- a/rules/include-dependencies.mk +++ /dev/null @@ -1,45 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (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 -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - -define include-dependencies -$(call trace, include-dependencies($1,$2,$3)) -$(call profStart, include-dependencies($1,$2,$3)) -# $1 = dir -# $2 = distdir -# $3 = GHC stage to use (0 == bootstrapping compiler) - -$1_$2_INCLUDE_DEPFILES = YES -ifeq "$$(NO_INCLUDE_DEPS)" "YES" -$1_$2_INCLUDE_DEPFILES = NO -endif -ifneq "$$(ONLY_DEPS_FOR)" "" -ifeq "$$(filter $1_$2,$$(ONLY_DEPS_FOR))" "" -$1_$2_INCLUDE_DEPFILES = NO -endif -endif - -ifeq "$$($1_$2_INCLUDE_DEPFILES)" "YES" -ifneq "$$(strip $$($1_$2_HS_SRCS) $$($1_$2_HS_BOOT_SRCS))" "" -ifneq "$$(NO_STAGE$3_DEPS)" "YES" -include $$($1_$2_depfile_haskell) -endif -endif -include $$($1_$2_depfile_c_asm) -else -ifeq "$$(DEBUG)" "YES" -$$(warning not building dependencies in $1) -endif -endif - -$(call profEnd, include-dependencies($1,$2,$3)) -endef - diff --git a/rules/includes-sources.mk b/rules/includes-sources.mk deleted file mode 100644 index fca114bffd..0000000000 --- a/rules/includes-sources.mk +++ /dev/null @@ -1,26 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (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 -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - - -define includes-sources # args: $1 = dir, $2 = distdir - -ifeq "$$($1_$2_INCLUDE_DIRS)" "" -$1_$2_INCLUDE_DIRS = . -endif - -$1_$2_INSTALL_INCLUDES_SRCS :=\ - $$(foreach file,$$($1_$2_INSTALL_INCLUDES),\ - $$(firstword \ - $$(wildcard \ - $$(foreach dir,$$($1_$2_INCLUDE_DIRS),\ - $1/$$(dir)/$$(file))))) -endef diff --git a/rules/library-path.mk b/rules/library-path.mk deleted file mode 100644 index 9a398eebf0..0000000000 --- a/rules/library-path.mk +++ /dev/null @@ -1,21 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (c) 2010 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 -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - -# $1 = paths to prepend -ifeq "$(TargetOS_CPP)" "mingw32" -prependLibraryPath = $(error Do not know how to prependLibraryPath on Windows) -else ifeq "$(TargetOS_CPP)" "darwin" -prependLibraryPath = export DYLD_LIBRARY_PATH="$1$${DYLD_LIBRARY_PATH:+:$$DYLD_LIBRARY_PATH}" -else -prependLibraryPath = export LD_LIBRARY_PATH="$1$${LD_LIBRARY_PATH:+:$$LD_LIBRARY_PATH}" -endif - diff --git a/rules/make-command.mk b/rules/make-command.mk deleted file mode 100644 index 17d0921525..0000000000 --- a/rules/make-command.mk +++ /dev/null @@ -1,21 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (c) 2010 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 -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - -# $1 = the line -# The formatting of this definition (in particular, the blank line at -# the start) is important, in order to get make to generate the right -# makefile code. - -define make-command - - $1 -endef diff --git a/rules/manual-package-config.mk b/rules/manual-package-config.mk deleted file mode 100644 index a9993d9fae..0000000000 --- a/rules/manual-package-config.mk +++ /dev/null @@ -1,45 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (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 -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - - -define manual-package-config -# args: -# $1 = dir -# $2 = distdir -$(call trace, manual-package-config($1, $2)) -$(call profStart, manual-package-config($1, $2)) - -$1/$2/package.conf.inplace : $1/package.conf.in $$$$(ghc-pkg_INPLACE) | $$$$(dir $$$$@)/. - $$(HS_CPP) -P \ - -DTOP='"$$(TOP)"' \ - $$($1_$2_PACKAGE_CPP_OPTS) \ - -x c $$< -o $$@.raw - grep -v '^#pragma GCC' $$@.raw | \ - sed -e 's/""//g' -e 's/:[ ]*,/: /g' > $$@ - - "$$(ghc-pkg_INPLACE)" update --force $$@ - -# This is actually a real file, but we need to recreate it on every -# "make install", so we declare it as phony -.PHONY: $1/$2/package.conf.install -$1/$2/package.conf.install : $1/package.conf.in | $$$$(dir $$$$@)/. - $$(HS_CPP) -P \ - -DINSTALLING \ - -DLIB_DIR='"$$(if $$(filter YES,$$(RelocatableBuild)),$$$$topdir,$$(ghclibdir))/$1"' \ - -DINCLUDE_DIR='"$$(if $$(filter YES,$$(RelocatableBuild)),$$$$topdir,$$(ghclibdir))/$1/include"' \ - $$($1_$2_PACKAGE_CPP_OPTS) \ - -x c $1/package.conf.in -o $$@.raw - grep -v '^#pragma GCC' $$@.raw | \ - sed -e 's/""//g' -e 's/:[ ]*,/: /g' >$$@ - -$(call profEnd, manual-package-config($1)) -endef diff --git a/rules/package-config.mk b/rules/package-config.mk deleted file mode 100644 index 86054071ad..0000000000 --- a/rules/package-config.mk +++ /dev/null @@ -1,69 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (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 -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - - -define package-config # args: $1 = dir, $2 = distdir, $3 = GHC stage -$(call trace, package-config($1,$2,$3)) -$(call profStart, package-config($1,$2,$3)) - -$1_$2_HC = $$(GHC_STAGE$3) -$1_$2_CC = $$(CC_STAGE$3) -$1_$2_AS = $$(AS_STAGE$3) -$1_$2_AR = $$(AR_STAGE$3) -$1_$2_AR_OPTS = $$(AR_OPTS_STAGE$3) -$1_$2_EXTRA_AR_ARGS = $$(EXTRA_AR_ARGS_STAGE$3) -$1_$2_ArSupportsAtFile = $$(ArSupportsAtFile_STAGE$3) - -# configuration stuff that depends on which GHC we're building with -ifeq "$3" "0" -$1_$2_HC_CONFIG = $$(GHC_STAGE0) -$1_$2_HC_CONFIG_DEP = -$1_$2_GHC_PKG = $$(GHC_PKG) -$1_$2_GHC_PKG_DEP = -$1_$2_HC_MK_DEPEND = $$($1_$2_HC) -# We can't make rules depend on the bootstrapping compiler, as then -# on cygwin we get a dep on c:/ghc/..., and make gets confused by the : -$1_$2_HC_MK_DEPEND_DEP = -$1_$2_HC_DEP = -$1_$2_HC_PKGCONF = -package-db $$(BOOTSTRAPPING_CONF) -$1_$2_GHC_PKG_OPTS = --package-db=$$(BOOTSTRAPPING_CONF) -$1_$2_CONFIGURE_OPTS += --package-db=$$(TOP)/$$(BOOTSTRAPPING_CONF) -$1_$2_MORE_HC_OPTS += -no-user-package-db -$1_$2_MORE_HC_OPTS += -rtsopts -else -$1_$2_HC_PKGCONF = -$1_$2_HC_CONFIG = $$(TOP)/$$(GHC_STAGE1) -$1_$2_HC_CONFIG_DEP = $$(GHC_STAGE1) -$1_$2_GHC_PKG = $$(TOP)/$$(ghc-pkg_INPLACE) -$1_$2_GHC_PKG_DEP = $$$$(ghc-pkg_INPLACE) -$1_$2_GHC_PKG_OPTS = -# If stage is not 0 then we always use stage1 for making .depend, as later -# stages aren't available early enough -$1_$2_HC_MK_DEPEND = $$(GHC_STAGE1) -$1_$2_HC_MK_DEPEND_DEP = $$($1_$2_HC_MK_DEPEND) -$1_$2_HC_DEP = $$($1_$2_HC) -$1_$2_MORE_HC_OPTS += -no-user-package-db -$1_$2_MORE_HC_OPTS += -rtsopts -endif - -# Used by pretty_commands.mk -label_$1_$2_CC=CC -label_$1_$2_AS=AS -label_$1_$2_AR=AR -label_$1_$2_HC=HC [stage $3] -label_$1_$2_GHC_PKG=GHC PKG - -# Useful later -$1_$2_SLASH_MODS = $$(subst .,/,$$($1_$2_MODULES)) - -$(call profEnd, package-config($1,$2,$3)) -endef diff --git a/rules/pretty_commands.mk b/rules/pretty_commands.mk deleted file mode 100644 index f7576e171f..0000000000 --- a/rules/pretty_commands.mk +++ /dev/null @@ -1,13 +0,0 @@ -ifneq ($(V),1) -cmd = @echo ' $(if $(label_$1),$(label_$1),$1) $@'; "$($1)" -else -cmd = "$($1)" -endif - -label_ALEX=ALEX -label_HAPPY=HAPPY -label_hsc2hs_INPLACE=HSC2HS - - - - diff --git a/rules/prof.mk b/rules/prof.mk deleted file mode 100644 index 5733b415ca..0000000000 --- a/rules/prof.mk +++ /dev/null @@ -1,20 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (c) 2010 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 -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - -define profStart -$$(if $(PROF),$$(info $$(shell date +%s.%N): Start $1)) -endef - -define profEnd -$$(if $(PROF),$$(info $$(shell date +%s.%N): End $1)) -endef - diff --git a/rules/sdist-ghc-file.mk b/rules/sdist-ghc-file.mk deleted file mode 100644 index b1e13a1ea0..0000000000 --- a/rules/sdist-ghc-file.mk +++ /dev/null @@ -1,77 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# This file is part of the GHC build system. -# -# To understand how the build system works and how to modify it, see -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - - -# Add files generated by alex and happy to a source distribution. -# -# Invoke like this: -# -# $(eval $(call sdist-ghc-file,compiler,stage2,parser,Parser,y)) -# -# This adds the file 'compiler/stage2/build/Parser.hs' to the sdist, in the -# same directory as 'compiler/GHC/Parser.y' (which is renamed). - -define sdist-ghc-file -# $1 = dir -# $2 = distdir -# $3 = srcdir (can be empty) -# $4 = filename -# $5 = extension - -.PHONY: sdist_$1_$2_$4 - -# We should do this before creating the `sdist-ghc` tarball, or when just -# running `make sdist-ghc-prep`. -sdist-ghc-prep : sdist_$1_$2_$4 - -# But first create SRC_DIST_GHC_DIR. -sdist_$1_$2_$4 : sdist-ghc-prep-tree - -# Generate the .hs files if they don't exist yet, then do actual copying and -# moving. -sdist_$1_$2_$4 : $1/$2/build/$4.hs - "$(CP)" $1/$2/build/$4.hs $(SRC_DIST_GHC_DIR)/$1/$3/$$(dir $4) - mv $(SRC_DIST_GHC_DIR)/$1/$3/$4.$5 $(SRC_DIST_GHC_DIR)/$1/$3/$4.$5.source - -# And make sure the rules for generating the .hs files exist, even when we -# didn't generate all package-data.mk files. -$$(eval $$(call hs-suffix-rules-srcdir,$1,$2,$3)) -endef - -# ----------------------------------------------------------------------------- -# Variant of sdist-ghc-file whose `$3`-argument is interpreted -# differently in a more appropriate way for cabal-packages - -define sdist-ghc-file2 -# $1 = dir -# $2 = distdir -# $3 = moduledir -# $4 = filename -# $5 = extension - -.PHONY: sdist_$1_$2_$4 - -# We should do this before creating the `sdist-ghc` tarball, or when just -# running `make sdist-ghc-prep`. -sdist-ghc-prep : sdist_$1_$2_$4 - -# But first create SRC_DIST_GHC_DIR. -sdist_$1_$2_$4 : sdist-ghc-prep-tree - -# Generate the .hs files if they don't exist yet, then do actual copying and -# moving. -sdist_$1_$2_$4 : $1/$2/build/$3/$4.hs - "$(CP)" $1/$2/build/$3/$4.hs $(SRC_DIST_GHC_DIR)/$1/$3 - mv $(SRC_DIST_GHC_DIR)/$1/$3/$4.$5 $(SRC_DIST_GHC_DIR)/$1/$3/$4.$5.source - -# And make sure the rules for generating the .hs files exist, even when we -# didn't generate all package-data.mk files. -$$(eval $$(call hs-suffix-rules-srcdir,$1,$2,$3)) -endef diff --git a/rules/shell-wrapper.mk b/rules/shell-wrapper.mk deleted file mode 100644 index 37d01e6ecd..0000000000 --- a/rules/shell-wrapper.mk +++ /dev/null @@ -1,120 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (c) 2009-2012 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 -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - -define shell-wrapper -$(call trace, shell-wrapper($1,$2)) -$(call profStart, shell-wrapper($1,$2)) -# $1 = dir -# $2 = distdir - -ifeq "$$($1_$2_SHELL_WRAPPER_NAME)" "" -$1_$2_SHELL_WRAPPER_NAME = $1/$$($1_$2_PROGNAME).wrapper -endif - - -ifeq "$$($1_$2_WANT_INPLACE_WRAPPER)" "YES" - -$1_$2_INPLACE_SHELL_WRAPPER_NAME = $$($1_$2_PROG) - -ifeq "$$($1_$2_TOPDIR)" "YES" -$1_$2_INPLACE_WRAPPER = $$(INPLACE_LIB)/bin/$$($1_$2_INPLACE_SHELL_WRAPPER_NAME) -else -$1_$2_INPLACE_WRAPPER = $$(INPLACE_BIN)/$$($1_$2_INPLACE_SHELL_WRAPPER_NAME) -endif - -all_$1_$2 : $$($1_$2_INPLACE_WRAPPER) - -$(call clean-target,$1,$2_inplace_wrapper,$$($1_$2_INPLACE_WRAPPER)) - -$$($1_$2_INPLACE_WRAPPER): WRAPPER=$$@ -ifeq "$$($1_$2_SHELL_WRAPPER)" "YES" -$$($1_$2_INPLACE_WRAPPER): $$($1_$2_SHELL_WRAPPER_NAME) -endif -$$($1_$2_INPLACE_WRAPPER): $$($1_$2_INPLACE) - $$(call removeFiles, $$@) - echo '#!/bin/sh' >> $$@ - echo 'executablename="$$(TOP)/$$<"' >> $$@ - echo 'datadir="$$(TOP)/$$(INPLACE_LIB)"' >> $$@ - echo 'bindir="$$(TOP)/$$(INPLACE_BIN)"' >> $$@ - echo 'topdir="$$(TOP)/$$(INPLACE_TOPDIR)"' >> $$@ - echo 'pgmgcc="$$(CC)"' >> $$@ - $$($1_$2_SHELL_WRAPPER_EXTRA) - $$($1_$2_INPLACE_SHELL_WRAPPER_EXTRA) -ifeq "$$(DYNAMIC_GHC_PROGRAMS)" "YES" - echo '$$(call prependLibraryPath,$$($1_$2_DEP_LIB_DIRS_SEARCHPATH))' >> $$@ -endif -ifeq "$$($1_$2_SHELL_WRAPPER)" "YES" - cat $$($1_$2_SHELL_WRAPPER_NAME) >> $$@ -else - echo 'exec "$$$$executablename" $$$${1+"$$$$@"}' >> $$@ -endif - $$(EXECUTABLE_FILE) $$@ - -endif # $1_$2_WANT_INPLACE_WRAPPER - - -ifeq "$$($1_$2_WANT_INSTALLED_WRAPPER)" "YES" - -ifeq "$$($1_$2_INSTALL_SHELL_WRAPPER_NAME)" "" -$1_$2_INSTALL_SHELL_WRAPPER_NAME = $$($1_$2_PROG) -endif - -# Install the binary in $(ghclibexecdir), and install a shell wrapper in $(bindir) -INSTALL_LIBEXECS += $1/$2/build/tmp/$$($1_$2_PROG) -BINDIST_WRAPPERS += $$($1_$2_SHELL_WRAPPER_NAME) - -install: install_$1_$2_wrapper - -.PHONY: install_$1_$2_wrapper -install_$1_$2_wrapper: WRAPPER=$$(DESTDIR)$$(bindir)/$(CrossCompilePrefix)$$($1_$2_INSTALL_SHELL_WRAPPER_NAME) -install_$1_$2_wrapper: - $$(INSTALL_DIR) "$$(DESTDIR)$$(bindir)" - $$(call removeFiles, "$$(WRAPPER)") - $$(CREATE_SCRIPT) "$$(WRAPPER)" - echo '#!/bin/sh' >> "$$(WRAPPER)" - echo 'exedir="$$(ghclibexecdir)/bin"' >> "$$(WRAPPER)" - echo 'exeprog="$$($1_$2_PROG)"' >> "$$(WRAPPER)" - echo 'executablename="$$$$exedir/$$$$exeprog"' >> "$$(WRAPPER)" - echo 'datadir="$$(datadir)"' >> "$$(WRAPPER)" - echo 'bindir="$$(bindir)"' >> "$$(WRAPPER)" - echo 'topdir="$$(topdir)"' >> "$$(WRAPPER)" - $$($1_$2_SHELL_WRAPPER_EXTRA) - $$($1_$2_INSTALL_SHELL_WRAPPER_EXTRA) - cat $$($1_$2_SHELL_WRAPPER_NAME) >> "$$(WRAPPER)" - $$(EXECUTABLE_FILE) "$$(WRAPPER)" - -endif # $1_$2_WANT_INSTALLED_WRAPPER - - -ifeq "$$($1_$2_WANT_BINDIST_WRAPPER)" "YES" -ifneq "$$(TargetOS_CPP)" "mingw32" - -$1_$2_BINDIST_WRAPPER = $1/$2/build/tmp/$$($1_$2_PROGNAME)-bindist - -all_$1_$2 : $$($1_$2_BINDIST_WRAPPER) - -BINDIST_EXTRAS += $$($1_$2_BINDIST_WRAPPER) - -$$($1_$2_BINDIST_WRAPPER): $1/$2/build/tmp/$$($1_$2_PROG) - $$(call removeFiles, $$@) - echo '#!/bin/sh' >> $$@ -ifeq "$$(DYNAMIC_GHC_PROGRAMS)" "YES" - echo '$$(call prependLibraryPath,$$($1_$2_DEP_LIB_REL_DIRS_SEARCHPATH))' >> $$@ -endif - echo 'exec "$$<" $$$${1+"$$$$@"}' >> $$@ - $$(EXECUTABLE_FILE) $$@ - -endif -endif # $1_$2_WANT_BINDIST_WRAPPER - -$(call profEnd, shell-wrapper($1,$2)) -endef diff --git a/rules/sphinx.mk b/rules/sphinx.mk deleted file mode 100644 index 38692a8cdb..0000000000 --- a/rules/sphinx.mk +++ /dev/null @@ -1,77 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (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 -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - - -# Build Sphinx documentation - -# We are careful not to use the same directory the doctree files for the -# various Sphinx targets as make may run them in parallel (see #10950). - -define sphinx -$(call trace, sphinx($1,$2)) -$(call profStart, sphinx($1,$2)) -# $1 = dir -# $2 = docname - -$(eval $(call clean-target,$1,sphinx,$1/.doctrees-html/ $1/.doctrees-pdf/ $1/build-html/ $1/build-pdf/ $1/$2.pdf)) - -# empty "all_$1" target just in case we're not building docs at all -$(call all-target,$1,) - -.PHONY: html_$1 -ifeq "$$(phase)" "final" -ifeq "$$(BUILD_SPHINX_HTML)" "YES" -$(call all-target,$1,html_$1) -INSTALL_HTML_DOC_DIRS += $1/build-html/$2 -endif -endif - -html_$1 : $1/build-html/$2/index.html -html : html_$1 - -ifneq "$$(BINDIST)" "YES" -$1/build-html/$2/index.html: $1/conf.py $$($1_RST_SOURCES) - $(SPHINXBUILD) -b html -d $1/.doctrees-html -w $1/.log -n $(SPHINXOPTS) $1 $1/build-html/$2 -endif - - -.PHONY: pdf_$1 -ifeq "$$(phase)" "final" -ifeq "$$(BUILD_SPHINX_PDF)" "YES" -$(call all-target,$1,pdf_$1) -INSTALL_DOCS += $1/$2.pdf -endif -endif - -pdf_$1 : $1/$2.pdf -pdf : pdf_$1 - -ifneq "$$(BINDIST)" "YES" -# N.B. If we don't redirect latex output to /dev/null then we end up with literally -# 30% of the build output being warnings, even in a successful build. However, -# to make sure that we don't silence errors we allow each xelatex invocation -# besides the last to fail. - -$1/$2.pdf: $1/conf.py $$($1_RST_SOURCES) - $(SPHINXBUILD) -b latex -d $1/.doctrees-pdf -w $1/.log -n $(SPHINXOPTS) $1 $1/build-pdf/$2 - cd $1/build-pdf/$2 ; $(XELATEX) -halt-on-error $2.tex 2>/dev/null >/dev/null || true - cd $1/build-pdf/$2 ; $(XELATEX) -halt-on-error $2.tex 2>/dev/null >/dev/null || true - cd $1/build-pdf/$2 ; $(XELATEX) -halt-on-error $2.tex 2>/dev/null >/dev/null || true - cd $1/build-pdf/$2 ; $(MAKEINDEX) -s python.ist $2.idx - cd $1/build-pdf/$2 ; $(XELATEX) -halt-on-error $2.tex 2>/dev/null >/dev/null || true - cd $1/build-pdf/$2 ; $(XELATEX) -halt-on-error $2.tex - cp $1/build-pdf/$2/$2.pdf $1/$2.pdf -endif - - -$(call profEnd, sphinx($1,$2)) -endef diff --git a/rules/trace.mk b/rules/trace.mk deleted file mode 100644 index ec92fea1d5..0000000000 --- a/rules/trace.mk +++ /dev/null @@ -1,21 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (c) 2010 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 -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - -# A helpful little debug macro. Call it from a macro like this: -# -# $(call trace, this-macro($1,$2,$3)) -# -# And invoke the build system with TRACE=1 to turn on tracing. - -define trace -$$(if $(TRACE),$$(warning $1),) -endef diff --git a/rules/way-prelims.mk b/rules/way-prelims.mk deleted file mode 100644 index 4709149dff..0000000000 --- a/rules/way-prelims.mk +++ /dev/null @@ -1,36 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (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 -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - -define way-prelims # $1 = way -ifeq "$1" "v" -$1__way = -$1_way_ = -else -$1__way = _$1 -$1_way_ = $1_ -endif -$1_osuf = $$($1_way_)o -$1_o-bootsuf = $$($1_way_)o-boot -$1_hisuf = $$($1_way_)hi -$1_hcsuf = $$($1_way_)hc -$1_ssuf = $$($1_way_)s - -ifneq "$(findstring dyn,$1)" "" -# If the way includes "dyn" then it's a dynamic lib way. We mangle the -# way name to remove "dyn" (or "_dyn") and we change the suffix to -# include the versioned dynamic lib extension (eg .so or .dynlib). -# For example: thr_debug_dyn_libsuf="_thr_debug-ghc6.11.20090426.so" -$1_libsuf = $$($(subst dyn,,$(subst _dyn,,$1))__way)-ghc$(ProjectVersion)$(soext) -else -$1_libsuf = $$($1__way).a -endif -endef |