summaryrefslogtreecommitdiff
path: root/configure
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <matthias@benkard.de>2008-08-20 11:28:48 +0200
committerMatthias Andreas Benkard <matthias@benkard.de>2008-08-20 11:28:48 +0200
commit859d1c0be2ee801308ec376caa60f247a3ad2ef7 (patch)
tree6bb63ba6a67d13d037ac9e1e4d40a7ba06f3741d /configure
parentb6170cf5efa9fe01e92f941d3e46d8343a1bc667 (diff)
Add a simple configure script.
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure139
1 files changed, 139 insertions, 0 deletions
diff --git a/configure b/configure
new file mode 100755
index 0000000..e029edd
--- /dev/null
+++ b/configure
@@ -0,0 +1,139 @@
+#! /usr/bin/env perl
+# -*- mode: perl -*-
+
+## Toilet Lisp, a Common Lisp subset for the Étoilé runtime.
+## Copyright (C) 2008 Matthias Andreas Benkard.
+##
+## This program is free software: you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or (at
+## your option) any later version.
+##
+## This program is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+$CC = $ENV{'CC'} // "gcc";
+$CFLAGS = $ENV{'CFLAGS'} // "";
+$OBJCFLAGS = $ENV{'OBJCFLAGS'} // $CFLAGS;
+$MAKE = $ENV{'MAKE'} // "make";
+$XCODEBUILD = $ENV{'XCODEBUILD'} // "xcodebuild";
+$LLVM_CONFIG = $ENV{'LLVM_CONFIG'} // "llvm-config";
+
+$llvm = `$LLVM_CONFIG --version`;
+if ($llvm =~ /(\d+)\.(\d+).*/) {
+ $llvm_maj = $1;
+ $llvm_min = $2;
+}
+
+`echo '\#include <ffi.h>' | $CC $CFLAGS $OBJCFLAGS -c -o /dev/null -x c - 2>/dev/null`;
+if ($? == 0) {
+ $ffi_h = 1;
+} else {
+ `echo '\#include <ffi/ffi.h>' | $CC $CFLAGS $OBJCFLAGS -c -o /dev/null -x c - 2>/dev/null`;
+ if ($? == 0) {
+ $ffi_ffi_h = 1;
+ }
+ else {
+ $no_ffi = 1;
+ }
+}
+
+`echo '\#include <histedit.h>' | $CC $CFLAGS $OBJCFLAGS -c -o /dev/null -x c - 2>/dev/null`;
+$histedit_h = 1 if ($? == 0);
+
+`$XCODEBUILD -version`;
+if ($? == 0) {
+ $xcode = 1;
+ $build_cmd = "xcodebuild";
+} elsif ($ENV{'GNUSTEP_MAKEFILES'} && (`$MAKE --version` =~ /^GNU.*/)) {
+ $build_cmd = "$MAKE";
+}
+
+$darwin = (`uname -s` =~ "Darwin");
+$debian = !$darwin;
+if ($darwin) {
+ $install = "sudo port install";
+} elsif ($debian) {
+ $install = "sudo apt-get install";
+}
+
+@steps = ();
+@optional_steps = ();
+$optional_install = $install;
+
+print "Your system lacks the following REQUIRED components:\n";
+
+if ($no_ffi) {
+ print " * libffi\n";
+ $install = "$install libffi" if $darwin;
+ $install = "$install libffi-dev" if $debian;
+ $installp = 1;
+}
+
+unless ($histedit_h) {
+ print " * libedit\n";
+ $install = "$install libedit" if $darwin;
+ $install = "$install libedit-dev" if $debian;
+ $installp = 1;
+}
+
+unless ($build_cmd) {
+ print " * Either xcodebuild or GNUstep-Make\n";
+ if ($debian) {
+ $install = "$install gnustep-make libgnustep-base-dev" if $debian;
+ $installp = 1;
+ } elsif ($darwin) {
+ push @steps, (" * Download and install Xcode from: http://developer.apple.com/tools/download/\n");
+ push @steps, (" OR: Install gnustep-make and gnustep-base through MacPorts.\n");
+ }
+}
+
+print "\n";
+print "Your system lacks the following OPTIONAL components:\n";
+
+unless ($llvm_maj && $llvm_min && $llvm_maj >= 2 && $llvm_min >= 4) {
+ print " * LLVM >= 2.3\n";
+ $optional_install = "$optional_install llvm" if $darwin;
+ $optional_install = "$optional_install llvm" if $debian;
+ $optionalp = 1;
+
+ push @optional_steps, (" NOTE: If your distribution's version of LLVM is too old, please download and\n");
+ push @optional_steps, (" install it manually from: http://llvm.org/releases/\n");
+}
+
+
+if ($installp) {
+ print "\n";
+ print "In order to be able to compile Toilet Lisp, please follow these steps:\n";
+ print " * In a shell, type: $install\n" if ($installp);
+ print join("", @steps);
+ print " * Rerun $0.\n";
+}
+
+if ($optionalp) {
+ print "\n";
+ print "If you want the compiler, please follow these steps:\n";
+ print " * In a shell, type: $optional_install\n" if ($optionalp);
+ print join("", @optional_steps);
+ print " * Rerun $0.\n";
+}
+
+if (!$installp) {
+ print "\n";
+ print "Congratulations! You can now build Toilet Lisp by following these steps:\n";
+ if ($xcode) {
+ print " * In a shell, type: $XCODEBUILD";
+ print " -configuration \"Debug (no LLVM)\"" if ($optionalp);
+ print "\n";
+ } else {
+ print " * In a shell, type: $MAKE";
+ print " USE_LLVM=NO" if ($optionalp);
+ print "\n";
+ }
+}