gregc@degas.Berkeley.EDU (Greg Couch) (02/19/88)
The following program is a "wrapper" around /bin/cc which adds the
-Llibrarydir flag by stripping the -Llibrarydir entries and constructing
a LPATH environment variable for ld (an undocumented feature). This
has been tested on HP-UX 5.5 and 6.01 on a 9000/320 and a 9000/350
respectively.
This program was written so we could keep our BSD makefiles and HP-UX
makefiles identical. The next step is to rewrite the lint script to
understand the -Llibrarydir flag.
- Greg Couch
gregc@degas.Berkeley.EDU
----
/*
* Greg Couch, UC Berkeley Unigrafix Group, February 1988
*
* HP-UX's cc and ld on the 9000/300 series don't understand
* the -Llibrarydir flag. Ld does, however, have an undocumented
* feature that will do library search paths - a LPATH environment
* variable.
*
* Thus this program is a wrapper around /bin/cc which puts
* -Llibrarydir parameters into the LPATH environment variable.
* It is a C program rather than a shell script because it is
* called very often in our development environment. It might
* even pay to make this program sticky.
*
* There are two recommend ways to install this, either install
* this as cc in /usr/local/bin or /usr/contrib/bin, or move
* /bin/cc to /lib/cc and install this as /bin/cc (with REAL_CC
* changed to /lib/cc below).
*/
# include <sys/param.h>
extern int errno;
# define REAL_CC "/bin/cc"
# define LPATH "LPATH"
# define LEN_LPATH 5
# define DEFAULT_LPATH "/lib:/usr/lib"
char lpath[NCARGS/2];
# define append(str) { for (s = str; *s; *lp++ = *s++) continue; }
main(argc, argv)
int argc;
char **argv;
{
register char *lp, *s;
register int i, j;
lp = lpath;
append(LPATH);
*lp++ = '=';
for (i = j = 0; i < argc; i++) {
if (argv[i][0] != '-' || argv[i][1] != 'L')
argv[j++] = argv[i];
else {
append(&argv[i][2]); /* -Llibrarydir */
*lp++ = ':';
}
}
argv[j] = NULL;
if (lpath[LEN_LPATH + 1] != '\0') {
append(DEFAULT_LPATH);
putenv(lpath);
}
execv(REAL_CC, argv);
/* perror("exec /bin/cc"); /* brings in too much code!! */
return errno;
}