build ghctags-inplace
authorSimon Marlow <simonmar@microsoft.com>
Mon, 5 Nov 2007 16:39:54 +0000 (16:39 +0000)
committerSimon Marlow <simonmar@microsoft.com>
Mon, 5 Nov 2007 16:39:54 +0000 (16:39 +0000)
mk/config.mk.in
utils/ghctags/Makefile

index c569159..68f460e 100644 (file)
@@ -785,7 +785,7 @@ GHC_SPLIT_DIR_ABS   = $(FPTOOLS_TOP_ABS)/$(GHC_SPLIT_DIR_REL)
 GHC_UNLIT_PGM          = unlit$(exeext)
 GHC_HP2PS_PGM          = hp2ps
 GHC_HSTAGS_PGM         = hasktags
-GHC_GHCTAGS_PGM                = ghctags
+GHC_GHCTAGS_INPLACE_PGM        = ghctags-inplace
 GHC_HSC2HS_INPLACE_PGM = hsc2hs-inplace
 GHC_TOUCHY_PGM         = touchy$(exeext)
 GHC_MANGLER_PGM                = ghc-asm
@@ -811,7 +811,7 @@ endif
 UNLIT                  = $(GHC_UNLIT_DIR)/$(GHC_UNLIT_PGM)
 HP2PS                  = $(GHC_HP2PS_DIR)/$(GHC_HP2PS_PGM)
 HSTAGS                 = $(GHC_HSTAGS_DIR)/$(GHC_HSTAGS_PGM)
-GHCTAGS                        = $(GHC_GHCTAGS_DIR)/$(GHC_GHCTAGS_PGM)
+GHCTAGS_INPLACE                = $(GHC_GHCTAGS_DIR)/$(GHC_GHCTAGS_INPLACE_PGM)
 HSC2HS_INPLACE         = $(GHC_HSC2HS_DIR)/$(GHC_HSC2HS_INPLACE_PGM)
 MANGLER                        = $(GHC_MANGLER_DIR)/$(GHC_MANGLER_PGM)
 SPLIT                  = $(GHC_SPLIT_DIR)/$(GHC_SPLIT_PGM)
index 586c3b0..d3a59ff 100644 (file)
@@ -1,13 +1,60 @@
 TOP=../..
 include $(TOP)/mk/boilerplate.mk
 
-HS_PROG = ghctags
 SRC_HC_OPTS += -package ghc
+
 HC=$(GHC_STAGE1)
 
-CLEAN_FILES += Main.hi
+# 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           = ghctags.exe
+INSTALL_PROGS    += $(HS_PROG)
+else
+HS_PROG           = ghctags.bin
+INSTALL_LIBEXECS += $(HS_PROG)
+endif
+
+# -----------------------------------------------------------------------------
+# ghctags and ghctags-inplace scripts
+
+# See commentary in ../ghc-pkg/Makefile
+
+INPLACE_HS=ghctags-inplace.hs
+INPLACE_PROG=ghctags-inplace
+EXCLUDED_SRCS+=$(INPLACE_HS)
+
+$(INPLACE_HS): Makefile $(FPTOOLS_TOP)/mk/config.mk
+       echo "import System.Cmd; import System.Environment; import System.Exit" > $@
+       echo "main = do args <- getArgs; rawSystem \"$(FPTOOLS_TOP_ABS)/$(GHC_GHCTAGS_DIR_REL)/$(HS_PROG)\" (\"--topdir\":\"$(FPTOOLS_TOP_ABS)\":args) >>= exitWith" >> $@
+
+$(INPLACE_PROG): $(INPLACE_HS)
+       $(HC) --make $< -o $@
+
+all :: $(INPLACE_PROG)
+
+CLEAN_FILES += $(INPLACE_HS) $(INPLACE_PROG)
+
+ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
+LINK = ghctags
+LINK_TARGET = $(LINK)-$(ProjectVersion)
+INSTALLED_SCRIPT=$(DESTDIR)$(bindir)/$(LINK_TARGET)
+install::
+       $(INSTALL_DIR) $(DESTDIR)$(bindir)
+       $(RM) -f $(INSTALLED_SCRIPT)
+       echo "#!$(SHELL)"                                      >> $(INSTALLED_SCRIPT)
+       echo "GHCTAGSBIN=$(libexecdir)/$(HS_PROG)"             >> $(INSTALLED_SCRIPT)
+       echo "TOPDIR=$(libdir)"                                >> $(INSTALLED_SCRIPT)
+       echo 'exec $$GHCTAGSBIN --topdir $$TOPDIR $${1+"$$@"}' >> $(INSTALLED_SCRIPT)
+       $(EXECUTABLE_FILE) $(INSTALLED_SCRIPT)
+endif
 
-INSTALL_PROGS += $(HS_PROG)
+binary-dist:
+       $(INSTALL_DIR)                $(BIN_DIST_DIR)/utils/ghctags
+       $(INSTALL_DATA)    Makefile   $(BIN_DIST_DIR)/utils/ghctags/
+       $(INSTALL_PROGRAM) $(HS_PROG) $(BIN_DIST_DIR)/utils/ghctags/
 
 include $(TOP)/mk/target.mk