Path: utzoo!attcan!utgpu!watmath!uunet!ethos!att!icus!lenny From: lenny@icus.islp.ny.us (Lenny Tropiano) Newsgroups: unix-pc.sources Subject: POSIX/SVID/X3J11 standard routines (libposix.a) (Part 5 of 5) Keywords: POSIX, SVID, X3J11, dirent, News 3.0, good stuff! Message-ID: <940@icus.islp.ny.us> Date: 3 Aug 89 01:53:46 GMT Distribution: unix-pc Organization: ICUS Software Systems, Islip, New York Lines: 632 #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh Makeposix <<'END_OF_Makeposix' X: use /bin/sh X# Makeposix -- add a POSIX-conformant library to your system X X: a sanity check XPATH='.:/bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/local:/usr/lbin:/etc' Xexport PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh $0; kill $$) X X(alias) >/dev/null 2>&1 && \ X echo "(Some versions of ksh blow up on Makeposix, especially on" && \ X echo "exotic machines. If yours does, try the Bourne shell instead.)" X XLIBC=/lib/libc.a X X# . ../configsys.sh X Xcase $1 in '') system="$species" ;; *) system=$1 ;; esac X Xif test -f /usr/lib/lint/llib-lc Xthen X LINTLIB=/usr/lib/lint/llib-lc Xelse X LINTLIB=/usr/lib/llib-lc Xfi X Xcat </dev/null XThis script generates a Makefile and lint library patch for your system that, Xwhen applied, will move it a good part of the way towards conformance with the XPOSIX/SVID/X3J11 C library standards. X XThis script assumes X X 1) that your C library is at $LIBC X 2) that your lint library is at $LINTLIB X XIf either of these assumptions is incorrect, you'll need to edit the shell Xvariable assignments at the beginning of the script. X XHit interrupt key to quit, return key to continue. XEOF X: read stuff X XUSG=-DUSG X XHDS=/usr/include XLINTPATCH=posix.lint X X# X# All pieces of libposix.a must be listed here X# XSTRINGS="strchr.o strrchr.o strcspn.o strpbrk.o strspn.o strtok.o strdup.o" XMEM="memccpy.o memcpy.o memcmp.o memchr.o memset.o" XDIRENT="seekdir.o readdir.o getdents.o closedir.o opendir.o rewinddir.o telldir.o" XMKDIR="mkdir.o rmdir.o" XSEARCH="lsearch.o lfind.o tsearch.o tfind.o bsearch.o" XMISCOBJS="ssignal.o strtol.o getopt.o rename.o putpwent.o" X Xtrap 'rm -f /tmp/needed$$ /tmp/allobjs$$ /tmp/present$$ /tmp/remove$$; exit 0' 0 1 2 15 X X# X# ALLOBJS should list all possible libposix.a parts, with one trailing space X# XALLOBJS="$STRINGS $MEM $SEARCH $MISCOBJS " X X# X# Put support modules that shouldn't show in the feature lists here X# XSUPPORT=getdents.o X Xecho $ALLOBJS | tr " " "\012" >/tmp/allobjs$$ Xecho " " Xecho "Facilities available in the POSIX/SVID/X3J11 compatibility library:" Xsort /tmp/allobjs$$ | grep -v $SUPPORT | pr -5 -t -l1 X Xcase $system in SVR3) X echo " " X echo "You said you're running $system, I'll assume you have:" X echo $DIRENT | tr " " "\012" >/tmp/present$$ X pr -5 -t -l1 /tmp/present$$ X pr -5 -t -l1 /dev/null >>/tmp/present$$ Xsort -u /tmp/present$$ -o /tmp/present$$ Xecho "POSIX/SVID/X3J11 library facilities already present on your system:" Xgrep -v $SUPPORT /dev/null Xecho " " X: echo "Hit interrupt key to quit, return key to continue." X: read stuff X Xif grep rewinddir /tmp/present$$ >/dev/null 2>&1 Xthen X cp /dev/null /tmp/needed$$ Xelse X echo $DIRENT | tr " " "\012" >/tmp/needed$$ X echo "You don't have rewinddir, I'll assume you need the new dirent" X echo "package." X echo " " Xfi X X# Extract already-present faculities from allobjs, preserving sort order Xsed -e "/^.*$/s//\/&\/d/" /tmp/remove$$ Xsed -f /tmp/remove$$ >/tmp/needed$$ Xecho " " Xecho "POSIX/SVID/X3J11 library facilities that should be installed:" Xsort /tmp/needed$$ | pr -5 -t -l1 2>/dev/null Xecho " " X: echo "Hit interrupt key to quit, return key to continue." X: read stuff X X# set corresponding shell variable for each object file needed Xfor x in `tr "\012" " " $LINTPATCH X Xif grep lockf $LINTLIB >/dev/null 2>&1 Xthen X : do nothing Xelse X echo "int lockf(fd, fn, sz) int fd, fn; long sz; {return 0;}" >>$LINTPATCH Xfi Xif [ ! -f $HDS/dirent.h ] Xthen X dirent='yes' X man4list="$man4list dirent.4" Xfi Xif grep getdents $LINTLIB >/dev/null 2>&1 Xthen X : do nothing Xelse X cat >>$LINTPATCH < Xint getdents(f, b, n) int f; char *b; unsigned n; { return 0; } XEOF Xfi X Xif grep closedir $LINTLIB >/dev/null 2>&1 Xthen X : do nothing Xelse X echo "int closedir(p) DIR *p; { return 0; }" >>$LINTPATCH Xfi Xif grep opendir $LINTLIB >/dev/null 2>&1 Xthen X : do nothing Xelse X echo "DIR *opendir(f) char *f; {return (DIR *)NULL;}" >>$LINTPATCH Xfi Xif grep readdir $LINTLIB >/dev/null 2>&1 Xthen X : do nothing Xelse X echo "struct dirent *readdir(p) DIR *p; {return (struct dirent*)NULL;}" >>$LINTPATCH Xfi Xif grep seekdir $LINTLIB >/dev/null 2>&1 Xthen X : do nothing Xelse X echo "void seekdir(p, l) DIR *p; long l; {}" >>$LINTPATCH Xfi Xif grep telldir $LINTLIB >/dev/null 2>&1 Xthen X : do nothing Xelse X echo "long telldir(p) DIR *p; {return 1L;}" >>$LINTPATCH Xfi X Xif grep mkdir $LINTLIB >/dev/null 2>&1 Xthen X : do nothing Xelse X echo "/* MKDIR(3) */" >>$LINTPATCH X echo "int mkdir(s, p) char *s; int p; {return (0);}" >>$LINTPATCH X man3list="$man3list mkdir.3" Xfi Xif grep rmdir $LINTLIB >/dev/null 2>&1 Xthen X : do nothing Xelse X echo "/* RMDIR(3) */" >>$LINTPATCH X echo "int rmdir(s) char *s; {return (0);}" >>$LINTPATCH X man3list="$man3list rmdir.3" Xfi X Xif grep str /tmp/needed$$ >/dev/null 2>&1 Xthen X echo "/* STRING(3C) */" >>$LINTPATCH X strings='yes' X man3list="$man3list string.3" Xfi Xif grep strcat $LINTLIB >/dev/null 2>&1 Xthen X : do nothing Xelse X echo "char * strcat(a, b) char *a, *b; { return (a); }" >>$LINTPATCH Xfi Xif grep strncat $LINTLIB >/dev/null 2>&1 Xthen X : do nothing Xelse X echo "char * strncat(a, b, n) char *a, *b; { return (a); }" >>$LINTPATCH Xfi Xif grep strcmp $LINTLIB >/dev/null 2>&1 Xthen X : do nothing Xelse X echo "int strcmp(a, b) char *a, *b; { return (0); }" >>$LINTPATCH Xfi Xif grep strncmp $LINTLIB >/dev/null 2>&1 Xthen X : do nothing Xelse X echo "int strncmp(a, b, n) char *a, *b; { return (n); }" >>$LINTPATCH Xfi Xif grep strcpy $LINTLIB >/dev/null 2>&1 Xthen X : do nothing Xelse X echo "char * strcpy(a, b) char *a, *b; { return (a); }" >>$LINTPATCH Xfi Xif grep strncpy $LINTLIB >/dev/null 2>&1 Xthen X : do nothing Xelse X echo "char * strncpy(a, b, n) char *a, *b; { return (a); }" >>$LINTPATCH Xfi Xif grep strlen $LINTLIB >/dev/null 2>&1 Xthen X : do nothing Xelse X echo "int strlen(s) char *s; { return (0); }" >>$LINTPATCH Xfi Xif grep strchr $LINTLIB >/dev/null 2>&1 Xthen X : do nothing Xelse X echo "char * strchr(a, b) char *a, b; { return (a); }" >>$LINTPATCH Xfi Xif grep strrchr $LINTLIB >/dev/null 2>&1 Xthen X : do nothing Xelse X echo "char * strrchr(a, b) char *a, b; { return (a); }" >>$LINTPATCH Xfi Xif grep strpbrk $LINTLIB >/dev/null 2>&1 Xthen X : do nothing Xelse X echo "char * strpbrk(a, b) char *a, *b; { return (a); }" >>$LINTPATCH Xfi Xif grep strspn $LINTLIB >/dev/null 2>&1 Xthen X : do nothing Xelse X echo "int strspn(a, b) char *a, *b; { return (0); }" >>$LINTPATCH Xfi Xif grep strcspn $LINTLIB >/dev/null 2>&1 Xthen X : do nothing Xelse X echo "int strcspn(a, b) char *a, *b; { return (0); }" >>$LINTPATCH Xfi Xif grep strtok $LINTLIB >/dev/null 2>&1 Xthen X : do nothing Xelse X echo "char * strtok(a, b) char *a, *b; { return (a); }" >>$LINTPATCH Xfi Xif grep strdup $LINTLIB >/dev/null 2>&1 Xthen X : do nothing Xelse X echo "char * strdup(a) char *a; { return (a); }" >>$LINTPATCH Xfi X Xif grep str /tmp/needed$$ >/dev/null 2>&1 Xthen X echo "/* MEMORY(3C) */" >>$LINTPATCH X memory='yes' X man3list="$man3list memory.3" Xfi Xif [ X$memccpy != X ] Xthen X echo "char *memccpy(a,b,c,n) char *a,*b; {return(a);}" >>$LINTPATCH Xfi Xif [ X$memchr != X ] Xthen X echo "char *memchr(s,c,n) char *s; {return (s);}" >>$LINTPATCH Xfi Xif [ X$memcmp != X ] Xthen X echo "int memcmp(a, b, n) char *a, *b; {return(n);}" >>$LINTPATCH Xfi Xif [ X$memcpy != X ] Xthen X echo "char *memcpy(a,b,n) char *a, *b; {return (a);}" >>$LINTPATCH Xfi Xif [ X$memset != X ] Xthen X echo "char *memset(s,c,n) char *s; {return (s);}" >>$LINTPATCH Xfi X Xif grep lsearch $LINTLIB >/dev/null 2>&1 Xthen X : do nothing Xelse X echo "/* LSEARCH(3C) */" >>$LINTPATCH X echo "char *lsearch(k,b,n,w,c) char *k,*b; unsigned *n,w; int (*c)(); {return(k);}" >>$LINTPATCH Xfi Xif grep lfind $LINTLIB >/dev/null 2>&1 Xthen X : do nothing Xelse X echo "char *lfind(k,b,n,w,c) char *k,*b; unsigned *n,w; int (*c)();{return(k); }" >>$LINTPATCH Xfi X#include Xif grep bsearch /tmp/needed$$ >/dev/null 2>&1 Xthen X echo "/* BSEARCH(3C) */" >>$LINTPATCH X search='yes' X man3list="$man3list bsearch.3c" Xfi Xif grep bsearch $LINTLIB >/dev/null 2>&1 Xthen X : do nothing Xelse X echo "char *bsearch(k,b,n,w,c) char *k,*b; unsigned n,w; int (*c)();{return(k);}" >>$LINTPATCH Xfi Xif grep tsearch /tmp/needed$$ >/dev/null 2>&1 Xthen X echo "/* TSEARCH(3C) */" >>$LINTPATCH X search='yes' X man3list="$man3list tsearch.3c" Xfi Xif grep tsearch $LINTLIB >/dev/null 2>&1 Xthen X : do nothing Xelse X echo "char *tsearch(k,r,c) char *k, **r; int (*c)(); {return(k);}" >>$LINTPATCH Xfi Xif grep tfind $LINTLIB >/dev/null 2>&1 Xthen X : do nothing Xelse X echo "char *tfind(k,r,c) char *k,**r; int (*c)(); {return(k);}" >>$LINTPATCH Xfi Xif grep [gs]signal $LINTLIB >/dev/null 2>&1 Xthen X : do nothing Xelse X echo "/* SSIGNAL(3) */" >>$LINTPATCH X echo "int (*ssignal(s, a))() int (*a)(); { return (a); }" >>$LINTPATCH X echo "int gsignal(s) {return (s);}" >>$LINTPATCH X man3list="$man3list ssignal.3c" Xfi X Xif grep strtol $LINTLIB >/dev/null 2>&1 Xthen X : do nothing Xelse X echo "long strtol(s,t,b) char *s,**t; {return(0L);}" >>$LINTPATCH X man3list="$man3list strtol.3c" Xfi Xif grep getopt $LINTLIB >/dev/null 2>&1 Xthen X : do nothing Xelse X echo "int getopt(c,v,o) char **v, *o; {return(c);}" >>$LINTPATCH X man3list="$man3list getopt.3c" Xfi Xif grep rename $LINTLIB >/dev/null 2>&1 Xthen X : do nothing Xelse X echo "/* RENAME(3) */" >>$LINTPATCH X echo "int rename(s, t) char *s, *t; {return (0);}" >>$LINTPATCH X man3list="$man3list rename.3c" Xfi Xif grep putpwent $LINTLIB >/dev/null 2>&1 Xthen X : do nothing Xelse X echo "/* PUTPWENT(3C) */" >>$LINTPATCH X echo "int putpwent(s,f) struct passwd *s; FILE *f; {return(0);}" >>$LINTPATCH X man3list="$man3list putpwent.3c" Xfi X Xcat </dev/null X XProductions that can install these changes will now be written to Makefile. XRemember to edit out the -DUSG from the CFLAGS line if you're on a non-AT&T XUNIX (i.e. a V7 or BSD-based version). -DUSG will be removed for you Xautomatically if you had specified 4.2BSD or 4.3BSD as the type of Xyour system. Other installation instructions will be found in a Xleading comment in the generated Makefile. XEOT Xobjlist=`tr '\012' ' ' Makefile <>Makefile X echo " -cp unistd.h \$(HDS)/unistd.h;" >>Makefile Xfi Xif [ "X$dirent" != "X" ] Xthen X echo " @echo 'Installing dirent library headers...'" >>Makefile X echo " -cp dirent.h \$(HDS)/dirent.h;" >>Makefile X echo " -cp sys.dirent.h \$(HDS)/sys/dirent.h;" >>Makefile Xfi Xif [ "X$strings" != "X" ] Xthen X echo " @echo 'Installing string library headers...'" >>Makefile X echo " -cp \$(HDS)/string.h \$(HDS)/string.h-orig;" >>Makefile X echo " -cp string.h \$(HDS)/string.h;" >>Makefile Xfi Xif [ "X$memory" != "X" ] Xthen X echo " @echo 'Installing memory library headers...'" >>Makefile X echo " -cp \$(HDS)/memory.h \$(HDS)/memory.h-orig;" >>Makefile X echo " -cp memory.h \$(HDS)/memory.h;" >>Makefile Xfi Xif [ "X$search" != "X" ] Xthen X echo " @echo 'Installing search library headers...'" >>Makefile X echo " -cp \$(HDS)/search.h \$(HDS)/search.h-orig;" >>Makefile X echo " -cp search.h \$(HDS)/search.h;" >>Makefile Xfi Xcat >>Makefile <>\$(LINTLIB) X @echo "Your $LINTLIB will need to be recompiled" X @echo "If you are on an SVr2 or later, just do 'make relint'" XEOF X Xcat </dev/null X XNow type 'make' to make the library. Test productions have been Xincluded. When you're satisfied that everything works, go root and Xtype 'make install' (you may want to look at the Makefile to make Xsure it's not doing anything untoward). X XIf you're on SVr2 or later, you will probably want to do a 'make relint' Xafter the installation. On V7, SIII and BSD systems you'll have to work out Xyour own way of recompiling the modified lint file. X XA restore production is provided to back out the changes. XEOF X Xtouch posix_conf Xmkdir profiled 2>&1 >/dev/null X# Portability library config script ends here END_OF_Makeposix if test 16003 -ne `wc -c