summaryrefslogtreecommitdiff
path: root/src/configure
diff options
context:
space:
mode:
Diffstat (limited to 'src/configure')
-rwxr-xr-xsrc/configure314
1 files changed, 199 insertions, 115 deletions
diff --git a/src/configure b/src/configure
index 2e0a34a..125890c 100755
--- a/src/configure
+++ b/src/configure
@@ -1,11 +1,11 @@
#!/bin/sh
+
#
-# The yChat Project (2003 - 2004)
+# The yChat Project (2003 - 2005)
#
-if ! which perl >/dev/null
+if ! ../scripts/checkperl.sh
then
- echo You need to have Perl in your PATH
exit 1
fi
@@ -29,7 +29,8 @@ perl -e '
"mysql/mysql.h", #//<< Not needed for yhttpd
"netinet/in.h",
"time.h",
- "ncurses.h"
+ "ncurses.h",
+ "::test::ext/hash_map"
);
my @libs = (
@@ -37,44 +38,13 @@ perl -e '
"libncurses.so"
);
- sub remove_from_array
- {
- my $elem = shift;
- my $array = shift;
-
- for ( my $i = 0; $i <= $#$array; ++$i )
- {
- if ( $$array[$i] eq $elem )
- {
- splice(@$array,$i,1);
- last;
- }
- }
- }
-
- open FILE, "glob.h" or die "glob.h: $!\n";
- while(<FILE>)
- {
- if ( /\/\/#define DATABASE/ )
- {
- remove_from_array("mysql/mysql.h",\@headers);
- remove_from_array("libmysqlclient.so",\@libs);
- }
-
- elsif ( /\/\/#define NCURSES/ )
- {
- remove_from_array("ncurses.h",\@headers);
- remove_from_array("libncurses.so",\@libs);
- }
- }
- close FILE;
-
my @headerpaths = (
$ENV{HOME}."/include",
$ENV{HOME}."/usr/include",
"/include",
"/usr/include",
"/usr/local/include",
+ "/usr/lib/",
"/usr/pkg/include",
"/opt/include",
"/opt/local/include"
@@ -91,88 +61,53 @@ perl -e '
"/opt/local/lib"
);
- if ( defined $ENV{YCHATHEADERPATHS} ) {
- map { print "Adding $_...\n";
- unshift @headerpaths, $_ } split /:/, $ENV{YCHATHEADERPATHS};
+ open FILE, "glob.h" or die "glob.h: $!\n";
+ while(<FILE>)
+ {
+ if ( /\/\/#define DATABASE/ )
+ {
+ remove_from_array("mysql/mysql.h",\@headers);
+ remove_from_array("libmysqlclient.so",\@libs);
+ }
+
+ if ( /\/\/#define NCURSES/ )
+ {
+ remove_from_array("ncurses.h",\@headers);
+ remove_from_array("libncurses.so",\@libs);
+ }
}
+ close FILE;
- if ( defined $ENV{YCHATLIBPATHS} ) {
+ if ( defined $ENV{YCHATHEADERPATHS} )
+ {
map { print "Adding $_...\n";
- unshift @libpaths, $_ } split /:/, $ENV{YCHATLIBPATHS};
+ unshift @headerpaths, $_ } split /:/, $ENV{YCHATHEADERPATHS};
}
- sub check {
- my $deep = shift;
-
- if ($deep == 0) {
- print "Looking too deep! ($deepness)\n";
- exit(1);
- }
-
- my $check = shift;
- my $print = 1;
- if ( $_[-1] eq "subsearch" ) {
- $print = 0;
- pop(@_);
- }
-
- print "Checking for $check... " if $print;
- foreach (@_) {
- if ( -f "$_/$check" ) {
- print "OK\n";
- return "" if $_ eq "/usr/lib" or $_ eq "/usr/include";
- return $_;
- }
- }
+ if ( defined $ENV{YCHATLIBPATHS} )
+ {
+ map { print "Adding $_...\n";
+ unshift @libpaths, $_ } split /:/, $ENV{YCHATLIBPATHS};
+ }
- foreach (@_) {
- next unless -d $_;
- opendir D, $_ or warn "$_: $!\n"; my @dir = readdir(D);
- closedir D;
- foreach my $dir ( @dir ) {
- next if $dir =~ /^\.+$/ or !-d "$_/$dir";
- my $path = &check($deep-1, $check, "$_/$dir", "subsearch");
- return $path if $path ne "";
- }
- }
- if ($print) {
- print "NOT OK\n";
- print "Please make sure that you have the needed software installed!\n";
- print "If you have a special path for your includes then edit src/configure!\n";
- print "Or set the environment variables YCHATHEADERPATHS and YCHATLIBPATHS.\n";
- print " Example: setenv YCHATHEADERPATHS \"/your/header/includes:/a/includes\"\n";
- print "(The environment variables have to be seperated by an :)\n";
- exit(1);
- }
- return "";
- }
+ print "Headers:\n";
+ my $testit = 0;
map { $incadd{&check($deepness, $_, @headerpaths)}++ }
@headers;
+ $testit = 0;
+ print "Libraries:\n";
map { $libadd{&check($deepness, $_, @libpaths)}++ }
@libs;
- sub makeadd {
- my $flag = shift;
- my $add = shift;
- my $ret = "";
-
- foreach (keys %$add) {
- next unless /.+/;
- $ret .= "$flag$_ ";
- }
- return $ret;
- }
-
- my $incadd = &makeadd("-I", \%incadd);
- my $libadd = &makeadd("-L", \%libadd);
+ my $incadd = &make_add("-I", \%incadd);
+ my $libadd = &make_add("-L", \%libadd);
- foreach ( @libs )
+ for ( @libs )
{
- $libadd .= "-l$_ "
- if s/^lib// and s/\.so$//;
+ $libadd .= "-l$_ " if s/^lib// and s/\.so$//;
}
print "Incadd: $incadd\n";
@@ -183,6 +118,7 @@ perl -e '
print "Creating new base Makefile...\n";
unlink("Makefile") if -f "Makefile";
+ unlink("../err") if -f "../err";
open Fin, "Makefile.in" or die "Makefile.in: $!\n";
open Fout, ">Makefile" or die "Makefile: $!\n";
@@ -190,14 +126,20 @@ perl -e '
my $compiler = `tail -n 1 ../g++.version`;
my $version = `tail -n 2 ../g++.version | head -n 1`;
my $uname = `uname -srm`;
+ my $compopt = join "; ", split /\n/, `cat ../g++.version`;
+
chomp $uname;
+ chomp $compopt;
+
print "Configuring for $uname...\n";
chomp $cpp;
chomp $version;
- while (<Fin>) {
+
+ while (<Fin>)
+ {
s/^(CC=).*\n/$1$compiler/;
s/^(SRCS=).*/$1$cpp/;
- s/ -frepo// unless $version =~ /3\.4/;
+ s/ -frepo//; # unless $version =~ /3\.4/;
if ( $uname !~ /Linux/i ) {
print "Disabling -ldl flag...\n" if s/ -ldl//;
}
@@ -208,19 +150,29 @@ perl -e '
my $args = join(" -",@ARGV);
$args = "-".$args unless $args eq "";
- foreach my $cppfile (split / /, $cpp) {
+ for my $cppfile (split / /, $cpp)
+ {
my $ofile = $cppfile;
$ofile =~ s/\.cpp/\.o/;
print Fout "../obj/$ofile: $cppfile\n";
print Fout "\t\@if ! test -d `dirname ../obj/$ofile`; then mkdir -p `dirname ../obj/$ofile`; fi\n";
- if ( $ofile =~ /contrib\/.+/ ) {
- my $dirname = `dirname $ofile`;
- print Fout "\t\@echo -n \"Compiling contributed class $ofile \"\n";
- } else {
- print Fout "\t\@echo -n \"Compiling base class $ofile \"\n";
+ my $class = $ofile;
+ $class =~ s/\.o//;
+
+ my $text;
+ if ( $class =~ /contrib\/.+/ )
+ {
+ my $dirname = `dirname $class`;
+ $text = "\t\@echo -n \"Contributed class $class \"\n";
}
+
+ else
+ {
+ $text = "\t\@echo -n \"Base class $class \"\n";
+ }
+
print Fout "\t\@\$(CC) \$(CFLAGS) \$(INCLUDES) $args -c -o ../obj/$ofile $cppfile\n";
- print Fout "\t\@du -hc ../obj/$ofile | tail -n 1 | sed s/total// | sed \"s/ //g\"\n";
+ print Fout $text."\t\@du -hc ../obj/$ofile | tail -n 1 | sed s/total// | sed \"s/ //g\"\n";
}
close Fout;
@@ -230,21 +182,153 @@ perl -e '
close F;
unlink("msgs.h");
open F, ">msgs.h" or die "msgs.h: $!\n";
- foreach (@msgs) {
+
+ for (@msgs)
+ {
s/(UNAME)(.+)$/UNAME "$uname"/;
+ s/(COMPOPT)(.+)$/COMPOPT "$compopt"/;
print F;
}
close F;
- if ( -d "mods" ) {
+ if ( -d "mods" )
+ {
chdir("mods");
my $cflags = "-fno-inline -fno-default-inline";
- $cflags .= " -nostdlib" if $uname !~ /Linux/i;
+
+ $cflags .= " -nostdlib" if $uname =~ /FreeBSD/i && `uname -r` =~ /^4\./;
+
system("echo $cflags > cflags.add");
system("./configure");
chdir("..");
}
- exit(0);
+ sub remove_from_array
+ {
+ my $elem = shift;
+ my $array = shift;
+
+ for ( my $i = 0; $i <= $#$array; ++$i )
+ {
+ if ( $$array[$i] eq $elem )
+ {
+ splice(@$array,$i,1);
+ last;
+ }
+ } # for
+ }
+
+ sub check {
+ my $deep = shift;
+
+ if ($deep == 0) {
+ print "Looking too deep! ($deepness)\n";
+ exit(1);
+ }
+
+ my $check = shift;
+ $testit = 1 if $check =~ s/::test:://;
+
+ my $print = 1;
+ if ( $_[-1] eq "subsearch" ) {
+ $print = 0;
+ pop(@_);
+ }
+
+ if ($print)
+ {
+ print "Checking for $check...";
+ print "\n" if $testit;
+ }
+
+ for (@_)
+ {
+ if ( -f "$_/$check" )
+ {
+ if ($testit)
+ {
+ return $_ if test_include($_, $check);
+ return "";
+ }
+
+ else
+ {
+ print "OK\n";
+ return "" if $_ eq "/usr/lib" or $_ eq "/usr/include";
+ return $_;
+ }
+ }
+ }
+
+ for (@_)
+ {
+ next unless -d $_;
+ opendir D, $_ or warn "$_: $!\n";
+ my @dir = readdir(D);
+ closedir D;
+
+ for my $dir ( @dir )
+ {
+ next if $dir =~ /^\.+$/ or !-d "$_/$dir";
+ my $path = &check($deep-1, $check, "$_/$dir", "subsearch");
+ return $path if $path ne "";
+ }
+ }
+
+ if ($print)
+ {
+ print "NOT OK\n";
+ print "Please make sure that you have the needed software installed!\n";
+ print "If you have a special path for your includes then edit src/configure!\n";
+ print "Or set the environment variables YCHATHEADERPATHS and YCHATLIBPATHS.\n";
+ print " Example: setenv YCHATHEADERPATHS \"/your/header/includes:/a/includes\"\n";
+ print "(The environment variables have to be seperated by an :)\n";
+ print "PS: You may use the locate and/or find command to search for files.\n";
+ exit(1);
+ }
+
+ `touch ../err`;
+ return "";
+ }
+
+ sub make_add {
+ my $flag = shift;
+ my $add = shift;
+ my $ret = "";
+
+ for (reverse keys %$add) {
+ next unless /.+/;
+ $ret .= "$flag$_ ";
+ }
+ return $ret;
+ }
+ sub test_include
+ {
+ my $shift = shift;
+ my $check = shift;
+ my $return = 0;
+ print "Testing $shift/$check...";
+
+ `echo "\#include \\"maps/hashmap.h\\"" > __test.cpp`;
+ `echo "int main(void){return 0;}" >> __test.cpp`;
+ my $cmd = "`tail -n 1 ../g++.version` -I$shift __test.cpp -o /dev/null 2>/dev/null";
+ system $cmd;
+
+ unless ($?)
+ {
+ print "OK\n";
+ $return = 1;
+ }
+
+ else
+ {
+ print "Not OK\n";
+ }
+
+ unlink "__test.cpp" if -f "__test.cpp";
+ return $return;
+ }
+
+ exit(0);
' `echo "$*" | sed "s/-//g"`