#!/bin/sh for PERL in /usr/bin/perl \ /bin/perl \ /usr/local/bin/perl \ /usr/pkg/bin/perl \ /usr/athena/bin/perl \ `which perl` do if [ -x $PERL ] then break fi done if [ ! -x $PERL ] then echo "" echo "*** Warning: Could not find perl interpreter." if [ ! -e build/Makefile.conf ] then echo "*** Creating default config file in build/Makefile.conf" echo "*** Please install perl and re-run $0" echo "VOCAL_TOOLCHAIN_TYPE := gnu VOCAL_COMPILE_TYPE := debug VOCAL_CROSS_ROOT := /skiff/local/bin CROSS_PLATFORM := arm-linux BUILD_SHARED_LIBS := no USE_DISTCC := no USE_CCACHE := no USE_DTLS := no USE_SSL := yes USE_SIGCOMP := no SIGCOMP_BASEDIR:= /usr/local USE_POPT := yes USE_CURL := no USE_GOOGLE_MALLOC := no USE_GOOGLE_CPUPERF := no USE_IPV6 := no DB_HEADERS := /usr/include/db4 RESIP_FIXED_POINT := no PEDANTIC_STACK := no INSTALL_PREFIX := /usr/local ARES_PREFIX := /usr/local " > build/Makefile.conf exit fi echo "*** Leaving build/Makefile.conf unmodified" exit fi exec $PERL -wx $0 $@ echo <<__END__ #!perl ###################################################################### # Usage: # ./configure [-y] # # Options: # -y Run non-interactively ###################################################################### # Change directory so that we can find the Makefile.conf file $mydir = $0; $mydir =~ s/\/[^\/]*$//; chdir ($mydir); $non_interactive = 0; $uname = `uname`; @yesno = ('yes','no'); @toolchains = ('gnu','intel','armcross','sunpro','msgnu'); @compiletypes = ('debug','nodebug','opt','gopt','prof','small'); ###################################################################### # The entries in the following array have the following # fields: # # name - Variable name to be used by the make system # # description - Question to ask the user # # default - Value to use by default # # validate - Optional array of allowed values # # predicate - Optional logical test; if false, the user # will not be asked to configure the value # # flag - For "yes/no" entries, adds commandline # flags of "--enable-foo" and "--disable-foo" # # option - Adds commandline options of "--foo=..." # @parameters = ( { name => "VOCAL_TOOLCHAIN_TYPE", description => "Which toolchain do you want to use?", default => &detectToolchain, validate => [@toolchains], option => 'with-toolchain', }, { name => "VOCAL_COMPILE_TYPE", description => "What compile profile will you use?", default => "debug", validate => [@compiletypes], option => 'with-compile-type', }, { name => "VOCAL_CROSS_ROOT", description => "Where is your cross compiler installed?", default => "/skiff/local/bin", predicate => "\$config{VOCAL_TOOLCHAIN_TYPE} =~ /cross/", option => 'with-cross-compiler-dir', }, { name => "CROSS_PLATFORM", description => "What is the name your toolchain uses for the cross platform?", default => "arm-linux", predicate => "\$config{VOCAL_TOOLCHAIN_TYPE} =~ /cross/", option => 'with-cross-platform', }, { name => "BUILD_SHARED_LIBS", description => "Should the resip libraries be built shared?", default => "no", validate => [@yesno], flag => 'shared-libs', }, { name => "USE_DISTCC", description => "Will you be using distcc?", default => &detectDistcc, validate => [@yesno], flag => 'distcc', }, { name => "USE_CCACHE", description => "Will you be using ccache?", default => "no", validate => [@yesno], flag => 'ccache', }, { name => "USE_DTLS", description => "Do you want to include DTLS support?", default => "no", validate => [@yesno], flag => 'dtls', }, { name => "USE_SSL", description => "Do you want to include SSL support?", default => "yes", validate => [@yesno], flag => 'ssl', }, { name => "SSL_LOCATION", description => "Where is OpenSSL? (leave blank to use installed copy)", default => "", predicate => "\$config{USE_SSL} eq 'yes'", option => 'with-ssl-location', }, { name => "USE_SIGCOMP", description => "Do you want to include SigComp support?", default => &sigcompInstalled, validate => [@yesno], flag => 'sigcomp', }, { name => "SIGCOMP_BASEDIR", description => "What is the base directory Open SigComp is installed in?", default => "/usr/local", predicate => "\$config{USE_SIGCOMP} eq 'yes'", option => 'with-sigcomp-basedir', }, { name => "USE_POPT", description => "Use popt to read commandline options?", default => "yes", validate => [@yesno], flag => 'popt', }, { name => "USE_CURL", description => "Should DUM use curl to retreive identity information?", default => "no", validate => [@yesno], flag => 'curl', }, { name => "USE_GOOGLE_MALLOC", description => "Use the Google malloc() implementation?", default => "no", validate => [@yesno], flag => 'google-malloc', }, { name => "USE_GOOGLE_CPUPERF", description => "Use Google cpuperf?", default => "no", validate => [@yesno], flag => 'google-cpuperf', }, { name => "USE_IPV6", description => "Compile in IPv6 support?", default => "no", validate => [@yesno], flag => 'ipv6', }, { name => "DB_HEADERS", description => "Where is db_cxx.h?", default => &findDb4, option => "db4-headers", }, { name => "RESIP_FIXED_POINT", description => "Compile with no floating point functions?", default => "no", validate => [@yesno], flag => 'resip-fixed-point', }, { name => "PEDANTIC_STACK", description => "Force stack to fully parse every message it receives?", default => "no", validate => [@yesno], flag => 'pedantic-stack', }, { name => "INSTALL_PREFIX", description => "Where should the libraries be installed?", default => "/usr/local", option => "prefix", }, { name => "ARES_PREFIX", description => "Where should ares be installed?", default => "/usr/local", option => "ares-prefix", }, ); if (open (CONF, "build/Makefile.conf")) { while () { chomp; if (/([^ :=]+) *:?= *([^ #]*)/) { $config{$1} = $2; } } close (CONF); } &parseOptions; foreach $parameter (@parameters) { if (!exists($config{$parameter->{name}})) { $config{$parameter->{name}} = $parameter->{default}; } if (exists($parameter->{predicate}) && !eval($parameter->{predicate})) { next; } # If we're running interactively, confirm with the user if (!$non_interactive) { do { if (exists($parameter->{validate}) && !&validate($config{$parameter->{name}},@{$parameter->{validate}})) { print "*** '$config{$parameter->{name}}' is not a valid value for ". "$parameter->{name}\n\n"; $config{$parameter->{name}} = $parameter->{default}; } print "".$parameter->{description}."\n"; if (exists $parameter->{validate}) { print "(".join(', ',@{$parameter->{validate}}).") "; } print "[".$config{$parameter->{name}}."] "; $userinput = readline(*STDIN); chomp ($userinput); if (length($userinput)) { $config{$parameter->{name}} = $userinput; } print "\n"; } until (!exists($parameter->{validate}) || &validate($config{$parameter->{name}},@{$parameter->{validate}})); } if (exists($parameter->{validate}) && !&validate($config{$parameter->{name}},@{$parameter->{validate}})) { print "*** '$config{$parameter->{name}}' is not a valid value for ". "$parameter->{name} -- using default: $parameter->{default}\n"; $config{$parameter->{name}} = $parameter->{default}; } } # Write out the resulting configure file to Makefile.conf open (CONF, ">build/Makefile.conf") || die "Could not write to build/Makefile.conf: $!"; print "Writing Makefile.conf...\n"; foreach $parameter (@parameters) { print CONF ("# ".$parameter->{description}."\n"); if (exists $parameter->{validate}) { print CONF ("# Allowed values: ".join(', ',@{$parameter->{validate}})."\n"); } print CONF ($parameter->{name}." := ".$config{$parameter->{name}}."\n\n"); } close (CONF); if (-e 'contrib/ares/Makefile') { system "make -C contrib/ares distclean"; } ###################################################################### sub validate { my ($value, @allowed) = @_; my ($allowed); if (@allowed == 0) { return 1; } foreach $allowed (@allowed) { if ($value eq $allowed) { return 1; } } return 0; } sub parseOptions { my($option); my($curr); option: foreach $option (@ARGV) { if ($option eq '-y' || $option eq '--non-interactive') { $non_interactive = 1; next option; } foreach $parameter (@parameters) { if (defined $parameter->{flag}) { $curr = $parameter->{flag}; if ($option =~ /^--(enable|disable)-$curr$/) { $config{$parameter->{name}} = ($1 eq 'enable'?'yes':'no'); next option; } } if (defined $parameter->{option}) { $curr = $parameter->{option}; if ($option =~ /^--$curr\=\"?([^"]*)\"?$/) { $config{$parameter->{name}} = $1; next option; } } } print "\nUnknown option: $option\n\n"; &usage; } } sub usage { print <{flag}) { print " --enable-".$parameter->{flag}."\n"; print " --disable-".$parameter->{flag}."\n"; print " ".$parameter->{description}." "; print "(Now ".($config{$parameter->{name}} eq 'yes'? "enabled":"disabled").")\n"; } if (defined $parameter->{option}) { print " --".$parameter->{option}."=\"...\"\n"; print " ".$parameter->{description}." "; print "(Now \"".$config{$parameter->{name}}."\")\n"; if (defined $parameter->{validate}) { print " Valid values are: [". join(', ',@{$parameter->{validate}})."]\n"; } } print "\n"; } exit; } ###################################################################### # Here are functions to determine reasonable defaults sub detectToolchain { if ($uname =~ /SunOS/ || $uname =~ /Solaris/) { return "sunpro"; } "gnu"; } sub detectDistcc { if ($ENV{DISTCC_HOSTS}) { return "yes"; } "no"; } sub sigcompInstalled { if (-e "/usr/local/lib/libopensigcomp.a") { return "yes"; } "no"; } sub findDb4 { my (@candidates) = ( '/usr/include/db4', '/opt/local/include/db4', '/include/db4', '/usr/local/include/db4', ); my ($candidate); foreach $candidate (@candidates) { if (-e "${candidate}/db_cxx.h") { return $candidate; } } $candidates[0]; } __END__ ############################################################################## # # The Vovida Software License, Version 1.0 # Copyright (c) 2000-2007 Vovida Networks, Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # 3. The names "VOCAL", "Vovida Open Communication Application Library", # and "Vovida Open Communication Application Library (VOCAL)" must # not be used to endorse or promote products derived from this # software without prior written permission. For written # permission, please contact vocal@vovida.org. # # 4. Products derived from this software may not be called "VOCAL", nor # may "VOCAL" appear in their name, without prior written # permission of Vovida Networks, Inc. # # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND # NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA # NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES # IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY # OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH # DAMAGE. # # ==================================================================== # # This software consists of voluntary contributions made by Vovida # Networks, Inc. and many individuals on behalf of Vovida Networks, # Inc. For more information on Vovida Networks, Inc., please see # . # ##############################################################################