X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=mk%2Ftarget.mk;h=ca32292db8ee38bb22e1a2f083de0b5c7dbf9f28;hb=53ededd082a1efa78d54aaa855d7e7e76a8c7366;hp=5008e98a56d6a290ebdc2581083694f887e67539;hpb=ebfa2f9752392829b68b541535c6c92c7e7f0919;p=ghc-hetmet.git diff --git a/mk/target.mk b/mk/target.mk index 5008e98..ca32292 100644 --- a/mk/target.mk +++ b/mk/target.mk @@ -79,14 +79,28 @@ ifneq "$(SUBDIRS)" "" -# we override the boot & all targets in the top level Makefile -ifneq "$(NO_ALL_TARGETS)" "YES" -ALL = all -BOOT = boot -INSTALL = install +# we override the 'boot', 'all' and 'install' targets in the top +# level Makefile. Some of the sub-projects also set 'boot' to empty. + +ifeq "$(NO_ALL_TARGET)" "YES" +ALL_TARGET = +else +ALL_TARGET = all +endif + +ifeq "$(NO_BOOT_TARGET)" "YES" +BOOT_TARGET = +else +BOOT_TARGET = boot endif -$(ALL) docs runtests $(BOOT) TAGS clean distclean mostlyclean maintainer-clean $(INSTALL) html ps dvi txt:: +ifneq "$(NO_INSTALL_TARGET)" "YES" +INSTALL_TARGET = +else +INSTALL_TARGET = install +endif + +$(ALL_TARGET) docs runtests $(BOOT_TARGET) TAGS clean distclean mostlyclean maintainer-clean $(INSTALL_TARGET) html ps dvi txt:: @echo "------------------------------------------------------------------------" @echo "===fptools== Recursively making \`$@' in $(SUBDIRS) ..." @echo "PWD = $(shell pwd)" @@ -155,7 +169,7 @@ ifneq "$(MKDEPENDC_SRCS)" "" $(MKDEPENDC) -f .depend $(MKDEPENDC_OPTS) $(foreach way,$(WAYS),-s $(way)) -- $(CC_OPTS) -- $(MKDEPENDC_SRCS) endif ifneq "$(MKDEPENDHS_SRCS)" "" - $(MKDEPENDHS) -M -optdep-f -optdep.depend $(foreach way,$(WAYS),-optdep-s -optdep$(way)) $(foreach obj,$(MKDEPENDHS_OBJ_SUFFICES),-osuf $(obj)) $(MKDEPENDHS_OPTS) $(HC_OPTS) $(MKDEPENDHS_SRCS) + $(MKDEPENDHS) -M -optdep-f -optdep.depend $(foreach way,$(WAYS),-optdep-s -optdep$(way)) $(foreach obj,$(MKDEPENDHS_OBJ_SUFFICES),-osuf $(obj)) $(MKDEPENDHS_OPTS) $(filter-out -split-objs, $(HC_OPTS)) $(MKDEPENDHS_SRCS) endif @@ -165,8 +179,12 @@ endif # The boot target, at a minimum generates dependency information .PHONY: boot -boot :: depend +ifeq "$(NO_BOOT_TARGET)" "YES" +boot :: +else +boot :: depend +endif ################################################################## # GNU Standard targets @@ -293,8 +311,17 @@ boot :: depend ifneq "$(HS_PROG)" "" all :: $(HS_PROG) +ifneq "$(BootingFromHc)" "YES" +$(HS_PROG) :: $(HS_OBJS) + $(HC) -o $@ $(HC_OPTS) $(LD_OPTS) $(HS_OBJS) +else +# see bootstrap.mk $(HS_PROG) :: $(HS_OBJS) - $(HC) -o $@ $(HC_OPTS) $(LD_OPTS) $(HS_OBJS) $(LIBS) + $(CC) -o $@ $(HC_BOOT_CC_OPTS) $(HC_BOOT_LD_OPTS) $(HS_OBJS) $(HC_BOOT_LIBS) +endif + +# for building a Haskell program, we add FptoolsHcOpts +SRC_HC_OPTS += $(FptoolsHcOpts) endif #---------------------------------------- @@ -309,38 +336,93 @@ endif #---------------------------------------- -# Libraries/archives +# Building HsLibs libraries. +# +# Inputs: +# $(PACKAGE) is the name of the library to build +# $(IS_CBITS_LIB) should be "YES" for a "cbits" library +# +# Outputs: +# $(LIBRARY) the name of the library.a +# $(GHIC_LIBRARY) the name of the library.o (for GHCi) +# $(LIBOBJS) objects to put in library +# $(STUBOBJS) more objects to put in library +# +# $(LIBOBJS) is set to $(HS_OBJS) or $(C_OBJS) depending +# on whether or not it's a "cbits" library. But you can +# override this by setting $(LIBOBJS) yourself + +ifneq "$(PACKAGE)" "" + +# add syslib dependencies and current package name +SRC_HC_OPTS += -package-name $(PACKAGE) +SRC_HC_OPTS += $(patsubst %, -package %, $(PACKAGE_DEPS)) ifeq "$(IS_CBITS_LIB)" "YES" _cbits := _cbits +STUBOBJS += $(HSC_C_OBJS) +# Add _hsc.c files to the cbits library +C_SRCS += $(wildcard ../*_hsc.c) +# Make .hsc.h include files from the directory above visible +# (and the cbits/ library too). +SRC_CC_OPTS += -I.. -I. +endif + +ifneq "$(way)" "i" +LIBRARY = libHS$(PACKAGE)$(_cbits)$(_way).a +GHCI_LIBRARY = HS$(PACKAGE)$(_cbits)$(_way).o +else +LIBRARY = $(PACKAGE).dll +endif + +ifneq "$(IS_CBITS_LIB)" "YES" +WAYS=$(GhcLibWays) endif -ifneq "$(HSLIB)" "" -LIBRARY = libHS$(HSLIB)$(_cbits)$(_way).a -GHCI_LIBRARY = HS$(HSLIB)$(_cbits)$(_way).o ifeq "$(LIBOBJS)" "" - ifneq "$(IS_CBITS_LIB)" "YES" - LIBOBJS = $(HS_OBJS) - else + ifeq "$(IS_CBITS_LIB)" "YES" LIBOBJS = $(C_OBJS) + else + LIBOBJS = $(HS_OBJS) endif endif -ifneq "$(IS_CBITS_LIB)" "" -CC = $(HC) -override datadir:=$(libdir)/includes -INSTALL_DATAS += Hs$(shell perl -e 'print ucfirst "$(HSLIB)"').h -SRC_CC_OPTS += -I$(GHC_INCLUDE_DIR) -I$(GHC_RUNTIME_DIR) -endif + +ifeq "$(IS_CBITS_LIB)" "YES" +override datadir:=$(libdir)/include +INSTALL_DATAS += Hs$(shell perl -e 'print ucfirst "$(PACKAGE)"').h +else +SRC_CC_OPTS += -Icbits endif +endif # PACKAGE + +#---------------------------------------- +# Libraries/archives +# +# Build $(LIBRARY) from $(LIBOBJS)+$(STUBOBJS) +# +# Inputs: +# $(LIBOBJS) +# $(STUBOBJS) +# +# Outputs: +# Rule to build $(LIBRARY) + ifneq "$(LIBRARY)" "" all :: $(LIBRARY) +ifneq "$(way)" "i" define BUILD_LIB $(RM) $@ $(AR) $(AR_OPTS) $@ $(STUBOBJS) $(LIBOBJS) $(RANLIB) $@ endef +else +define BUILD_LIB +$(RM) $@ +al -out:$@ $(STUBOBJS) $(LIBOBJS) +endef +endif # # For Haskell object files, we might have chosen to split @@ -357,21 +439,36 @@ ifneq "$(way)" "u" SRC_HC_OPTS += -split-objs +ifeq "$(ArSupportsInput)" "" define BUILD_LIB $(RM) $@ -( echo $(STUBOBJS) ; $(FIND) $(patsubst %.$(way_)o,%,$(LIBOBJS)) -name '*.$(way_)o' -print ) | xargs ar q $@ +(echo $(STUBOBJS); $(FIND) $(patsubst %.$(way_)o,%,$(LIBOBJS)) -name '*.$(way_)o') | xargs ar q $@ $(RANLIB) $@ endef +else +define BUILD_LIB +$(RM) $@ +echo $(STUBOBJS) > $@.list +$(FIND) $(patsubst %.$(way_)o,%,$(LIBOBJS)) -name '*.$(way_)o' >> $@.list +$(AR) $(AR_OPTS) $@ $(ArSupportsInput) $@.list +$(RM) $@.list +$(RANLIB) $@ +endef +endif # Extra stuff for compiling Haskell files with $(SplitObjs): -HC_SPLIT_PRE= \ - $(RM) $@ ; if [ ! -d $(basename $@) ]; then mkdir $(basename $@); else \ - $(FIND) $(basename $@) -name '*.$(way_)o' -print | xargs $(RM) __rm_food ; fi -HC_SPLIT_POST = touch $@ +HC_SPLIT_PRE = \ + $(RM) $@; if [ ! -d $(basename $@) ]; then mkdir $(basename $@); else \ + $(FIND) $(basename $@) -name '*.$(way_)o' | xargs $(RM) __rm_food; fi +ifeq "$(GhcWithInterpreter)" "YES" +HC_SPLIT_POST = $(LD) -r -x -o $@ $(basename $@)/*.$(way_)o +else +HC_SPLIT_POST = touch $@ +endif # GhcWithInterpreter == YES -SRC_HC_PRE_OPTS += $(HC_SPLIT_PRE) ; -SRC_HC_POST_OPTS += $(HC_SPLIT_POST) ; +SRC_HC_PRE_OPTS += $(HC_SPLIT_PRE); +SRC_HC_POST_OPTS += $(HC_SPLIT_POST); # # If (Haskell) object files are split, cleaning up @@ -395,78 +492,95 @@ ifeq "$(StripLibraries)" "YES" ifeq "$(SplitObjs)" "YES" SRC_HC_POST_OPTS += \ for i in $(basename $@)/*; do \ - ld -r -x -o $$i.tmp $$i; \ + $(LD) -r -x -o $$i.tmp $$i; \ $(MV) $$i.tmp $$i; \ done else SRC_HC_POST_OPTS += \ - ld -r -x -o $@.tmp $@; $(MV) $@.tmp $@ -endif -endif + $(LD) -r -x -o $@.tmp $@; $(MV) $@.tmp $@ +endif # SplitObjs +endif # StripLibraries $(LIBRARY) :: $(STUBOBJS) $(LIBOBJS) $(BUILD_LIB) -endif +endif # LIBRARY = "" #-------------------------------------------------------------- # Build dynamically-linkable libraries for GHCi # +# Build $(GHCI_LIBRARY) from $(LIBOBJS)+$(STUBOBJS) +# +# Why? GHCi can only link .o files (at the moment), not .a files +# so we have to build libFoo.o as well as libFoo.a +# +# Furthermore, GHCi currently never loads +# profiling libraries (or other non-std ways) +# +# Inputs: +# $(GHCI_LIBRARY) +# +# Outputs: +# Rule to build $(GHCI_LIBRARY) + ifneq "$(GHCI_LIBRARY)" "" +ifeq "$(way)" "" ifeq "$(GhcWithInterpreter)" "YES" + +INSTALL_LIBS += $(GHCI_LIBRARY) +CLEAN_FILES += $(GHCI_LIBRARY) + all :: $(GHCI_LIBRARY) -ifeq "$(GHCI_LIBOBJS)" "" -GHCI_LIBOBJS = $(LIBOBJS) -endif +ifneq "$(DONT_WANT_STD_GHCI_LIB_RULE)" "YES" +# If you don't want to build GHCI_LIBRARY the 'standard' way, +# set DONT_WANT_STD_GHCI_LIB_RULE to YES. The Prelude and +# hslibs/Win32 uses this 'feature'. +# +$(GHCI_LIBRARY) :: $(LIBOBJS) + $(LD) -r -x -o $@ $(LIBOBJS) $(STUBOBJS) -ifneq "$(HS_SRCS)" "" -ifeq "$(SplitObjs)" "YES" -$(GHCI_LIBRARY) :: $(GHCI_LIBOBJS) - ( echo $(STUBOBJS) ; $(FIND) $(patsubst %.$(way_)o,%,$(GHCI_LIBOBJS)) -name '*.$(way_)o' -print ) | xargs ld -r -x -o $@ -else # not SplitObjs -$(GHCI_LIBRARY) :: $(GHCI_LIBOBJS) - ld -r -x -o $@ $(GHCI_LIBOBJS) -endif -else # no HS_SRCS -$(GHCI_LIBRARY) :: $(GHCI_LIBOBJS) - ld -r -x -o $@ $(GHCI_LIBOBJS) -endif +endif # DONT_WANT_STD_GHCI_LIB_RULE +endif # GhcWithInterpreter +endif # way +endif # GHCI_LIBRARY != "" -CLEAN_FILES += $(GHCI_LIBRARY) -endif -endif #---------------------------------------- # Building Win32 DLLs # ifeq "$(DLLized)" "YES" +SRC_CC_OPTS += -DDLLized -ifneq "$(HSLIB)" "" +ifneq "$(PACKAGE)" "" -SRC_BLD_DLL_OPTS += --export-all --output-def=HS$(HSLIB)$(_cbits)$(_way).def DllVersionInfo.$(way_)o -ifneq "$(HSLIB)" "rts" +SRC_BLD_DLL_OPTS += --export-all --output-def=HS$(PACKAGE)$(_cbits)$(_way).def DllVersionInfo.$(way_)o + +ifneq "$(PACKAGE) $(IS_CBITS_LIB)" "std YES" +ifneq "$(PACKAGE)" "rts" SRC_BLD_DLL_OPTS += -lHSstd_cbits_imp -L$(GHC_LIB_DIR)/std/cbits SRC_BLD_DLL_OPTS += -lHSrts_$(way_)imp -L$(GHC_RUNTIME_DIR) -ifneq "$(HSLIB)" "std" +ifneq "$(PACKAGE)" "std" ifeq "$(IS_CBITS_LIB)" "" SRC_BLD_DLL_OPTS += -lHSstd_$(way_)imp -L$(GHC_LIB_DIR)/std endif endif endif +endif + SRC_BLD_DLL_OPTS += -lgmp -L. -L$(GHC_RUNTIME_DIR)/gmp ifeq "$(IS_CBITS_LIB)" "" -SRC_BLD_DLL_OPTS += $(patsubst %,-lHS%_$(way_)imp, $(HSLIB_DEPS)) -SRC_BLD_DLL_OPTS += $(patsubst %,-L../%, $(HSLIB_DEPS)) +SRC_BLD_DLL_OPTS += $(patsubst %,-lHS%_$(way_)imp, $(PACKAGE_DEPS)) +SRC_BLD_DLL_OPTS += $(patsubst %,-L../%, $(PACKAGE_DEPS)) endif ifneq "$(HAS_CBITS)" "" -SRC_BLD_DLL_OPTS += -lHS$(HSLIB)_cbits_imp -Lcbits +SRC_BLD_DLL_OPTS += -lHS$(PACKAGE)_cbits_imp -Lcbits endif SRC_BLD_DLL_OPTS += -lwsock32 -lwinmm -endif # HSLIB != "" +endif # PACKAGE != "" SplitObjs = NO @@ -610,12 +724,6 @@ endif all :: $(SCRIPT_PROG) -# -# #! support under cygwin32 is not quite there yet, -# so we rely on the eval `trick' instead. On all other -# platforms, we prepend #!$(INTERP) -- SOF 6/97 -# - $(SCRIPT_PROG) : $(SCRIPT_OBJS) $(RM) $@ @echo Creating $@... @@ -639,30 +747,68 @@ endif @echo Done. endif -# links to script programs: we sometimes install a script as -# - with a link from to the real script. +# --------------------------------------------------------------------------- +# Symbolic links + +# links to programs: we sometimes install a program as +# - with a link from to the real program. + +ifneq "$(LINK)" "" -ifneq "$(SCRIPT_LINK)" "" -all :: $(SCRIPT_LINK) +all :: $(LINK) + +CLEAN_FILES += $(LINK) + +ifeq "$(LINK_TARGET)" "" +ifneq "$(SCRIPT_PROG)" "" +LINK_TARGET = $(SCRIPT_PROG) +else +ifneq "$(HS_PROG)" "" +LINK_TARGET = $(HS_PROG) +else +ifneq "$(C_PROG)" "" +LINK_TARGET = $(C_PROG) +else +LINK_TARGET = dunno +endif +endif +endif +endif # -# Don't want to overwrite $(SCRIPT_LINK)s that aren't symbolic +# Don't want to overwrite $(LINK)s that aren't symbolic # links. Testing for symbolic links is problematic to do in # a portable fashion using a /bin/sh test, so we simply rely # on perl. # -$(SCRIPT_LINK) : $(SCRIPT_PROG) - @if ( $(PERL) -e '$$fn="$(SCRIPT_LINK)"; exit ((! -f $$fn || -l $$fn) ? 0 : 1);' ); then \ - echo "Creating a symbolic link from $(SCRIPT_PROG) to $(SCRIPT_LINK)"; \ - $(RM) $(SCRIPT_LINK); \ - $(LN_S) $(SCRIPT_PROG) $(SCRIPT_LINK); \ +$(LINK) : $(LINK_TARGET) + @if ( $(PERL) -e '$$fn="$(LINK)"; exit ((! -f $$fn || -l $$fn) ? 0 : 1);' ); then \ + echo "Creating a symbolic link from $(LINK_TARGET) to $(LINK)"; \ + $(RM) $(LINK); \ + $(LN_S) $(LINK_TARGET) $(LINK); \ else \ - echo "Creating a symbolic link from $(SCRIPT_PROG) to $(SCRIPT_LINK) failed: \`$(SCRIPT_LINK)' already exists"; \ - echo "Perhaps remove \`$(SCRIPT_LINK)' manually?"; \ + echo "Creating a symbolic link from $(LINK_TARGET) to $(LINK) failed: \`$(LINK)' already exists"; \ + echo "Perhaps remove \`$(LINK)' manually?"; \ + exit 1; \ + fi; + + +# +# install links to script drivers. +# +install :: + @$(INSTALL_DIR) $(bindir) + @if ( $(PERL) -e '$$fn="$(bindir)/$(LINK)"; exit ((! -f $$fn || -l $$fn) ? 0 : 1);' ); then \ + echo "Creating a symbol link from $(LINK_TARGET) to $(LINK) in $(bindir)"; \ + $(RM) $(bindir)/$(LINK); \ + $(LN_S) $(LINK_TARGET) $(bindir)/$(LINK); \ + else \ + echo "Creating a symbol link from $(LINK_TARGET) to $(LINK) in $(bindir) failed: \`$(bindir)/$(LINK)' already exists"; \ + echo "Perhaps remove \`$(bindir)/$(LINK)' manually?"; \ exit 1; \ fi; -endif +endif # LINK ########################################### @@ -716,11 +862,8 @@ ifneq "$(LIBRARY)" "" INSTALL_LIBS += $(LIBRARY) ifeq "$(DLLized)" "YES" INSTALL_PROGS += $(DLL_NAME) -else -ifeq "$(DLLized)" "YES" INSTALL_LIBS += $(patsubst %.a,%_imp.a, $(LIBRARY)) endif -endif INSTALL_DATAS += $(HS_IFACES) endif @@ -862,28 +1005,11 @@ install-strip:: @$(MAKE) EXTRA_INSTALL_OPTS='-s' install endif -# -# install links to script drivers. -# -ifneq "$(SCRIPT_LINK)" "" -install :: - @if ( $(PERL) -e '$$fn="$(bindir)/$(SCRIPT_LINK)"; exit ((! -f $$fn || -l $$fn) ? 0 : 1);' ); then \ - echo "Creating a symbol link from $(SCRIPT_PROG) to $(SCRIPT_LINK) in $(bindir)"; \ - $(RM) $(bindir)/$(SCRIPT_LINK); \ - $(LN_S) $(SCRIPT_PROG) $(bindir)/$(SCRIPT_LINK); \ - else \ - echo "Creating a symbol link from $(SCRIPT_PROG) to $(SCRIPT_LINK) in $(bindir) failed: \`$(bindir)/$(SCRIPT_LINK)' already exists"; \ - echo "Perhaps remove \`$(bindir)/$(SCRIPT_LINK)' manually?"; \ - exit 1; \ - fi; - -endif - -########################################### +############################################################################## # # Targets: check tags show # -########################################### +############################################################################## #------------------------------------------------------------ # Check @@ -921,11 +1047,14 @@ endif # show: - @echo '$(VALUE)=$($(VALUE))' + @echo '$(VALUE)="$($(VALUE))"' -#-------------------------------------------------------------------------- -# SGML Documentation +################################################################################ +# +# SGML Documentation # +################################################################################ + .PHONY: dvi ps html pdf rtf ifneq "$(SGML_DOC)" "" @@ -946,7 +1075,7 @@ SGML_HTML = $(addsuffix .html,$(SGML_DOC)) # HTML output goes in a subdirectory on its own. SGML_TEXT = $(addsuffix .txt,$(SGML_DOC)) -$(SGML_DVI) $(SGML_PS) $(SGML_HTML) $(SGML_TEXT) :: $(SGML_SRCS) +$(SGML_DVI) $(SGML_PS) $(SGML_HTML) $(SGML_TEXT) $(SGML_PDF) :: $(SGML_SRCS) dvi :: $(SGML_DVI) ps :: $(SGML_PS) @@ -964,11 +1093,11 @@ extraclean :: $(RM) -rf $(SGML_DOC) endif -########################################### +############################################################################## # # Targets: clean # -########################################### +############################################################################## # we have to be careful about recursion here; since all the clean # targets are recursive, we don't want to make eg. distclean depend on @@ -993,11 +1122,11 @@ maintainer-clean:: extraclean @echo 'deletes files that may need special tools to rebuild.' rm -f $(MOSTLY_CLEAN_FILES) $(CLEAN_FILES) $(DIST_CLEAN_FILES) $(MAINTAINER_CLEAN_FILES) -################################################################################# +################################################################################ # # Way management # -################################################################################# +################################################################################ # Here is the ingenious jiggery pokery that allows you to build multiple versions # of a program in a single build tree. @@ -1052,6 +1181,16 @@ $(LIB_WAY_TARGETS) : endif # if way +# ------------------------------------------------------------------------- +# Object and interface files have suffixes tagged with their ways + +ifneq "$(way)" "" +SRC_HC_OPTS += -hisuf $(way_)hi -hcsuf $(way_)hc -osuf $(way_)o +endif + +# ------------------------------------------------------------------------- +# Rules to invoke the current target recursively for each way + ifneq "$(WAYS)" "" ifeq "$(way)" ""