[project @ 2001-07-23 22:38:02 by ken]
[ghc-hetmet.git] / mk / target.mk
index 7d0a2e8..6eabebf 100644 (file)
@@ -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
 
 
@@ -308,6 +308,15 @@ ifneq "$(way)" ""
 SRC_HC_OPTS += -hisuf $(way_)hi -hcsuf $(way_)hc -osuf $(way_)o
 endif
 
+# add syslib dependencies and current package name
+SRC_HC_OPTS += $(patsubst %, -package %, $(PACKAGE_DEPS))
+ifneq "$(PACKAGE)" ""
+SRC_HC_OPTS += -package-name $(PACKAGE)
+else
+# No library, we are actually building the tools
+SRC_HC_OPTS += $(FptoolsHcOpts)
+endif
+
 #----------------------------------------
 #      C programs
 
@@ -323,12 +332,12 @@ endif
 #      Building HsLibs libraries.
 #
 # Inputs:
-#   $(HSLIB) is the name of the library to build
+#   $(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 GHCi0
+#   $(GHIC_LIBRARY)    the name of the library.o (for GHCi)
 #   $(LIBOBJS)         objects to put in library
 #   $(STUBOBJS)                more objects to put in library
 # 
@@ -336,14 +345,19 @@ endif
 # on whether or not it's a "cbits" library.  But you can
 # override this by setting $(LIBOBJS) yourself
 
-ifneq "$(HSLIB)" ""
+ifneq "$(PACKAGE)" ""
 
 ifeq "$(IS_CBITS_LIB)" "YES"
 _cbits := _cbits
+STUBOBJS += $(HSC_C_OBJS)
+# Add _hsc.c files to the cbits library
+SRCS       += $(wildcard ../*_hsc.c)
+# Make .hsc.h include files from the directory above visible
+SRC_CC_OPTS += -I..
 endif
 
-LIBRARY      = libHS$(HSLIB)$(_cbits)$(_way).a
-GHCI_LIBRARY = HS$(HSLIB)$(_cbits)$(_way).o
+LIBRARY      = libHS$(PACKAGE)$(_cbits)$(_way).a
+GHCI_LIBRARY = HS$(PACKAGE)$(_cbits)$(_way).o
 
 ifneq "$(IS_CBITS_LIB)" "YES"
 WAYS=$(GhcLibWays)
@@ -357,17 +371,16 @@ ifeq "$(LIBOBJS)" ""
   endif
 endif
 
-STUBOBJS += $(HSC_C_OBJS)
 SRC_CC_OPTS += -I$(GHC_INCLUDE_DIR) -I$(GHC_RUNTIME_DIR)
 
 ifeq "$(IS_CBITS_LIB)" "YES"
-override datadir:=$(libdir)/includes
-INSTALL_DATAS += Hs$(shell perl -e 'print ucfirst "$(HSLIB)"').h
+override datadir:=$(libdir)/include
+INSTALL_DATAS += Hs$(shell perl -e 'print ucfirst "$(PACKAGE)"').h
 else
 SRC_CC_OPTS += -Icbits
 endif
 
-endif # HSLIB
+endif # PACKAGE
 
 #----------------------------------------
 #      Libraries/archives
@@ -494,7 +507,7 @@ ifneq "$(GHCI_LIBRARY)" "HSstd.o"
 # So we only put in this standard rule for packages other than std
 # The rule for the Prelude is in ghc/lib/std/Makefile
 # We check for GHCI_LIBRARY being HSstd.o rather than
-# HSLIB being std, because we want to still use the boilerplate rule 
+# PACKAGE being std, because we want to still use the boilerplate rule 
 # for cbits.
 $(GHCI_LIBRARY) :: $(LIBOBJS)
        ld -r -x -o $@ $(LIBOBJS) $(STUBOBJS)
@@ -510,30 +523,35 @@ endif # GHCI_LIBRARY
 #
 
 ifeq "$(DLLized)" "YES"
+SRC_CC_OPTS += -DDLLized
+
+ifneq "$(PACKAGE)" ""
 
-ifneq "$(HSLIB)" ""
+SRC_BLD_DLL_OPTS += --export-all --output-def=HS$(PACKAGE)$(_cbits)$(_way).def DllVersionInfo.$(way_)o
 
-SRC_BLD_DLL_OPTS += --export-all --output-def=HS$(HSLIB)$(_cbits)$(_way).def DllVersionInfo.$(way_)o
-ifneq "$(HSLIB)" "rts"
+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