1# ----------------------------------------------------------------------------- 2# 3# (c) 2009 The University of Glasgow 4# 5# This file is part of the GHC build system. 6# 7# To understand how the build system works and how to modify it, see 8# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture 9# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying 10# 11# ----------------------------------------------------------------------------- 12 13 14define hs-suffix-way-rules-srcdir 15# args: $1 = dir, $2 = distdir, $3 = way, $4 = srcdir, $5 = stage 16 17ifneq "$$(BINDIST)" "YES" 18 19# Compiling Haskell source 20 21$1/$2/build/%.$$($3_osuf) : $1/$4/%.hs $$(LAX_DEPS_FOLLOW) $$$$($1_$2_HC_DEP) $$($1_$2_PKGDATA_DEP) 22 $$(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 $$@))) 23 $$(call ohi-sanity-check,$1,$2,$3,$1/$2/build/$$*) 24 25$1/$2/build/%.$$($3_osuf) : $1/$4/%.lhs $$(LAX_DEPS_FOLLOW) $$$$($1_$2_HC_DEP) $$($1_$2_PKGDATA_DEP) 26 $$(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 $$@))) 27 $$(call ohi-sanity-check,$1,$2,$3,$1/$2/build/$$*) 28 29$1/$2/build/%.$$($3_hcsuf) : $1/$4/%.hs $$(LAX_DEPS_FOLLOW) $$$$($1_$2_HC_DEP) $$($1_$2_PKGDATA_DEP) 30 $$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -C $$< -o $$@ 31 32$1/$2/build/%.$$($3_hcsuf) : $1/$4/%.lhs $$(LAX_DEPS_FOLLOW) $$$$($1_$2_HC_DEP) $$($1_$2_PKGDATA_DEP) 33 $$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -C $$< -o $$@ 34 35# XXX: for some reason these get used in preference to the direct 36# .hs->.o rule, I don't know why --SDM 37 38$1/$2/build/%.$$($3_osuf) : $1/$4/%.hc $$(includes_$5_H_CONFIG) $$(includes_$5_H_PLATFORM) | $$$$(dir $$$$@)/. 39 $$(call cmd,$1_$2_CC) \ 40 $$($1_$2_$3_ALL_CC_OPTS) \ 41 $$(addprefix -I,$$(GHC_INCLUDE_DIRS)) \ 42 -I$$(BUILD_$5_INCLUDE_DIR) \ 43 -x c -c $$< -o $$@ \ 44 $$(if $$(findstring YES,$$($1_$2_DYNAMIC_TOO)),-dyno $$(addsuffix .$$(dyn_osuf),$$(basename $$@))) 45 46$1/$2/build/%.$$($3_osuf) : $1/$2/build/%.hc $$(includes_$5_H_CONFIG) $$(includes_$5_H_PLATFORM) 47 $$(call cmd,$1_$2_CC) \ 48 $$($1_$2_$3_ALL_CC_OPTS) \ 49 $$(addprefix -I,$$(GHC_INCLUDE_DIRS)) \ 50 -I$$(BUILD_$5_INCLUDE_DIR) \ 51 -x c -c $$< -o $$@ \ 52 $$(if $$(findstring YES,$$($1_$2_DYNAMIC_TOO)),-dyno $$(addsuffix .$$(dyn_osuf),$$(basename $$@))) 53 54# $1/$2/build/%.$$($3_osuf) : $1/$2/build/%.$$($3_hcsuf) 55# $$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@ 56# 57# $1/$2/build/%.$$($3_osuf) : $1/$2/build/%.hc 58# $$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@ 59# 60# $1/$2/build/%.$$($3_ssuf) : $1/$2/build/%.$$($3_hcsuf) 61# $$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -S $$< -o $$@ 62 63# Now the rules for hs-boot files. 64 65$1/$2/build/%.$$($3_o-bootsuf) : $1/$4/%.hs-boot $$(LAX_DEPS_FOLLOW) $$$$($1_$2_HC_DEP) $$($1_$2_PKGDATA_DEP) 66 $$(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 $$@))) 67 68$1/$2/build/%.$$($3_o-bootsuf) : $1/$4/%.lhs-boot $$(LAX_DEPS_FOLLOW) $$$$($1_$2_HC_DEP) $$($1_$2_PKGDATA_DEP) 69 $$(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 $$@))) 70 71# stubs are automatically generated and compiled by GHC 72 73$1/$2/build/%_stub.$$($3_osuf): $1/$2/build/%.$$($3_osuf) 74 @: 75 76endif 77 78endef 79 80ifeq "$(ExtraMakefileSanityChecks)" "NO" 81ohi-sanity-check = 82else 83# We don't look for the .hi file if this is for a program, as if the 84# Main module is in foo.hs then we get foo.o but Main.hi 85define ohi-sanity-check 86 @for f in $4.$($3_osuf) \ 87 $(if $($1_$2_PROG),,$4.$($3_hisuf)) \ 88 $(if $(findstring v,$3), \ 89 $(if $(findstring YES,$($1_$2_DYNAMIC_TOO)), \ 90 $4.$(dyn_osuf) $4.$(dyn_hisuf))); do \ 91 if [ ! -f $$f ]; then \ 92 echo "Panic! $$f not created."; \ 93 exit 1; \ 94 fi; \ 95 done 96endef 97endif 98 99