From 86e14c4a11178f0372fa181903c910b35372fa23 Mon Sep 17 00:00:00 2001 From: garbled Date: Wed, 22 Mar 2000 01:09:34 +0000 Subject: [PATCH] Add parsing of the CC env variable, and a -Bpath flag (for /usr/libexec) so cross-building of lint libraries can be made possible. Tested building a powerpc libc via make build on an alpha. --- usr.bin/xlint/xlint/lint.1 | 14 +++++++++++- usr.bin/xlint/xlint/xlint.c | 43 +++++++++++++++++++++++++++---------- 2 files changed, 45 insertions(+), 12 deletions(-) diff --git a/usr.bin/xlint/xlint/lint.1 b/usr.bin/xlint/xlint/lint.1 index 0d7d13990a19..f0b066a2c9a1 100644 --- a/usr.bin/xlint/xlint/lint.1 +++ b/usr.bin/xlint/xlint/lint.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: lint.1,v 1.10 1999/03/22 18:16:47 garbled Exp $ +.\" $NetBSD: lint.1,v 1.11 2000/03/22 01:09:34 garbled Exp $ .\" .\" Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. .\" Copyright (c) 1994, 1995 Jochen Pohl @@ -66,6 +66,9 @@ .Bk -words .Op Fl o Ar outputfile .Ek +.Bk -words +.Op Fl B Ar directory +.Ek .Ar .Nm lint .Op Fl abceghprvzHFV @@ -87,6 +90,9 @@ .Bk -words .Op Fl d Ar directory .Ek +.Bk -words +.Op Fl B Ar directory +.Ek .Ar .Sh DESCRIPTION .Nm @@ -304,6 +310,9 @@ declarations, but never used. Do not complain about structures that are never defined (for example, using a structure pointer without knowing its contents). +.It Fl B Ns Ar path +Path to use when looking for the lint1 and lint2 binaries. Defualts to +.Pa /usr/libexec . .It Fl C Ns Ar library Create a .Nm @@ -524,6 +533,9 @@ will be used to search for the libraries. .It Ev TMPDIR usually the path for temporary files can be redefined by setting this environment variable. +.It Ev CC +Location of the C compiler program. Defaults to +.Pa /usr/bin/cc . .El .Sh FILES .Bl -tag -width /usr/libdata/lint/llib-lc.ln -compact diff --git a/usr.bin/xlint/xlint/xlint.c b/usr.bin/xlint/xlint/xlint.c index 2b61800f0e7f..e56921ed58a1 100644 --- a/usr.bin/xlint/xlint/xlint.c +++ b/usr.bin/xlint/xlint/xlint.c @@ -1,4 +1,4 @@ -/* $NetBSD: xlint.c,v 1.16 1999/09/09 09:34:25 kleink Exp $ */ +/* $NetBSD: xlint.c,v 1.17 2000/03/22 01:09:34 garbled Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -34,7 +34,7 @@ #include #ifndef lint -__RCSID("$NetBSD: xlint.c,v 1.16 1999/09/09 09:34:25 kleink Exp $"); +__RCSID("$NetBSD: xlint.c,v 1.17 2000/03/22 01:09:34 garbled Exp $"); #endif #include @@ -98,8 +98,10 @@ static char **libs; /* search path for libraries */ static char **libsrchpath; +static char *libexec_path; + /* flags */ -static int iflag, oflag, Cflag, sflag, tflag, Fflag, dflag; +static int iflag, oflag, Cflag, sflag, tflag, Fflag, dflag, Bflag; /* print the commands executed to run the stages of compilation */ static int Vflag; @@ -290,7 +292,7 @@ usage() "\t[-Idirectory] [-Ldirectory] [-llibrary] [-ooutputfile] file ...\n"); (void)fprintf(stderr, " %s [-abceghprvzHF] [-s|-t] -Clibrary [-Dname[=def]]\n", __progname); - (void)fprintf(stderr, "\t[-Idirectory] [-Uname] file ...\n"); + (void)fprintf(stderr, "\t[-Idirectory] [-Uname] [-Bpath] file ...\n"); terminate(-1); } @@ -364,7 +366,7 @@ main(argc, argv) argv += optind; optind = 0; - c = getopt(argc, argv, "abcd:eghil:no:prstuvxzC:D:FHI:L:U:V"); + c = getopt(argc, argv, "abcd:eghil:no:prstuvxzB:C:D:FHI:L:U:V"); switch (c) { @@ -483,6 +485,11 @@ main(argc, argv) appcstrg(&l2flags, "-H"); break; + case 'B': + Bflag = 1; + libexec_path = xstrdup(optarg); + break; + case 'V': Vflag = 1; break; @@ -594,8 +601,12 @@ fname(name, last) /* run cc */ - path = xmalloc(strlen(PATH_USRBIN) + sizeof ("/cc")); - (void)sprintf(path, "%s/cc", PATH_USRBIN); + if (getenv("CC") == NULL) { + path = xmalloc(strlen(PATH_USRBIN) + sizeof ("/cc")); + (void)sprintf(path, "%s/cc", PATH_USRBIN); + } else { + path = strdup(getenv("CC")); + } appcstrg(&args, path); applst(&args, cflags); @@ -618,8 +629,13 @@ fname(name, last) /* run lint1 */ - path = xmalloc(strlen(PATH_LIBEXEC) + sizeof ("/lint1")); - (void)sprintf(path, "%s/lint1", PATH_LIBEXEC); + if (!Bflag) { + path = xmalloc(strlen(PATH_LIBEXEC) + sizeof ("/lint1")); + (void)sprintf(path, "%s/lint1", PATH_LIBEXEC); + } else { + path = xmalloc(strlen(libexec_path) + sizeof ("/lint1")); + (void)sprintf(path, "%s/lint1", libexec_path); + } appcstrg(&args, path); applst(&args, l1flags); @@ -746,8 +762,13 @@ lint2() args = xcalloc(1, sizeof (char *)); - path = xmalloc(strlen(PATH_LIBEXEC) + sizeof ("/lint2")); - (void)sprintf(path, "%s/lint2", PATH_LIBEXEC); + if (!Bflag) { + path = xmalloc(strlen(PATH_LIBEXEC) + sizeof ("/lint2")); + (void)sprintf(path, "%s/lint2", PATH_LIBEXEC); + } else { + path = xmalloc(strlen(libexec_path) + sizeof ("/lint2")); + (void)sprintf(path, "%s/lint2", libexec_path); + } appcstrg(&args, path); applst(&args, l2flags);