X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=mk%2Ftarget.mk;h=dd2ddcbd2a9b482eced21ad7873d32e1c088ea5d;hb=ec2e177faf6ed8ff934f0bd97cf77fcb0f2210bd;hp=56d1193c9430177d44607a43d63633a35fd0a3f2;hpb=76c7c599020012d62dc52a4babcc503f56b64563;p=ghc-hetmet.git diff --git a/mk/target.mk b/mk/target.mk index 56d1193..dd2ddcb 100644 --- a/mk/target.mk +++ b/mk/target.mk @@ -155,7 +155,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 @@ -293,8 +293,17 @@ boot :: depend ifneq "$(HS_PROG)" "" all :: $(HS_PROG) +ifneq "$(BootingFromHc)" "YES" $(HS_PROG) :: $(HS_OBJS) - $(HC) -o $@ $(HC_OPTS) $(LD_OPTS) $(HS_OBJS) $(LIBS) + $(HC) -o $@ $(HC_OPTS) $(LD_OPTS) $(HS_OBJS) +else +# see bootstrp.mk +$(HS_PROG) :: $(HS_OBJS) + $(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 +318,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,11 +421,22 @@ ifneq "$(way)" "u" SRC_HC_OPTS += -split-objs +ifeq "$(ArSupportsInput)" "" define BUILD_LIB $(RM) $@ (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): @@ -372,7 +447,7 @@ ifeq "$(GhcWithInterpreter)" "YES" HC_SPLIT_POST = ld -r -x -o $@ $(basename $@)/*.$(way_)o else HC_SPLIT_POST = touch $@ -endif +endif # GhcWithInterpreter == YES SRC_HC_PRE_OPTS += $(HC_SPLIT_PRE); SRC_HC_POST_OPTS += $(HC_SPLIT_POST); @@ -405,63 +480,89 @@ SRC_HC_POST_OPTS += \ else SRC_HC_POST_OPTS += \ ld -r -x -o $@.tmp $@; $(MV) $@.tmp $@ -endif -endif +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) -$(GHCI_LIBRARY) :: $(GHCI_LIBOBJS) - ld -r -x -o $@ $(GHCI_LIBOBJS) $(STUBOBJS) +endif # DONT_WANT_STD_GHCI_LIB_RULE +endif # GhcWithInterpreter +endif # way +endif # GHCI_LIBRARY != "" -INSTALL_LIBS += $(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 @@ -605,12 +706,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 $@... @@ -684,6 +779,7 @@ $(LINK) : $(LINK_TARGET) # 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); \ @@ -748,11 +844,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 @@ -894,11 +987,11 @@ install-strip:: @$(MAKE) EXTRA_INSTALL_OPTS='-s' install endif -########################################### +############################################################################## # # Targets: check tags show # -########################################### +############################################################################## #------------------------------------------------------------ # Check @@ -936,11 +1029,14 @@ endif # show: - @echo '$(VALUE)=$($(VALUE))' + @echo '$(VALUE)="$($(VALUE))"' -#-------------------------------------------------------------------------- -# SGML Documentation +################################################################################ +# +# SGML Documentation # +################################################################################ + .PHONY: dvi ps html pdf rtf ifneq "$(SGML_DOC)" "" @@ -961,7 +1057,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) @@ -979,11 +1075,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 @@ -1008,11 +1104,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. @@ -1067,6 +1163,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)" ""