Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Freebsd port #13

Merged
merged 8 commits into from

5 participants

@fperrin

This branch contains a series of tweaks to the build system (mostly) that enables opalang ot be built on FreeBSD. The code should still build fine on Linux and Mac systems.

One additionnal change (the one contained in the no-java branch) is necessary to build opalang under GNU/kFreeBSD, as on this system java is broken.

@aszlig

hm, might make more sense to remove bashisms from those scripts and use /bin/sh.
just created an issue in my fork, so if i should have some time these days, i'll work on it.

@aszlig

okay, if that works for bsd sed (but i guess it won't), it will definitely break gnu sed, as the * multiplier doesn't have to be quoted there (but the + has, because it's a gnu extension).
i'd write it that way:
"^ *import *\\([^ ][^ ]*\\) *$"
(i put the [^ ] there, because sed is greedy and .* already eats up whitespaces until the end of the line)

Hum, indeed, I have one * quoted, and one that isn't. GNU sed accepts both, IIUC the "Regular Expressions" node of sed.info. It's possible that it worked in BSD sed only by accident...

Actually, it is possible to use the `-r' flad to sed (like I did in the other sed call) and use "modern" regexp, where +, * and () are special characters. That would make the regexp clearer, and without double escaping:

let dep_regexp = "^ *import +([^ ]+) *$" in
  Cmd(S[sed; A"-n"; A"-r"; A("s%"^dep_regex^"%\\1.opx%p");
@frsinot

It seems to work on MacOS X too, and your commits are clean. So I'm going: 1. to thank you for the great work 2. to merge into master.

Independently, we can discuss about dependency to bash. I don't see clearly what the arguments are against this dependency, but I can be convinced.

@git-mlstate git-mlstate referenced this pull request from a commit
François-Régis Sinot [contrib] merge: FreeBSD port, pull request #13 from git://github.com…
…/fperrin/opalang
f37a024
@git-mlstate git-mlstate merged commit 39997a8 into from
@alokmenghrajani

You need md5 for mac os too. I tried to build on mac os x (10.8), and things failed because of this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 21, 2011
  1. @fperrin

    Use kqueue on FreeBSD too

    fperrin authored
  2. @fperrin

    Check for java

    fperrin authored
  3. @fperrin
  4. @fperrin

    amd64 is a synonym for x86_64

    fperrin authored
Commits on Sep 25, 2011
  1. @fperrin
  2. @fperrin

    New platform: `FreeBSD'

    fperrin authored
    GNU/kFreeBSD still uses `Linux' as the platform.
    
    Like Linux, but uses `cp' instead of `cp -u'.
  3. @fperrin
  4. @fperrin
This page is out of date. Refresh to see the latest.
View
10 Makefile
@@ -10,6 +10,8 @@
include config.make
INSTALL ?= cp -u -L
+MAKE ?= $_
+export MAKE
ifndef NO_REBUILD_OPA_PACKAGES
OPAOPT += "--rebuild"
@@ -152,7 +154,9 @@ uninstall:
# Install our ocamlbuild-generation engine
install-bld:
@mkdir -p $(INSTALL_DIR)/bin
- @echo "#!/bin/bash -ue" > $(INSTALL_DIR)/bin/bld
+ @echo "#!/usr/bin/env bash" > $(INSTALL_DIR)/bin/bld
+ @echo "set -e" >> $(INSTALL_DIR)/bin/bld
+ @echo "set -u" >> $(INSTALL_DIR)/bin/bld
@chmod 755 $(INSTALL_DIR)/bin/bld
@echo "BLDDIR=$(PREFIX)/share/opa/bld $(PREFIX)/share/opa/bld/gen_myocamlbuild.sh" >> $(INSTALL_DIR)/bin/bld
@echo "_build/myocamlbuild -no-plugin -j 6 \"\$$@\"" >> $(INSTALL_DIR)/bin/bld
@@ -164,7 +168,9 @@ install-bld:
install-qmlflat: # depends on opabsl_for_compiler, but we don't want to run ocamlbuild twice
@mkdir -p $(INSTALL_DIR)/bin $(INSTALL_DIR)/share/opa/mlstatebsl
@$(INSTALL) $(BUILD_DIR)/opabsl/mlstatebsl/opabslgen_*.opa $(INSTALL_DIR)/share/opa/mlstatebsl
- @echo "#!/bin/bash -ue" > $(INSTALL_DIR)/bin/qmlflat
+ @echo "#!/usr/bin/env bash" > $(INSTALL_DIR)/bin/qmlflat
+ @echo "set -e" >> $(INSTALL_DIR)/bin/qmlflat
+ @echo "set -u" >> $(INSTALL_DIR)/bin/qmlflat
@chmod 755 $(INSTALL_DIR)/bin/qmlflat
@echo 'exec opa --no-stdlib --no-server --no-cps --no-closure --no-ei --no-constant-sharing --no-undot --separated off --value-restriction disabled --no-warn duplicateL0 --no-warn typer.warncoerce --no-warn unused --no-discard-of-unused-stdlib --no-warn pattern $$(if ! grep -qE "(^| )--no-stdlib( |$$)" <<<"$$*"; then echo $(shell sed "s%^[^# ]\+%$(PREFIX)/share/opa/mlstatebsl/opabslgen_&%; t OK; d; :OK" opabsl/mlstatebsl/bsl-sources); fi) "$$@"' \
>> $(INSTALL_DIR)/bin/qmlflat
View
2  README
@@ -21,7 +21,7 @@ $ sudo make install
should get you there. ./configure should report any missing dependencies and
point you to the packages you may install to fix them (although those may depend
-on your distribution).
+on your distribution). make needs to be GNU make.
The main dependency of OPA is OCaml 3.12. In case your distribution doesn't
provide a recent enough version, or if you miss some other dependencies, you can
View
12 appruntime/io/binding_epoll.c
@@ -75,13 +75,11 @@ value ep_close(value fd)
CAMLreturn(Val_int(close(fd)));
}
-#ifdef __APPLE__
-#ifdef __MACH__
-#define __APPLE__MACH__
-#endif
+#if (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#define USE_KQUEUE
#endif
-#ifdef __APPLE__MACH__
+#ifdef USE_KQUEUE
#include <sys/types.h>
#include <sys/event.h>
@@ -246,7 +244,7 @@ EXPORT(EPOLLHUP, EV_ERROR); // TODO with a hang up like event
//TODO //EXPORT(EPOLLET);
//TODO //EXPORT(EPOLLONESHOT);
-#else
+#else /* not USE_KQUEUE */
#include <sys/epoll.h>
@@ -344,7 +342,7 @@ SIMPLE_EXPORT(EPOLLERR)
SIMPLE_EXPORT(EPOLLET)
SIMPLE_EXPORT(EPOLLONESHOT)*/
-#endif // __APPLE__MACH__ FALSE BRANCH
+#endif // USE_KQUEUE FALSE BRANCH
#endif // MLSTATE_UNIX
View
5 build/bld.sh
@@ -1,4 +1,7 @@
-#!/bin/bash -ue
+#!/usr/bin/env bash
+
+set -u
+set -e
# README BEFORE EDITING THIS FILE!
#
View
5 build/gen_myocamlbuild.sh
@@ -1,4 +1,7 @@
-#!/bin/bash -ue
+#!/usr/bin/env bash
+
+set -u
+set -e
# This script reads files config.{sh,ml}, build_rules*.ml, build_libs, build_tools and uses them
# to build an ocamlbuild plugin in <build_dir>/myocamlbuild
View
10 build/myocamlbuild_prefix.ml
@@ -26,8 +26,10 @@ open Command
let mlstate_platform = "mlstate_platform"
let is_mac = Config.os = Config.Mac
+let is_fbsd = Config.os = Config.FreeBSD
-let sed = if is_mac then P"gsed" else P"sed"
+let sed = if is_mac then P"gsed" else P"sed"
+let md5 = if is_fbsd then P"md5" else P"md5sum"
(**
tools for which we call the windows version (and that need some call translation)
@@ -319,11 +321,11 @@ let _ = dispatch begin function
~dep:"%.mllibp"
~prod:"%.mllib"
(fun env _build ->
- let tags = String.uppercase (String.concat "\\|" Config.available) in
+ let tags = String.uppercase (String.concat "|" Config.available) in
let sedexpr =
- Printf.sprintf "s/^?HAS_\\(%s\\)://; t OK; /^?HAS_.*:/d; :OK" tags
+ Printf.sprintf "s/^\\?HAS_(%s)://; /HAS_.*:/d" tags
in
- Cmd(S[sed; A sedexpr; P(env "%.mllibp"); Sh">"; P(env "%.mllib")]));
+ Cmd(S[sed; A"-r"; A sedexpr; P(env "%.mllibp"); Sh">"; P(env "%.mllib")]));
(* Windows specific : redefinition of an existing rule in Ocaml_specific.ml,
Louis please have a look to avoid the two copies at the end
View
6 build_rules.ml
@@ -241,7 +241,7 @@ rule "opa parser version: opalang/syntax/* stdlib -> opalang/syntax/opaParserVer
let files = List.map (fun s-> P s) parser_files in
Seq[
Cmd(S ( [Sh"echo let hash = \\\" > "; P (opaParserVersion)]));
- Cmd(S ( [Sh"cat"] @ files @ [Sh"|";Sh"md5sum";Sh">>";P opaParserVersion]));
+ Cmd(S ( [Sh"cat"] @ files @ [Sh"|"; md5; Sh">>"; P opaParserVersion]));
Cmd(S ( [Sh"echo \\\" >>"; P opaParserVersion ] ))
]
);
@@ -650,8 +650,8 @@ rule "opadep: .opa -> .opa.depends"
~dep: "%.opa"
~prod: "%.opa.depends"
(fun env build ->
- let dep_regex = "^ *import \\+\\(.\\+\\)$" in
- Cmd(S[sed; A("s%"^dep_regex^"%\\1.opx%; t OK; d; :OK s% %%g"); P(env "%.opa");
+ let dep_regex = "^ *import \\*\\(.\\+\\) *$" in
+ Cmd(S[sed; A"-n"; A("s%"^dep_regex^"%\\1.opx%p"); P(env "%.opa");
Sh">";P(env "%.opa.depends")]));
rule "opacomp: .opa -> .native"
View
5 buildinfos/generate_buildinfos.sh
@@ -1,4 +1,7 @@
-#!/bin/bash -eu
+#!/usr/bin/env bash
+
+set -e
+set -u
# Copyright © 2011 MLstate
# This file is part of OPA.
View
2  compilerlib/opadep.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
# This script is used for generating opa files and packages dependency graphs
# It is meant to be called from any directory containing some .opx/ directories
View
5 config.mli
@@ -60,9 +60,12 @@ val all_tags : string list
val is_release : bool
(** the target OS type *)
-type os = Linux | Mac | Win32 | Cygwin
+type os = Linux | Mac | Win32 | Cygwin | FreeBSD
val os : os
+(** the name of the GNU make binary, gmake on fBSD, make on other platforms *)
+val makebinary : string
+
(** the installation directory of external libraries, as in the ocamlopt '-I'
command-line option ; None if no extra include directory is needed *)
module Libdir : sig
View
49 configure
@@ -1,4 +1,7 @@
-#!/bin/bash -ue
+#!/usr/bin/env bash
+
+set -u
+set -e
: ${OPA_SOURCE_DIR:=$(dirname $0)}
if [ "${OPA_SOURCE_DIR#/}" = "$OPA_SOURCE_DIR" ]; then OPA_SOURCE_DIR=$PWD/$OPA_SOURCE_DIR; fi
@@ -112,9 +115,12 @@ case $(uname) in
Darwin*)
echo-ok MacOS
IS_MAC=1;;
- Linux*)
+ Linux*|GNU/kFreeBSD)
echo-ok Linux
IS_LINUX=1;;
+ FreeBSD)
+ echo-ok FreeBSD
+ IS_FREEBSD=1;;
*)
echo-err "Not sure, probably Unix / Linux"
IS_LINUX=1
@@ -122,7 +128,7 @@ esac
echo-check your architecture
case $(uname -m) in
- x86_64)
+ x86_64|amd64)
echo-ok x86_64;;
i?86)
echo-ok ix86;;
@@ -170,6 +176,16 @@ if [ -n "${IS_MAC:-}" ]; then
. ./platform_helper.sh
fi
+if [ -n "${IS_FREEBSD:-}" ]; then
+ echo-check gmake
+ if which gmake >/dev/null 2>&1; then echo-ok ok
+ else
+ echo-err Not found
+ echo "Please install port devel/gmake."
+ exit 1
+ fi >&2
+fi
+
# check ocaml version and location
echo-check ocamlopt
if OCAMLOPT=${OCAMLOPT:-$(which ocamlopt.opt)} || OCAMLOPT=${OCAMLOPT:-$(which ocamlopt)}
@@ -287,6 +303,15 @@ else
exit 1
fi >&2
+# - checking for java
+echo-check for java
+if which java &>/dev/null; then
+ echo-ok found
+else
+ echo-err Not found
+ exit 1
+fi
+
# - checking camlidl *
echo-check for camlidl
if [ -n "${NO_CAMLIDL:-}" ]; then
@@ -627,13 +652,20 @@ let available = [ $TAGS_LIST]
let all_tags = [ $(for t in $ALL_TAGS_LIST; do echo -n "\"$t\"; "; done)]
let is_release = $(camlbool "$IS_RELEASE")
-type os = Linux | Mac | Win32 | Cygwin
+type os = Linux | Mac | Win32 | Cygwin | FreeBSD
let os =
$(if [ -n "${IS_LINUX:-}" ]; then echo Linux
elif [ -n "${IS_MAC:-}" ]; then echo Mac
+ elif [ -n "${IS_FREEBSD:-}" ]; then echo FreeBSD
else echo 'match Sys.os_type with "Win32" -> Win32 | "Cygwin" -> Cygwin | _ -> assert false'
fi)
+let makebinary =
+ $(if [ -n "${IS_FREEBSD:-}" ];
+ then echo '"gmake"'
+ else echo '"make"'
+ fi)
+
module Libdir = struct
let ssl = $(dir_opt "$CONFIG_LIB_OCAMLSSL")
let cryptokit = $(dir_opt "$CONFIG_LIB_CRYPTOKIT")
@@ -670,9 +702,11 @@ IS_RELEASE="$IS_RELEASE"
IS_LINUX="${IS_LINUX:-}"
IS_WINDOWS="${IS_WINDOWS:-}"
IS_MAC="${IS_MAC:-}"
+IS_FREEBSD="${IS_FREEBSD:-}"
OS=$(if [ -n "${IS_LINUX:-}" ]; then echo '"Linux"'
elif [ -n "${IS_MAC:-}" ]; then echo '"Mac"'
elif [ -n "${IS_WINDOWS:-}" ]; then echo '"Win32"'
+ elif [ -n "${IS_FREEBSD:-}" ]; then echo '"FreeBSD"'
else echo "Error: OS inconsistency" >&2; exit 2
fi)
@@ -690,8 +724,11 @@ EOF
sed 's/=["(]\(.*\)[)"]$/ := \1/' config.sh > config.make
if [ -n "${IS_MAC:-}" ]; then
- echo "INSTALL := gcp -u -L"
-fi >>config.make
+ echo "INSTALL := gcp -u -L" >>config.make
+fi
+if [ -n "${IS_FREEBSD:-}" ]; then
+ echo "INSTALL := cp" >>config.make
+fi
{
echo
View
7 dependencies/installation_helper.sh
@@ -1,4 +1,7 @@
-#!/bin/bash -ue
+#!/usr/bin/env bash
+
+set -u
+set -e
SCRIPTDIR=$(dirname $0)
cd $SCRIPTDIR
@@ -335,7 +338,7 @@ package_install (){
./configure -prefix $PREFIX ${CYGOPT:-}
make world # clean world
make bootstrap
- if [ $IS_LINUX ] || [ $IS_MAC ]; then
+ if [ $IS_LINUX ] || [ $IS_MAC ] || [ $IS_FREEBSD ]; then
make opt && make opt.opt
fi
PREFIX=$INSTALLDIR $SUDO make install -e
View
5 dissemination/spawn.sh
@@ -1,4 +1,7 @@
-#!/bin/bash -ue
+#!/usr/bin/env bash
+
+set -u
+set -e
#
# Copyright © 2011 MLstate
View
4 gitinit.sh
@@ -1,4 +1,6 @@
-#!/bin/bash -e
+#!/usr/bin/env bash
+
+set -e
help () (
echo "$0:"
View
5 install_release.sh
@@ -1,4 +1,7 @@
-#!/bin/bash -eu
+#!/usr/bin/env bash
+
+set -e
+set -u
. ./platform_helper.sh
View
2  libbase/ocamlbase
@@ -1,3 +1,3 @@
-#!/bin/bash
+#!/usr/bin/env bash
rlwrap ocamlbase.top -I $MLSTATELIBS/lib/opa/static $@
View
2  libbsl/bslbrowser
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
P=$MLSTATELIBS/lib/opa/static
OPA=$P/opabslgen.bypass
View
15 make_package.sh
@@ -1,4 +1,7 @@
-#!/bin/bash -eu
+#!/usr/bin/env bash
+
+set -e
+set -u
#PREFIX=/usr
INSTALLDIR=$PWD/release_install_root
@@ -123,7 +126,10 @@ if [ -n "$AUTOINSTALL" ]; then
AUTOINSTALL=${AUTOINSTALL//\{\}/$VERSION_STRING}
msg "Making $AUTOINSTALL"
cat >"$INSTALLDIR/install.sh" <<EOF
-#!/bin/bash -eu
+#!/usr/bin/env bash
+
+set -e
+set -u
if [ -n "\${1:-}" ]; then
echo "Installing in \$1"
@@ -164,7 +170,10 @@ EOF
chmod a+x "$INSTALLDIR/install.sh"
cat >"$INSTALLDIR/share/opa/uninstall.sh" <<"EOF"
-#!/bin/bash -eu
+#!/usr/bin/env bash
+
+set -e
+set -u
SCRIPT="$0"
if [ "${SCRIPT:0:1}" != "/" ]; then
View
2  passlib/opatrack.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
export ROOT=`pwd`
View
8 platform_helper.sh
@@ -1,4 +1,7 @@
-#!/bin/bash -eu
+#!/usr/bin/env bash
+
+set -e
+set -u
# Include in your scripts to detect the host platform and have appropriate
# aliases set for some commands (eg use the GNU versions on a mac)
@@ -13,7 +16,8 @@ IS_WINDOWS=""
case $(uname) in
CYGWIN*) IS_WINDOWS=1;;
Darwin*) IS_MAC=1;;
- Linux*) IS_LINUX=1;;
+ Linux*|GNU/kFreeBSD) IS_LINUX=1;;
+ FreeBSD) IS_FREEBSD=1;;
*)
echo "Error: could not detect OS. Defaulting to Linux" >&2
IS_LINUX=1
View
2  qml2ocaml/qml2ocaml.ml
@@ -703,7 +703,7 @@ prerr_endline \"CHECKUP - LIBS - OK\"
in
let compilation_via_makefile =
- let make = Printf.sprintf "make --makefile=%s -W %s -j %d %s" target_makefile target_makefile options.O.makefile_max_jobs
+ let make = Printf.sprintf "%s --makefile=%s -W %s -j %d %s" Config.makebinary target_makefile target_makefile options.O.makefile_max_jobs
(match options.O.makefile_rule with
| O.Bytecode ->
(match ObjectFiles.compilation_mode () with
View
2  stdlib/all_packages.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
# script used to generate the list of packages
DIRS=$(find . -type d | sed "s/.\///")
View
2  teerex/java/bench.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
#java-bench.lst obtained with:
# find /home/koper/soft/jdk-1_5_0-src-jrl/ -type f -name '*.java' ! -exec grep -q '#warn' {} \; -print > ./teerex/java/java-bench.lst
#we ignore files containing #warn as they need some preprocessing
View
2  tools/jschecker/jsnormalize
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
CC_DIR="$OPAGENERAL/tools/jschecker"
CC="$CC_DIR/compiler.jar"
View
4 utils/plotpipe
@@ -1,4 +1,6 @@
-#!/bin/bash -e
+#!/usr/bin/env bash
+
+set -e
skip=1
Something went wrong with that request. Please try again.