enable previously-broken thread tests on Darwin
[sbcl.git] / make-config.sh
index 472cd3a..62f08b4 100644 (file)
@@ -42,6 +42,10 @@ bad_option() {
     exit 1
 }
 
     exit 1
 }
 
+WITH_FEATURES=""
+WITHOUT_FEATURES=""
+
+fancy=false
 some_options=false
 for option
 do
 some_options=false
 for option
 do
@@ -49,11 +53,16 @@ do
   # Split --foo=bar into --foo and bar.
   case $option in
       *=*)
   # Split --foo=bar into --foo and bar.
   case $option in
       *=*)
-        # For ease of scripting treat skip valued options with empty
+        # For ease of scripting skip valued options with empty
         # values.
         optarg=`expr "X$option" : '[^=]*=\(.*\)'` || optarg_ok=false
         option=`expr "X$option" : 'X\([^=]*=\).*'`
         ;;
         # values.
         optarg=`expr "X$option" : '[^=]*=\(.*\)'` || optarg_ok=false
         option=`expr "X$option" : 'X\([^=]*=\).*'`
         ;;
+      --with*)
+        optarg=`expr "X$option" : 'X--[^-]*-\(.*\)'` \
+            || bad_option "Malformed feature toggle: $option"
+        option=`expr "X$option" : 'X\(--[^-]*\).*'`
+        ;;
       *)
         optarg=""
         ;;
       *)
         optarg=""
         ;;
@@ -74,6 +83,17 @@ do
       --dynamic-space-size=)
         $optarg_ok && SBCL_DYNAMIC_SPACE_SIZE=$optarg
        ;;
       --dynamic-space-size=)
         $optarg_ok && SBCL_DYNAMIC_SPACE_SIZE=$optarg
        ;;
+      --with)
+        WITH_FEATURES="$WITH_FEATURES :$optarg"
+        ;;
+      --without)
+        WITHOUT_FEATURES="$WITHOUT_FEATURES :$optarg"
+       ;;
+      --fancy)
+        WITH_FEATURES="$WITH_FEATURES :sb-core-compression :sb-xref-for-internals :sb-after-xc-core"
+        # Lower down we add :sb-thread for platforms where it can be built.
+        fancy=true
+        ;;
       -*)
         bad_option "Unknown command-line option to $0: \"$option\""
         ;;
       -*)
         bad_option "Unknown command-line option to $0: \"$option\""
         ;;
@@ -89,6 +109,17 @@ do
   some_options=true
 done
 
   some_options=true
 done
 
+if (test -f customize-target-features.lisp && \
+    (test -n "$WITH_FEATURES" || test -n "$WITHOUT_FEATURES"))
+then
+    # Actually there's no reason why it would not work, but it would
+    # be confusing to say --with-thread only to have it turned off by
+    # customize-target-features.lisp...
+    echo "ERROR: Both customize-target-features.lisp, and feature-options"
+    echo "to make.sh present -- cannot use both at the same time."
+    exit 1
+fi
+
 # Previously XC host was provided as a positional argument. 
 if test -n "$legacy_xc_spec"
 then
 # Previously XC host was provided as a positional argument. 
 if test -n "$legacy_xc_spec"
 then
@@ -131,6 +162,9 @@ Options:
       taken to be megabytes unless explicitly suffixed with Gb in
       order to specify the size in gigabytes.
 
       taken to be megabytes unless explicitly suffixed with Gb in
       order to specify the size in gigabytes.
 
+  --with-<feature>     Build with specified feature.
+  --without-<feature>  Build wihout the specfied feature.
+
   --arch=<string>      Specify the architecture to build for.
 
       Mainly for doing x86 builds on x86-64.
   --arch=<string>      Specify the architecture to build for.
 
       Mainly for doing x86 builds on x86-64.
