ocaml-core / base / core / extended / oasis.sh

The branch 'bash' does not exist.
Diff from to

base/core/extended/oasis.sh

-#!/bin/bash
+#!/usr/bin/env bash
 set -e -u -o pipefail
 
+enable_linux=false
+enable_linux_default="--disable-linux"
+case $(ocamlc -config | awk '$1 == "system:" {print $2}') in
+    linux|linux_elf)
+        enable_linux=true
+        enable_linux_default="--enable-linux"
+    ;;
+esac
+
+enable_timers=false
+enable_timers_default="--disable-posix-timers"
+if [[ $(getconf _POSIX_TIMERS 2>/dev/null) -ge 200112 ]]; then
+    enable_timers=true
+    enable_timers_default="--enable-posix-timers"
+fi
+
+opts=( "$@" )
+for ((i=0; i<$#; i++)); do
+    case ${opts[$i]} in
+        --enable-linux)  enable_linux=true;  enable_linux_default= ;;
+        --disable-linux) enable_linux=false; enable_linux_default= ;;
+        --enable-posix-timers)  enable_timers=true;  enable_timers_default= ;;
+        --disable-posix-timers) enable_timers=false; enable_timers_default= ;;
+    esac
+done
+
 here="$(dirname "${BASH_SOURCE[0]}")"
 my_join () {
     FIRST="true"
         bname="$(basename $i)"
         j=${bname%%.ml*};
         case $j in
-            malloc) continue;;
-            extended_linux) continue;;
+            malloc|extended_linux)
+                if [ "$enable_linux" == "false" ]; then continue; fi;;
+            bench|posix_clock)
+                if [ "$enable_timers" == "false" ]; then continue; fi;;
             inline_tests_runner) continue;;
-            type) continue;;
             *);;
         esac
         echo -n "${j:0:1}" | tr "[:lower:]" "[:upper:]"; echo ${j:1};
         bname="$(basename $i)"
         j=${bname%%.?};
         case $j in
-            malloc_stubs) continue;;
-            extended_linux_stubs) continue;;
+            malloc_stubs|extended_linux_stubs)
+                if [ "$enable_linux" == "false" ]; then continue; fi;;
+            posix_clock_stubs)
+                if [ "$enable_timers" == "false" ]; then continue; fi;;
             *);;
         esac
         echo "$bname"
 }
 
 MODULES="$(list_mods | sort -u | my_join)"
+CSOURCES="fork_exec.h,$(list_stubs | sort -u | my_join)"
 
 cat >$here/_oasis <<EOF
 #AUTOGENERATED FILE; EDIT oasis.sh INSTEAD
 XStdFilesINSTALLFilename: INSTALL
 XStdFilesREADME: false
 
-PreBuildCommand: mkdir -p _build; cp lib/*mlh _build/
+Flag linux
+  Description: Enable linux specific extensions
+  Default\$:   $enable_linux
+
+Flag "posix-timers"
+  Description: Enable POSIX timers
+  Default\$:   $enable_timers
+
+PreBuildCommand: mkdir -p _build/lib; cp lib/*.mlh _build/; cp ../lib/*.h _build/lib/
+PreDistCleanCommand: \$rm lib/version_defaults.mlh lib/config.mlh
 
 Library core_extended
   Path:               lib
   FindlibName:        core_extended
   Pack:               true
-  Modules:${MODULES}
-  CCopt+:              -I../../lib
-#ls *.{c,h} | sort
-  CSources:           fork_exec.h,$(list_stubs | sort -u|my_join)
+  Modules:            ${MODULES}
+  CSources:           ${CSOURCES}
+  CCOpt+:             -Ilib
 
   BuildDepends:       sexplib.syntax,
                       sexplib,
 # OASIS_START
 # OASIS_STOP
 <lib/*.ml{,i}>: syntax_camlp4o
-"lib/std.ml": pp(cpp -undef -traditional -Werror -I.)
+"lib/std.ml": pkg_camlp4.macro
 "lib/command.ml": pkg_camlp4.macro
+"lib/console.ml": pkg_camlp4.macro
 "lib/core_command.ml": pkg_camlp4.macro
 EOF
 
 EOF
 fi
 
+cat >$here/lib/config.mlh <<EOF
+$(if [[ "$enable_linux"  == "true" ]]; then echo "DEFINE LINUX_EXT"; fi)
+$(if [[ "$enable_timers" == "true" ]]; then echo "DEFINE POSIX_TIMERS"; fi)
+EOF
+
 cd $here
 oasis setup
-./configure "$@"
+./configure "$enable_timers_default" "$enable_linux_default" "$@"
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.