[project @ 2000-01-11 14:09:17 by sewardj]
[ghc-hetmet.git] / mk / target.mk
index 8458618..e23a6b6 100644 (file)
@@ -365,6 +365,74 @@ $(DLL_NAME) :: $(LIBRARY)
        touch dLL_ifs.hi
 endif
 
+#
+# Version information is baked into a DLL by having the DLL include DllVersionInfo.o.
+# The version info contains two user tweakables: DLL_VERSION and DLL_VERSION_NAME.
+# (both are given sensible defaults though.)
+#
+# Note: this will not work as expected with Cygwin B20.1; you need a more recent
+#       snapshot of binutils (to pick up windres bugfixes.)
+
+ifndef DLL_VERSION
+DLL_VERSION=$(ProjectVersion)
+endif
+
+ifndef DLL_VERSION_NAME
+DLL_VERSION_NAME="http://www.haskell.org/ghc"
+endif
+
+ifndef DLL_DESCRIPTION
+DLL_DESCRIPTION="A GHC-compiled DLL"
+endif
+
+ifndef EXE_VERSION
+EXE_VERSION=$(ProjectVersion)
+endif
+
+ifndef EXE_VERSION_NAME
+EXE_VERSION_NAME="http://www.haskell.org/ghc"
+endif
+
+ifndef EXE_DESCRIPTION
+EXE_DESCRIPTION="A GHC-compiled binary"
+endif
+
+#
+# Little bit of lo-fi mangling to get at the right set of settings depending
+# on whether we're generating the VERSIONINFO for a DLL or EXE
+# 
+DLL_OR_EXE=$(subst VersionInfo.rc,,$@)
+VERSION_FT=$(subst Dll, 0x2L, $(subst Exe, 0x1L, $(DLL_OR_EXE)))
+VERSION_RES_NAME=$(subst Exe,$(EXE_VERSION_NAME), $(subst Dll, $(DLL_VERSION_NAME),$(DLL_OR_EXE)))
+VERSION_RES=$(subst Exe,$(EXE_VERSION), $(subst Dll, $(DLL_VERSION),$(DLL_OR_EXE)))
+VERSION_DESC=$(subst Exe,$(EXE_DESCRIPTION), $(subst Dll, $(DLL_DESCRIPTION),$(DLL_OR_EXE)))
+
+DllVersionInfo.rc ExeVersionInfo.rc:
+       $(RM) DllVersionInfo.rc
+       echo "1 VERSIONINFO"                > $@
+       echo "FILEVERSION 1,0,0,1"         >> $@
+       echo "PRODUCTVERSION 1,0,0,1"      >> $@
+       echo "FILEFLAGSMASK 0x3fL"         >> $@
+       echo "FILEOS 0x4L"                 >> $@
+       echo "FILETYPE $(VERSION_FT)"      >> $@
+       echo "FILESUBTYPE 0x0L"            >> $@
+       echo "BEGIN"                       >> $@
+       echo " BLOCK \"StringFileInfo\""   >> $@
+       echo " BEGIN"                      >> $@
+       echo "  BLOCK \"040904B0\""        >> $@
+       echo "  BEGIN"                     >> $@
+       echo "   VALUE \"CompanyName\", \"$(VERSION_RES_NAME)\\0\"" >> $@
+       echo "   VALUE \"FileVersion\", \"$(VERSION_RES)\\0\"" >> $@
+       echo "   VALUE \"ProductVersion\", \"$(VERSION_RES)\\0\"" >> $@
+       echo "   VALUE \"FileDescription\", \"$(VERSION_DESC)\\0\"" >> $@
+       echo "  END" >> $@
+       echo " END" >> $@
+       echo " BLOCK \"VarFileInfo\""  >> $@
+       echo " BEGIN" >> $@
+       echo "  VALUE \"Translation\", 0x0409, 1200" >> $@
+       echo " END" >> $@
+       echo "END" >> $@
+
 #----------------------------------------
 #      Script programs
 
@@ -513,17 +581,29 @@ install-dirs ::
 #install:: install-dirs
 
 ifneq "$(INSTALL_PROGS)" ""