@@ -281,13 +315,6 @@ echo //entering make-config.sh
 echo //ensuring the existence of output/ directory
 if [ ! -d output ] ; then mkdir output; fi
 
 echo //ensuring the existence of output/ directory
 if [ ! -d output ] ; then mkdir output; fi
 
-ltf=`pwd`/local-target-features.lisp-expr
-echo //initializing $ltf
-echo ';;;; This is a machine-generated file.' > $ltf
-echo ';;;; Please do not edit it by hand.' >> $ltf
-echo ';;;; See make-config.sh.' >> $ltf
-printf '(' >> $ltf
-
 echo //guessing default target CPU architecture from host architecture
 case `uname -m` in
     *86) guessed_sbcl_arch=x86 ;;
 echo //guessing default target CPU architecture from host architecture
 case `uname -m` in
     *86) guessed_sbcl_arch=x86 ;;
@@ -322,16 +349,42 @@ if [ "$sbcl_os" = "darwin" ] && [ "`/usr/sbin/sysctl -n hw.optional.x86_64`" = "
 fi
 
 echo //setting up CPU-architecture-dependent information
 fi
 
 echo //setting up CPU-architecture-dependent information
+if test -n "$SBCL_ARCH"
+then
+    # Normalize it.
+    SBCL_ARCH=`echo $SBCL_ARCH | tr '[A-Z]' '[a-z]' | tr _ -`
+fi
 sbcl_arch=${SBCL_ARCH:-$guessed_sbcl_arch}
 echo sbcl_arch=\"$sbcl_arch\"
 if [ "$sbcl_arch" = "" ] ; then
     echo "can't guess target SBCL architecture, please specify --arch=<name>"
     exit 1
 fi
 sbcl_arch=${SBCL_ARCH:-$guessed_sbcl_arch}
 echo sbcl_arch=\"$sbcl_arch\"
 if [ "$sbcl_arch" = "" ] ; then
     echo "can't guess target SBCL architecture, please specify --arch=<name>"
     exit 1
 fi
+if $fancy
+then
+    # If --fancy, enable threads on platforms where they can be built.
+    case $sbcl_arch in
+        x86|x86-64|ppc)
+            WITH_FEATURES="$WITH_FEATURES :sb-thread"
+            echo "Enabling threads due to --fancy."
+            ;;
+        *)
+            echo "No threads on this platform."
+            ;;
+    esac
+fi
+
+ltf=`pwd`/local-target-features.lisp-expr
+echo //initializing $ltf
+echo ';;;; This is a machine-generated file.' > $ltf
+echo ';;;; Please do not edit it by hand.' >> $ltf
+echo ';;;; See make-config.sh.' >> $ltf
+echo "((lambda (features) (set-difference features (list$WITHOUT_FEATURES)))" >> $ltf
+printf " (union (list$WITH_FEATURES) (list " >> $ltf
+
 printf ":%s" "$sbcl_arch" >> $ltf
 
 echo //setting up OS-dependent information
 printf ":%s" "$sbcl_arch" >> $ltf
 
 echo //setting up OS-dependent information
-
 # Under Darwin x86-64, guess whether Darwin 9+ or below.
 if [ "$sbcl_os" = "darwin" ] && [ "$sbcl_arch" = "x86-64" ]; then
     darwin_version=`uname -r`
 # Under Darwin x86-64, guess whether Darwin 9+ or below.
 if [ "$sbcl_os" = "darwin" ] && [ "$sbcl_arch" = "x86-64" ]; then
     darwin_version=`uname -r`
@@ -571,7 +624,7 @@ export sbcl_os sbcl_arch
 sh tools-for-build/grovel-features.sh >> $ltf
 
 echo //finishing $ltf
 sh tools-for-build/grovel-features.sh >> $ltf
 
 echo //finishing $ltf
-echo ')' >> $ltf
+echo ')))' >> $ltf
 
 # FIXME: The version system should probably be redone along these lines:
 #
 
 # FIXME: The version system should probably be redone along these lines:
 #