[project @ 2004-11-10 03:20:31 by wolfgang]
[ghc-hetmet.git] / ghc / utils / ghc-pkg / Makefile
index 896742e..5280887 100644 (file)
@@ -1,5 +1,4 @@
 # -----------------------------------------------------------------------------
-# $Id: Makefile,v 1.18 2002/09/09 11:32:38 simonmar Exp $
 
 TOP=../..
 include $(TOP)/mk/boilerplate.mk
@@ -10,23 +9,40 @@ INSTALLING=1
 # -----------------------------------------------------------------------------
 # ghc-pkg.bin
 
-SRC_HC_OPTS      += -cpp -DPKG_TOOL -DWANT_PRETTY
-
 ghc_ge_504 = $(shell if (test $(GhcCanonVersion) -ge 504); then echo YES; else echo NO; fi)
 
+SRC_HC_OPTS      += -cpp -DPKG_TOOL -DWANT_PRETTY
+
 ifeq "$(ghc_ge_504)" "NO"
 SRC_HC_OPTS +=  -package lang -package util -package text
 endif
 
-HS_PROG           = ghc-pkg.bin
-INSTALL_LIBEXECS += $(HS_PROG)
-
+# On Windows, ghc-pkg is a standalone program
+# ($bindir/ghc-pkg.exe), whereas on Unix it needs a wrapper script
+# to pass the appropriate flag to the real binary
+# ($libexecdir/ghc-pkg.bin) so that it can find package.conf.
 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
 HS_PROG           = ghc-pkg.exe
 INSTALL_PROGS    += $(HS_PROG)
-SRC_HC_OPTS      += -package win32
+else
+HS_PROG           = ghc-pkg.bin
+INSTALL_LIBEXECS += $(HS_PROG)
 endif
 
+# -----------------------------------------------------------------------------=
+# Create the Version.hs file
+
+VERSION_HS = Version.hs
+EXTRA_SRCS += $(VERSION_HS)
+
+boot :: $(VERSION_HS)
+
+Version.hs : $(TOP)/mk/version.mk
+       @$(RM) -f $(VERSION_HS)
+       @echo "Creating $(VERSION_HS) ... "
+       @echo "module Version where" >>$(VERSION_HS)
+       @echo "version = \"$(ProjectVersion)\"" >> $(VERSION_HS)
+
 # -----------------------------------------------------------------------------
 # ghc-pkg script
 
@@ -40,7 +56,7 @@ PKGCONF=$(libdir)/package.conf
 endif # BIN_DIST
 else
 GHCPKGBIN=$(FPTOOLS_TOP_ABS)/ghc/utils/ghc-pkg/$(HS_PROG)
-PKGCONF=$(FPTOOLS_TOP_ABS)/ghc/driver/package.conf.inplace
+PKGCONF=$(FPTOOLS_TOP_ABS_PLATFORM)/ghc/driver/package.conf.inplace
 endif
 
 ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"