From ae4e87df37ed8904de92c7cf2f3a11128cda2a21 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 6 Apr 2013 13:14:41 +0200 Subject: tagging ychat-0.7.4.1 --- scripts/config.sh | 152 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100755 scripts/config.sh (limited to 'scripts/config.sh') diff --git a/scripts/config.sh b/scripts/config.sh new file mode 100755 index 0000000..373fad4 --- /dev/null +++ b/scripts/config.sh @@ -0,0 +1,152 @@ +#!/bin/sh +# The yChat Project (2004) +# +# This script modifues the src/glob.h file. + +if ! which perl >/dev/null +then + echo You need to have Perl in your PATH + exit 1 +fi + +perl -e ' + use strict; + + use scripts::modules::file; + +print <; + chomp $stdin; + prove_if_default(\$stdin); + print "\n"; + + + if ( $stdin eq "yes") + { + print " You chose to use all the default before-compile options. Exiti-\n"; + print " ng the configurator now!\n"; + print $sep; + exit(0); + } + last if $stdin eq "no" or $stdin eq ""; + print " Wrong input: You need to specify yes or no!\n"; + } # for + + `cp src/glob.h src/glob.h.org` + unless -f "src/glob.h.org"; + + my @glob = fopen("src/glob.h.org"); + my $flag = 0; + + foreach( @glob ) + { + if ( $flag == 0 && /- CONFIG -/ ) + { + print $sep; + $flag = 1; + next; + } + + elsif ( $flag == 1 ) + { + if ( /\*\// ) + { + $flag = 2; + } + + else + { + print; + } + + next; + } + + elsif ( $flag == 2 ) + { + if ( /#define (.+) (.+)/ ) + { + my $def = $1; + my $val = $2; + my $flg = 0; + + $flg = 1 if $val =~ s/"//g; + + print " [Press enter to use default value: $val] "; + $stdin = ; + chomp $stdin; + + unless ( prove_if_default(\$stdin) ) + { + $stdin = "\"$stdin\"" if $flg == 1; + $_ = "#define $def $stdin\n"; + } + + print "\n"; + $flag = 0; + next; + } + + elsif ( /#define .+/ ) + { + my $default = "true"; + my $stdin; + + for (;;) + { + $default = "false" if /\/\/#define/; + + print " [Press enter to use default value: $default] "; + $stdin = ; + chomp $stdin; + + last if $stdin eq "" || $stdin eq "true" || $stdin eq "false"; + print " Wrong input: You need to specify true or false!\n"; + } + + if ( $default eq "true" ) + { + $_ = "//$_" + unless prove_if_default(\$stdin); + } + + else + { + s/^\/\/// + unless prove_if_default(\$stdin); + } + + print "\n"; + $flag = 0; + next; + } + } + } // foreach + + fwrite("src/glob.h", @glob); + + sub prove_if_default + { + my $val = shift; + if ( $$val eq "" ) + { + print " -> Using default option!\n"; + return 1; + } + print " -> Using new option $$val!\n"; + return 0; + } +' -- cgit v1.2.3