Build the timeout program with Cabal
authorIan Lynagh <igloo@earth.li>
Wed, 23 Jul 2008 20:24:43 +0000 (20:24 +0000)
committerIan Lynagh <igloo@earth.li>
Wed, 23 Jul 2008 20:24:43 +0000 (20:24 +0000)
testsuite/mk/test.mk
testsuite/timeout/Makefile
testsuite/timeout/timeout.cabal [new file with mode: 0644]

index f147821..0b7f6a0 100644 (file)
@@ -104,7 +104,7 @@ RUNTEST_OPTS +=  \
        -e config.wordsize=\"$(WORDSIZE)\" \
        -e default_testopts.cleanup=\"$(CLEANUP)\" \
        -e config.timeout="int($(TIMEOUT)) or config.timeout" \
-       -e config.timeout_prog=\"$(TOP)/timeout/timeout\" \
+       -e config.timeout_prog=\"$(TIMEOUT_PROGRAM)\" \
        -e config.exeext=\"$(exeext)\" \
        -e config.top=\"$(FPTOOLS_TOP_ABS)/testsuite\" \
        $(EXTRA_RUNTEST_OPTS)
@@ -130,9 +130,11 @@ WAY =
 
 all :: test
 
-timeout : $(TOP)/timeout/timeout$(exeext)
+TIMEOUT_PROGRAM = $(TOP)/timeout/install-inplace/bin/timeout$(exeext)
 
-$(TOP)/timeout/timeout$(exeext) :
+timeout : $(TIMEOUT_PROGRAM)
+
+$(TIMEOUT_PROGRAM) :
        @echo "Looks like you don't have timeout, building it first..."
        cd $(TOP)/timeout && $(MAKE) $(MFLAGS) all
 
index 64c2ec7..7accd59 100644 (file)
@@ -1,41 +1,36 @@
-TOP = ..
+TOP = ../..
 include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/cabal-flags.mk
 
-HC = $(GHC_INPLACE)
-# These are required to stop the build system adding -package-conf
-# bootstrapping.mk, which only makes sense when $(HC)==$(GHC)
-BOOTSTRAPPING_PACKAGE_CONF_HC_OPTS=
-BOOTSTRAPPING_PACKAGE_CONF_MKDEPENDHS_OPTS=
+TIMEOUT_PROGRAM = install-inplace/bin/timeout$(exeext)
 
-MKDEPENDHS = $(GHC_INPLACE)
-SRC_HC_OPTS += -threaded
-EXCLUDED_SRCS += TimeMe.hs
-
-ifeq "$(Windows)" "YES"
-SRC_HC_OPTS += -package Win32
+ifeq "$(findstring thr,$(GhcRTSWays))" ""
+$(TIMEOUT_PROGRAM): timeout.py
+       $(MKDIRHIER) `dirname $@`
+       cp $< $@
+       chmod +x $@
 else
-SRC_HC_OPTS += -package unix
+$(TIMEOUT_PROGRAM): timeout.hs
+       $(CABAL) configure $(USE_STAGE1_CONFIGURE_FLAGS)   \
+                          $(INPLACE_DIRS_CONFIGURE_FLAGS) \
+                          $(COMMON_CONFIGURE_FLAGS)       \
+                                          --ghc-option=-threaded
+       $(CABAL) build
+       $(CABAL) install
 endif
 
-all :: calibrate.out
-
-ifeq "$(findstring thr,$(GhcRTSWays))" "thr"
-HS_PROG = timeout
-else
-all :: python-timeout
-CLEAN_FILES += timeout
-endif
-
-boot :: all
+boot all :: calibrate.out $(TIMEOUT_PROGRAM)
 
 calibrate.out:
-       rm -f TimeMe.o TimeMe.hi TimeMe
-       $(PYTHON) calibrate "$(HC)" > $@
-
-CLEAN_FILES += calibrate.out
-
-python-timeout:
-       cp timeout.py timeout
-       chmod +x timeout
+       $(RM) -f TimeMe.o TimeMe.hi TimeMe TimeMe.exe
+       $(PYTHON) calibrate "$(GHC_STAGE1)" > $@
+# We use stage 1 to do the calibration, as stage 2 may not exist.
+# This isn't necessarily the compiler we'll be running the testsuite
+# with, but it's really the performance of the machine that we're
+# interested in
+
+clean distclean:
+       $(CABAL) clean
+       $(RM) -rf install-inplace
+       $(RM) -f calibrate.out
 
-include $(TOP)/mk/target.mk
diff --git a/testsuite/timeout/timeout.cabal b/testsuite/timeout/timeout.cabal
new file mode 100644 (file)
index 0000000..276edb4
--- /dev/null
@@ -0,0 +1,24 @@
+Name: timeout
+-- XXX Version number:
+Version: 1
+Copyright: XXX
+License: BSD3
+-- XXX License-File: LICENSE
+Author: XXX
+Maintainer: XXX
+Synopsis: XXX
+Description:
+       XXX
+Category: Development
+build-type: Simple
+cabal-version: >=1.2
+
+Executable timeout
+    Main-Is: timeout.hs
+    Extensions: CPP
+    Build-Depends: base, process
+    if os(windows)
+        Build-Depends: Win32
+    else
+        Build-Depends: unix
+