[project @ 1997-03-23 22:28:03 by sof]
[ghc-hetmet.git] / distrib / Makefile-bin.in
index 404f4d1..c741518 100644 (file)
@@ -1,12 +1,15 @@
+#
+# @configure_input@
+#
 # Instructions for configuring an fptools package.
 #
 # There are two ways you can get started with an fptools package, either
 # by using the unpacked distribution tree in-situ or by installing the
 # package.
 #
-# Using the package directly is easy, just do `make config', i.e.,
-# the distribution will *not* work out-of-the-box, you'll have to do
-# this first.
+# Using the package directly is easy, just do `make config'. (The
+# distribution will *not* work straight out of the box, you'll have to do
+# this first)
 #
 # To install the package, you'll have to set one or more of the
 # following variables:
@@ -18,7 +21,7 @@
 #     where you want the library archives to go.
 #     Note, if you specify /usr/foo/lib for libdir,
 #     the library files for your fptools package will be
-#     installed in  /usr/foo/lib/<package>-<version>, i.e.,
+#     installed in  /usr/foo/lib/<package>-<version>, e.g.,
 #     /usr/foo/lib/ghc-2.02. If you don't want the package/version
 #     directory appended, you'll have to modify $(real_libdir)
 #     below.
 #     path to where the platform-independent files will go.
 #     As for libdir, the effective path for the platform-indep
 #     stuff is $(datadir)/<package>-<version>. If you want
-#     complete control, see $(real_libdir)
+#     complete control, see $(real_datadir)
 #
 #  * platform 
-#     the platform you're installing for. The configure
-#     makes an educated guess what it, so you will only
-#     have to set this if it clashes with your reality.
+#     the platform you're installing for. The configure script
+#     makes an educated guess, so you'll only have to set this
+#     if it clashes with your reality, I guess.
 #
-#  * infodir
-#     where to install the Emacs info files
 #  * htmldir
 #     where to install the documentation HTML files.
 #  * dvidir
 #     where to install the DVI files.
+#  * infodir
+#     where to install the Emacs info files
 #
-# Installing the documentation is not via the `install' rule, but
-# via the rules: `install-docs', `install-html', `install-dvi'
-# and `install-info'.
+# Installing the documentation is not done as part of the `install' rule, but
+# via `install-docs' (or if you want to be selective: `install-html', `install-dvi'
+# and `install-info').
 #
 # For more complete instructions, consult the INSTALL file
 # that came with the bundle, and/or consult the installation
 # documentation in one of the document directories.
 #
-bindir    = @bindir@
-libdir    = @libdir@
-datadir   = @datadir@
-platform  = @platform@
+# Please report any bugs, problems etc. with installing and using this bundle
+# Makefile setup to glasgow-haskell-bugs@dcs.gla.ac.uk
+# 
+
+# Where the different pieces of the bundle should go:
+bindir      = @bindir@
+libdir      = @libdir@
+datadir     = @datadir@
+
+platform    = @TargetPlatform@
+prefix      = @prefix@
+exec_prefix = @exec_prefix@
 
-infodir   = @infodir@
-htmldir   = @htmldir@
-dvidir    = @dvidir@
+# default
+infodir   = $(datadir)
+htmldir   = $(datadir)
+dvidir    = $(datadir)
 
 #
 # Putting the package stuff in package-specific
 # directories:
 #
-real_libdir  = $(libdir)/$(package)-$(version)
-real_datadir = $(datadir)/$(package)-$(version)
+real_libdir      = $(libdir)/$(package)-$(version)
+real_datadir     = $(datadir)/$(package)-$(version)
+
+package     = ghc
+version     = 2.02
+PERL        = @PerlCmd@
+RM          = rm -f
+MV          = mv
+LN_S        = @LN_S@
+CHMOD       = chmod
+INSTALL            = @INSTALL@
+# sigh
+INSTALL_DIR  = ./mkdirhier
 
