2000-11-29 19:46:30 +00:00
|
|
|
#!/bin/sh
|
2000-06-22 04:17:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# The contents of this file are subject to the Mozilla Public
|
|
|
|
# License Version 1.1 (the "License"); you may not use this file
|
|
|
|
# except in compliance with the License. You may obtain a copy of
|
|
|
|
# the License at http://www.mozilla.org/NPL/
|
|
|
|
#
|
|
|
|
# Software distributed under the License is distributed on an "AS
|
|
|
|
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
# implied. See the License for the specific language governing
|
|
|
|
# rights and limitations under the License.
|
|
|
|
#
|
|
|
|
# The Original Code is the Tinderbox build tool.
|
|
|
|
#
|
|
|
|
# The Initial Developer of the Original Code is Netscape Communications
|
|
|
|
# Corporation. Portions created by Netscape are
|
|
|
|
# Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
# Rights Reserved.
|
|
|
|
#
|
|
|
|
|
|
|
|
# complete rewrite by Ken Estes, Mail.com (kestes@staff.mail.com).
|
|
|
|
# Contributor(s):
|
|
|
|
|
|
|
|
|
2001-02-15 20:54:32 +00:00
|
|
|
# Users can set these variables or accept the defaults. These
|
|
|
|
# variables can either be set in configure (like in gnu configure) or
|
|
|
|
# overridden in the makefile.
|
2000-06-22 04:17:19 +00:00
|
|
|
|
2001-02-15 20:54:32 +00:00
|
|
|
# I do not wish to bother writing a command line parser in shell and
|
|
|
|
# configure can not easily be extended to handle other directories.
|
2000-06-22 04:17:19 +00:00
|
|
|
|
2001-02-15 20:54:32 +00:00
|
|
|
: ${prefix:=/home/web/tinderbox} > /dev/null
|
|
|
|
: ${cgibin_prefix:="\$(prefix)/bin"} > /dev/null
|
|
|
|
: ${htmldir:="/home/httpd/html/tinderbox"} > /dev/null
|
2000-06-22 04:17:19 +00:00
|
|
|
|
2001-02-15 20:54:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
: ${builddir:=./build} > /dev/null
|
|
|
|
|
|
|
|
|
|
|
|
config_script='./config.out'
|
2001-02-15 21:13:33 +00:00
|
|
|
tinder_version='0.09'
|
2000-11-09 19:34:25 +00:00
|
|
|
perl_flags='-T'
|
2000-06-22 04:17:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
# -------------------
|
|
|
|
# Build Makefile
|
|
|
|
# -------------------
|
|
|
|
|
2000-11-29 19:46:30 +00:00
|
|
|
/bin/echo "Building Makefile"
|
|
|
|
|
2000-06-22 04:17:19 +00:00
|
|
|
# build a makefile to copy our executables into place and perform
|
|
|
|
# subsitutions on them
|
|
|
|
|
|
|
|
#(cd src; find . -type f -print) | perl
|
|
|
|
( find ./src -type f -print) | \
|
|
|
|
egrep -v '/CVS/' | egrep -v '\#' | egrep -v '~' | \
|
|
|
|
perl \
|
2001-02-15 20:54:32 +00:00
|
|
|
-e "\$prefix = '$prefix';" \
|
|
|
|
-e "\$cgibin_prefix = '$cgibin_prefix';"\
|
|
|
|
-e "\$htmldir = '$htmldir';" \
|
|
|
|
-e "\$builddir = '$builddir';" \
|
|
|
|
-e "\$config_script='$config_script';"\
|
2000-06-22 04:17:19 +00:00
|
|
|
-e '
|
|
|
|
use File::Basename;
|
2000-11-09 19:34:25 +00:00
|
|
|
|
|
|
|
# print Makefile Header
|
|
|
|
print <<EOF1;
|
2000-06-22 04:17:19 +00:00
|
|
|
# Makefile automatically generated by configure
|
2000-11-09 19:34:25 +00:00
|
|
|
# Do not edit this file
|
2000-06-22 04:17:19 +00:00
|
|
|
|
|
|
|
# files are processed by the perl script ./config.out as they are copied
|
|
|
|
# from the source tree to the build tree.
|
|
|
|
|
|
|
|
# files are installed without change from the build directory into the
|
|
|
|
# tree rooted at prefix.
|
|
|
|
|
|
|
|
|
2000-11-09 19:34:25 +00:00
|
|
|
# Makefile Variables
|
|
|
|
# ------------------
|
2000-06-22 04:17:19 +00:00
|
|
|
|
2001-02-15 20:54:32 +00:00
|
|
|
|
|
|
|
# the prefix where most of the binaries will be install
|
|
|
|
prefix=$prefix
|
|
|
|
|
|
|
|
# the directory where the cgibin files must go
|
|
|
|
cgibin_prefix=$cgibin_prefix
|
|
|
|
|
|
|
|
# the root of the html directory
|
2000-11-28 00:37:13 +00:00
|
|
|
htmldir=$htmldir
|
2000-06-22 04:17:19 +00:00
|
|
|
|
2001-02-15 20:54:32 +00:00
|
|
|
# where files will be built before they are installed
|
|
|
|
builddir=$builddir
|
|
|
|
|
2000-06-22 04:17:19 +00:00
|
|
|
config_script=$config_script
|
2000-11-09 19:34:25 +00:00
|
|
|
confdir=localconf
|
|
|
|
|
|
|
|
# Makefile Targets
|
|
|
|
# ----------------
|
2000-06-22 04:17:19 +00:00
|
|
|
|
|
|
|
all: build
|
|
|
|
ALL: all
|
|
|
|
|
2000-11-28 00:37:13 +00:00
|
|
|
build: mk_build_dirs build_files set_build_permissions
|
2000-06-22 04:17:19 +00:00
|
|
|
|
|
|
|
install: build mk_dest_dirs install_files
|
|
|
|
|
|
|
|
clean:
|
2000-11-29 19:46:30 +00:00
|
|
|
@ /bin/echo "\\n\\n-----Cleaning Build Directory-----\\n\\n"
|
2000-06-22 04:17:19 +00:00
|
|
|
rm -rf \$(builddir)
|
|
|
|
|
|
|
|
|
2000-11-09 19:34:25 +00:00
|
|
|
# We do not accidently wish to edit to the 'binary' version of these
|
|
|
|
# files so ensure the build dir copies are not writable.
|
2000-06-22 04:17:19 +00:00
|
|
|
|
2000-11-28 00:37:13 +00:00
|
|
|
set_build_permissions:
|
2000-11-29 19:46:30 +00:00
|
|
|
@ /bin/echo "\\n\\n-----Setting Build directory permissions-----\\n\\n"
|
2000-11-09 19:34:25 +00:00
|
|
|
find \$(builddir) -type f | xargs chmod 444
|
|
|
|
find \$(builddir)/bin -type f | xargs chmod 555
|
2000-11-28 00:37:13 +00:00
|
|
|
find \$(builddir)/test -type f -name 'gen*' | xargs chmod 555
|
2000-11-09 19:34:25 +00:00
|
|
|
find \$(builddir)/clientbin -type f | xargs chmod 555
|
2000-06-22 04:17:19 +00:00
|
|
|
|
2000-11-28 00:37:13 +00:00
|
|
|
compile_all_code: build
|
2000-11-29 19:46:30 +00:00
|
|
|
@ /bin/echo "\\n\\n-----Testing if perl can compile code-----\\n\\n"
|
2000-11-09 19:34:25 +00:00
|
|
|
find \$(builddir) -type f | \\
|
2000-11-28 00:37:13 +00:00
|
|
|
egrep -v -i "readme|\.gif|/test/|addimage.cgi|images.pm|bustagestats.cgi|Storable.pm" | \\
|
|
|
|
xargs -l perl -T -c
|
|
|
|
|
|
|
|
compile_bin_code: build
|
2000-11-29 19:46:30 +00:00
|
|
|
@ /bin/echo "\\n\\n-----Testing if perl can compile all files in the bin directory-----\\n\\n"
|
2000-11-28 00:37:13 +00:00
|
|
|
find \$(builddir)/bin -type f | \\
|
|
|
|
egrep -v -i "readme|\.gif|/test/|addimage.cgi|images.pm|bustagestats.cgi|Storable.pm" | \\
|
2000-11-09 19:34:25 +00:00
|
|
|
xargs -l perl -T -c
|
2000-06-22 04:17:19 +00:00
|
|
|
|
2000-11-28 00:37:13 +00:00
|
|
|
gen_test: compile_bin_code
|
|
|
|
rm -rf \$(htmldir)
|
|
|
|
perl \$(builddir)/test/genbuilds.tst
|
|
|
|
perl \$(builddir)/test/gennotices.tst
|
|
|
|
perl \$(builddir)/test/genbugs.tst
|
|
|
|
\$(builddir)/bin/tinder.cgi --daemon-mode
|
|
|
|
|
2000-11-29 19:46:30 +00:00
|
|
|
link_test:
|
|
|
|
find \$(builddir) -type f -print | \
|
|
|
|
egrep -v -i "test|mage" | \
|
|
|
|
xargs egrep -i "<a +href"
|
|
|
|
|
2000-11-28 00:37:13 +00:00
|
|
|
|
2000-11-09 19:34:25 +00:00
|
|
|
# Automated file list is generated after this line
|
|
|
|
# ------------------------------------------------
|
|
|
|
|
|
|
|
EOF1
|
|
|
|
;
|
2000-06-22 04:17:19 +00:00
|
|
|
while($_=<>) {
|
|
|
|
chomp $_;
|
|
|
|
my ($src_file) = $_;
|
|
|
|
my ($build_file) = $_;
|
|
|
|
my ($dest_file) = $_;
|
|
|
|
$build_file =~ s!\./src!\$\(builddir\)!;
|
2001-02-15 20:54:32 +00:00
|
|
|
if ($build_file =~ m/\.cgi$/) {
|
|
|
|
$dest_file = '\'\$\(cgibin_prefix\)/\''.basename($dest_file);
|
|
|
|
} else {
|
|
|
|
$dest_file =~ s!\./src!\$\(prefix\)!;
|
|
|
|
}
|
2000-11-09 19:34:25 +00:00
|
|
|
$deps=<<EOF2;
|
|
|
|
build_files: $build_file
|
|
|
|
install_files: $dest_file
|
|
|
|
|
|
|
|
$build_file: $src_file Makefile config.out
|
|
|
|
@ if [ -f $build_file ]; then chmod +w $build_file; fi;
|
|
|
|
perl \$\(config_script\) < $src_file > $build_file;
|
|
|
|
@ chmod -w $build_file;
|
|
|
|
|
|
|
|
$dest_file: $build_file
|
|
|
|
@ if [ -f $dest_file ]; then chmod +w $dest_file; fi;
|
|
|
|
cp -p $build_file $dest_file
|
|
|
|
|
|
|
|
EOF2
|
|
|
|
|
|
|
|
;
|
|
|
|
|
2000-06-22 04:17:19 +00:00
|
|
|
$deps =~ s![ \t]+$!!mg;
|
|
|
|
$deps =~ s!^ +!!mg;
|
|
|
|
$deps =~ s!^\t\t+!\t!mg;
|
|
|
|
$dest_dirs{File::Basename::dirname($dest_file)} = 1;
|
|
|
|
$build_dirs{File::Basename::dirname($build_file)} = 1;
|
|
|
|
print $deps;
|
|
|
|
};
|
|
|
|
@dest_dirs = sort keys %dest_dirs;
|
|
|
|
@build_dirs = sort keys %build_dirs;
|
2000-11-09 19:34:25 +00:00
|
|
|
|
|
|
|
# print Makefile Footer
|
|
|
|
|
|
|
|
print <<EOF3;
|
2000-06-22 04:17:19 +00:00
|
|
|
|
|
|
|
DEST_DIRS = @dest_dirs
|
|
|
|
|
|
|
|
BUILD_DIRS = @build_dirs
|
|
|
|
|
|
|
|
mk_dest_dirs:
|
|
|
|
for D in \$(DEST_DIRS);do \\
|
|
|
|
mkdir -p \$\$D;\\
|
|
|
|
done
|
|
|
|
|
|
|
|
mk_build_dirs:
|
|
|
|
for D in \$(BUILD_DIRS);do \\
|
|
|
|
mkdir -p \$\$D;\\
|
|
|
|
done
|
|
|
|
|
2000-11-09 19:34:25 +00:00
|
|
|
EOF3
|
2000-06-22 04:17:19 +00:00
|
|
|
' > Makefile
|
|
|
|
|
|
|
|
# -------------------
|
|
|
|
# Build Config.out
|
|
|
|
# -------------------
|
|
|
|
|
2000-11-29 19:46:30 +00:00
|
|
|
/bin/echo "Building config.out"
|
|
|
|
|
2000-06-22 04:17:19 +00:00
|
|
|
rm -rf $config_script
|
|
|
|
|
|
|
|
pwd=`/bin/pwd`
|
|
|
|
|
2000-11-29 19:46:30 +00:00
|
|
|
/bin/echo "#!perl - this script is run from makefile with -n\n" >> $config_script
|
|
|
|
/bin/echo "# This script is automatically genareated by configure." >> $config_script
|
|
|
|
/bin/echo "# This script configures various global variables.\n" >> $config_script
|
|
|
|
|
|
|
|
/bin/echo "while (<>) {" >> $config_script
|
|
|
|
|
|
|
|
/bin/echo >> $config_script
|
|
|
|
/bin/echo " # Set the library search path with suitable interposing directories." >> $config_script
|
|
|
|
|
2001-02-15 20:54:32 +00:00
|
|
|
/bin/echo " s!\#tinder_libdir\#!$prefix/local_conf',\n '$prefix/default_conf',\n '$prefix/lib',\n '$pwd/$builddir/local_conf',\n '$pwd/$builddir/default_conf',\n '$pwd/$builddir/lib!;" >> $config_script
|
2000-11-29 19:46:30 +00:00
|
|
|
/bin/echo >> $config_script
|
2000-06-22 04:17:19 +00:00
|
|
|
|
2001-02-15 20:54:32 +00:00
|
|
|
/bin/echo " s!\#prefix\#!$prefix!;" >> $config_script
|
|
|
|
/bin/echo " s!\#cgibin_prefix\#!$cgibin_prefix!;" >> $config_script
|
|
|
|
|
|
|
|
/bin/echo " # Use Taint Perl mode for security." >> $config_script
|
2000-11-29 19:46:30 +00:00
|
|
|
/bin/echo " s!\#perlflags\#!$perl_flags!;" >> $config_script
|
|
|
|
/bin/echo " s!\#tinder_version\#!$tinder_version!;" >> $config_script
|
2000-11-28 00:37:13 +00:00
|
|
|
|
|
|
|
|
2001-01-08 22:36:21 +00:00
|
|
|
# some bash seems to not interpolate the '\n' I wish I understood what
|
|
|
|
# was going on here as MY bash does fine. I will leave this here
|
|
|
|
# commeted out until I figure out what is going on.
|
|
|
|
|
|
|
|
# /bin/echo "\n" >> $config_script
|
|
|
|
|
|
|
|
/bin/echo >> $config_script
|
2000-11-09 19:34:25 +00:00
|
|
|
|
2000-11-29 19:46:30 +00:00
|
|
|
/bin/echo " # Hard code various executable paths into the source for security reasons." >> $config_script
|
2000-06-22 04:17:19 +00:00
|
|
|
|
2000-11-29 21:12:12 +00:00
|
|
|
for cmd in perl
|
2000-06-22 04:17:19 +00:00
|
|
|
do
|
|
|
|
full_cmd=`which $cmd 2> /dev/null `
|
|
|
|
if [ $? -ne 0 ]; then
|
2000-11-29 19:46:30 +00:00
|
|
|
/bin/echo "Could not find program: $cmd"
|
2000-06-22 04:17:19 +00:00
|
|
|
exit 9;
|
|
|
|
fi
|
2000-11-29 19:46:30 +00:00
|
|
|
/bin/echo " s!\#$cmd\#!$full_cmd!;" >> $config_script
|
2000-06-22 04:17:19 +00:00
|
|
|
done
|
|
|
|
|
2000-11-29 19:46:30 +00:00
|
|
|
/bin/echo "} continue {" >> $config_script
|
|
|
|
/bin/echo " print or die \"-p destination: \$!\\\\n\";" >> $config_script
|
|
|
|
/bin/echo "}" >> $config_script
|
2000-06-22 04:17:19 +00:00
|
|
|
|
2000-11-29 19:46:30 +00:00
|
|
|
/bin/chmod +x $config_script
|
2000-06-22 04:17:19 +00:00
|
|
|
|
|
|
|
exit 0;
|