|
From: <cod...@go...> - 2008-12-10 22:32:17
|
Author: jam...@us...
Date: Wed Dec 10 14:10:22 2008
New Revision: 376
Modified:
/ (props changed)
branches/objc2/hoc/HOC.cabal
branches/objc2/hoc/Setup.hs
Log:
r380@Macintosh: james.cook | 2008-12-10 17:09:59 -0500
(objc2 branch) Added simple autodetection for ObjC2 build flag.
Modified: branches/objc2/hoc/HOC.cabal
==============================================================================
--- branches/objc2/hoc/HOC.cabal (original)
+++ branches/objc2/hoc/HOC.cabal Wed Dec 10 14:10:22 2008
@@ -16,7 +16,6 @@
Flag ObjC2
description: build for Objective-C 2.0
- default: False
Library
build-depends: base, template-haskell, unix
Modified: branches/objc2/hoc/Setup.hs
==============================================================================
--- branches/objc2/hoc/Setup.hs (original)
+++ branches/objc2/hoc/Setup.hs Wed Dec 10 14:10:22 2008
@@ -27,6 +27,34 @@
| exeName e == "hoc-test" = True
| otherwise = False
+objc2_flagName = FlagName "objc2"
+
+setObjC2Flag :: ConfigFlags -> IO ConfigFlags
+setObjC2Flag cf
+ -- if the flag is set on the command line, do nothing
+ | lookup (objc2_flagName) (configConfigurationsFlags cf) /= Nothing
+ = return cf
+
+ -- if we're not on darwin, assume false
+ | System.Info.os /= "darwin"
+ = return $ addFlag objc2_flagName False cf
+
+ -- otherwise make an educated guess
+ | otherwise
+ = do
+ value <- objC2Available
+ return $ addFlag objc2_flagName value cf
+
+ where addFlag flag value cf = cf { configConfigurationsFlags =
+ (flag,value) : configConfigurationsFlags cf }
+
+objC2Available :: IO Bool
+objC2Available
+ | System.Info.os /= "darwin" = return False
+ | otherwise = do
+ result <- system "grep -qR /usr/include/objc -e
objc_allocateClassPair"
+ return (result == ExitSuccess)
+
backquote :: String -> IO String
backquote cmd = do
(inp,out,err,pid) <- runInteractiveCommand cmd
@@ -54,6 +82,8 @@
customConfig :: (Either GenericPackageDescription PackageDescription,
HookedBuildInfo) -> ConfigFlags -> IO LocalBuildInfo
customConfig pdbi cf = do
+ cf <- setObjC2Flag cf
+
lbi <- configure pdbi cf
if System.Info.os == "darwin"
then return()
|