+#
+# Set of package scripts for which you'd like a name-<version> symlink
+# to be created, i.e., create a symlink, ghc-2.02, pointing to ghc to
+# avoid version vertigo.
+#
+VERSION_SYMLINKS_FOR=ghc
+
+#
+# List of files in bin directory that need to have
+# local setup/install information prepended.
+#
+PACKAGE_SCRIPTS=ghc stat2resid hstags mkdependHS
+
+# Binaries to install
+PACKAGE_BINS=$(PACKAGE_SCRIPTS) hp2ps
+
+#----------end of user-serviceable parts------------
+#
+#
+# How to install the different pieces
+# 
+INSTALL_BIN  = $(INSTALL) $(INSTALL_BIN_OPTS)
+INSTALL_LIB  = $(INSTALL) $(INSTALL_LIB_OPTS)
+INSTALL_DATA = $(INSTALL) $(INSTALL_DATA_OPTS)
+
+# What's common to all installs
+INSTALL_OPTS= $(EXTRA_INSTALL_OPTS)
+
+BIN_PERMS = 755
+LIB_PERMS = 644
+
+INSTALL_BIN_OPTS  = -m $(BIN_PERMS) $(INSTALL_OPTS) $(EXTRA_INSTALL_BIN_OPTS)
+INSTALL_LIB_OPTS  = -m $(LIB_PERMS) $(INSTALL_OPTS) $(EXTRA_INSTALL_LIB_OPTS)
+INSTALL_DATA_OPTS = -m $(LIB_PERMS) $(INSTALL_OPTS) $(EXTRA_INSTALL_DATA_OPTS)
+
+.PHONY: in-place config-pkgs mk-version-symlinks install-dirs install
+
+config-pkgs ::
+       @echo "Configuring $(package), version $(version), on $(platform) ..."
+       $(RM) bin/$(platform)/$(package)-$(version)/$(package)-$(version)
+       @for i in $(PACKAGE_SCRIPTS); do \
+          echo "Creating a configured version of $$i .."; \
+          $(RM) bin/$(platform)/$(package)-$(version)/$$i.bak; \
+          test -f bin/$(platform)/$(package)-$(version)/$$i && $(MV) bin/$(platform)/$(package)-$(version)/$$i bin/$(platform)/$(package)-$(version)/$$i.bak; \
+          echo "eval 'exec $(PERL) -S $$$""0 $$""{1+\"$$$""@\"}'"         > bin/$(platform)/$(package)-$(version)/$$i; \
+          echo "      if $$""running_under_some_shell;"                  >> bin/$(platform)/$(package)-$(version)/$$i; \
+          echo $$"bindir='$(bindir)';"                                   >> bin/$(platform)/$(package)-$(version)/$$i; \
+          echo $$"libdir='$(real_libdir)';"                              >> bin/$(platform)/$(package)-$(version)/$$i; \
+          echo $$"datadir='$(real_datadir)';"                            >> bin/$(platform)/$(package)-$(version)/$$i; \
+          cat bin/$(platform)/$(package)-$(version)/$(package).prl       >> bin/$(platform)/$(package)-$(version)/$$i; \
+          $(CHMOD) $(BIN_PERMS) bin/$(platform)/$(package)-$(version)/$$i; \
+          echo "Done."; \
+       done
 
+#
+# The vaguely funky eval 'exec ...' echo line above *might* be
+# a tad too much for some `make's - here's what it should return
+# if all is well:
+#
+#   eval 'exec /installed/path/for/perl -S $0 ${1+"$@"}'
+#         if $running_under_some_shell;
+#
 
+mk-version-symlinks ::
+       @for i in $(VERSION_SYMLINKS_FOR) ""; do \
+         if [ "x$$i" != "x" ]; then \
+            echo "Symlinking $$i to $$i-$(version)"; \
+            (cd bin/$(platform)/$(package)-$(version); $(RM) $$i-$(version); $(LN_S) $$i $$i-$(version) ); \
+         fi;\
+       done
 
-package   = ghc
-version   = 2.02
-PERL      = @PerlCmd@
+in-place ::
+       $(MAKE) $(MFLAGS) config-pkgs bindir=`pwd`/bin/$(platform)/$(package)-$(version) libdir=`pwd`/lib/$(platform) datadir=`pwd`/share/$(package)-$(version)
+       $(MAKE) $(MFLAGS) mk-version-symlinks
+       @echo "Finished configuring..to use, add `pwd`/bin/$(platform)/$(package)-$(version) to your PATH."
 
-.PHONY: config install install-dirs
+install-dirs ::
+       $(INSTALL_DIR) $(bindir)
+       (cd lib/$(platform)/$(package)-$(version); find . -type d -exec sh -c '$(INSTALL_DIR) $0 $(real_libdir)/$0' {} \; )
+       (cd share/$(package)-$(version); find . -type d -exec sh -c '$(INSTALL_DIR) $0 $(real_datadir)/$0' {} \; )
 
