Author: vedge
Date: 2008-10-21 05:29:05 -0300 (Tue, 21 Oct 2008)
New Revision: 747
Added:
trunk/gen-includes.pl
Modified:
trunk/INSTALL
trunk/README
trunk/configure
trunk/configure.in
trunk/gen-declspecs.pl
trunk/man/mkconfigure.1
trunk/mkconfigure.pl
trunk/mkify.pl
Log:
- implement C_INCPREP() configure directive (preprocess C headers for DECLSPEC).
- add --includes=[yes|no|link] as standard configure option.
- define $SRCDIR and $BLDDIR in configure.
Modified: trunk/INSTALL
===================================================================
--- trunk/INSTALL 2008-10-21 08:26:53 UTC (rev 746)
+++ trunk/INSTALL 2008-10-21 08:29:05 UTC (rev 747)
@@ -5,7 +5,7 @@
To install BSDBuild onto your system, use the following:
$ ./configure
- $ make depend all
+ $ make
# make install
This will install mkconfigure(1) and mkify(1) on your system.
Modified: trunk/README
===================================================================
--- trunk/README 2008-10-21 08:26:53 UTC (rev 746)
+++ trunk/README 2008-10-21 08:29:05 UTC (rev 747)
@@ -1,3 +1,8 @@
+ __ __ _
+ |__) |_ | \
+ |__) __| |_ /
+ | | |
+ +---+---+------> Build
This is BSDBuild, a self-contained, portable build system in the spirit
of the traditional 4.4BSD make library files. It allows standard BSD-style
Modified: trunk/configure
===================================================================
--- trunk/configure 2008-10-21 08:26:53 UTC (rev 746)
+++ trunk/configure 2008-10-21 08:29:05 UTC (rev 747)
@@ -115,6 +115,9 @@
--cache=*)
cache=$optarg
;;
+ --includes=*)
+ includes=$optarg
+ ;;
*)
echo "invalid argument: $arg"
echo "try ./configure --help"
@@ -150,6 +153,7 @@
else
SRC=`pwd`
fi
+BLD=`pwd`
if [ "${testdir}" != "" ]; then
echo "Configure tests will be executed in ${testdir}"
@@ -160,6 +164,24 @@
else
testdir="."
fi
+
+if [ "${includes}" = "" ]; then
+ includes="yes"
+fi
+if [ "${includes}" = "link" ]; then
+ if [ "${with_proj_generation}" ]; then
+ echo "Cannot use --includes=link with --with-proj-generation!"
+ exit 1
+ fi
+elif [ "${includes}" = "yes" ]; then
+ noop=1
+elif [ "${includes}" = "no" ]; then
+ noop=1
+else
+ echo "Usage: --includes [yes|no|link]"
+ exit 1
+fi
+
if [ "${help}" = "yes" ]; then
echo "Usage: ./configure [args]"
echo " --prefix Installation prefix [/usr/local]"
@@ -177,6 +199,7 @@
echo " --with-manlinks Manual pages links for functions [no]"
echo " --with-ctags Automatically generate tag files [no]"
echo " --with-docs Printable docs (-me/tbl/eqn/pic/refer)
[no]"
+echo " --includes Preprocess headers (yes|no|link) [yes]"
echo " --with-libtool Specify path to libtool [use bundled]"
echo " --with-cygwin Add cygwin dependencies under cygwin [no]"
echo " --enable-nls Native Language Support [no]"
@@ -189,12 +212,18 @@
OSRELEASE=`uname -r 2>/dev/null` || OSRELEASE=unknown
SYSTEM=`uname -s 2>/dev/null` || SYSTEM=unknown
HOST="$SYSTEM-$OSRELEASE-$MACHINE"
-echo "Host: $HOST"
echo "# File generated by configure script (BSDbuild %VERSION%)." >
Makefile.config
+echo "# Host: ${HOST}" >> Makefile.config
+echo "" >> Makefile.config
+echo "SRCDIR=${SRC}" >> Makefile.config
+echo "BLDDIR=${BLD}" >> Makefile.config
+
+echo "Host: $HOST"
echo "Machine: $MACHINE" > config.log
echo "Release: $OSRELEASE" >> config.log
echo "System: $SYSTEM" >> config.log
+
for arg
do
echo "Argument: $arg" >> config.log
@@ -213,6 +242,7 @@
exit 1
fi
+# Process built-in documentation options.
HAVE_MANDOC="no"
NROFF=""
for path in `echo $PATH | sed 's/:/ /g'`; do
@@ -248,10 +278,11 @@
fi
fi
fi
-
if [ "${with_docs}" = "no" ]; then
echo "NODOC=yes" >> Makefile.config
fi
+
+# Process debug option.
if [ "${enable_debug}" = "yes" ]; then
echo "LDFLAGS+=-g" >> Makefile.config
echo "#ifndef DEBUG" > config/debug.h
@@ -261,6 +292,7 @@
echo "#undef DEBUG" > config/debug.h
fi
+# Process NLS options.
if [ "${enable_nls}" = "yes" ]; then
ENABLE_NLS="yes"
echo "#ifndef ENABLE_NLS" > config/enable_nls.h
@@ -285,6 +317,7 @@
echo "ENABLE_NLS=${ENABLE_NLS}" >> Makefile.config
echo "HAVE_GETTEXT=${HAVE_GETTEXT}" >> Makefile.config
+# Process ctags option.
CTAGS=""
if [ "${with_ctags}" = "yes" ]; then
for path in `echo $PATH | sed 's/:/ /g'`; do
@@ -302,10 +335,14 @@
fi
echo "CTAGS=${CTAGS}" >> Makefile.config
+# Default to bundled libtool.
LIBTOOL_BUNDLED="yes"
LIBTOOL=\${TOP}/mk/libtool/libtool
echo "LIBTOOL=${LIBTOOL}" >> Makefile.config
+#
+# Process the installation paths.
+#
echo "PREFIX?=${PREFIX}" >> Makefile.config
echo "#ifndef PREFIX" > config/prefix.h
echo "#define PREFIX \"${PREFIX}\"" >> config/prefix.h
@@ -391,6 +428,7 @@
echo "RELEASE=$RELEASE" >>Makefile.config
echo "mdefs[\"RELEASE\"] = \"$RELEASE\"" >>configure.lua
echo "*"
+echo "* Configuration successful."
echo "* Use \"make all install\" to compile and install BSDBuild."
echo "* Use \"make install-links\" to install links to source (for
developers)."
echo "*"
Modified: trunk/configure.in
===================================================================
--- trunk/configure.in 2008-10-21 08:26:53 UTC (rev 746)
+++ trunk/configure.in 2008-10-21 08:29:05 UTC (rev 747)
@@ -5,6 +5,7 @@
MDEFINE(RELEASE, "Alive in Strange Reality")
echo "*"
+echo "* Configuration successful."
echo "* Use \"make all install\" to compile and install BSDBuild."
echo "* Use \"make install-links\" to install links to source (for
developers)."
echo "*"
Modified: trunk/gen-declspecs.pl
===================================================================
--- trunk/gen-declspecs.pl 2008-10-21 08:26:53 UTC (rev 746)
+++ trunk/gen-declspecs.pl 2008-10-21 08:29:05 UTC (rev 747)
@@ -15,67 +15,64 @@
foreach my $line (@_) {
# Begin/resume inline block
if ($inline) {
- print OUT $line."\n";
+ print $line."\n";
if ($line =~ /^}\s*/) {
$inline = 0;
}
next;
- } elsif ($line =~ /^static __inline__/) {
+ } elsif ($line =~ /^static\s+__inline__/) {
$inline = 1;
- print OUT $line."\n";
+ print $line."\n";
next;
}
# Begin/resume long comment
if ($comment) {
- print OUT $line."\n";
+ print $line."\n";
if ($line =~ /\*\/\s*$/) {
$comment = 0;
}
next;
} elsif ($line =~ /^\s*\/\*/) {
- print OUT $line."\n";
+ print $line."\n";
$comment = 1;
next;
}
if ($line =~ /^\s*extern DECLSPEC/) { # Already processed
- print OUT $line."\n";
+ print $line."\n";
next;
}
$line =~ s/\s+/ /g; # Fix whitespace
if ($line =~ /^\s*struct\s*\w+\s*;\s*$/) { # Forward decl
- print OUT $line."\n";
+ print $line."\n";
next;
} elsif ($line =~ /^\s*extern (.+)$/) { # Extern var
- print OUT 'extern DECLSPEC '."$1\n";
+ print 'extern DECLSPEC '."$1\n";
next;
} elsif ($line =~ # Function decl
/^\s*([\w\*]+)\s+
([\w\*\[\]]+)
([\w\*\s,\.\[\]\(\)]*)\s*;\s*$/x) {
- print OUT 'extern DECLSPEC '."$1 $2$3;\n";
+ print 'extern DECLSPEC '."$1 $2$3;\n";
next;
}
$line =~ s/\s+/ /g;
- print OUT $line."\n";
+ print $line."\n";
}
}
my @input = ();
my $decls = 0;
my @blk = ();
-my $outFile = '';
if (@ARGV == 0) {
print STDERR "Usage: gen-declspecs.pl [file]\n";
exit(1);
}
-$outFile = $ARGV[0];
open(F, $ARGV[0]) || die "$ARGV[0]: $!";
-open(OUT, ">$outFile.tmp") || die ">$outFile.tmp: $!";
#
# First pass: Process cpp long lines.
@@ -117,7 +114,7 @@
if (/^\s*__BEGIN_DECLS\s*$/) {
# Begin declarations block
if ($decls) {
- print STDERR "$outFile: Nested __BEGIN_DECLS!\n";
+ print STDERR "Nested __BEGIN_DECLS!\n";
}
@blk = ($_);
$decls = 1;
@@ -125,15 +122,15 @@
}
unless ($decls) {
# Not in declarations block
- print OUT $_."\n";
+ print $_."\n";
next;
}
if (/^\s*__END_DECLS\s*$/) {
# End declarations block
push @blk, $_;
- print OUT "/* Block begin */\n";
+ print "/* Begin generated block */\n";
OutputDecls(@blk);
- print OUT "/* Block end */\n";
+ print "/* Close generated block */\n";
$decls = 0;
next;
}
@@ -193,7 +190,5 @@
push @blk, $_;
}
-close(OUT);
close(F);
-rename($outFile.'.tmp', $outFile) || die "$outFile: $!";
Added: trunk/gen-includes.pl
===================================================================
--- trunk/gen-includes.pl (rev 0)
+++ trunk/gen-includes.pl 2008-10-21 08:29:05 UTC (rev 747)
@@ -0,0 +1,84 @@
+#!/usr/bin/perl
+#
+# Public domain.
+#
+# Scan C header files and generate preprocessed versions of them in the
+# specified target directory.
+#
+
+my $outdir = '';
+
+sub Scan ($$)
+{
+ my $dir = shift;
+ my $outdir = shift;
+
+ if (! -e $outdir) {
+ mkdir($outdir, 0755) || die "$outdir: $!";
+ }
+ unless (opendir(CWD, $dir)) {
+ print STDERR "$dir: $!; ignored\n";
+ return;
+ }
+ foreach my $ent (readdir(CWD)) {
+ my $file = $dir.'/'.$ent;
+ my $outfile = $outdir.'/'.$ent;
+
+ if ($ent =~ /^\./ || -l $outfile || -l $file) {
+ next;
+ }
+ if (-d $ent) {
+ if (-e $file.'/.generated') { next; }
+ Scan($file, $outfile);
+ next;
+ }
+ if ($ent =~ /\.h$/) {
+ print $outfile,"\n";
+ my @o = readpipe("perl mk/gen-declspecs.pl '$file'");
+ if ($? != 0) {
+ print STDERR "gen-declspecs.pl failed\n";
+ exit(1);
+ }
+ open(OUT, ">$outfile") || die "$outfile: $!";
+ print OUT @o;
+ close(OUT);
+ }
+ }
+ closedir(CWD);
+}
+
+sub CleanEmptyDirs ($)
+{
+ my $dir = shift;
+
+ unless (opendir(CWD, $dir)) {
+ print STDERR "$dir: $!; ignored\n";
+ return;
+ }
+ foreach my $ent (readdir(CWD)) {
+ my $subdir = $dir.'/'.$ent;
+
+ if ($ent =~ /^\./ || -l $subdir || !-d $subdir) {
+ next;
+ }
+ CleanEmptyDirs($subdir);
+ rmdir($subdir);
+ }
+ closedir(CWD);
+}
+
+if (@ARGV < 1) {
+ print STDERR "Usage: prep-headers.pl [directory]\n";
+ exit(1);
+}
+$outdir = $ARGV[0];
+
+if (! -e $outdir) {
+ my $now = localtime;
+ mkdir($outdir, 0755) || die "$outdir: $!";
+ open(STAMP, ">$outdir/.generated") || die "$outdir/.generated: $!";
+ print STAMP $now,"\n";
+ close(STAMP);
+}
+Scan('.', $outdir);
+CleanEmptyDirs($outdir);
Modified: trunk/man/mkconfigure.1
===================================================================
--- trunk/man/mkconfigure.1 2008-10-21 08:26:53 UTC (rev 746)
+++ trunk/man/mkconfigure.1 2008-10-21 08:29:05 UTC (rev 747)
@@ -105,6 +105,11 @@
flag being added to the compiler command line, but it is also interpreted
by
.Xr build.proj.mk 5 .
+.It Ev C_INCPREP(dir)
+(C-style compilers only) Specify a single directory to contain include files.
+The configure script will provide the user with the option of generating
+preprocessed header files into this directory, or replace it by a symlink
+to the source directory.
.It Ev C_OPTION
Provide a gcc-style compiler option, such as
.Ar -Wall ,
Modified: trunk/mkconfigure.pl
===================================================================
--- trunk/mkconfigure.pl 2008-10-21 08:26:53 UTC (rev 746)
+++ trunk/mkconfigure.pl 2008-10-21 08:29:05 UTC (rev 747)
@@ -1,6 +1,6 @@
#!/usr/bin/perl -I%PREFIX%/share/bsdbuild
#
-# Copyright (c) 2001-2007 Hypertriton, Inc. <http://hypertriton.com/>
+# Copyright (c) 2001-2008 Hypertriton, Inc. <http://hypertriton.com/>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -8,9 +8,9 @@
# are met:
# 1. Redistribution of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
-# 2. Neither the name of CubeSoft Communications, nor the names of its
-# contributors may be used to endorse or promote products derived from
-# this software without specific prior written permission.
+# 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..
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -80,6 +80,49 @@
PmIncludePath($dir);
}
+sub c_incprep
+{
+ my $dir = shift;
+ my $subdir = shift;
+
+ print << "EOF";
+#
+# Preprocess headers for visibility and calling convention stuff. Developers
+# can use the unpreprocessed headers directly with --includes=link.
+#
+if [ ! -e "$dir" ]; then
+ mkdir "$dir"
+fi
+if [ "\${includes}" = "link" ]; then
+ echo "* Not preprocessing includes"
+ if [ ! -e "$dir/$subdir" ]; then
+ if [ "\${srcdir}" != "" ]; then
+ ln -s "\$SRC" "$dir/$subdir"
+ else
+ ln -s "\$BLD" "$dir/$subdir"
+ fi
+ fi
+else
+ if [ ! -e "$dir/$subdir" ]; then
+ \$ECHO_N "* Preprocessing includes..."
+ if [ "\${srcdir}" != "" ]; then
+ (cd \$SRC && perl mk/gen-includes.pl
"\$BLD/$dir/$subdir" 1>>\$BLD/config.log 2>&1)
+ cp -fR config $dir/$subdir
+ else
+ perl mk/gen-includes.pl "$dir/$subdir" 1>config.log 2>&1
+ fi
+ if [ \$? != 0 ]; then
+ echo "perl mk/gen-includes.pl failed";
+ exit 1
+ fi
+ echo "done"
+ else
+ echo "* Using existing includes"
+ fi
+fi
+EOF
+}
+
sub c_libdir
{
my $dir = shift;
@@ -144,7 +187,7 @@
my $testdir_opt = pack('A' x 25, split('', '--testdir'));
my $cache_opt = pack('A' x 25, split('', '--cache'));
- my $help_opt = pack('A' x 25, split('', '--help'));
+ my $includes_opt = pack('A' x 25, split('', '--includes'));
my $nls_opt = pack('A' x 25, split('', '--enable-nls'));
my $gettext_opt = pack('A' x 25, split('', '--with-gettext'));
@@ -173,6 +216,7 @@
"echo \" $manlinks_opt Manual pages links for functions [no]\"",
"echo \" $ctags_opt Automatically generate tag files [no]\"",
"echo \" $docs_opt Printable docs (-me/tbl/eqn/pic/refer) [no]\"",
+ "echo \" $includes_opt Preprocess headers (yes|no|link) [yes]\"",
"echo \" $libtool_opt Specify path to libtool [use bundled]\"",
"echo \" $cygwin_opt Add cygwin dependencies under cygwin [no]\"",
"echo \" $nls_opt Native Language Support [no]\"",
@@ -336,6 +380,9 @@
--cache=*)
cache=$optarg
;;
+ --includes=*)
+ includes=$optarg
+ ;;
*)
echo "invalid argument: $arg"
echo "try ./configure --help"
@@ -371,6 +418,7 @@
else
SRC=`pwd`
fi
+BLD=`pwd`
if [ "${testdir}" != "" ]; then
echo "Configure tests will be executed in ${testdir}"
@@ -381,6 +429,24 @@
else
testdir="."
fi
+
+if [ "${includes}" = "" ]; then
+ includes="yes"
+fi
+if [ "${includes}" = "link" ]; then
+ if [ "${with_proj_generation}" ]; then
+ echo "Cannot use --includes=link with --with-proj-generation!"
+ exit 1
+ fi
+elif [ "${includes}" = "yes" ]; then
+ noop=1
+elif [ "${includes}" = "no" ]; then
+ noop=1
+else
+ echo "Usage: --includes [yes|no|link]"
+ exit 1
+fi
+
EOF
GetOptions("emul-os=s" => \$EmulOS,
@@ -425,12 +491,18 @@
OSRELEASE=`uname -r 2>/dev/null` || OSRELEASE=unknown
SYSTEM=`uname -s 2>/dev/null` || SYSTEM=unknown
HOST="$SYSTEM-$OSRELEASE-$MACHINE"
-echo "Host: $HOST"
echo "# File generated by configure script (BSDbuild %VERSION%)." >
Makefile.config
+echo "# Host: ${HOST}" >> Makefile.config
+echo "" >> Makefile.config
+echo "SRCDIR=${SRC}" >> Makefile.config
+echo "BLDDIR=${BLD}" >> Makefile.config
+
+echo "Host: $HOST"
echo "Machine: $MACHINE" > config.log
echo "Release: $OSRELEASE" >> config.log
echo "System: $SYSTEM" >> config.log
+
for arg
do
echo "Argument: $arg" >> config.log
@@ -449,6 +521,7 @@
exit 1
fi
+# Process built-in documentation options.
HAVE_MANDOC="no"
NROFF=""
for path in `echo $PATH | sed 's/:/ /g'`; do
@@ -484,10 +557,11 @@
fi
fi
fi
-
if [ "${with_docs}" = "no" ]; then
echo "NODOC=yes" >> Makefile.config
fi
+
+# Process debug option.
if [ "${enable_debug}" = "yes" ]; then
echo "LDFLAGS+=-g" >> Makefile.config
echo "#ifndef DEBUG" > config/debug.h
@@ -497,6 +571,7 @@
echo "#undef DEBUG" > config/debug.h
fi
+# Process NLS options.
if [ "${enable_nls}" = "yes" ]; then
ENABLE_NLS="yes"
echo "#ifndef ENABLE_NLS" > config/enable_nls.h
@@ -521,6 +596,7 @@
echo "ENABLE_NLS=${ENABLE_NLS}" >> Makefile.config
echo "HAVE_GETTEXT=${HAVE_GETTEXT}" >> Makefile.config
+# Process ctags option.
CTAGS=""
if [ "${with_ctags}" = "yes" ]; then
for path in `echo $PATH | sed 's/:/ /g'`; do
@@ -538,10 +614,14 @@
fi
echo "CTAGS=${CTAGS}" >> Makefile.config
+# Default to bundled libtool.
LIBTOOL_BUNDLED="yes"
LIBTOOL=\${TOP}/mk/libtool/libtool
echo "LIBTOOL=${LIBTOOL}" >> Makefile.config
+#
+# Process the installation paths.
+#
echo "PREFIX?=${PREFIX}" >> Makefile.config
echo "#ifndef PREFIX" > config/prefix.h
echo "#define PREFIX \"${PREFIX}\"" >> config/prefix.h
@@ -683,6 +763,8 @@
c_define(@args);
} elsif ($cmd eq 'c_incdir') {
c_incdir(@args);
+ } elsif ($cmd eq 'c_incprep') {
+ c_incprep(@args);
} elsif ($cmd eq 'c_libdir') {
c_libdir(@args);
} elsif ($cmd eq 'c_option') {
Modified: trunk/mkify.pl
===================================================================
--- trunk/mkify.pl 2008-10-21 08:26:53 UTC (rev 746)
+++ trunk/mkify.pl 2008-10-21 08:29:05 UTC (rev 747)
@@ -29,7 +29,8 @@
mkconcurrent.pl
manlinks.pl
cmpfiles.pl
- gen-declspecs.pl);
+ gen-declspecs.pl
+ gen-includes.pl);
@LibtoolFiles = qw(
config.guess
_______________________________________________
BSDBuild-Commits mailing list
[email protected]
http://mail231.csoft.net/mailman/listinfo/bsdbuild-commits