Subject: bootstrap: check compiler, check preserve-path
To: None <tech-pkg@netbsd.org>
From: Jan Schaumann <jschauma@netmeister.org>
List: tech-pkg
Date: 03/31/2005 15:37:12
--RDS4xtyBfx+7DiaI
Content-Type: multipart/mixed; boundary="R6sEYoIZpp9JErk7"
Content-Disposition: inline
--R6sEYoIZpp9JErk7
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Hi,
Looking at bootstrap/bootstrap, I noticed that it does not provide the
users with a hint as to which compiler settings they might need. On
IRIX at least, setting PKGSRC_COMPILER=3Dmipspro is required, so I added a
check to detect gcc. Does that look about right? Do other platforms
also need this?
Secondly, bootstrap currently does a whole lot of work before it starts
parsing the command-line options. Among other things, it may try to
manipulate the PATH variable, and the only way to prevent that (setting
PRESERVE_PATH in the environment) is not documented.
I've re-arranged the command-line options parsing to allow the user to
set '--preserve-path', but since I moved the parsing before we check for
certain programs, I had to move from '--option=3Darg' to '--option arg'.
Does anybody see a problem with that?
Thanks,
-Jan
--=20
The reader is encouraged to add smileys where necessary to increase
positive perception. Right here might be a good place:
--R6sEYoIZpp9JErk7
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="bootstrap.diff"
Content-Transfer-Encoding: quoted-printable
Index: bootstrap
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/pkgsrc/bootstrap/bootstrap,v
retrieving revision 1.32
diff -b -u -r1.32 bootstrap
--- bootstrap 8 Mar 2005 15:43:10 -0000 1.32
+++ bootstrap 31 Mar 2005 20:28:41 -0000
@@ -45,18 +45,21 @@
ignorecasecheck=3Dno
ignoreusercheck=3Dno
=20
+preserve_path=3Dno
+
# where the building takes place
wrkdir=3Dwork # default: relative to pkgsrc/bootstrap
bootstrapdir=3D`pwd`
pkgsrcdir=3D`dirname $bootstrapdir`
=20
usage=3D"Usage: $0 "'
- [ --workdir=3D<workdir> ]
- [ --prefix=3D<prefix> ]
- [ --pkgdbdir=3D<pkgdbdir> ]
- [ --sysconfdir=3D<sysconfdir> ]
+ [ --workdir <workdir> ]
+ [ --prefix <prefix> ]
+ [ --pkgdbdir <pkgdbdir> ]
+ [ --sysconfdir <sysconfdir> ]
[ --ignore-case-check ]
[ --ignore-user-check ]
+ [ --preserve-path ]
[ --help ]'
=20
# this replicates some of the logic in bsd.prefs.mk. until
@@ -77,6 +80,34 @@
echo "=3D=3D=3D> $@"
}
=20
+# see if we're using gcc. If so, set $compiler_is_gnu to '1'.
+get_compiler()
+{
+ testcc=3D"${CC}"
+ # normally, we'd just use 'cc', but certain configure tools look
+ # for gcc specifically, so we have to see if that comes first
+ if [ -z "${testcc}" ]; then
+ save_IFS=3D"${IFS}"
+ IFS=3D':'
+ for dir in ${PATH}; do
+ test -z "$dir" && dir=3D.
+ if [ -x "$dir/gcc" ]; then
+ testcc=3D"$dir/gcc"
+ break
+ fi
+ done
+ IFS=3D"${save_IFS}"
+ fi
+
+ cat >${wrkdir}/$$.c <<EOF
+#ifdef __GNUC__
+indeed
+#endif
+EOF
+ compiler_is_gnu=3D`${testcc:-cc} -E ${wrkdir}/$$.c 2>/dev/null | grep -c =
indeed`
+ rm -f ${wrkdir}/$$.c
+
+}
get_abi()
{
abi_opsys=3D$@
@@ -198,8 +229,25 @@
echo_msg "bootstrap command: $0 $@"
echo_msg "bootstrap started: $build_start"
=20
-if [ "x${PRESERVE_PATH}" !=3D "xyes" ]; then
- PATH=3D"${PATH}:/sbin:/usr/sbin"
+while [ $# -gt 0 ]; do
+ case $1 in
+ --workdir) wrkdir=3D"$2"; shift ;;
+ --prefix) prefix=3D"$2"; shift;
+ sysconfdir=3D${prefix}/etc ;;
+ --pkgdbdir) pkgdbdir=3D"$2"; shift ;;
+ --sysconfdir) sysconfdir=3D"$2"; shift ;;
+ --ignore-case-check) ignorecasecheck=3Dyes ;;
+ --ignore-user-check) ignoreusercheck=3Dyes ;;
+ --preserve-path) preserve_path=3Dyes ;;
+ --help) echo "$usage"; exit ;;
+ -h) echo "$usage"; exit ;;
+ --*) echo "$usage"; exit 1 ;;
+ esac
+ shift
+done
+
+if [ "x$preserve_path" !=3D "xyes" ]; then
+ PATH=3D"$PATH:/sbin:/usr/sbin"
fi
=20
overpath=3D""
@@ -260,6 +308,7 @@
need_sed=3Dyes
set_opsys=3Dyes
machine_arch=3Dmipseb
+ check_compiler=3Dyes
;;
Linux)
if [ -f /etc/debian_version ]; then
@@ -383,7 +432,7 @@
export MACHINE_ARCH
fi
=20
-if [ "x${PRESERVE_PATH}" !=3D "xyes" ]; then
+if [ "x$preserve_path" !=3D "xyes" ]; then
PATH=3D"$overpath:$PATH"
fi
=20
@@ -398,21 +447,6 @@
check_prog shprog sh
check_prog whoamiprog whoami
=20
-while [ $# -gt 0 ]; do
- case $1 in
- --workdir=3D*) wrkdir=3D`echo $1 | $sedprog -e 's|--workdir=3D||'` ;;
- --prefix=3D*) prefix=3D`echo $1 | $sedprog -e 's|--prefix=3D||'`
- sysconfdir=3D${prefix}/etc ;;
- --pkgdbdir=3D*) pkgdbdir=3D`echo $1 | $sedprog -e 's|--pkgdbdir=3D||'` ;;
- --sysconfdir=3D*) sysconfdir=3D`echo $1 | $sedprog -e 's|--sysconfdir=3D|=
|'`;;
- --ignore-case-check) ignorecasecheck=3Dyes ;;
- --ignore-user-check) ignoreusercheck=3Dyes ;;
- --help) echo "$usage"; exit ;;
- -h) echo "$usage"; exit ;;
- --*) echo "$usage"; exit 1 ;;
- esac
- shift
-done
=20
if [ ! -d ${wrkdir} ]; then
if mkdir ${wrkdir}; then
@@ -430,6 +464,19 @@
fi
echo "Working directory is: ${wrkdir}"
=20
+if [ x"$check_compiler" =3D x"yes" ]; then
+ get_compiler
+ if [ $compiler_is_gnu -gt 0 ]; then
+ compiler=3D"gcc"
+ else
+ case "$opsys" in
+ IRIX)
+ compiler=3D"mipspro"
+ ;;
+ esac
+ fi
+fi
+
if [ ! -x ${wrkdir}/install-sh ]; then
run_cmd "$sedprog -e 's|@DEFAULT_INSTALL_MODE@|'${default_install_mode-07=
55}'|' files/install-sh.in > $wrkdir/install-sh"
run_cmd "$chmodprog +x $wrkdir/install-sh"
@@ -507,6 +554,10 @@
if [ ! -z "$abi" ]; then
echo "ABI=3D$abi" >> ${MKCONF_EXAMPLE}
fi
+if [ ! -z "$compiler" ]; then
+ echo "PKGSRC_COMPILER=3D$compiler" >> ${MKCONF_EXAMPLE}
+fi
+ =09
=20
# save environment in example mk.conf
echo "PKG_DBDIR=3D$pkgdbdir" >> ${MKCONF_EXAMPLE}
--R6sEYoIZpp9JErk7--
--RDS4xtyBfx+7DiaI
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (NetBSD)
iD8DBQFCTF94fFtkr68iakwRAiarAJ0SLI/J4J7QdiE0GRigkL8BBkiNrQCgsDuz
okREU9UwVR3GrB/4D8lvU7s=
=reqx
-----END PGP SIGNATURE-----
--RDS4xtyBfx+7DiaI--