X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rules%2Fbuild-package-way.mk;h=95ec21b6b7ab6f3153c7721bfb0649b41a2a9323;hb=8a1f533adf691a008ba2ffd0487f9b9254517020;hp=086c231b4377a08513b5049d079c0876f605cbb0;hpb=34cc75e1a62638f2833815746ebce0a9114dc26b;p=ghc-hetmet.git diff --git a/rules/build-package-way.mk b/rules/build-package-way.mk index 086c231..95ec21b 100644 --- a/rules/build-package-way.mk +++ b/rules/build-package-way.mk @@ -1,28 +1,65 @@ +# ----------------------------------------------------------------------------- +# +# (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 +# http://hackage.haskell.org/trac/ghc/wiki/Building/Architecture +# http://hackage.haskell.org/trac/ghc/wiki/Building/Modifying +# +# ----------------------------------------------------------------------------- + define build-package-way # $1 = dir, $2 = distdir, $3 = way, $4 = stage -$(call distdir-way-opts,$1,$2,$3) +$(call distdir-way-opts,$1,$2,$3,$4) $(call hs-suffix-rules,$1,$2,$3) $$(foreach dir,$$($1_$2_HS_SRC_DIRS),\ $$(eval $$(call hs-suffix-rules-srcdir,$1,$2,$3,$$(dir)))) $(call hs-objs,$1,$2,$3) -$1_$2_$3_LIB = $1/$2/build/libHS$$($1_PACKAGE)-$$($1_$2_VERSION)$$($3__way).a +# 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 = $1/$2/build/libHS$$($1_PACKAGE)-$$($1_$2_VERSION)$$($3_libsuf) +$$($1_PACKAGE)-$($1_$2_VERSION)_$2_$3_LIB = $$($1_$2_$3_LIB) + +# All the .a/.so library file dependencies for this library +$1_$2_$3_DEPS_LIBS=$$(foreach dep,$$($1_$2_DEPS),$$($$(dep)_$2_$3_LIB)) -$1_$2_$3_MKSTUBOBJS = find $1/$2/build -name "*_stub.$$($3_osuf)" -print +ifneq "$$(BootingFromHc)" "YES" +$1_$2_$3_MKSTUBOBJS = $$(FIND) $1/$2/build -name "*_stub.$$($3_osuf)" -print # HACK ^^^ we tried to use $(wildcard), but apparently it fails due to # make using cached directory contents, or something. +else +$1_$2_$3_MKSTUBOBJS = true +$1_$2_$3_C_OBJS += $$(shell $$(FIND) $1/$2/build -name "*_stub.c" -print | sed 's/c$$$$/o/') +endif +$1_$2_$3_NON_HS_OBJS = $$($1_$2_$3_CMM_OBJS) $$($1_$2_$3_C_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 +$$($1_$2_$3_LIB) : $$($1_$2_$3_ALL_OBJS) $$(ALL_RTS_LIBS) $$($1_$2_$3_DEPS_LIBS) + "$$($1_$2_HC)" $$($1_$2_$3_ALL_OBJS) \ + `$$($1_$2_$3_MKSTUBOBJS)` \ + -shared -dynamic -dynload deploy \ + -no-auto-link-packages $$(addprefix -package,$$($1_$2_DEPS)) \ + -o $$@ +else # Build the ordinary .a library ifeq "$$($1_$2_SplitObjs)" "YES" -$$($1_$2_$3_LIB) : $$($1_$2_$3_HS_OBJS) $$($1_$2_C_OBJS) $$($1_$2_S_OBJS) - $$(RM) $$@ - (echo $$($1_$2_C_OBJS) $$($1_$2_S_OBJS) `$$($1_$2_$3_MKSTUBOBJS)`; find $$(patsubst %.$$($3_osuf),%_split,$$($1_$2_$3_HS_OBJS)) -name '*.$$($3_osuf)' -print) | xargs $$(AR) $$(EXTRA_AR_ARGS) $$@ +$$($1_$2_$3_LIB) : $$($1_$2_$3_ALL_OBJS) + "$$(RM)" $$(RM_OPTS) $$@ + (echo $$($1_$2_$3_NON_HS_OBJS) `$$($1_$2_$3_MKSTUBOBJS)`; $$(FIND) $$(patsubst %.$$($3_osuf),%_$$($3_osuf)_split,$$($1_$2_$3_HS_OBJS)) -name '*.$$($3_osuf)' -print) | $$(XARGS) $$(AR) $$(EXTRA_AR_ARGS) $$@ else -$$($1_$2_$3_LIB) : $$($1_$2_$3_HS_OBJS) $$($1_$2_C_OBJS) $$($1_$2_S_OBJS) - $$(RM) $$@ - echo $$($1_$2_C_OBJS) $$($1_$2_S_OBJS) $$($1_$2_$3_HS_OBJS) `$$($1_$2_$3_MKSTUBOBJS)` | xargs $$(AR) $$(EXTRA_AR_ARGS) $$@ +$$($1_$2_$3_LIB) : $$($1_$2_$3_ALL_OBJS) + "$$(RM)" $$(RM_OPTS) $$@ + echo $$($1_$2_$3_ALL_OBJS) `$$($1_$2_$3_MKSTUBOBJS)` | $$(XARGS) $$(AR) $$(EXTRA_AR_ARGS) $$@ +endif endif $(call all-target,$1_$2,all_$1_$2_$3) @@ -41,9 +78,8 @@ $1_$2_GHCI_LIB = $1/$2/build/HS$$($1_PACKAGE)-$$($1_$2_VERSION).$$($3_osuf) ifneq "$4" "0" BINDIST_LIBS += $$($1_$2_GHCI_LIB) endif -$$($1_$2_GHCI_LIB) : $$($1_$2_$3_HS_OBJS) $$($1_$2_C_OBJS) $$($1_$2_S_OBJS) - $$(RM) $$@ - $$(LD) -r -o $$@ $$(EXTRA_LD_OPTS) $$($1_$2_$3_HS_OBJS) $$($1_$2_C_OBJS) $$($1_$2_S_OBJS) `$$($1_$2_$3_MKSTUBOBJS)` +$$($1_$2_GHCI_LIB) : $$($1_$2_$3_HS_OBJS) $$($1_$2_$3_CMM_OBJS) $$($1_$2_$3_C_OBJS) $$($1_$2_$3_S_OBJS) $$($1_$2_EXTRA_OBJS) + "$$(LD)" -r -o $$@ $$(EXTRA_LD_OPTS) $$($1_$2_$3_HS_OBJS) $$($1_$2_$3_CMM_OBJS) $$($1_$2_$3_C_OBJS) $$($1_$2_$3_S_OBJS) `$$($1_$2_$3_MKSTUBOBJS)` $$($1_$2_EXTRA_OBJS) $(call all-target,$1_$2,$$($1_$2_GHCI_LIB)) endif