native executable even for Linux, to avoid surprises with file managers opening executable script as text file;
authorwenzelm
Mon, 07 Oct 2013 21:24:44 +0200
changeset 54313 da2e6282a4f5
parent 54312 d6121362d705
child 54314 8f7061babae4
native executable even for Linux, to avoid surprises with file managers opening executable script as text file;
Admin/Linux/Isabelle
Admin/Linux/Isabelle.c
Admin/Linux/Isabelle.run
Admin/Linux/build
--- a/Admin/Linux/Isabelle	Mon Oct 07 17:55:01 2013 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-#!/usr/bin/env bash
-#
-# Author: Makarius
-#
-# Main Isabelle application wrapper.
-
-# dereference executable
-if [ -L "$0" ]; then
-  TARGET="$(LC_ALL=C ls -l "$0" | sed 's/.* -> //')"
-  exec "$(cd "$(dirname "$0")"; cd "$(pwd -P)"; cd "$(dirname "$TARGET")"; pwd)/$(basename "$TARGET")" "$@"
-fi
-
-
-# minimal Isabelle environment
-
-ISABELLE_HOME="$(cd "$(dirname "$0")"; cd "$(pwd -P)"; pwd)"
-source "$ISABELLE_HOME/lib/scripts/isabelle-platform"
-
-
-# main
-
-#paranoia setting -- avoid problems of Java/Swing versus XIM/IBus etc.
-unset XMODIFIERS
-
-exec "$ISABELLE_HOME/contrib/jdk/${ISABELLE_PLATFORM64:-$ISABELLE_PLATFORM32}/bin/java" \
-  "-Disabelle.home=$ISABELLE_HOME" \
-  {JAVA_ARGS} \
-  -classpath "{CLASSPATH}" \
-  isabelle.Main "$@"
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Admin/Linux/Isabelle.c	Mon Oct 07 21:24:44 2013 +0200
@@ -0,0 +1,39 @@
+/*  Author:     Makarius
+
+Main Isabelle application executable.
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+
+static void fail(const char *msg)
+{
+  fprintf(stderr, "%s\n", msg);
+  exit(2);
+}
+
+
+int main(int argc, char *argv[])
+{
+  char **cmd_line = NULL;
+  int i = 0;
+
+  cmd_line = malloc(sizeof(char *) * argc);
+  if (cmd_line == NULL) fail("Failed to allocate command line");
+
+  cmd_line[0] = malloc(strlen(argv[0]) + 5);
+  if (cmd_line[0] == NULL) fail("Failed to allocate command line");
+
+  strcpy(cmd_line[0], argv[0]);
+  strcat(cmd_line[0], ".run");
+
+  for (i = 1; i < argc; i++) cmd_line[i] = argv[i];
+
+  execvp(cmd_line[0], cmd_line);
+  fail("Failed to execute application script");
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Admin/Linux/Isabelle.run	Mon Oct 07 21:24:44 2013 +0200
@@ -0,0 +1,30 @@
+#!/usr/bin/env bash
+#
+# Author: Makarius
+#
+# Main Isabelle application script.
+
+# dereference executable
+if [ -L "$0" ]; then
+  TARGET="$(LC_ALL=C ls -l "$0" | sed 's/.* -> //')"
+  exec "$(cd "$(dirname "$0")"; cd "$(pwd -P)"; cd "$(dirname "$TARGET")"; pwd)/$(basename "$TARGET")" "$@"
+fi
+
+
+# minimal Isabelle environment
+
+ISABELLE_HOME="$(cd "$(dirname "$0")"; cd "$(pwd -P)"; pwd)"
+source "$ISABELLE_HOME/lib/scripts/isabelle-platform"
+
+
+# main
+
+#paranoia setting -- avoid problems of Java/Swing versus XIM/IBus etc.
+unset XMODIFIERS
+
+exec "$ISABELLE_HOME/contrib/jdk/${ISABELLE_PLATFORM64:-$ISABELLE_PLATFORM32}/bin/java" \
+  "-Disabelle.home=$ISABELLE_HOME" \
+  {JAVA_ARGS} \
+  -classpath "{CLASSPATH}" \
+  isabelle.Main "$@"
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Admin/Linux/build	Mon Oct 07 21:24:44 2013 +0200
@@ -0,0 +1,4 @@
+#!/usr/bin/env bash
+
+cc -static -m32 Isabelle.c -o Isabelle
+