From 859d1c0be2ee801308ec376caa60f247a3ad2ef7 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Wed, 20 Aug 2008 11:28:48 +0200 Subject: Add a simple configure script. --- configure | 139 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100755 configure (limited to 'configure') 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 . + + +$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 ' | $CC $CFLAGS $OBJCFLAGS -c -o /dev/null -x c - 2>/dev/null`; +if ($? == 0) { + $ffi_h = 1; +} else { + `echo '\#include ' | $CC $CFLAGS $OBJCFLAGS -c -o /dev/null -x c - 2>/dev/null`; + if ($? == 0) { + $ffi_ffi_h = 1; + } + else { + $no_ffi = 1; + } +} + +`echo '\#include ' | $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"; + } +} -- cgit v1.2.3 From 551a3b5c0364446f1c244e6aac0e5099eaf251e4 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Wed, 20 Aug 2008 11:44:05 +0200 Subject: configure: Recognise non-Debian, non-Darwin systems. --- configure | 52 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 16 deletions(-) (limited to 'configure') diff --git a/configure b/configure index e029edd..862f542 100755 --- a/configure +++ b/configure @@ -56,7 +56,7 @@ if ($? == 0) { } $darwin = (`uname -s` =~ "Darwin"); -$debian = !$darwin; +$debian = !$darwin && (`apt-cache show llvm 2>/dev/null` =~ /.*llvm.*/); if ($darwin) { $install = "sudo port install"; } elsif ($debian) { @@ -71,26 +71,42 @@ 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; + if ($darwin || $debian) { + $install = "$install libffi" if $darwin; + $install = "$install libffi-dev" if $debian; + $installp = 1; + } else { + push @steps, (" * Download and install libffi from: http://sourceware.org/libffi/\n"); + } } unless ($histedit_h) { print " * libedit\n"; - $install = "$install libedit" if $darwin; - $install = "$install libedit-dev" if $debian; - $installp = 1; + if ($darwin || $debian) { + $install = "$install libedit" if $darwin; + $install = "$install libedit-dev" if $debian; + $installp = 1; + } else { + push @steps, (" * Download and install libedit from: http://www.thrysoee.dk/editline/\n"); + } } unless ($build_cmd) { - print " * Either xcodebuild or GNUstep-Make\n"; + if ($darwin) { + print " * xcodebuild\n"; + print " OR: GNUstep-Make and GNUstep-Base\n"; + } else { + print " * GNUstep-Make and GNUstep-Base\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"); + } else { + push @steps, (" * Download and install GNUstep-Startup from: http://gnustep.org/resources/sources.html\n"); } } @@ -99,16 +115,20 @@ 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; + if ($darwin || $debian) { + $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"); + 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"); + } else { + push @optional_steps, (" * Download and install LLVM from: http://llvm.org/releases/\n"); + } } -if ($installp) { +if ($installp || @steps) { 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); @@ -116,7 +136,7 @@ if ($installp) { print " * Rerun $0.\n"; } -if ($optionalp) { +if ($optionalp || @optional_steps) { print "\n"; print "If you want the compiler, please follow these steps:\n"; print " * In a shell, type: $optional_install\n" if ($optionalp); @@ -124,7 +144,7 @@ if ($optionalp) { print " * Rerun $0.\n"; } -if (!$installp) { +if (!$installp && !@steps) { print "\n"; print "Congratulations! You can now build Toilet Lisp by following these steps:\n"; if ($xcode) { -- cgit v1.2.3 From a1bd5fac22b51da3d0593de04e26c1215f6730e9 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Wed, 20 Aug 2008 11:50:46 +0200 Subject: configure: Do not require Perl 5.10. --- configure | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'configure') diff --git a/configure b/configure index 862f542..39fe2a6 100755 --- a/configure +++ b/configure @@ -18,12 +18,12 @@ ## along with this program. If not, see . -$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"; +$CC = defined($ENV{'CC'}) ? $ENV{'CC'} : "gcc"; +$CFLAGS = defined($ENV{'CFLAGS'}) ? $ENV{'CFLAGS'} : ""; +$OBJCFLAGS = defined($ENV{'OBJCFLAGS'}) ? $ENV{'OBJCFLAGS'} : $CFLAGS; +$MAKE = defined($ENV{'MAKE'}) ? $ENV{'MAKE'} : "make"; +$XCODEBUILD = defined($ENV{'XCODEBUILD'}) ? $ENV{'XCODEBUILD'} : "xcodebuild"; +$LLVM_CONFIG = defined($ENV{'LLVM_CONFIG'}) ? $ENV{'LLVM_CONFIG'} : "llvm-config"; $llvm = `$LLVM_CONFIG --version`; if ($llvm =~ /(\d+)\.(\d+).*/) { -- cgit v1.2.3 From 597a22df04342e04051388564b86c649603727d9 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Wed, 20 Aug 2008 13:08:39 +0200 Subject: configure: Check for GNU MP. --- configure | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'configure') diff --git a/configure b/configure index 39fe2a6..0fff95c 100755 --- a/configure +++ b/configure @@ -47,6 +47,9 @@ if ($? == 0) { `echo '\#include ' | $CC $CFLAGS $OBJCFLAGS -c -o /dev/null -x c - 2>/dev/null`; $histedit_h = 1 if ($? == 0); +`echo '\#include ' | $CC $CFLAGS $OBJCFLAGS -c -o /dev/null -x c - 2>/dev/null`; +$gmp_h = 1 if ($? == 0); + `$XCODEBUILD -version`; if ($? == 0) { $xcode = 1; @@ -80,6 +83,17 @@ if ($no_ffi) { } } +unless ($gmp_h) { + print " * GNU MP\n"; + if ($darwin || $debian) { + $install = "$install gmp" if $darwin; + $install = "$install libgmp3-dev" if $debian; + $installp = 1; + } else { + push @steps, (" * Download and install GNU MP from: http://gmplib.org/\n"); + } +} + unless ($histedit_h) { print " * libedit\n"; if ($darwin || $debian) { -- cgit v1.2.3 From bc4f0a3b06380df3d97118130573067c84f2733d Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Wed, 20 Aug 2008 13:16:34 +0200 Subject: configure: Give correct building instructions when custom compiler flags are defined. --- configure | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) (limited to 'configure') diff --git a/configure b/configure index 0fff95c..33ac732 100755 --- a/configure +++ b/configure @@ -18,9 +18,15 @@ ## along with this program. If not, see . +$darwin = (`uname -s` =~ "Darwin"); +$debian = !$darwin && (`apt-cache show llvm 2>/dev/null` =~ /.*llvm.*/); + $CC = defined($ENV{'CC'}) ? $ENV{'CC'} : "gcc"; -$CFLAGS = defined($ENV{'CFLAGS'}) ? $ENV{'CFLAGS'} : ""; +$CFLAGS = defined($ENV{'CFLAGS'}) ? $ENV{'CFLAGS'} : ($darwin ? "-I/opt/local/include" : ""); $OBJCFLAGS = defined($ENV{'OBJCFLAGS'}) ? $ENV{'OBJCFLAGS'} : $CFLAGS; +$CXXFLAGS = defined($ENV{'CXXFLAGS'}) ? $ENV{'CXXFLAGS'} : $CFLAGS; +$OBJCCFLAGS = defined($ENV{'OBJCCFLAGS'}) ? $ENV{'OBJCCFLAGS'} : "$CXXFLAGS $OBJCFLAGS"; +$LDFLAGS = defined($ENV{'LDFLAGS'}) ? $ENV{'LDFLAGS'} : ($darwin ? "-L/opt/local/lib" : ""); $MAKE = defined($ENV{'MAKE'}) ? $ENV{'MAKE'} : "make"; $XCODEBUILD = defined($ENV{'XCODEBUILD'}) ? $ENV{'XCODEBUILD'} : "xcodebuild"; $LLVM_CONFIG = defined($ENV{'LLVM_CONFIG'}) ? $ENV{'LLVM_CONFIG'} : "llvm-config"; @@ -58,8 +64,6 @@ if ($? == 0) { $build_cmd = "$MAKE"; } -$darwin = (`uname -s` =~ "Darwin"); -$debian = !$darwin && (`apt-cache show llvm 2>/dev/null` =~ /.*llvm.*/); if ($darwin) { $install = "sudo port install"; } elsif ($debian) { @@ -162,12 +166,34 @@ if (!$installp && !@steps) { 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 " * In a shell, type:\n $XCODEBUILD"; + if ($optionalp) { + print ' -configuration "Debug (no LLVM)"' if ($optionalp); + } else { + print ' -configuration Debug'; + } + print " OTHER_CFLAGS=\""; + print "`llvm-config --cflags` -DUSE_LLVM " unless ($optionalp); + if ($ffi_h) { + print " $CFLAGS $OBJCFLAGS -DHAVE_FFI_H\""; + } else { + print " $CFLAGS $OBJCFLAGS -DHAVE_FFI_FFI_H\""; + } + unless ($optionalp) { + print " OTHER_CPLUSPLUSFLAGS=\"\\\$(OTHER_CFLAGS) `llvm-config --cxxflags` $CXXFLAGS $OBJCCFLAGS\""; + print " OTHER_LDFLAGS=\"`llvm-config --ldflags` `llvm-config --libs` $LDFLAGS\""; + print ' LIBRARY_SEARCH_PATHS= HEADER_SEARCH_PATHS=' + } print "\n"; } else { - print " * In a shell, type: $MAKE"; - print " USE_LLVM=NO" if ($optionalp); + print " * In a shell, type:\n $MAKE"; + if ($optionalp) { + print " USE_LLVM=NO"; + } else { + print " CUSTOM_OBJCFLAGS=\"$CXXFLAGS $OBJCCFLAGS\""; + print " CUSTOM_LDFLAGS=\"$LDFLAGS\""; + print " LLVM_CONFIG=\"$LLVM_CONFIG\""; + } print "\n"; } } -- cgit v1.2.3 From 13dc1ca7ca1d785313517b9f8d78e63414cb43df Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Wed, 20 Aug 2008 13:24:29 +0200 Subject: configure: Prefer GNUstep-Make over xcodebuild. --- configure | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'configure') diff --git a/configure b/configure index 33ac732..eb1b2b6 100755 --- a/configure +++ b/configure @@ -56,12 +56,14 @@ $histedit_h = 1 if ($? == 0); `echo '\#include ' | $CC $CFLAGS $OBJCFLAGS -c -o /dev/null -x c - 2>/dev/null`; $gmp_h = 1 if ($? == 0); -`$XCODEBUILD -version`; -if ($? == 0) { - $xcode = 1; - $build_cmd = "xcodebuild"; -} elsif ($ENV{'GNUSTEP_MAKEFILES'} && (`$MAKE --version` =~ /^GNU.*/)) { +if ($ENV{'GNUSTEP_MAKEFILES'} && (`$MAKE --version` =~ /^GNU.*/)) { $build_cmd = "$MAKE"; +} else { + `$XCODEBUILD -version`; + if ($? == 0) { + $xcode = 1; + $build_cmd = "xcodebuild"; + } } if ($darwin) { -- cgit v1.2.3