Source

ocaml-core / base / core / oasis.sh

The branch 'bash' does not exist.
#!/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

use_librt=
if ld -lrt -shared -o /dev/null 2>/dev/null; then
    use_librt=-lrt
fi

here="$(dirname "${BASH_SOURCE[0]}")"
my_join () {
    local FIRST="true"
    while read line; do
        if [[ "$FIRST" != "true" ]]; then
            echo -n ","
        else
            FIRST="false"
        fi
        echo -n "$line"
    done
    echo
}

list_mods () {
    for i in "$here"/lib/*.ml; do
        bname="$(basename $i)"
        j=${bname%%.ml*};
        case $j in
            linux_ext|bigstring_marshal)
                if [ "$enable_linux" == "false" ]; then continue; fi;;
            inline_tests_runner) continue;;
            *);;
        esac
        echo -n "${j:0:1}" | tr "[:lower:]" "[:upper:]"; echo ${j:1};
    done
}

list_stubs () {
    for i in "$here"/lib/*.{c,h}; do
        bname="$(basename $i)"
        j=${bname%%.?};
        case $j in
            linux_ext_stubs|bigstring_marshal_stubs)
                if [ "$enable_linux" == "false" ]; then continue; fi;;
            *);;
        esac
        echo "$bname"
    done
}

MODULES="$(list_mods | sort -u | my_join)"
CSOURCES="config.h,$(list_stubs | sort -u| my_join)"
CCLIB="$use_librt"

cat >$here/_oasis<<EOF
#AUTOGENERATED FILE; EDIT oasis.sh INSTEAD

OASISFormat:  0.2
OCamlVersion: >= 3.12
Name:         core
Version:      107.01
Synopsis:     Jane Street Capital's standard library overlay
Authors:      Jane street capital
Copyrights:   (C) 2008-2010 Jane Street Capital LLC
License:      LGPL-2.1 with OCaml linking exception
LicenseFile:  LICENSE
Plugins:      StdFiles (0.2),
              DevFiles (0.2),
              META (0.2)
BuildTools:   ocamlbuild
Description:  Jane Street Capital's standard library overlay
FindlibVersion: >= 1.2.7
XStdFilesAUTHORS: false
XStdFilesINSTALLFilename: INSTALL
XStdFilesREADME: false


Flag linux
  Description: Enable linux specific extensions
  Default\$:   $enable_linux

Flag "posix-timers"
  Description: Enable POSIX timers
  Default\$:   $enable_timers

PostConfCommand: lib/discover.sh lib/config.mlh lib/config.h $(
  if [[ "$enable_linux"  == "true" ]]; then echo -n " -DLINUX_EXT"; fi
  if [[ "$enable_timers" == "true" ]]; then echo -n " -DPOSIX_TIMERS"; fi
  echo
)

PreBuildCommand:     mkdir -p _build/; cp lib/*.mlh _build/
PreDistCleanCommand: \$rm "lib/config.mlh" "lib/config.h"

Library core
  Path:               lib
  FindlibName:        core
  Pack:               true
  Modules:${MODULES}
  CCOpt:              $(getconf LFS64_CFLAGS)
  CSources:           ${CSOURCES}
  CCLib:              ${CCLIB}
  BuildDepends:       variantslib,
                      variantslib.syntax,
                      sexplib.syntax,
                      sexplib,
                      fieldslib.syntax,
                      fieldslib,
                      bin_prot,
                      bin_prot.syntax,
                      bigarray,
                      pa_ounit,
                      pa_pipebang,
                      res,
                      unix,
                      threads

Flag tests
  Description:        Build and run tests
  Default:            false

Executable test_runner
  Path:               lib_test
  MainIs:             test_runner.ml
  Build$:             flag(tests)
  Custom:             true
#  CompiledObject:     best
  Install:            false
  BuildDepends:       core,oUnit (>= 1.0.2)

Test test_runner
  Run\$:               flag(tests)
  Command:            \$test_runner
  WorkingDirectory:   lib_test

Document "core"
  Title:                Jane street's core library
  Type:                 ocamlbuild (0.2)
  BuildTools+:          ocamldoc
  XOCamlbuildPath:      lib
  XOCamlbuildLibraries: core

EOF

cat >$here/_tags <<EOF
# OASIS_START
# OASIS_STOP
<lib{,_test}/*.ml{,i}>: syntax_camlp4o
<lib/{std,core_int63,bigstring,core_mutex,core_unix,bigstring_marshal,linux_ext}.ml{,i}>:pkg_camlp4.macro
EOF

cd $here
oasis setup
./configure "$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.