-config:
-       @echo Configuring $(package), version $(version), on $(platform)
-       @RM `pwd`/bin/$(platform)/$(package)-$(version)/$(package)-$(version)
-       @RM `pwd`/bin/$(platform)/$(package)-$(version)/$(package)
-       @echo $(PerlCmd)                  > `pwd`/bin/$(platform)/$(package)
-       @echo "$""bindir='"`pwd`"/bin/$(platform)/$(package)-$(version)';"    >> `pwd`/bin/$(platform)/$(package)-$(version)/$(package)
-       @echo "$""libdir='"`pwd`"/lib/$(platform)/$(package)-$(version)';"    >> `pwd`/bin/$(platform)/$(package)-$(version)/$(package)
-       @echo "$""datadir='"`pwd`"/share/$(platform)/$(package)-$(version)';" >> `pwd`/bin/$(platform)/$(package)-$(version)/$(package)
-       @cat `pwd`/bin/$(platform)/$(package)-$(version)/$(package).prl';"    >> `pwd`/bin/$(platform)/$(package)-$(version)/$(package)
-       @(cd `pwd`/bin/$(platform)/$(package)-$(version); $(LN_S) $(package) $(package)-$(version) )
-       @echo Finished..to use, add `pwd`/bin/$(platform)/$(package)-$(version) to your PATH.
+install :: config-pkgs mk-version-symlinks install-dirs install-bin install-libs install-data
 
-libdirs  = . imports include
-datadirs = . include
+.PHONY: install-bin install-libs install-datas
 
-install-dirs:
-       $(MKDIRHIER) $(bindir) 
-       @for i in $(libdirs) ; do \
-         echo (MKDIRHIER) $(real_libdir)/$$i; \
-         (MKDIRHIER) $(real_libdir)/$$i; \
-       done;
-       @for i in $(datadirs) ; do \
-         echo (MKDIRHIER) $(real_datadir)/$$i; \
-         (MKDIRHIER) $(real_datadir)/$$i; \
+install-bin:
+       for i in $(PACKAGE_BINS); do \
+          $(INSTALL_BIN) bin/$(platform)/$(package)-$(version)/$$i $(bindir); \
        done;
+       for in in $(VERSION_SYMLINKS_FOR) ""; do \
+          if [ "x$$i" != "x"]; then \
+               $(INSTALL_BIN) bin/$(platform)/$(package)-$(version)/$$i $(bindir); \
+          fi; \
+       done
 
-install : install-dirs
 
-install :
-       $(INSTALL_PROGRAM) `pwd`/bin/$(platform)/$(package)-$(version)/* $(bindir)
-       @for i in $(libdirs); do \
-          echo $(INSTALL) `pwd`/lib/$(platform)/$(package)-$(version)/$$i/* $(real_libdir)/$$i; \
-          $(INSTALL) `pwd`/lib/$(platform)/$(package)-$(version)/$$i/* $(real_libdir)/$$i; \
-       done; 
-       @for i in $(datadirs); do \
-          echo $(INSTALL) `pwd`/share/$(package)-$(version)/$$i/* $(real_datadir)/$$i; \
-          $(INSTALL) `pwd`/share/$(package)-$(version)/$$i/* $(real_datadir)/$$i; \
-       done; 
+install-libs:
+       (cd lib/$(platform)/$(package)-$(version); find . -type f -exec sh -c '$(INSTALL_LIB) $0 $(real_libdir)/$0' {} \; )
 
-install-docs : install-info install-html install-dvi
+install-datas:
+       (cd share/$(package)-$(version); find . -type f -exec sh -c '$(INSTALL_DATA) $0 $(real_datadir)/$0' {} \; )
 
-install-dirs-html:
-       $(MKDIRHIER) $(htmldir) 
+show-install-setup:
+       @echo "Install setup..."
+       @echo "bindir  = $(bindir)"
+       @echo "libdir  = $(libdir) (real_libdir  = $(real_libdir))"
+       @echo "datadir = $(datadir) (real_datadir = $(real_datadir))"
 
-install-dirs-info:
-       $(MKDIRHIER) $(infodir) 
+#
+# Documentation targets, install-docs for the whole lot, or
+# install-{dvi,html,info}
+#
 
-install-dirs-dvi:
-       $(MKDIRHIER) $(dvidir) 
+.PHONY: show-install-setup install-docs install-html install-info install-dirs-dvi install-dirs-html install-dirs-info
 
-install-docs : install-html install-info install-dvi 
+install-docs : install-html install-dvi install-info
 
 install-dvi: install-dirs-dvi
-       $(INSTALL) `pwd`/dvi/$(package)-$(version)/* $(dvidir)
+       $(INSTALL_DATA) dvi/$(package)-$(version)/* $(dvidir)
 
 install-info: install-dirs-info
-       $(INSTALL) `pwd`/info/$(package)-$(version)/* $(infodir)
+       $(INSTALL_DATA) info/$(package)-$(version)/* $(infodir)
 
 install-html: install-dirs-html
-       $(INSTALL) `pwd`/html/$(package)-$(version)/* $(htmldir)
+       $(INSTALL_DATA) html/$(package)-$(version)/* $(htmldir)
+
+install-dirs-html:
+       $(INSTALL_DIR) $(htmldir) 
+
+install-dirs-info:
+       $(INSTALL_DIR) $(infodir) 
+
+install-dirs-dvi:
+       $(INSTALL_DIR) $(dvidir)