+
+#
+# Here's an interesting one - when using the win32 version
+# of install (provided via the cygwin toolkit), we have to
+# supply the .exe suffix, *if* there's no other suffix.
+#
+# The rule below does this by ferreting out the suffix of each
+# entry in the INSTALL_PROGS list. If there's no suffix, use
+# $(exeext).
+# 
+# This is bit of a pain to express since GNU make doesn't have
+# something like $(if ...), but possible using $(subst ..)
+# [Aside: I added support for $(if ..) to my local copy of GNU
+# make at one stage, perhaps I should propagate the patch to
+# the GNU make maintainers..] 
+#
+INSTALL_PROGS := $(foreach p, $(INSTALL_PROGS), $(addsuffix $(subst _,,$(subst __,$(exeext),_$(suffix $(p))_)), $(basename $(p))))
+
 install:: $(INSTALL_PROGS)
        @$(INSTALL_DIR) $(bindir)
        @for i in $(INSTALL_PROGS); do \
-               case $$i in \
-                 *.dll) \
-                   echo $(INSTALL_DATA) $(INSTALL_BIN_OPTS) $$i $(bindir); \
-                   $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i $(bindir) ;; \
-                 *) \
-                   echo $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i$(exeext) $(bindir); \
-                   $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i$(exeext) $(bindir) ;;  \
-               esac; \
+                   echo $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i $(bindir); \
+                   $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i $(bindir) ;  \
        done
 endif
 
@@ -572,10 +652,16 @@ install:: $(INSTALL_LIBS)
 endif
 
 ifneq "$(INSTALL_LIBEXECS)" ""
+#
+# See above comment next to defn of INSTALL_PROGS for what
+# the purpose of this one-liner is.
+# 
+INSTALL_LIBEXECS := $(foreach p, $(INSTALL_LIBEXECS), $(addsuffix $(subst _,,$(subst __,$(exeext),_$(suffix $(p))_)), $(basename $(p))))
+
 install:: $(INSTALL_LIBEXECS)
        @$(INSTALL_DIR) $(libexecdir)
        -for i in $(INSTALL_LIBEXECS); do \
-               $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i$(exeext) $(libexecdir); \
+               $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i $(libexecdir); \
        done
 endif
 
@@ -786,12 +872,14 @@ SGML_SRCS = $(wildcard *.sgml)
 endif
 endif
 
+SGML_TEX  = $(SGML_DOC).tex
 SGML_DVI  = $(SGML_DOC).dvi
 SGML_PS   = $(SGML_DOC).ps
 SGML_PDF  = $(SGML_DOC).pdf
 SGML_RTF  = $(SGML_DOC).rtf
 SGML_HTML = $(SGML_DOC).html
 # HTML output goes in a subdirectory on its own.
+SGML_TEXT = $(SGML_DOC).txt
 
 $(SGML_DVI) $(SGML_PS) $(SGML_INFO) $(SGML_HTML) $(SGML_TEXT) :: $(SGML_SRCS)
 
@@ -800,8 +888,11 @@ ps   :: $(SGML_PS)
 pdf  :: $(SGML_PDF)
 rtf  :: $(SGML_RTF)
 html :: $(SGML_HTML)
+txt  :: $(SGML_TEXT)
 
-CLEAN_FILES += $(SGML_TEXT) $(SGML_PS) $(SGML_DVI) $(SGML_PDF) $(SGML_RTF) $(SGML_HTML)
+CLEAN_FILES += $(SGML_TEXT) $(SGML_TEX) $(SGML_PS) $(SGML_DVI) $(SGML_PDF) $(SGML_RTF) $(SGML_HTML) $(SGML_DOC)-*.html
+# can't use $(SGML_SRCS) here, it was maybe used elsewhere
+MOSTLY_CLEAN_FILES += $(patsubst %.vsgml, %.sgml, $(VSGML_SRCS))
 
 clean ::
        $(RM) -rf $(SGML_DOC)
@@ -961,7 +1052,7 @@ endif      # if way
 
 ifneq "$(SUBDIRS)" ""
 
-all docs runtests boot TAGS clean veryclean maintainer-clean install info ::
+all docs runtests boot TAGS clean veryclean maintainer-clean install info html ps dvi txt::
        @echo "------------------------------------------------------------------------"
        @echo "===fptools== Recursively making \`$@' in $(SUBDIRS) ..."
        @echo "PWD = $(shell pwd)"