[project @ 2001-05-09 09:55:41 by simonmar]
[ghc-hetmet.git] / mk / target.mk
index 2aaf39a..295ec4c 100644 (file)
@@ -81,12 +81,12 @@ ifneq "$(SUBDIRS)" ""
 
 # we override the boot & all targets in the top level Makefile
 ifneq "$(NO_ALL_TARGETS)" "YES"
-ALL     = all
-BOOT    = boot
-INSTALL = install
+ALL_TARGET     = all
+BOOT_TARGET    = boot
+INSTALL_TARGET = install
 endif
 
-$(ALL) docs runtests $(BOOT) TAGS clean distclean mostlyclean maintainer-clean $(INSTALL) html ps dvi txt::
+$(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)"
@@ -293,8 +293,19 @@ 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
+endif
+
+# 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
 
 #----------------------------------------
@@ -309,29 +320,39 @@ endif
 
 
 #----------------------------------------
-#      Libraries/archives
+#      Building HsLibs libraries.
+
+ifneq "$(HSLIB)" ""
 
 ifeq "$(IS_CBITS_LIB)" "YES"
 _cbits := _cbits
 endif
 
-ifneq "$(HSLIB)" ""
 LIBRARY      = libHS$(HSLIB)$(_cbits)$(_way).a
 GHCI_LIBRARY = HS$(HSLIB)$(_cbits)$(_way).o
+
+ifneq "$(IS_CBITS_LIB)" "YES"
+WAYS=$(GhcLibWays)
+endif
+
 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)
+
+ifeq "$(IS_CBITS_LIB)" "YES"
 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
-endif
+
+endif # HSLIB
+
+#----------------------------------------
+#      Libraries/archives
 
 ifneq "$(LIBRARY)" ""
 all :: $(LIBRARY)
@@ -417,6 +438,7 @@ endif
 #
 
 ifneq "$(GHCI_LIBRARY)" ""
+ifeq "$(way)" ""
 ifeq "$(GhcWithInterpreter)" "YES"
 
 all :: $(GHCI_LIBRARY)
@@ -428,9 +450,11 @@ endif
 $(GHCI_LIBRARY) :: $(GHCI_LIBOBJS)
        ld -r -x -o $@ $(GHCI_LIBOBJS) $(STUBOBJS)
 
+INSTALL_LIBS += $(GHCI_LIBRARY)
 CLEAN_FILES += $(GHCI_LIBRARY)
 endif
 endif
+endif
 
 #----------------------------------------
 #      Building Win32 DLLs
@@ -604,12 +628,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 $@...
@@ -633,31 +651,69 @@ endif
        @echo Done.
 endif
 
-# links to script programs: we sometimes install a script as
-# <name>-<version> with a link from <name> to the real script.
+# ---------------------------------------------------------------------------
+# Symbolic links
+
+# links to programs: we sometimes install a program as
+# <name>-<version> with a link from <name> to the real program.
 
-ifneq "$(SCRIPT_LINK)" ""
-all :: $(SCRIPT_LINK)
+ifneq "$(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;
-endif
 
 
+#
+# 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 # LINK 
+
 
 ###########################################
 #
@@ -710,11 +766,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
 
@@ -856,23 +909,6 @@ 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
@@ -940,7 +976,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)