Initial import of the CDE 2.1.30 sources from the Open Group.
This commit is contained in:
65
cde/config/util/Imakefile
Normal file
65
cde/config/util/Imakefile
Normal file
@@ -0,0 +1,65 @@
|
||||
XCOMM $XConsortium: Imakefile /main/16 1996/11/13 14:43:28 lehors $
|
||||
#if UseCCMakeDepend
|
||||
MDEP_PROG = makedepend
|
||||
#endif
|
||||
|
||||
#ifdef ExportListGenSource
|
||||
EXPORTLISTGEN = exportlistgen
|
||||
#endif
|
||||
|
||||
#ifdef Win32Architecture
|
||||
CMKDIRHIER = mkdirhier.exe
|
||||
#endif
|
||||
|
||||
PROGRAMS = xmkmf $(MDEP_PROG) mergelib ProgramTargetName(makestrs) $(EXPORTLISTGEN) $(CMKDIRHIER)
|
||||
DEPLIBS =
|
||||
#ifndef Win32Architecture
|
||||
EXTRA_LIBRARIES =
|
||||
#endif
|
||||
|
||||
XCOMM Some compilers generate fatal errors if an -L directory does
|
||||
XCOMM not exist. Since BUILDLIBDIR may not exist yet suppress its use.
|
||||
LDPRELIB =
|
||||
LDPRELIBS =
|
||||
|
||||
all:: $(PROGRAMS)
|
||||
|
||||
includes:: ProgramTargetName(makestrs)
|
||||
|
||||
#ifdef ExportListGenSource
|
||||
CppScriptTarget(exportlistgen,ExportListGenSource,-DCXXFILT=$(CXXFILT),)
|
||||
InstallNamedProg(exportlistgen,exportlistgen,$(BINDIR))
|
||||
#endif
|
||||
|
||||
CppScriptTarget(xmkmf,xmkmf.cpp,-DCONFIGDIRSPEC='"'"-I$(CONFIGDIR)"'"',$(ICONFIGFILES))
|
||||
CppScriptTarget(makedepend,mdepend.cpp,-DPREPROC='"'"$(PREPROCESSCMD)"'"',$(ICONFIGFILES))
|
||||
CppScriptTarget(mergelib,mergelib.cpp,"-DARCMD=$(AR)" "-DRANLIB=$(RANLIB)",$(ICONFIGFILES))
|
||||
|
||||
#if HasSymLinks
|
||||
#if CrossCompiling
|
||||
SimpleHostProgramTarget(lndir)
|
||||
#else
|
||||
SimpleProgramTarget(lndir)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef Win32Architecture
|
||||
SimpleProgramTarget(mkdirhier)
|
||||
#endif
|
||||
|
||||
NormalProgramTarget(makestrs,makestrs.o,,,)
|
||||
|
||||
InstallNamedProg(xmkmf,xmkmf,$(BINDIR))
|
||||
InstallManPage(xmkmf,$(MANDIR))
|
||||
InstallNamedProg(mkdirhier.sh,mkdirhier,$(BINDIR))
|
||||
InstallManPage(mkdirhier,$(MANDIR))
|
||||
#if UseCCMakeDepend
|
||||
InstallNamedProg(makedepend,makedepend,$(BINDIR))
|
||||
#endif
|
||||
#if SystemV || SystemV4
|
||||
InstallNamedProg(bsdinst.sh,bsdinst,$(BINDIR))
|
||||
#endif
|
||||
InstallNamedProg(mergelib,mergelib,$(BINDIR))
|
||||
|
||||
InstallNamedProg(makeg.sh,makeg,$(BINDIR))
|
||||
InstallManPage(makeg,$(MANDIR))
|
||||
20
cde/config/util/Makefile.ini
Normal file
20
cde/config/util/Makefile.ini
Normal file
@@ -0,0 +1,20 @@
|
||||
# $XConsortium: Makefile.ini,v 1.2 94/04/17 14:55:28 gildea Exp $
|
||||
#
|
||||
# A way to get lndir built the first time, before you have imake up
|
||||
# and running. You may well have to specify OSFLAGS=-D<something> to
|
||||
# get it to compile, which values are embedded in config files. What
|
||||
# you would pass as BOOTSTRAPCFLAGS might work.
|
||||
|
||||
OSFLAGS =
|
||||
CC = cc
|
||||
CDEBUGFLAGS = -O
|
||||
INCLUDES = -I.
|
||||
CFLAGS = $(OSFLAGS) $(CDEBUGFLAGS) $(INCLUDES)
|
||||
SHELL = /bin/sh
|
||||
RM = rm -f
|
||||
LN = ln -s
|
||||
|
||||
lndir:
|
||||
$(LN) ../../include X11
|
||||
$(CC) -o lndir $(CFLAGS) lndir.c
|
||||
$(RM) X11
|
||||
74
cde/config/util/aminstall.sh
Normal file
74
cde/config/util/aminstall.sh
Normal file
@@ -0,0 +1,74 @@
|
||||
#!/bin/sh
|
||||
# $XConsortium: aminstall.sh,v 1.1 94/03/29 15:54:08 gildea Exp $
|
||||
# aminstall - transfer cross-compiled files to system running Amoeba.
|
||||
# Usage: aminstall binary-directory [-s stksz] unix-source amoeba-dest
|
||||
|
||||
#
|
||||
# Default soap mask for files
|
||||
#
|
||||
SPMASK=0xFF:2:2
|
||||
export SPMASK
|
||||
PROG=$0
|
||||
USAGE="Usage: $PROG binary-directory unix-source amoeba-dest"
|
||||
|
||||
#
|
||||
# Argument check
|
||||
#
|
||||
case $# in
|
||||
3|5) ;;
|
||||
*) echo $USAGE >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
bindir=$1
|
||||
stksz=
|
||||
case $2 in
|
||||
-s) if [ $# -ne 5 ]
|
||||
then
|
||||
echo $USAGE >&2
|
||||
exit 1
|
||||
fi
|
||||
stksz="-s $3"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
|
||||
unxfile=$2
|
||||
dest=$3
|
||||
|
||||
#
|
||||
# Change /public .... into /super (just for installation)
|
||||
#
|
||||
stripped=`echo $dest | sed 's:^/public::'`
|
||||
if [ X$dest != X$stripped ]; then
|
||||
dest=/super$stripped
|
||||
fi
|
||||
|
||||
#
|
||||
# If the file already exists, then delete it
|
||||
#
|
||||
INFO=`$bindir/std_info $dest 2>&1`
|
||||
case $INFO in
|
||||
*"not found"*) ;;
|
||||
*failed*) ;;
|
||||
*bytes*) $bindir/del -f $dest
|
||||
;;
|
||||
/??????) echo $PROG: cannot install over directory 1>&2
|
||||
exit
|
||||
;;
|
||||
*) $bindir/del -d $dest
|
||||
;;
|
||||
esac
|
||||
|
||||
#
|
||||
# Transfer the file to Amoeba
|
||||
#
|
||||
$bindir/../bin.scripts/ainstall $stksz $unxfile $dest > /dev/null 2>&1
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "This is not binary - using tob"
|
||||
$bindir/tob $unxfile $dest
|
||||
fi
|
||||
|
||||
136
cde/config/util/bsdinst.sh
Executable file
136
cde/config/util/bsdinst.sh
Executable file
@@ -0,0 +1,136 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# This accepts bsd-style install arguments and makes the appropriate calls
|
||||
# to the System V install.
|
||||
# $XConsortium: bsdinst.sh /main/8 1996/09/28 16:16:11 rws $
|
||||
|
||||
flags=""
|
||||
dst=""
|
||||
src=""
|
||||
dostrip=""
|
||||
owner=""
|
||||
mode=""
|
||||
|
||||
while [ x$1 != x ]; do
|
||||
case $1 in
|
||||
-c) shift
|
||||
continue;;
|
||||
|
||||
-m) flags="$flags $1 $2 "
|
||||
mode="$2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-o) flags="$flags -u $2 "
|
||||
owner="$2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-g) flags="$flags $1 $2 "
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-s) dostrip="strip"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
*) if [ x$src = x ]
|
||||
then
|
||||
src=$1
|
||||
else
|
||||
dst=$1
|
||||
fi
|
||||
shift
|
||||
continue;;
|
||||
esac
|
||||
done
|
||||
|
||||
case "$mode" in
|
||||
"")
|
||||
;;
|
||||
*)
|
||||
case "$owner" in
|
||||
"")
|
||||
flags="$flags -u root"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ x$src = x ]
|
||||
then
|
||||
echo "$0: no input file specified"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ x$dst = x ]
|
||||
then
|
||||
echo "$0: no destination specified"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# set up some variable to be used later
|
||||
|
||||
rmcmd=""
|
||||
srcdir="."
|
||||
|
||||
# if the destination isn't a directory we'll need to copy it first
|
||||
|
||||
if [ ! -d $dst ]
|
||||
then
|
||||
dstbase=`basename $dst`
|
||||
cp $src /tmp/$dstbase
|
||||
rmcmd="rm -f /tmp/$dstbase"
|
||||
src=$dstbase
|
||||
srcdir=/tmp
|
||||
dst="`echo $dst | sed 's,^\(.*\)/.*$,\1,'`"
|
||||
if [ x$dst = x ]
|
||||
then
|
||||
dst="."
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# If the src file has a directory, copy it to /tmp to make install happy
|
||||
|
||||
srcbase=`basename $src`
|
||||
|
||||
if [ "$src" != "$srcbase" ] && [ "$src" != "./$srcbase" ]
|
||||
then
|
||||
cp $src /tmp/$srcbase
|
||||
src=$srcbase
|
||||
srcdir=/tmp
|
||||
rmcmd="rm -f /tmp/$srcbase"
|
||||
fi
|
||||
|
||||
# do the actual install
|
||||
|
||||
if [ -f /usr/sbin/install ]
|
||||
then
|
||||
installcmd=/usr/sbin/install
|
||||
elif [ -f /etc/install ]
|
||||
then
|
||||
installcmd=/etc/install
|
||||
else
|
||||
installcmd=install
|
||||
fi
|
||||
|
||||
# This rm is commented out because some people want to be able to
|
||||
# install through symbolic links. Uncomment it if it offends you.
|
||||
# rm -f $dst/$srcbase
|
||||
(cd $srcdir ; $installcmd -f $dst $flags $src)
|
||||
|
||||
if [ x$dostrip = xstrip ]
|
||||
then
|
||||
strip $dst/$srcbase
|
||||
fi
|
||||
|
||||
# and clean up
|
||||
|
||||
$rmcmd
|
||||
|
||||
338
cde/config/util/checktree.c
Normal file
338
cde/config/util/checktree.c
Normal file
@@ -0,0 +1,338 @@
|
||||
/* $TOG: checktree.c /main/8 1998/02/06 11:23:04 kaleb $ */
|
||||
|
||||
/*
|
||||
|
||||
Copyright (c) 1993, 1998 The Open Group
|
||||
|
||||
All Rights Reserved.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of The Open Group shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings
|
||||
in this Software without prior written authorization from The Open Group.
|
||||
*/
|
||||
|
||||
#include <X11/Xos.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/param.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifndef X_NOT_POSIX
|
||||
#include <dirent.h>
|
||||
#else
|
||||
#ifdef SYSV
|
||||
#include <dirent.h>
|
||||
#else
|
||||
#ifdef USG
|
||||
#include <dirent.h>
|
||||
#else
|
||||
#include <sys/dir.h>
|
||||
#ifndef dirent
|
||||
#define dirent direct
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef S_IFLNK
|
||||
#define Stat lstat
|
||||
#else
|
||||
#define Stat stat
|
||||
#endif
|
||||
|
||||
#define CHARSALLOWED \
|
||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_."
|
||||
|
||||
#define fmode_bits_minset 0444
|
||||
#define fmode_bits_maxset 0777
|
||||
#define fmode_bits_write 0222
|
||||
#define dmode_bits_minset 0775
|
||||
|
||||
#ifdef X_NOT_STDC_ENV
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
int dorcs = 1; /* check RCS file */
|
||||
int do83 = 1; /* check for 8+3 clash */
|
||||
int doro = 1; /* disallow writable (checked out) files */
|
||||
int dodot = 1; /* disallow .files */
|
||||
int dotwiddle = 1; /* disallow file~ */
|
||||
|
||||
int dontcare(fn)
|
||||
char *fn;
|
||||
{
|
||||
char *cp;
|
||||
|
||||
if (fn[strlen(fn) - 1] == '~')
|
||||
return 1;
|
||||
cp = strrchr(fn, '.');
|
||||
return cp && (!strcmp(cp + 1, "Z") || !strcmp(cp + 1, "PS"));
|
||||
}
|
||||
|
||||
checkfile(fullname, fn, fs)
|
||||
char *fullname, *fn;
|
||||
struct stat *fs;
|
||||
{
|
||||
char *cp;
|
||||
int maxlen = 12;
|
||||
int len, mode;
|
||||
|
||||
if (dodot && fn[0] == '.') {
|
||||
printf("dot file: %s\n", fullname);
|
||||
return;
|
||||
}
|
||||
for (len = 0, cp = fn; *cp; len++, cp++) {
|
||||
if (!strchr(CHARSALLOWED, *cp)) {
|
||||
if (dotwiddle || *cp != '~' || cp[1])
|
||||
printf ("bad character: %s\n", fullname);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (len > maxlen && !dontcare(fn))
|
||||
printf("too long (%d): %s\n", len, fullname);
|
||||
#ifdef S_IFLNK
|
||||
if ((fs->st_mode & S_IFLNK) == S_IFLNK) {
|
||||
printf("symbolic link: %s\n", fullname);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
mode = fs->st_mode & (~S_IFMT);
|
||||
if ((fs->st_mode & S_IFDIR) == S_IFDIR) {
|
||||
maxlen = 14;
|
||||
if ((mode & dmode_bits_minset) != dmode_bits_minset)
|
||||
printf("directory mode 0%o not minimum 0%o: %s\n",
|
||||
mode, dmode_bits_minset, fullname);
|
||||
} else if ((fs->st_mode & S_IFREG) != S_IFREG)
|
||||
printf("not a regular file: %s\n", fullname);
|
||||
else {
|
||||
if ((mode & fmode_bits_minset) != fmode_bits_minset)
|
||||
printf("file mode 0%o not minimum 0%o: %s\n",
|
||||
fs->st_mode, fmode_bits_minset, fullname);
|
||||
if (fs->st_nlink != 1)
|
||||
printf("%d links instead of 1: %s\n", fs->st_nlink, fullname);
|
||||
if (doro && (mode & fmode_bits_write) && !dontcare(fn))
|
||||
printf("writable: %s\n", fullname);
|
||||
}
|
||||
if ((mode & ~fmode_bits_maxset) != 0)
|
||||
printf("mode 0%o outside maximum set 0%o: %s\n",
|
||||
mode, fmode_bits_maxset, fullname);
|
||||
}
|
||||
|
||||
void
|
||||
checkrcs(dir, p)
|
||||
char *dir;
|
||||
char *p;
|
||||
{
|
||||
DIR *df;
|
||||
struct dirent *dp;
|
||||
struct stat fs;
|
||||
int i;
|
||||
|
||||
if (!(df = opendir(dir))) {
|
||||
fprintf(stderr, "cannot open: %s\n", dir);
|
||||
return;
|
||||
}
|
||||
while (dp = readdir(df)) {
|
||||
i = strlen(dp->d_name);
|
||||
if (dp->d_name[i - 1] == 'v' && dp->d_name[i - 2] == ',') {
|
||||
strcpy(p, dp->d_name);
|
||||
p[i - 2] = '\0';
|
||||
if (Stat(dir, &fs) < 0) {
|
||||
strcpy(p, "RCS/");
|
||||
strcat(p, dp->d_name);
|
||||
printf("not used: %s\n", dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir(df);
|
||||
}
|
||||
|
||||
int
|
||||
Strncmp(cp1, cp2, n)
|
||||
char *cp1, *cp2;
|
||||
int n;
|
||||
{
|
||||
char c1, c2;
|
||||
|
||||
for (; --n >= 0 && *cp1 && *cp2; cp1++, cp2++) {
|
||||
if (*cp1 != *cp2) {
|
||||
c1 = *cp1;
|
||||
c2 = *cp2;
|
||||
if (c1 >= 'A' && c1 <= 'Z')
|
||||
c1 += 'a' - 'A';
|
||||
else if (c1 == '-')
|
||||
c1 = '_';
|
||||
if (c2 >= 'A' && c2 <= 'Z')
|
||||
c2 += 'a' - 'A';
|
||||
else if (c2 == '-')
|
||||
c2 = '_';
|
||||
if (c1 != c2)
|
||||
return (int)c1 - (int)c2;
|
||||
}
|
||||
}
|
||||
if (n < 0)
|
||||
return 0;
|
||||
return (int)*cp1 - (int)*cp2;
|
||||
}
|
||||
|
||||
int
|
||||
fncomp(n1, n2)
|
||||
char **n1, **n2;
|
||||
{
|
||||
int i, res;
|
||||
char *cp1, *cp2;
|
||||
char c1, c2;
|
||||
|
||||
i = Strncmp(*n1, *n2, 8);
|
||||
if (!i) {
|
||||
cp1 = strrchr(*n1, '.');
|
||||
cp2 = strrchr(*n2, '.');
|
||||
if (cp1 || cp2) {
|
||||
if (!cp1)
|
||||
return -1;
|
||||
if (!cp2)
|
||||
return 1;
|
||||
i = Strncmp(cp1 + 1, cp2 + 1, 3);
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
void
|
||||
checkdir(dir)
|
||||
char *dir;
|
||||
{
|
||||
DIR *df;
|
||||
struct dirent *dp;
|
||||
char *p;
|
||||
struct stat fs;
|
||||
char *s, **names;
|
||||
int i, max;
|
||||
|
||||
if (!(df = opendir(dir))) {
|
||||
fprintf(stderr, "cannot open: %s\n", dir);
|
||||
return;
|
||||
}
|
||||
p = dir + strlen(dir);
|
||||
if (p[-1] != '/')
|
||||
*p++ = '/';
|
||||
i = 0;
|
||||
max = 0;
|
||||
names = NULL;
|
||||
while (dp = readdir(df)) {
|
||||
strcpy(p, dp->d_name);
|
||||
if (Stat(dir, &fs) < 0) {
|
||||
perror(dir);
|
||||
continue;
|
||||
}
|
||||
if ((fs.st_mode & S_IFDIR) == S_IFDIR) {
|
||||
if (dp->d_name[0] == '.' &&
|
||||
(dp->d_name[1] == '\0' || (dp->d_name[1] == '.' &&
|
||||
dp->d_name[2] == '\0')))
|
||||
continue;
|
||||
if (!strcmp (dp->d_name, "RCS")) {
|
||||
if (dorcs)
|
||||
checkrcs(dir, p);
|
||||
continue;
|
||||
}
|
||||
if (!strcmp (dp->d_name, "SCCS"))
|
||||
continue;
|
||||
if (!strcmp (dp->d_name, "CVS.adm"))
|
||||
continue;
|
||||
checkfile(dir, p, &fs);
|
||||
checkdir(dir);
|
||||
continue;
|
||||
}
|
||||
checkfile(dir, p, &fs);
|
||||
if (dorcs && !dontcare(dp->d_name)) {
|
||||
strcpy(p, "RCS/");
|
||||
strcat(p, dp->d_name);
|
||||
strcat(p, ",v");
|
||||
if (Stat(dir, &fs) < 0) {
|
||||
strcpy(p, dp->d_name);
|
||||
printf("no RCS: %s\n", dir);
|
||||
}
|
||||
}
|
||||
if (do83) {
|
||||
s = (char *)malloc(strlen(dp->d_name) + 1);
|
||||
strcpy(s, dp->d_name);
|
||||
if (i >= max) {
|
||||
max += 25;
|
||||
if (names)
|
||||
names = (char **)realloc((char *)names,
|
||||
(max + 1) * sizeof(char *));
|
||||
else
|
||||
names = (char **)malloc((max + 1) * sizeof(char *));
|
||||
}
|
||||
names[i++] = s;
|
||||
}
|
||||
}
|
||||
closedir(df);
|
||||
if (do83) {
|
||||
qsort((char *)names, i, sizeof(char *), fncomp);
|
||||
max = i - 1;
|
||||
*p = '\0';
|
||||
for (i = 0; i < max; i++) {
|
||||
if (!fncomp(&names[i], &names[i + 1]))
|
||||
printf("8+3 clash: %s%s and %s\n",
|
||||
dir, names[i], names[i + 1]);
|
||||
free(names[i]);
|
||||
}
|
||||
if (names) {
|
||||
free(names[i]);
|
||||
free((char *)names);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
char buf[2048];
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
while (argc > 0) {
|
||||
if (!strcmp(*argv, "-rcs")) {
|
||||
dorcs = 0;
|
||||
argc--;
|
||||
argv++;
|
||||
} else if (!strcmp(*argv, "-83")) {
|
||||
do83 = 0;
|
||||
argc--;
|
||||
argv++;
|
||||
} else if (!strcmp(*argv, "-ro")) {
|
||||
doro = 0;
|
||||
argc--;
|
||||
argv++;
|
||||
} else if (!strcmp(*argv, "-dot")) {
|
||||
dodot = 0;
|
||||
argc--;
|
||||
argv++;
|
||||
} else if (!strcmp(*argv, "-twiddle")) {
|
||||
dotwiddle = 0;
|
||||
argc--;
|
||||
argv++;
|
||||
} else
|
||||
break;
|
||||
}
|
||||
if (!argc) {
|
||||
strcpy(buf, ".");
|
||||
checkdir(buf);
|
||||
} else
|
||||
while (--argc >= 0) {
|
||||
strcpy(buf, *argv++);
|
||||
checkdir(buf);
|
||||
}
|
||||
}
|
||||
71
cde/config/util/chownxterm.c
Normal file
71
cde/config/util/chownxterm.c
Normal file
@@ -0,0 +1,71 @@
|
||||
/* $TOG: chownxterm.c /main/4 1998/02/06 11:23:10 kaleb $ */
|
||||
/*
|
||||
|
||||
Copyright (c) 1993, 1994, 1998 The Open Group
|
||||
|
||||
All Rights Reserved.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of The Open Group shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings
|
||||
in this Software without prior written authorization from The Open Group.
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
* chownxterm --- make xterm suid root
|
||||
*
|
||||
* By Stephen Gildea, December 1993
|
||||
*/
|
||||
|
||||
|
||||
#define XTERM_PATH "/x11/programs/xterm/xterm"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
char *prog_name;
|
||||
|
||||
void help()
|
||||
{
|
||||
setgid(getgid());
|
||||
setuid(getuid());
|
||||
printf("chown-xterm makes %s suid root\n", XTERM_PATH);
|
||||
printf("This is necessary on Ultrix for /dev/tty operation.\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void print_error(err_string)
|
||||
char *err_string;
|
||||
{
|
||||
setgid(getgid());
|
||||
setuid(getuid());
|
||||
fprintf(stderr, "%s: \"%s\"", prog_name, err_string);
|
||||
perror(" failed");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
prog_name = argv[0];
|
||||
if (argc >= 2 && strcmp(argv[1], "-help") == 0) {
|
||||
help();
|
||||
} else {
|
||||
if (chown(XTERM_PATH, 0, -1) != 0)
|
||||
print_error("chown root " XTERM_PATH);
|
||||
if (chmod(XTERM_PATH, 04555) != 0)
|
||||
print_error("chmod 4555 " XTERM_PATH);
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
9
cde/config/util/crayar.sh
Executable file
9
cde/config/util/crayar.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
lib=$1
|
||||
shift
|
||||
if cray2; then
|
||||
bld cr $lib `lorder $* | tsort`
|
||||
else
|
||||
ar clq $lib $*
|
||||
fi
|
||||
|
||||
215
cde/config/util/elistgen.hp
Normal file
215
cde/config/util/elistgen.hp
Normal file
@@ -0,0 +1,215 @@
|
||||
XCOMM!/bin/sh
|
||||
XCOMM $TOG: elistgen.hp /main/5 1999/04/16 13:54:01 mgreess $
|
||||
XCOMM
|
||||
XCOMM #########################################################################
|
||||
XCOMM Construct shared-library export lists for HP-UX based on standardized
|
||||
XCOMM export list description file
|
||||
XCOMM
|
||||
XCOMM Usage: exportlistgen libfoo.sl libfoo.elist > libfoo.lopt
|
||||
XCOMM
|
||||
XCOMM libfoo.sl => shared library of interest
|
||||
XCOMM libfoo.elist => Meta description of necessary export list.
|
||||
XCOMM
|
||||
XCOMM The output may then be passed to the linker to reconstruct the
|
||||
XCOMM shared library. For unknown reasons naming only exported symbols
|
||||
XCOMM with "+e" does not work for debuggable C++ code, even though "nm"
|
||||
XCOMM reports no difference between the resulting libraries. The linker
|
||||
XCOMM complains that "first non-inline virtual function" is not defined for
|
||||
XCOMM vtables. We instead hide internal symbols with "-h" as a work-around.
|
||||
XCOMM
|
||||
XCOMM Author: Aloke Gupta 5/25/94.
|
||||
XCOMM (c) Copyright 1996 Digital Equipment Corporation.
|
||||
XCOMM (c) Copyright 1994,1996 Hewlett-Packard Company.
|
||||
XCOMM (c) Copyright 1996 International Business Machines Corp.
|
||||
XCOMM (c) Copyright 1996 Sun Microsystems, Inc.
|
||||
XCOMM (c) Copyright 1996 Novell, Inc.
|
||||
XCOMM (c) Copyright 1996 FUJITSU LIMITED.
|
||||
XCOMM (c) Copyright 1996 Hitachi.
|
||||
XCOMM
|
||||
XCOMM #########################################################################
|
||||
|
||||
XCOMM Utility programs
|
||||
FILTER=CXXFILT # C++ symbol demangler
|
||||
AWK=awk # awk
|
||||
PATH=/usr/bin:/bin:/usr/ucb # For nm, cat, pr, expand, awk, c++filt
|
||||
|
||||
XCOMM Temporary files
|
||||
EXPORTLIST=/tmp/elistgen1.$$ # list of export symbols from "libfoo.elist"
|
||||
NMLIST=/tmp/elistgen2.$$ # name list from libfoo.sl
|
||||
FILTLIST=/tmp/elistgen3.$$ # demangled (C++) version of NMLIST
|
||||
|
||||
XCOMM Print useful information at the top of the output
|
||||
echo "#" `date`
|
||||
echo "# This linker options list was produced by" $0
|
||||
echo "# Input export list description taken from:" $2
|
||||
echo "# Target library:" $1
|
||||
echo "# Target Operating System:" `uname -msrv`
|
||||
echo "# "
|
||||
|
||||
XCOMM Extract the globally visible symbols from target library
|
||||
XCOMM The NMLIST generated here is later used to cross-check the symbols in the
|
||||
XCOMM supplied export-list.
|
||||
XCOMM
|
||||
nm -p $1 | $AWK '
|
||||
/ [cCTDB][S ] [^\$]/{print $3} # Text, Data, BSS, or Secondary symbols
|
||||
' | uniq > $NMLIST.all
|
||||
|
||||
nm -p $1 | $AWK '
|
||||
/ [uU][S ] [^\$]/{print $3} # Text, Data, BSS, or Secondary symbols
|
||||
' | uniq > $NMLIST.undef
|
||||
|
||||
cat $NMLIST.all $NMLIST.undef $NMLIST.undef | sort | uniq -c | $AWK '{if ($1=="1") print $2}' > $NMLIST
|
||||
|
||||
|
||||
XCOMM nm -p $1 | $AWK '
|
||||
XCOMM / [cCTDB][S ] [^\$]/{print $3} # Text, Data, BSS, or Secondary symbols
|
||||
XCOMM ' > $NMLIST
|
||||
|
||||
XCOMM Demangle the global library symbols. This operation is necessary to
|
||||
XCOMM convert mangled C++ symbols into their C++ notation.
|
||||
${FILTER:-cat} $NMLIST > $FILTLIST
|
||||
|
||||
XCOMM
|
||||
XCOMM Cleanup the export-list description file.
|
||||
XCOMM Note that C++ symbols may have embedded spaces in them.
|
||||
XCOMM
|
||||
cat $2 | $AWK '
|
||||
BEGIN {
|
||||
csyms = 0; # C language symbols in libfoo.list
|
||||
cplusplus = 0; # C++ language symbols in libfoo.list
|
||||
isyms = 0; # C internal symbols in libfoo.elist
|
||||
icplusplus = 0; # C++ internal symbols in libfoo.elist
|
||||
implicit = ""; # Handling of implicit symbols.
|
||||
}
|
||||
$1 == "default" {
|
||||
# A default clause suppresses warnings about implicit symbols.
|
||||
if ($2 != "" && $2 != "force" && $2 != "public" &&
|
||||
$2 != "private" && $2 != "internal") {
|
||||
print "# Warning: illegal default clause:", $2 | "cat 1>&2";
|
||||
next;
|
||||
}
|
||||
if (implicit != "")
|
||||
print "# Warning: multiple default clauses." | "cat 1>&2";
|
||||
implicit = $2;
|
||||
next;
|
||||
}
|
||||
$1 == "force" || $1 == "public" || $1 == "private" {
|
||||
csyms ++;
|
||||
print $1 ";;" $2;
|
||||
next;
|
||||
}
|
||||
$1 == "publicC++" || $1 == "privateC++" {
|
||||
cplusplus ++;
|
||||
string = $2;
|
||||
for (n = 3; n <= NF; n++)
|
||||
string = string " " $n;
|
||||
print $1 ";;" string;
|
||||
next;
|
||||
}
|
||||
$1 == "internal" {
|
||||
isyms ++;
|
||||
print $1 ";;" $2;
|
||||
next;
|
||||
}
|
||||
$1 == "internalC++" {
|
||||
icplusplus ++;
|
||||
string = $2;
|
||||
for (n = 3; n <= NF; n++)
|
||||
string = string " " $n;
|
||||
print $1 ";;" string;
|
||||
next;
|
||||
}
|
||||
END {
|
||||
printf("# Exporting %d C and %d C++ symbols, hiding %d and %d.\n",
|
||||
csyms, cplusplus, isyms, icplusplus) | "cat 1>&2";
|
||||
if (implicit != "") {
|
||||
print "# Unspecified symbols are " implicit "." | "cat 1>&2";
|
||||
print "default;;" implicit;
|
||||
}
|
||||
}
|
||||
' > $EXPORTLIST
|
||||
|
||||
XCOMM Read in the above files and write result to stdout. The contents
|
||||
XCOMM of NMLIST and FILTLIST are used to construct a symbol lookup table.
|
||||
XCOMM The contents of EXPORTLIST are converted with the help of this table.
|
||||
XCOMM Use ";" as a delimiter in the symbol lookup table.
|
||||
XCOMM
|
||||
(pr -m -s";" -t -w1024 $NMLIST $FILTLIST| expand -t 1;cat $EXPORTLIST ) | $AWK '
|
||||
BEGIN {
|
||||
FS = ";";
|
||||
implicit = 0;
|
||||
}
|
||||
NF == 2 {
|
||||
# This is "pr" output, i.e., symbol translation table.
|
||||
syms[$2] = $1;
|
||||
next;
|
||||
}
|
||||
NF == 3 && $1 == "default" {
|
||||
# Treatment of unspecified symbols.
|
||||
if ($3 == "internal" || $3 == "internalC++")
|
||||
implicit = 1;
|
||||
else if ($3 == "private" || $3 == "privateC++")
|
||||
implicit = 2;
|
||||
else if ($3 == "public" || $3 == "publicC++")
|
||||
implicit = 3;
|
||||
else # $3 == "force"
|
||||
implicit = 4;
|
||||
next;
|
||||
}
|
||||
NF == 3 {
|
||||
# Parse our instructions for this symbol.
|
||||
if ($1 == "internal" || $1 == "internalC++")
|
||||
export = 1;
|
||||
else if ($1 == "private" || $1 == "privateC++")
|
||||
export = 2;
|
||||
else if ($1 == "public" || $1 == "publicC++")
|
||||
export = 3;
|
||||
else # $1 == "force"
|
||||
export = 4;
|
||||
|
||||
# Process it.
|
||||
if (length(syms[$3]) > 0) {
|
||||
if (donelist[$3])
|
||||
print "# Warning: Duplicate entry for", $3,
|
||||
"in export list" | "cat 1>&2";
|
||||
if (donelist[$3] < export)
|
||||
donelist[$3] = export;
|
||||
} else {
|
||||
if (export == 4)
|
||||
donelist[$3] = export;
|
||||
else
|
||||
print "# Warning:", $3,
|
||||
"was not in the nm list for this library" | "cat 1>&2";
|
||||
}
|
||||
next;
|
||||
}
|
||||
END {
|
||||
# Force implicit exporting of errno.
|
||||
if (! donelist["errno"])
|
||||
donelist["errno"] = 4;
|
||||
|
||||
# Complain about some implicit symbols.
|
||||
for (i in syms) {
|
||||
if (!donelist[i] && (length(syms[i]) > 0)) {
|
||||
# Ignore automatic symbols generated by the C++ compiler.
|
||||
if (implicit == 0 &&
|
||||
(syms[i] !~ /^__noperfopt__/) &&
|
||||
(syms[i] !~ /^__ptbl_vec__/) &&
|
||||
(syms[i] !~ /^__vtbl__[0-9]*_/) &&
|
||||
(syms[i] !~ /^__cfront_version_[0-9]*_xxxxxxxx$/))
|
||||
print "# Warning:", syms[i],
|
||||
"was not in the export list" | "cat 1>&2";
|
||||
donelist[i] = implicit;
|
||||
}
|
||||
if ((donelist[i] > 1) && (length(syms[i]) > 0))
|
||||
print "-e", syms[i];
|
||||
}
|
||||
}
|
||||
'
|
||||
|
||||
XCOMM Clean up temporary files
|
||||
rm $EXPORTLIST
|
||||
rm $NMLIST.all
|
||||
rm $NMLIST.undef
|
||||
rm $NMLIST
|
||||
rm $FILTLIST
|
||||
220
cde/config/util/elistgen.ibm
Normal file
220
cde/config/util/elistgen.ibm
Normal file
@@ -0,0 +1,220 @@
|
||||
XCOMM!/bin/sh
|
||||
XCOMM $XConsortium: elistgen.ibm /main/2 1996/12/04 10:13:18 swick $
|
||||
XCOMM
|
||||
XCOMM #########################################################################
|
||||
XCOMM Construct shared-library export lists for IBM-AIX based on standardized
|
||||
XCOMM export list description file
|
||||
XCOMM
|
||||
XCOMM Usage: elistgen libfoo.sl libfoo.elist > libfoo.lopt
|
||||
XCOMM
|
||||
XCOMM libfoo.a => shared library of interest
|
||||
XCOMM libfoo.elist => Meta description of necessary export list.
|
||||
XCOMM
|
||||
XCOMM The output file, "libfoo.lopt" may then be passed to the IBM linker to
|
||||
XCOMM reconstruct the shared library, libfoo.sl.
|
||||
XCOMM
|
||||
XCOMM Author: Yanling Qi 10/03/94, Last updated 10/03/94
|
||||
XCOMM (c) Copyright 1996 Digital Equipment Corporation.
|
||||
XCOMM (c) Copyright 1996 Hewlett-Packard Company.
|
||||
XCOMM (c) Copyright 1994,1996 International Business Machines Corp.
|
||||
XCOMM (c) Copyright 1996 Sun Microsystems, Inc.
|
||||
XCOMM (c) Copyright 1996 Novell, Inc.
|
||||
XCOMM (c) Copyright 1996 FUJITSU LIMITED.
|
||||
XCOMM (c) Copyright 1996 Hitachi.
|
||||
XCOMM
|
||||
XCOMM #########################################################################
|
||||
|
||||
#define HASH #
|
||||
|
||||
XCOMM Utility programs
|
||||
FILTER=CXXFILT # C++ symbol demangler
|
||||
AWK=awk # awk
|
||||
|
||||
XCOMM For dump, cat, pr, expand, awk, c++filt
|
||||
PATH=/usr/bin:/bin:/usr/ucb:/usr/lpp/xlC/bin
|
||||
|
||||
XCOMM Temporary files
|
||||
EXPORTLIST=/tmp/elistgen1.$$ # export directives from "libfoo.list"
|
||||
NMLIST=/tmp/elistgen2.$$ # name list from libfoo.sl
|
||||
FILTLIST=/tmp/elistgen3.$$ # demangled (C++) version of above
|
||||
|
||||
XCOMM Print useful information
|
||||
echo "*" `date`
|
||||
echo "* This linker options list was produced by" $0
|
||||
echo "* Input export list description taken from:" $2
|
||||
echo "* Target library:" $1
|
||||
echo "* Target Operating System:" `uname`
|
||||
echo "*"
|
||||
|
||||
XCOMM Extract the globally visible symbols from target library
|
||||
dump -g $1 | $AWK '$1 ~ /[0-9][0-9]/ && $2 !~ /^[\.]/ {print $2}' > $NMLIST
|
||||
|
||||
XCOMM Demangle the global library symbols
|
||||
${FILTER:-cat} $NMLIST > $FILTLIST
|
||||
|
||||
XCOMM
|
||||
XCOMM Clean up the export-list description file.
|
||||
XCOMM Note that C++ symbols may have embedded spaces in them.
|
||||
XCOMM
|
||||
$AWK '
|
||||
BEGIN {
|
||||
csyms = 0; # C language symbols in libfoo.list
|
||||
cplusplus = 0; # C++ language symbols in libfoo.list
|
||||
isyms = 0; # C internal symbols in libfoo.list
|
||||
iplusplus = 0; # C++ internal symbols in libfoo.list
|
||||
count = 0; # Running count of symbols
|
||||
implicit = ""; # Handling of implicit symbols.
|
||||
}
|
||||
$1 == "default" {
|
||||
HASH A default clause suppresses warnings about implicit symbols.
|
||||
if ($2 != "" && $2 != "force" && $2 != "public" &&
|
||||
$2 != "private" && $2 != "internal") {
|
||||
print "# Warning: illegal default clause:", $2 | "cat 1>&2";
|
||||
next;
|
||||
}
|
||||
if (implicit != "")
|
||||
print "# Warning: multiple default clauses." | "cat 1>&2";
|
||||
implicit = $2;
|
||||
next;
|
||||
}
|
||||
$1 == "force" || $1 == "public" || $1 == "private" {
|
||||
csyms ++;
|
||||
symbol[count++] = $1 ";;" $2;
|
||||
next;
|
||||
}
|
||||
$1 == "publicC++" || $1 == "privateC++" {
|
||||
HASH forceC++ is unsupported because we only know how to demangle,
|
||||
HASH not how to mangle symbols, and the final ld input file must
|
||||
HASH be mangled.
|
||||
cplusplus ++;
|
||||
string = $2;
|
||||
for (n = 3; n <= NF; n++)
|
||||
string = string " " $n;
|
||||
symbol[count++] = $1 ";;" string;
|
||||
next;
|
||||
}
|
||||
$1 == "internal" {
|
||||
isyms ++;
|
||||
symbol[count++] = $1 ";;" $2;
|
||||
next;
|
||||
}
|
||||
$1 == "internalC++" {
|
||||
iplusplus ++;
|
||||
string = ";;" $2;
|
||||
for (n = 3; n <= NF; n++)
|
||||
string = string " " $n;
|
||||
symbol[count++] = $1 ";;" string;
|
||||
next;
|
||||
}
|
||||
$1 == "#line" || $1 == "#" {
|
||||
HASH cpp will have removed comments, but may have added other stuff.
|
||||
next;
|
||||
}
|
||||
NF > 0 {
|
||||
print "# Warning: unrecognized directive:", $0 | "cat 1>&2";
|
||||
next;
|
||||
}
|
||||
END {
|
||||
printf("# Exporting %d C and %d C++ symbols, hiding %d and %d.\n",
|
||||
csyms, cplusplus, isyms, iplusplus) | "cat 1>&2";
|
||||
if (implicit != "") {
|
||||
print "# Unspecified symbols are " implicit "." | "cat 1>&2";
|
||||
print "default;;" implicit;
|
||||
}
|
||||
for (i in symbol)
|
||||
print symbol[i];
|
||||
}
|
||||
' $2 > $EXPORTLIST
|
||||
|
||||
XCOMM
|
||||
XCOMM Read in the above files and write result to stdout. Use the
|
||||
XCOMM delimiter ";" to identify the entries in the symbol lookup table.
|
||||
XCOMM
|
||||
(pr -m -s";" -t -w1024 $NMLIST $FILTLIST | expand -t 1; cat $EXPORTLIST) | $AWK '
|
||||
BEGIN {
|
||||
FS = ";";
|
||||
implicit = 0;
|
||||
}
|
||||
NF == 2 {
|
||||
HASH This is "pr" output, i.e., symbol translation table
|
||||
r2=$2
|
||||
gsub(/ /,"",r2); # Remove spaces because c++filt is unpredictable
|
||||
syms[r2] = $1;
|
||||
r1=$1;
|
||||
gsub(/ /,"",r1);
|
||||
mangled[r1] = 1; # Save the mangling because the export lists
|
||||
HASH sometimes use it instead of a prototype.
|
||||
next;
|
||||
}
|
||||
NF == 3 && $1 == "default" {
|
||||
HASH Treatment of unspecified symbols.
|
||||
if ($3 == "internal")
|
||||
implicit = 1;
|
||||
else if ($3 == "private" || $3 == "privateC++")
|
||||
implicit = 2;
|
||||
else if ($3 == "public" || $3 == "publicC++")
|
||||
implicit = 3;
|
||||
else # $3 == "force"
|
||||
implicit = 4;
|
||||
next;
|
||||
}
|
||||
NF == 3 {
|
||||
HASH Generate canonical demangled form as an alternate symbol.
|
||||
alt=$3;
|
||||
gsub(/ \.\.\./,",...",alt); # change " ..." to ",..." to match c++filt
|
||||
gsub(/ /,"",alt); # remove all spaces
|
||||
gsub(/\(void\)/,"()",alt); # change "(void)" to "()" to match c++filt
|
||||
|
||||
HASH Parse our instructions for this symbol.
|
||||
if ($1 == "internal" || $1 == "internalC++")
|
||||
export = 1;
|
||||
else if ($1 == "private" || $1 == "privateC++")
|
||||
export = 2;
|
||||
else if ($1 == "public" || $1 == "publicC++")
|
||||
export = 3;
|
||||
else # $1 == "force"
|
||||
export = 4;
|
||||
|
||||
HASH Process it.
|
||||
if ((length(syms[alt]) > 0) || mangled[alt]) {
|
||||
HASH This symbol is present in the library.
|
||||
if (donelist[alt])
|
||||
print "# Warning: Duplicate entry for", $3,
|
||||
"in export list" | "cat 1>&2";
|
||||
if (donelist[alt] < export) {
|
||||
if (export > 1)
|
||||
print syms[alt];
|
||||
donelist[alt] = export;
|
||||
}
|
||||
} else {
|
||||
HASH Print forced-export symbols without complaining.
|
||||
if (export == 4) {
|
||||
print alt;
|
||||
donelist[alt] = export;
|
||||
} else {
|
||||
print "# Warning:", $3,
|
||||
"was not in the nm list for this library" | "cat 1>&2";
|
||||
}
|
||||
}
|
||||
|
||||
next;
|
||||
}
|
||||
END {
|
||||
HASH Process implicit symbols.
|
||||
for (i in syms) {
|
||||
if ((! donelist[i]) && (length(syms[i]) > 0)) {
|
||||
HASH Do not complain about C++ virtual function tables.
|
||||
if (implicit == 0 && syms[i] !~ /^__vft[0-9]*_/)
|
||||
print "# Warning:", syms[i],
|
||||
"was not in the export list" | "cat 1>&2";
|
||||
if (implicit > 1)
|
||||
print syms[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
'
|
||||
|
||||
XCOMM Clean up temporary files
|
||||
rm $EXPORTLIST
|
||||
rm $NMLIST
|
||||
rm $FILTLIST
|
||||
270
cde/config/util/elistgen.sun
Normal file
270
cde/config/util/elistgen.sun
Normal file
@@ -0,0 +1,270 @@
|
||||
XCOMM!/bin/sh -f
|
||||
XCOMM $TOG: elistgen.sun /main/9 1999/09/07 17:54:17 mgreess $
|
||||
XCOMM
|
||||
XCOMM ########################################################################
|
||||
XCOMM Construct shared-library scoping mapfile for Solaris based on standardized
|
||||
XCOMM export list description file
|
||||
XCOMM
|
||||
XCOMM Usage: exportlistgen libfoo.so libfoo.elist > mapfile.scope
|
||||
XCOMM
|
||||
XCOMM libfoo.so => shared library of interest
|
||||
XCOMM libfoo.elist => Meta description of necessary export list.
|
||||
XCOMM
|
||||
XCOMM The output file, "mapfile.scope" may then be passed to the Solaris
|
||||
XCOMM linker to reconstruct the shared library, libfoo.so.
|
||||
XCOMM
|
||||
XCOMM ########################################################################
|
||||
|
||||
XCOMM Utility programs
|
||||
FILTER=CXXFILT # C++ symbol demangler
|
||||
AWK=nawk # Awk
|
||||
|
||||
XCOMM For nm, cat, pr, expand, awk, c++filt
|
||||
PATH=/usr/bin:/bin:/usr/ccs/bin:/usr/ucb:/opt/SUNWspro/bin
|
||||
|
||||
XCOMM Try to detect broken versions of c++filt.
|
||||
if [ `echo _okay | ${FILTER:-cat}` != "_okay" ]; then
|
||||
if [ -x /opt/SUNWspro/bin/c++filt ]; then
|
||||
echo "# Your $FILTER is broken -- using /opt/SUNWspro/bin/c++filt."
|
||||
FILTER=/opt/SUNWspro/bin/c++filt
|
||||
else
|
||||
echo "# ERROR: no working $FILTER available."
|
||||
exit 1
|
||||
fi;
|
||||
fi;
|
||||
|
||||
XCOMM Temporary files
|
||||
EXPORTLIST=/tmp/elistgen1.$$ # export directives from "libfoo.list"
|
||||
NMLIST=/tmp/elistgen2.$$ # name list from libfoo.sl
|
||||
FILTLIST=/tmp/elistgen3.$$ # demangled (C++) version of above
|
||||
|
||||
XCOMM Print useful information at the top of the output
|
||||
echo "#" `date`
|
||||
echo "# This scoping mapfile was produced by" $0
|
||||
echo "# Export list description taken from:" $2
|
||||
echo "# Target library:" $1
|
||||
echo "# Target Operating System:" `uname -msrv`
|
||||
echo "# "
|
||||
|
||||
XCOMM Extract the globally visible symbols from target library
|
||||
XCOMM The NMLIST generated here is later used to cross-check the symbols in the
|
||||
XCOMM nm stopped working on Solaris 2.5, use dump instead.
|
||||
XCOMM nm -p $1 | $AWK '/ [ TDBS] /{print $3}' > $NMLIST
|
||||
/usr/ccs/bin/dump -t -v $1 | egrep "(FUNC|OBJT).(GLOB|WEAK)" | egrep -v "(FUNC|OBJT).(GLOB|WEAK). *[0-9]. *UNDEF" | $AWK '{print $8}' > $NMLIST
|
||||
|
||||
XCOMM Extract the globally visible symbols from target library
|
||||
XCOMM The NMLIST generated here is later used to cross-check the symbols in the
|
||||
${FILTER:-cat} $NMLIST > $FILTLIST
|
||||
|
||||
XCOMM Clean up the export-list description file. Sort the directives.
|
||||
$AWK '
|
||||
BEGIN {
|
||||
csyms = 0; # C public symbols in libfoo.list
|
||||
cplusplus = 0; # C++ public symbols in libfoo.list
|
||||
isyms = 0; # C internal symbols in libfoo.list
|
||||
iplusplus = 0; # C++ internal symbols in libfoo.list
|
||||
implicit = ""; # Handling of implicit symbols
|
||||
}
|
||||
$1 == "default" {
|
||||
# A default clause suppresses warnings about implicit symbols.
|
||||
if ($2 != "" && $2 != "force" && $2 != "public" && $2 != "private" && $2 != "internal") {
|
||||
print "# Warning: illegal default clause:", $2 | "cat 1>&2";
|
||||
next;
|
||||
}
|
||||
if (implicit != "")
|
||||
print "# Warning: multiple default clauses." | "cat 1>&2";
|
||||
implicit = $2;
|
||||
next;
|
||||
}
|
||||
$1 == "force" {
|
||||
csyms ++;
|
||||
print $1 ";;" $2;
|
||||
next;
|
||||
}
|
||||
$1 == "public" {
|
||||
csyms ++;
|
||||
print $1 ";;" $2;
|
||||
next;
|
||||
}
|
||||
$1 == "publicC++" {
|
||||
cplusplus ++;
|
||||
string = $2;
|
||||
for (n = 3; n <= NF; n++)
|
||||
string = string " " $n;
|
||||
print $1 ";;" string;
|
||||
next;
|
||||
}
|
||||
$1 == "private" {
|
||||
csyms ++;
|
||||
print $1 ";;" $2;
|
||||
next;
|
||||
}
|
||||
$1 == "privateC++" {
|
||||
cplusplus ++;
|
||||
string = $2;
|
||||
for (n = 3; n <= NF; n++)
|
||||
string = string " " $n;
|
||||
print $1 ";;" string;
|
||||
next;
|
||||
}
|
||||
$1 == "internal" {
|
||||
isyms ++;
|
||||
print $1 ";;" $2;
|
||||
next;
|
||||
}
|
||||
$1 == "internalC++" {
|
||||
iplusplus ++;
|
||||
string = $2;
|
||||
for (n = 3; n <= NF; n++)
|
||||
string = string " " $n;
|
||||
print $1 ";;" string;
|
||||
next;
|
||||
}
|
||||
$1 == "#line" || $1 == "#" {
|
||||
# cpp will have removed comments, but may have added other stuff.
|
||||
next;
|
||||
}
|
||||
NF > 0 {
|
||||
print "# Warning: unrecognized directive:", $0 | "cat 1>&2";
|
||||
next;
|
||||
}
|
||||
END {
|
||||
printf("# Exporting %d C and %d C++ symbols, hiding %d and %d.\n", csyms, cplusplus, isyms, iplusplus) | "cat 1>&2";
|
||||
if (implicit != "") {
|
||||
print "# Unspecified symbols are " implicit "." | "cat 1>&2";
|
||||
print "default;;" implicit;
|
||||
}
|
||||
}
|
||||
' $2 1>$EXPORTLIST
|
||||
|
||||
|
||||
XCOMM Read in the above files and write result to stdout. The contents
|
||||
XCOMM of NMLIST and FILTLIST are used to construct a symbol lookup table.
|
||||
XCOMM The contents of EXPORTLIST are converted with the help of this table.
|
||||
XCOMM Use ";" as a delimiter in the symbol lookup table.
|
||||
(pr -m -s";" -t -w1024 $NMLIST $FILTLIST | expand -1; cat $EXPORTLIST) | $AWK '
|
||||
BEGIN {
|
||||
FS = ";";
|
||||
implicit = 0;
|
||||
}
|
||||
NF == 2 {
|
||||
# This is "pr" output, i.e., symbol translation table
|
||||
r2=$2;
|
||||
gsub(/static /,"",r2); # remove keyword "static" as above
|
||||
gsub(/ /,"",r2); # Remove spaces because c++filt is unpredictable
|
||||
syms[r2] = $1;
|
||||
r1=$1;
|
||||
gsub(/ /,"",r1);
|
||||
mangled[r1] = 1; # Save the mangling because the export lists
|
||||
# sometimes use it instead of a prototype.
|
||||
next;
|
||||
}
|
||||
NF == 3 && $1 == "default" {
|
||||
# Treatment of unspecified symbols.
|
||||
if ($3 == "internal" || $3 == "internalC++")
|
||||
implicit = 1;
|
||||
else if ($3 == "private" || $3 == "privateC++")
|
||||
implicit = 2;
|
||||
else if ($3 == "public" || $3 == "publicC++")
|
||||
implicit = 3;
|
||||
else # $3 == "force"
|
||||
implicit = 4;
|
||||
next;
|
||||
}
|
||||
NF == 3 {
|
||||
# Generate canonical demangled form as an alternate symbol.
|
||||
alt=$3;
|
||||
gsub(/ \.\.\./,",...",alt); # change " ..." to ",..." to match c++filt
|
||||
gsub(/ /,"",alt); # remove all spaces
|
||||
|
||||
# An export directive. Parse our instructions for this symbol.
|
||||
if ($1 == "internal" || $1 == "internalC++")
|
||||
export = 1;
|
||||
else if ($3 == "private" || $3 == "privateC++")
|
||||
export = 2;
|
||||
else if ($3 == "public" || $3 == "publicC++")
|
||||
export = 3;
|
||||
else # $3 == "force"
|
||||
export = 4;
|
||||
|
||||
# Process it.
|
||||
if ((length(syms[alt]) > 0) || mangled[alt]) {
|
||||
# This symbol is present in the library.
|
||||
if (donelist[alt])
|
||||
print "# Warning: Duplicate entry for", $3,
|
||||
"in export list" | "cat 1>&2";
|
||||
if (donelist[alt] < export) {
|
||||
donelist[alt] = export;
|
||||
}
|
||||
} else {
|
||||
# Print forced-export symbols without complaining.
|
||||
if (export == 4) {
|
||||
donelist[alt] = export;
|
||||
} else {
|
||||
print "# Warning:", $3,
|
||||
"was not in the nm list for this library" | "cat 1>&2";
|
||||
}
|
||||
}
|
||||
|
||||
next;
|
||||
}
|
||||
END {
|
||||
# Ignore magic linker symbols.
|
||||
if (implicit == 0) {
|
||||
if (!donelist["_DYNAMIC"])
|
||||
donelist["_DYNAMIC"] = 1;
|
||||
if (!donelist["_GLOBAL_OFFSET_TABLE_"])
|
||||
donelist["_GLOBAL_OFFSET_TABLE_"] = 1;
|
||||
if (!donelist["_PROCEDURE_LINKAGE_TABLE_"])
|
||||
donelist["_PROCEDURE_LINKAGE_TABLE_"] = 1;
|
||||
if (!donelist["_edata"])
|
||||
donelist["_edata"] = 1;
|
||||
if (!donelist["_end"])
|
||||
donelist["_end"] = 1;
|
||||
if (!donelist["_etext"])
|
||||
donelist["_etext"] = 1;
|
||||
}
|
||||
|
||||
# Process implicit symbols.
|
||||
for (i in syms) {
|
||||
if (donelist[i] == 0 && length(syms[i]) > 0) {
|
||||
if (implicit == 0) {
|
||||
# Ignore magic symbols introduced by the C++ compiler.
|
||||
if ((syms[i] !~ /[_a-zA-Z0-9]*__vtbl$/) &&
|
||||
(syms[i] !~ /libC_errors/) &&
|
||||
(syms[i] !~ /_ex_/) &&
|
||||
(syms[i] !~ /__rt/) &&
|
||||
(syms[i] !~ /__RT/) &&
|
||||
(syms[i] !~ /^__ptbl_vec__/))
|
||||
print "# Warning:", syms[i], "was not in the export list" | "cat 1>&2";
|
||||
} else {
|
||||
donelist[i] = implicit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Generate the linker file.
|
||||
print "";
|
||||
print "SUNW.1.1 {";
|
||||
print " global:";
|
||||
for (i in syms)
|
||||
if (donelist[i] >= 2 && length(syms[i]) > 0)
|
||||
print " " syms[i] ";";
|
||||
print " local:";
|
||||
print " *;";
|
||||
print "};";
|
||||
|
||||
print "";
|
||||
print "SUNW_private.1.1 {";
|
||||
print " global:";
|
||||
for (i in syms)
|
||||
if (donelist[i] == 1 && length(syms[i]) > 0)
|
||||
print " " syms[i] ";";
|
||||
print "} SUNW.1.1;"
|
||||
}
|
||||
'
|
||||
|
||||
XCOMM Clean up temporary files
|
||||
rm $EXPORTLIST
|
||||
rm $NMLIST
|
||||
rm $FILTLIST
|
||||
219
cde/config/util/elistgen.usl
Normal file
219
cde/config/util/elistgen.usl
Normal file
@@ -0,0 +1,219 @@
|
||||
XCOMM!/bin/sh
|
||||
XCOMM $XConsortium: elistgen.usl /main/2 1996/12/04 10:13:26 swick $
|
||||
XCOMM
|
||||
XCOMM #########################################################################
|
||||
XCOMM Construct shared-library export lists for Novell based on standardized
|
||||
XCOMM export list description file
|
||||
XCOMM
|
||||
XCOMM Usage: exportlistgen libFoo.so libFoo.elist > libFoo.lopt
|
||||
XCOMM
|
||||
XCOMM libFoo.so => shared library of interest
|
||||
XCOMM libFoo.elist => Meta description of necessary export list.
|
||||
XCOMM
|
||||
XCOMM The output file, "libFoo.lopt" may then be passed to the linker to
|
||||
XCOMM reconstruct the shared library.
|
||||
XCOMM
|
||||
XCOMM (c) Copyright 1996 Digital Equipment Corporation.
|
||||
XCOMM (c) Copyright 1996 Hewlett-Packard Company.
|
||||
XCOMM (c) Copyright 1996 International Business Machines Corp.
|
||||
XCOMM (c) Copyright 1996 Sun Microsystems, Inc.
|
||||
XCOMM (c) Copyright 1996 Novell, Inc.
|
||||
XCOMM (c) Copyright 1996 FUJITSU LIMITED.
|
||||
XCOMM (c) Copyright 1996 Hitachi.
|
||||
XCOMM
|
||||
XCOMM #########################################################################
|
||||
|
||||
XCOMM Utility programs
|
||||
FILTER=CXXFILT # C++ symbol demangler
|
||||
AWK=awk # awk
|
||||
|
||||
XCOMM For nm, cat, pr, expand, awk, c++filt
|
||||
PATH=/usr/bin:/bin:/usr/ucb:/usr/ccs/bin
|
||||
|
||||
XCOMM Temporary files
|
||||
EXPORTLIST=/tmp/elistgen1.$$ # list of export symbols from "libfoo.elist"
|
||||
NMLIST=/tmp/elistgen2.$$ # name list from libfoo.sl
|
||||
FILTLIST=/tmp/elistgen3.$$ # demangled (C++) version of NMLIST
|
||||
|
||||
XCOMM Print useful information at the top of the output
|
||||
echo "#" `date`
|
||||
echo "# This linker options list was produced by" $0
|
||||
echo "# Input export list description taken from:" $2
|
||||
echo "# Target library:" $1
|
||||
echo "# Target Operating System:" `uname -msrv`
|
||||
echo "# "
|
||||
|
||||
XCOMM Extract the globally visible symbols from target library.
|
||||
XCOMM The NMLIST generated here is later used to cross-check the symbols in the
|
||||
XCOMM supplied export-list.
|
||||
nm -p $1 | $AWK '
|
||||
/ [TD] [^\$]/{print $3} # Text, Data, BSS, or Secondary symbols
|
||||
' > $NMLIST
|
||||
|
||||
XCOMM Demangle the global library symbols. This operation is necessary to convert
|
||||
XCOMM mangled C++ symbols into their C++ notation.
|
||||
${FILTER:-cat} $NMLIST > $FILTLIST
|
||||
|
||||
XCOMM Clean up the export-list description file.
|
||||
XCOMM Note that C++ symbols may have embedded spaces in them.
|
||||
cat $2 | $AWK '
|
||||
BEGIN {
|
||||
csyms = 0; # C language symbols in libfoo.list
|
||||
cplusplus = 0; # C++ language symbols in libfoo.list
|
||||
isyms = 0; # C internal symbols in libfoo.elist
|
||||
iplusplus = 0; # C++ internal symbols in libfoo.elist
|
||||
implicit = ""; # Handling of implicit symbols
|
||||
}
|
||||
$1 == "default" {
|
||||
# A default clause suppresses warnings about implicit symbols.
|
||||
if ($2 != "" && $2 != "force" && $2 != "public" &&
|
||||
$2 != "private" && $2 != "internal") {
|
||||
print "# Warning: illegal default clause:", $2 | "cat 1>&2";
|
||||
next;
|
||||
}
|
||||
if (implicit != "")
|
||||
print "# Warning: multiple default clauses." | "cat 1>&2";
|
||||
implicit = $2;
|
||||
next;
|
||||
}
|
||||
$1 == "force" || $1 == "public" || $1 == "private" {
|
||||
csyms ++;
|
||||
print $1 ";;" $2;
|
||||
next;
|
||||
}
|
||||
$1 == "publicC++" || $1 == "privateC++" {
|
||||
cplusplus ++;
|
||||
string = $2;
|
||||
for (n = 3; n <= NF; n++) {
|
||||
string = string " " $n;
|
||||
}
|
||||
print $1 ";;" string;
|
||||
next;
|
||||
}
|
||||
$1 == "internal" {
|
||||
isyms ++;
|
||||
print $1 ";;" $2;
|
||||
next;
|
||||
}
|
||||
$1 == "internalC++" {
|
||||
iplusplus ++;
|
||||
string = $2;
|
||||
for (n = 3; n <= NF; n++) {
|
||||
string = string " " $n;
|
||||
}
|
||||
print $1 ";;" string;
|
||||
next;
|
||||
}
|
||||
$1 == "#line" || $1 == "#" {
|
||||
# cpp will have removed comments, but may have added other stuff.
|
||||
next;
|
||||
}
|
||||
NF > 0 {
|
||||
print "# Warning: unrecognized directive:", $0 | "cat 1>&2";
|
||||
next;
|
||||
}
|
||||
END {
|
||||
printf("# Exporting %d C and %d C++ symbols, hiding %d and %d.\n",
|
||||
csyms, cplusplus, isyms, iplusplus) | "cat 1>&2";
|
||||
if (implicit != "") {
|
||||
print "# Unspecified symbols are " implicit "." | "cat 1>&2";
|
||||
print "default;;" implicit;
|
||||
}
|
||||
}
|
||||
' > $EXPORTLIST
|
||||
|
||||
XCOMM Read in the above files and write result to stdout. The contents
|
||||
XCOMM of NMLIST and FILTLIST are used to construct a symbol lookup table.
|
||||
XCOMM The contents of EXPORTLIST are converted with the help of this table.
|
||||
XCOMM Use ";" as a delimiter in the symbol lookup table.
|
||||
(pr -m -s";" -t -w1024 $NMLIST $FILTLIST | expand -1; cat $EXPORTLIST) | $AWK '
|
||||
BEGIN {
|
||||
FS = ";";
|
||||
implicit = 0;
|
||||
}
|
||||
NF == 2 {
|
||||
# This is "pr" output, i.e., symbol translation table
|
||||
syms[$2] = $1;
|
||||
next;
|
||||
}
|
||||
NF == 3 && $1 == "default" {
|
||||
# Treatment of unspecified symbols.
|
||||
if ($3 == "internal")
|
||||
implicit = 1;
|
||||
else if ($3 == "private" || $3 == "privateC++")
|
||||
implicit = 2;
|
||||
else if ($3 == "public" || $3 == "publicC++")
|
||||
implicit = 3;
|
||||
else # $3 == "force"
|
||||
implicit = 4;
|
||||
next;
|
||||
}
|
||||
NF == 3 {
|
||||
# Parse our instructions for this symbol.
|
||||
if ($1 == "internal" || $1 == "internalC++")
|
||||
export = 1;
|
||||
else if ($1 == "private" || $1 == "privateC++")
|
||||
export = 2;
|
||||
else if ($1 == "public" || $1 == "publicC++")
|
||||
export = 3;
|
||||
else # $1 == "force"
|
||||
export = 4;
|
||||
|
||||
# Process it.
|
||||
if (length(syms[$3]) > 0) {
|
||||
# This symbol is present in the library.
|
||||
if (donelist[$3])
|
||||
print "# Warning: Duplicate entry for", $3,
|
||||
"in export list" | "cat 1>&2";
|
||||
if (donelist[$3] < export) {
|
||||
if (export > 1)
|
||||
print syms[$3];
|
||||
donelist[$3] = export;
|
||||
}
|
||||
} else {
|
||||
# Do not complain about unknown forced-export symbols.
|
||||
if (export == 4) {
|
||||
print $3;
|
||||
donelist[$3] = export;
|
||||
} else
|
||||
print "# Warning:", $3,
|
||||
"was not in the nm list for this library" | "cat 1>&2";
|
||||
}
|
||||
|
||||
next;
|
||||
}
|
||||
END {
|
||||
# Ignore built-in linker symbols.
|
||||
if (implicit == 0) {
|
||||
if (!donelist["_DYNAMIC"])
|
||||
donelist["_DYNAMIC"] = 1;
|
||||
if (!donelist["_GLOBAL_OFFSET_TABLE_"])
|
||||
donelist["_GLOBAL_OFFSET_TABLE_"] = 1;
|
||||
if (!donelist["_edata"])
|
||||
donelist["_edata"] = 1;
|
||||
if (!donelist["_end"])
|
||||
donelist["_end"] = 1;
|
||||
if (!donelist["_etext"])
|
||||
donelist["_etext"] = 1;
|
||||
}
|
||||
|
||||
# Process implicit symbols.
|
||||
for (i in syms) {
|
||||
if (!donelist[i] && (length(syms[i]) > 0)) {
|
||||
# Ignore C++ compiler symbols
|
||||
if (implicit == 0 &&
|
||||
(syms[i] !~ /^__vtbl__[0-9]*_/) &&
|
||||
(syms[i] !~ /^__cpp_unixware_[0-9]*$/))
|
||||
print "# Warning:", syms[i],
|
||||
"was not in the export list" | "cat 1>&2";
|
||||
if (implicit > 1)
|
||||
print syms[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
'
|
||||
|
||||
XCOMM Clean up temporary files
|
||||
rm $EXPORTLIST
|
||||
rm $NMLIST
|
||||
rm $FILTLIST
|
||||
108
cde/config/util/install.sh
Executable file
108
cde/config/util/install.sh
Executable file
@@ -0,0 +1,108 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# install - install a program, script, or datafile
|
||||
#
|
||||
# $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch.
|
||||
#
|
||||
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
doit="${DOITPROG:-}"
|
||||
|
||||
|
||||
# put in absolute paths if you don't have them in your path; or use env. vars.
|
||||
|
||||
mvprog="${MVPROG:-mv}"
|
||||
cpprog="${CPPROG:-cp}"
|
||||
chmodprog="${CHMODPROG:-chmod}"
|
||||
chownprog="${CHOWNPROG:-chown}"
|
||||
chgrpprog="${CHGRPPROG:-chgrp}"
|
||||
stripprog="${STRIPPROG:-strip}"
|
||||
rmprog="${RMPROG:-rm}"
|
||||
|
||||
instcmd="$mvprog"
|
||||
chmodcmd=""
|
||||
chowncmd=""
|
||||
chgrpcmd=""
|
||||
stripcmd=""
|
||||
rmcmd="$rmprog -f"
|
||||
src=""
|
||||
dst=""
|
||||
|
||||
while [ x"$1" != x ]; do
|
||||
case $1 in
|
||||
-c) instcmd="$cpprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-m) chmodcmd="$chmodprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-s) stripcmd="$stripprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
*) if [ x"$src" = x ]
|
||||
then
|
||||
src=$1
|
||||
else
|
||||
dst=$1
|
||||
fi
|
||||
shift
|
||||
continue;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ x"$src" = x ]
|
||||
then
|
||||
echo "install: no input file specified"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ x"$dst" = x ]
|
||||
then
|
||||
echo "install: no destination specified"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# if destination is a directory, append the input filename; if your system
|
||||
# does not like double slashes in filenames, you may need to add some logic
|
||||
|
||||
if [ -d $dst ]
|
||||
then
|
||||
dst="$dst"/`basename $src`
|
||||
fi
|
||||
|
||||
|
||||
# get rid of the old one and mode the new one in
|
||||
|
||||
$doit $rmcmd $dst
|
||||
$doit $instcmd $src $dst
|
||||
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; fi
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; fi
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; fi
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; fi
|
||||
|
||||
exit 0
|
||||
349
cde/config/util/lndir.c
Normal file
349
cde/config/util/lndir.c
Normal file
@@ -0,0 +1,349 @@
|
||||
/* $TOG: lndir.c /main/17 1998/02/06 11:23:50 kaleb $ */
|
||||
/* Create shadow link tree (after X11R4 script of the same name)
|
||||
Mark Reinhold (mbr@lcs.mit.edu)/3 January 1990 */
|
||||
|
||||
/*
|
||||
Copyright (c) 1990, 1998 The Open Group
|
||||
|
||||
All Rights Reserved.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of The Open Group shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings
|
||||
in this Software without prior written authorization from The Open Group.
|
||||
|
||||
*/
|
||||
|
||||
/* From the original /bin/sh script:
|
||||
|
||||
Used to create a copy of the a directory tree that has links for all
|
||||
non-directories (except those named RCS, SCCS or CVS.adm). If you are
|
||||
building the distribution on more than one machine, you should use
|
||||
this technique.
|
||||
|
||||
If your master sources are located in /usr/local/src/X and you would like
|
||||
your link tree to be in /usr/local/src/new-X, do the following:
|
||||
|
||||
% mkdir /usr/local/src/new-X
|
||||
% cd /usr/local/src/new-X
|
||||
% lndir ../X
|
||||
*/
|
||||
|
||||
#include <X11/Xos.h>
|
||||
#include <X11/Xfuncproto.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/param.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifndef X_NOT_POSIX
|
||||
#include <dirent.h>
|
||||
#else
|
||||
#ifdef SYSV
|
||||
#include <dirent.h>
|
||||
#else
|
||||
#ifdef USG
|
||||
#include <dirent.h>
|
||||
#else
|
||||
#include <sys/dir.h>
|
||||
#ifndef dirent
|
||||
#define dirent direct
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#ifndef MAXPATHLEN
|
||||
#define MAXPATHLEN 2048
|
||||
#endif
|
||||
|
||||
#if NeedVarargsPrototypes
|
||||
#include <stdarg.h>
|
||||
#endif
|
||||
|
||||
#ifdef X_NOT_STDC_ENV
|
||||
extern int errno;
|
||||
#endif
|
||||
int silent = 0; /* -silent */
|
||||
int ignore_links = 0; /* -ignorelinks */
|
||||
|
||||
char *rcurdir;
|
||||
char *curdir;
|
||||
|
||||
void
|
||||
quit (
|
||||
#if NeedVarargsPrototypes
|
||||
int code, char * fmt, ...)
|
||||
#else
|
||||
code, fmt, a1, a2, a3)
|
||||
char *fmt;
|
||||
#endif
|
||||
{
|
||||
#if NeedVarargsPrototypes
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
vfprintf (stderr, fmt, args);
|
||||
va_end(args);
|
||||
#else
|
||||
fprintf (stderr, fmt, a1, a2, a3);
|
||||
#endif
|
||||
putc ('\n', stderr);
|
||||
exit (code);
|
||||
}
|
||||
|
||||
void
|
||||
quiterr (code, s)
|
||||
char *s;
|
||||
{
|
||||
perror (s);
|
||||
exit (code);
|
||||
}
|
||||
|
||||
void
|
||||
msg (
|
||||
#if NeedVarargsPrototypes
|
||||
char * fmt, ...)
|
||||
#else
|
||||
fmt, a1, a2, a3)
|
||||
char *fmt;
|
||||
#endif
|
||||
{
|
||||
#if NeedVarargsPrototypes
|
||||
va_list args;
|
||||
#endif
|
||||
if (curdir) {
|
||||
fprintf (stderr, "%s:\n", curdir);
|
||||
curdir = 0;
|
||||
}
|
||||
#if NeedVarargsPrototypes
|
||||
va_start(args, fmt);
|
||||
vfprintf (stderr, fmt, args);
|
||||
va_end(args);
|
||||
#else
|
||||
fprintf (stderr, fmt, a1, a2, a3);
|
||||
#endif
|
||||
putc ('\n', stderr);
|
||||
}
|
||||
|
||||
void
|
||||
mperror (s)
|
||||
char *s;
|
||||
{
|
||||
if (curdir) {
|
||||
fprintf (stderr, "%s:\n", curdir);
|
||||
curdir = 0;
|
||||
}
|
||||
perror (s);
|
||||
}
|
||||
|
||||
|
||||
int equivalent(lname, rname)
|
||||
char *lname;
|
||||
char *rname;
|
||||
{
|
||||
char *s;
|
||||
|
||||
if (!strcmp(lname, rname))
|
||||
return 1;
|
||||
for (s = lname; *s && (s = strchr(s, '/')); s++) {
|
||||
while (s[1] == '/')
|
||||
strcpy(s+1, s+2);
|
||||
}
|
||||
return !strcmp(lname, rname);
|
||||
}
|
||||
|
||||
|
||||
/* Recursively create symbolic links from the current directory to the "from"
|
||||
directory. Assumes that files described by fs and ts are directories. */
|
||||
|
||||
dodir (fn, fs, ts, rel)
|
||||
char *fn; /* name of "from" directory, either absolute or
|
||||
relative to cwd */
|
||||
struct stat *fs, *ts; /* stats for the "from" directory and cwd */
|
||||
int rel; /* if true, prepend "../" to fn before using */
|
||||
{
|
||||
DIR *df;
|
||||
struct dirent *dp;
|
||||
char buf[MAXPATHLEN + 1], *p;
|
||||
char symbuf[MAXPATHLEN + 1];
|
||||
char basesym[MAXPATHLEN + 1];
|
||||
struct stat sb, sc;
|
||||
int n_dirs;
|
||||
int symlen;
|
||||
int basesymlen = -1;
|
||||
char *ocurdir;
|
||||
|
||||
if ((fs->st_dev == ts->st_dev) && (fs->st_ino == ts->st_ino)) {
|
||||
msg ("%s: From and to directories are identical!", fn);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (rel)
|
||||
strcpy (buf, "../");
|
||||
else
|
||||
buf[0] = '\0';
|
||||
strcat (buf, fn);
|
||||
|
||||
if (!(df = opendir (buf))) {
|
||||
msg ("%s: Cannot opendir", buf);
|
||||
return 1;
|
||||
}
|
||||
|
||||
p = buf + strlen (buf);
|
||||
*p++ = '/';
|
||||
n_dirs = fs->st_nlink;
|
||||
while (dp = readdir (df)) {
|
||||
if (dp->d_name[strlen(dp->d_name) - 1] == '~')
|
||||
continue;
|
||||
strcpy (p, dp->d_name);
|
||||
|
||||
if (n_dirs > 0) {
|
||||
if (stat (buf, &sb) < 0) {
|
||||
mperror (buf);
|
||||
continue;
|
||||
}
|
||||
|
||||
#ifdef S_ISDIR
|
||||
if(S_ISDIR(sb.st_mode))
|
||||
#else
|
||||
if (sb.st_mode & S_IFDIR)
|
||||
#endif
|
||||
{
|
||||
/* directory */
|
||||
n_dirs--;
|
||||
if (dp->d_name[0] == '.' &&
|
||||
(dp->d_name[1] == '\0' || (dp->d_name[1] == '.' &&
|
||||
dp->d_name[2] == '\0')))
|
||||
continue;
|
||||
if (!strcmp (dp->d_name, "RCS"))
|
||||
continue;
|
||||
if (!strcmp (dp->d_name, "SCCS"))
|
||||
continue;
|
||||
if (!strcmp (dp->d_name, "CVS"))
|
||||
continue;
|
||||
if (!strcmp (dp->d_name, "CVS.adm"))
|
||||
continue;
|
||||
ocurdir = rcurdir;
|
||||
rcurdir = buf;
|
||||
curdir = silent ? buf : (char *)0;
|
||||
if (!silent)
|
||||
printf ("%s:\n", buf);
|
||||
if ((stat (dp->d_name, &sc) < 0) && (errno == ENOENT)) {
|
||||
if (mkdir (dp->d_name, 0777) < 0 ||
|
||||
stat (dp->d_name, &sc) < 0) {
|
||||
mperror (dp->d_name);
|
||||
curdir = rcurdir = ocurdir;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (readlink (dp->d_name, symbuf, sizeof(symbuf) - 1) >= 0) {
|
||||
msg ("%s: is a link instead of a directory", dp->d_name);
|
||||
curdir = rcurdir = ocurdir;
|
||||
continue;
|
||||
}
|
||||
if (chdir (dp->d_name) < 0) {
|
||||
mperror (dp->d_name);
|
||||
curdir = rcurdir = ocurdir;
|
||||
continue;
|
||||
}
|
||||
dodir (buf, &sb, &sc, (buf[0] != '/'));
|
||||
if (chdir ("..") < 0)
|
||||
quiterr (1, "..");
|
||||
curdir = rcurdir = ocurdir;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/* non-directory */
|
||||
symlen = readlink (dp->d_name, symbuf, sizeof(symbuf) - 1);
|
||||
if (symlen >= 0)
|
||||
symbuf[symlen] = '\0';
|
||||
|
||||
/* The option to ignore links exists mostly because
|
||||
checking for them slows us down by 10-20%.
|
||||
But it is off by default because this really is a useful check. */
|
||||
if (!ignore_links) {
|
||||
/* see if the file in the base tree was a symlink */
|
||||
basesymlen = readlink(buf, basesym, sizeof(basesym) - 1);
|
||||
if (basesymlen >= 0)
|
||||
basesym[basesymlen] = '\0';
|
||||
}
|
||||
|
||||
if (symlen >= 0) {
|
||||
/* Link exists in new tree. Print message if it doesn't match. */
|
||||
if (!equivalent (basesymlen>=0 ? basesym : buf, symbuf))
|
||||
msg ("%s: %s", dp->d_name, symbuf);
|
||||
} else {
|
||||
if (symlink (basesymlen>=0 ? basesym : buf, dp->d_name) < 0)
|
||||
mperror (dp->d_name);
|
||||
}
|
||||
}
|
||||
|
||||
closedir (df);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
main (ac, av)
|
||||
int ac;
|
||||
char **av;
|
||||
{
|
||||
char *prog_name = av[0];
|
||||
char *fn, *tn;
|
||||
struct stat fs, ts;
|
||||
|
||||
while (++av, --ac) {
|
||||
if (strcmp(*av, "-silent") == 0)
|
||||
silent = 1;
|
||||
else if (strcmp(*av, "-ignorelinks") == 0)
|
||||
ignore_links = 1;
|
||||
else if (strcmp(*av, "--") == 0) {
|
||||
++av, --ac;
|
||||
break;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
if (ac < 1 || ac > 2)
|
||||
quit (1, "usage: %s [-silent] [-ignorelinks] fromdir [todir]",
|
||||
prog_name);
|
||||
|
||||
fn = av[0];
|
||||
if (ac == 2)
|
||||
tn = av[1];
|
||||
else
|
||||
tn = ".";
|
||||
|
||||
/* to directory */
|
||||
if (stat (tn, &ts) < 0)
|
||||
quiterr (1, tn);
|
||||
#ifdef S_ISDIR
|
||||
if (!(S_ISDIR(ts.st_mode)))
|
||||
#else
|
||||
if (!(ts.st_mode & S_IFDIR))
|
||||
#endif
|
||||
quit (2, "%s: Not a directory", tn);
|
||||
if (chdir (tn) < 0)
|
||||
quiterr (1, tn);
|
||||
|
||||
/* from directory */
|
||||
if (stat (fn, &fs) < 0)
|
||||
quiterr (1, fn);
|
||||
#ifdef S_ISDIR
|
||||
if (!(S_ISDIR(fs.st_mode)))
|
||||
#else
|
||||
if (!(fs.st_mode & S_IFDIR))
|
||||
#endif
|
||||
quit (2, "%s: Not a directory", fn);
|
||||
|
||||
exit (dodir (fn, &fs, &ts, 0));
|
||||
}
|
||||
123
cde/config/util/lndir.man
Normal file
123
cde/config/util/lndir.man
Normal file
@@ -0,0 +1,123 @@
|
||||
.\" $TOG: lndir.man /main/11 1998/02/06 11:23:56 kaleb $
|
||||
.\"
|
||||
.\" Copyright (c) 1993, 1994, 1998 The Open Group
|
||||
.\"
|
||||
.\" All Rights Reserved.
|
||||
.\"
|
||||
.\" The above copyright notice and this permission notice shall be
|
||||
.\" included in all copies or substantial portions of the Software.
|
||||
.\"
|
||||
.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
.\" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
.\" IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
.\" OTHER DEALINGS IN THE SOFTWARE.
|
||||
.\"
|
||||
.\" Except as contained in this notice, the name of The Open Group shall
|
||||
.\" not be used in advertising or otherwise to promote the sale, use or
|
||||
.\" other dealings in this Software without prior written authorization
|
||||
.\" from The Open Group.
|
||||
.\"
|
||||
.TH LNDIR 1 "Release 6.4" "X Version 11"
|
||||
.SH NAME
|
||||
lndir \- create a shadow directory of symbolic links to another directory tree
|
||||
.SH SYNOPSIS
|
||||
.B lndir
|
||||
[
|
||||
.B \-silent
|
||||
] [
|
||||
.B \-ignorelinks
|
||||
]
|
||||
.I \|fromdir\|
|
||||
[
|
||||
.I todir
|
||||
]
|
||||
.SH DESCRIPTION
|
||||
The
|
||||
.I lndir
|
||||
program makes a shadow copy
|
||||
.I todir
|
||||
of a directory tree
|
||||
.I fromdir,
|
||||
except that the shadow is not
|
||||
populated with real files but instead with symbolic links pointing at
|
||||
the real files in the
|
||||
.I fromdir
|
||||
directory tree. This is usually useful for maintaining source code for
|
||||
different machine architectures. You create a shadow directory
|
||||
containing links to the real source, which you will have usually
|
||||
mounted from a remote machine. You can build in the shadow tree, and
|
||||
the object files will be in the shadow directory, while the
|
||||
source files in the shadow directory are just symlinks to the real
|
||||
files.
|
||||
.PP
|
||||
This scheme has the advantage that if you update the source, you need not
|
||||
propagate the change to the other architectures by hand, since all
|
||||
source in all shadow directories are symlinks to the real thing: just cd
|
||||
to the shadow directory and recompile away.
|
||||
.PP
|
||||
The
|
||||
.I todir
|
||||
argument is optional and defaults to the current directory. The
|
||||
.I fromdir
|
||||
argument may be relative (e.g., ../src) and is relative to
|
||||
.I todir
|
||||
(not the current directory).
|
||||
.PP
|
||||
.\" CVS.adm is used by the Concurrent Versions System.
|
||||
Note that RCS, SCCS, CVS and CVS.adm directories are not shadowed.
|
||||
.PP
|
||||
If you add files, simply run
|
||||
.I lndir
|
||||
again. New files will be silently added. Old files will be
|
||||
checked that they have the correct link.
|
||||
.PP
|
||||
Deleting files is a more painful problem; the symlinks will
|
||||
just point into never never land.
|
||||
.PP
|
||||
If a file in \fIfromdir\fP is a symbolic link, \fIlndir\fP will make
|
||||
the same link in \fItodir\fP rather than making a link back to the
|
||||
(symbolic link) entry in \fIfromdir.\fP The \fB\-ignorelinks\fP flag
|
||||
changes this behavior.
|
||||
.SH OPTIONS
|
||||
.IP \-silent
|
||||
Normally \fIlndir\fP outputs the name of each subdirectory as it
|
||||
descends into it. The \fB\-silent\fP option suppresses these status
|
||||
messages.
|
||||
.IP \-ignorelinks
|
||||
Causes the program to not treat symbolic links in \fIfromdir\fP
|
||||
specially. The link created in \fItodir\fP will point back to the
|
||||
corresponding (symbolic link) file in \fIfromdir\fP.
|
||||
If the link is to a directory, this is almost certainly the wrong thing.
|
||||
.IP
|
||||
This option exists mostly to emulate the behavior the C version of
|
||||
\fIlndir\fP had in X11R6. Its use is not recommended.
|
||||
.SH DIAGNOSTICS
|
||||
The program displays the name of each subdirectory it enters, followed
|
||||
by a colon. The \fB\-silent\fP option suppresses these messages.
|
||||
.PP
|
||||
A warning message is displayed if the symbolic link cannot be created.
|
||||
The usual problem is that a regular file of the same name already
|
||||
exists.
|
||||
.PP
|
||||
If the link already exists but doesn't point to the correct file, the
|
||||
program prints the link name and the location where it does point.
|
||||
.SH BUGS
|
||||
The
|
||||
.I patch
|
||||
program gets upset if it cannot change the files. You should never run
|
||||
.I patch
|
||||
from a shadow directory anyway.
|
||||
.PP
|
||||
You need to use something like
|
||||
.nf
|
||||
find todir \|\-type l \|\-print \||\| xargs rm
|
||||
.fi
|
||||
to clear out all files before you can relink (if fromdir moved, for instance).
|
||||
Something like
|
||||
.nf
|
||||
find . \|\\! \|\-type d \|\-print
|
||||
.fi
|
||||
will find all files that are not directories.
|
||||
57
cde/config/util/makeg.man
Normal file
57
cde/config/util/makeg.man
Normal file
@@ -0,0 +1,57 @@
|
||||
.\" $TOG: makeg.man /main/2 1998/02/06 11:24:05 kaleb $
|
||||
.\" Copyright (c) 1996, 1998 The Open Group
|
||||
.\"
|
||||
.\" All Rights Reserved.
|
||||
.\"
|
||||
.\" The above copyright notice and this permission notice shall be
|
||||
.\" included in all copies or substantial portions of the Software.
|
||||
.\"
|
||||
.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
.\" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
.\" IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
.\" OTHER DEALINGS IN THE SOFTWARE.
|
||||
.\"
|
||||
.\" Except as contained in this notice, the name of The Open Group shall
|
||||
.\" not be used in advertising or otherwise to promote the sale, use or
|
||||
.\" other dealings in this Software without prior written authorization
|
||||
.\" from The Open Group.
|
||||
.\"
|
||||
.TH MAKEG 1 "Release 6.4" "X Version 11"
|
||||
.SH NAME
|
||||
makeg \- make a debuggable executable
|
||||
.SH SYNOPSIS
|
||||
.B makeg
|
||||
[
|
||||
.I make-options .\|.\|.
|
||||
] [
|
||||
.I targets .\|.\|.
|
||||
]
|
||||
.SH DESCRIPTION
|
||||
The
|
||||
.I makeg
|
||||
script runs
|
||||
.I make,
|
||||
passing it variable settings to create a debuggable target when used
|
||||
with a Makefile generated by
|
||||
.I imake.
|
||||
For example, it arranges for the C compiler to be called with the
|
||||
.B \-g
|
||||
option.
|
||||
.SH ENVIRONMENT
|
||||
.TP 8
|
||||
.B MAKE
|
||||
The
|
||||
.I make
|
||||
program to use. Default ``make''.
|
||||
.TP 8
|
||||
.B GDB
|
||||
Set to a non-null value if using the
|
||||
.I gdb
|
||||
debugger on Solaris 2, which requires additional debugging options to
|
||||
be passed to the compiler.
|
||||
.SH "SEE ALSO"
|
||||
.I make (1),
|
||||
.I imake (1)
|
||||
13
cde/config/util/makeg.sh
Executable file
13
cde/config/util/makeg.sh
Executable file
@@ -0,0 +1,13 @@
|
||||
#! /bin/sh
|
||||
# makeg - run "make" with options necessary to make a debuggable executable
|
||||
# $XConsortium: makeg.sh /main/4 1996/06/13 11:45:08 ray $
|
||||
|
||||
# set GDB=1 in your environment if using gdb on Solaris 2.
|
||||
|
||||
make="${MAKE-make}"
|
||||
flags="CDEBUGFLAGS=-g CXXDEBUGFLAGS=-g"
|
||||
|
||||
# gdb on Solaris needs the stabs included in the executable
|
||||
test "${GDB+yes}" = yes && flags="$flags -xs"
|
||||
|
||||
exec "$make" $flags LDSTRIPFLAGS= ${1+"$@"}
|
||||
736
cde/config/util/makestrs.c
Normal file
736
cde/config/util/makestrs.c
Normal file
@@ -0,0 +1,736 @@
|
||||
/* $TOG: makestrs.c /main/11 1998/02/06 11:24:15 kaleb $ */
|
||||
|
||||
/*
|
||||
|
||||
Copyright (c) 1991, 1998 The Open Group
|
||||
|
||||
All Rights Reserved.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of The Open Group shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings
|
||||
in this Software without prior written authorization from The Open Group.
|
||||
|
||||
*/
|
||||
|
||||
/* Constructs string definitions */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <X11/Xos.h>
|
||||
#ifndef X_NOT_STDC_ENV
|
||||
#include <stdlib.h>
|
||||
#else
|
||||
char *malloc();
|
||||
#endif
|
||||
#if defined(macII) && !defined(__STDC__) /* stdlib.h fails to define these */
|
||||
char *malloc();
|
||||
#endif /* macII */
|
||||
|
||||
typedef struct _TableEnt {
|
||||
struct _TableEnt* next;
|
||||
char* left;
|
||||
char* right;
|
||||
int offset;
|
||||
} TableEnt;
|
||||
|
||||
typedef struct _Table {
|
||||
struct _Table* next;
|
||||
TableEnt* tableent;
|
||||
TableEnt* tableentcurrent;
|
||||
TableEnt** tableenttail;
|
||||
char* name;
|
||||
int offset;
|
||||
} Table;
|
||||
|
||||
typedef struct _File {
|
||||
struct _File* next;
|
||||
FILE* tmpl;
|
||||
char* name;
|
||||
Table* table;
|
||||
Table* tablecurrent;
|
||||
Table** tabletail;
|
||||
} File;
|
||||
|
||||
static File* file = NULL;
|
||||
static File* filecurrent = NULL;
|
||||
static File** filetail = &file;
|
||||
static char* conststr;
|
||||
static char* prefixstr = NULL;
|
||||
static char* featurestr = NULL;
|
||||
static char* ctmplstr = NULL;
|
||||
static char* fileprotstr;
|
||||
static char* externrefstr;
|
||||
static char* externdefstr;
|
||||
|
||||
#define X_DEFAULT_ABI 0
|
||||
#define X_ARRAYPER_ABI 1
|
||||
#define X_INTEL_ABI 2
|
||||
#define X_INTEL_ABI_BC 3
|
||||
#define X_SPARC_ABI 4
|
||||
#define X_FUNCTION_ABI 5
|
||||
|
||||
#define X_MAGIC_STRING "<<<STRING_TABLE_GOES_HERE>>>"
|
||||
|
||||
static void WriteHeaderProlog (f, phile)
|
||||
FILE* f;
|
||||
File* phile;
|
||||
{
|
||||
Table* t;
|
||||
TableEnt* te;
|
||||
|
||||
(void) fprintf (f, "#ifdef %s\n", featurestr);
|
||||
for (t = phile->table; t; t = t->next)
|
||||
for (te = t->tableent; te; te = te->next) {
|
||||
if (strcmp (te->left, "RAtom") == 0) {
|
||||
(void) fprintf (f,
|
||||
"#ifndef %s%s\n#define %s%s \"%s\"\n#endif\n",
|
||||
prefixstr, te->left, prefixstr, te->left, te->right);
|
||||
} else {
|
||||
(void) fprintf (f,
|
||||
"#define %s%s \"%s\"\n",
|
||||
prefixstr, te->left, te->right);
|
||||
}
|
||||
}
|
||||
(void) fprintf (f, "%s", "#else\n");
|
||||
}
|
||||
|
||||
static void IntelABIWriteHeader (f, phile)
|
||||
FILE* f;
|
||||
File* phile;
|
||||
{
|
||||
Table* t;
|
||||
TableEnt* te;
|
||||
|
||||
WriteHeaderProlog (f, phile);
|
||||
|
||||
for (t = phile->table; t; t = t->next) {
|
||||
(void) fprintf (f, "%s %sConst char %s[];\n",
|
||||
externrefstr, conststr ? conststr : fileprotstr, t->name);
|
||||
for (te = t->tableent; te; te = te->next)
|
||||
(void) fprintf (f,
|
||||
"#ifndef %s%s\n#define %s%s ((char*)&%s[%d])\n#endif\n",
|
||||
prefixstr, te->left, prefixstr, te->left, t->name, te->offset);
|
||||
}
|
||||
|
||||
(void) fprintf (f, "#endif /* %s */\n", featurestr);
|
||||
}
|
||||
|
||||
static void SPARCABIWriteHeader (f, phile)
|
||||
FILE* f;
|
||||
File* phile;
|
||||
{
|
||||
Table* t;
|
||||
TableEnt* te;
|
||||
|
||||
for (t = phile->table; t; t = t->next)
|
||||
for (te = t->tableent; te; te = te->next)
|
||||
(void) fprintf (f, "#define %s%s \"%s\"\n",
|
||||
prefixstr, te->left, te->right);
|
||||
}
|
||||
|
||||
static void FunctionWriteHeader (f, phile)
|
||||
FILE* f;
|
||||
File* phile;
|
||||
{
|
||||
Table* t;
|
||||
TableEnt* te;
|
||||
|
||||
WriteHeaderProlog (f, phile);
|
||||
|
||||
(void) fprintf (f, "%s %sConst char* %s();\n",
|
||||
externrefstr, conststr ? conststr : fileprotstr,
|
||||
phile->table->name);
|
||||
|
||||
for (t = phile->table; t; t = t->next)
|
||||
for (te = t->tableent; te; te = te->next)
|
||||
(void) fprintf (f,
|
||||
"#ifndef %s%s\n#define %s%s (%s(%d))\n#endif\n",
|
||||
prefixstr, te->left, prefixstr, te->left, phile->table->name,
|
||||
te->offset);
|
||||
|
||||
(void) fprintf (f, "#endif /* %s */\n", featurestr);
|
||||
}
|
||||
|
||||
static void ArrayperWriteHeader (f, phile)
|
||||
FILE* f;
|
||||
File* phile;
|
||||
{
|
||||
Table* t;
|
||||
TableEnt* te;
|
||||
|
||||
WriteHeaderProlog (f, phile);
|
||||
|
||||
for (t = phile->table; t; t = t->next)
|
||||
for (te = t->tableent; te; te = te->next)
|
||||
(void) fprintf (f,
|
||||
"#ifndef %s%s\n%s %sConst char %s%s[];\n#endif\n",
|
||||
prefixstr, te->left,
|
||||
externrefstr, conststr ? conststr : fileprotstr,
|
||||
prefixstr, te->left);
|
||||
|
||||
(void) fprintf (f, "#endif /* %s */\n", featurestr);
|
||||
}
|
||||
|
||||
static void DefaultWriteHeader (f, phile)
|
||||
FILE* f;
|
||||
File* phile;
|
||||
{
|
||||
Table* t;
|
||||
TableEnt* te;
|
||||
|
||||
WriteHeaderProlog (f, phile);
|
||||
|
||||
(void) fprintf (f, "%s %sConst char %s[];\n",
|
||||
externrefstr, conststr ? conststr : fileprotstr,
|
||||
phile->table->name);
|
||||
|
||||
for (t = phile->table; t; t = t->next)
|
||||
for (te = t->tableent; te; te = te->next)
|
||||
(void) fprintf (f,
|
||||
"#ifndef %s%s\n#define %s%s ((char*)&%s[%d])\n#endif\n",
|
||||
prefixstr, te->left, prefixstr, te->left, phile->table->name,
|
||||
te->offset);
|
||||
|
||||
(void) fprintf (f, "#endif /* %s */\n", featurestr);
|
||||
}
|
||||
|
||||
static void CopyTmplProlog (tmpl, f)
|
||||
FILE* tmpl;
|
||||
FILE* f;
|
||||
{
|
||||
char buf[1024];
|
||||
static char* magic_string = X_MAGIC_STRING;
|
||||
int magic_string_len = strlen (magic_string);
|
||||
|
||||
while (fgets (buf, sizeof buf, tmpl)) {
|
||||
if (strncmp (buf, magic_string, magic_string_len) == 0) {
|
||||
return;
|
||||
}
|
||||
(void) fputs (buf, f);
|
||||
}
|
||||
}
|
||||
|
||||
static void CopyTmplEpilog (tmpl, f)
|
||||
FILE* tmpl;
|
||||
FILE* f;
|
||||
{
|
||||
char buf[1024];
|
||||
|
||||
while (fgets (buf, sizeof buf, tmpl))
|
||||
(void) fputs (buf, f);
|
||||
}
|
||||
|
||||
static char* abistring[] = {
|
||||
"Default", "Array per string", "Intel", "Intel BC", "SPARC", "Function" };
|
||||
|
||||
static void WriteHeader (tagline, phile, abi)
|
||||
char* tagline;
|
||||
File* phile;
|
||||
int abi;
|
||||
{
|
||||
FILE* f;
|
||||
char* tmp;
|
||||
Table* t;
|
||||
TableEnt* te;
|
||||
static void (*headerproc[])() = {
|
||||
DefaultWriteHeader, ArrayperWriteHeader,
|
||||
IntelABIWriteHeader, IntelABIWriteHeader,
|
||||
SPARCABIWriteHeader, FunctionWriteHeader };
|
||||
|
||||
if ((f = fopen (phile->name, "w+")) == NULL) exit (1);
|
||||
|
||||
if (phile->tmpl) CopyTmplProlog (phile->tmpl, f);
|
||||
|
||||
(void) fprintf (f,
|
||||
"%s\n%s\n/* %s ABI version -- Do not edit */\n",
|
||||
"/* $TOG: makestrs.c /main/11 1998/02/06 11:24:15 kaleb $ */",
|
||||
"/* This file is automatically generated. */",
|
||||
abistring[abi]);
|
||||
|
||||
if (tagline) (void) fprintf (f, "/* %s */\n\n", tagline);
|
||||
|
||||
/* do the right thing for Motif, i.e. avoid _XmXmStrDefs_h_ */
|
||||
if (strcmp (prefixstr, "Xm") == 0) {
|
||||
if ((fileprotstr = malloc (strlen (phile->name) + 3)) == NULL)
|
||||
exit (1);
|
||||
(void) sprintf (fileprotstr, "_%s_", phile->name);
|
||||
} else {
|
||||
if ((fileprotstr = malloc (strlen (phile->name) + strlen (prefixstr) + 3)) == NULL)
|
||||
exit (1);
|
||||
(void) sprintf (fileprotstr, "_%s%s_", prefixstr, phile->name);
|
||||
}
|
||||
|
||||
for (tmp = fileprotstr; *tmp; tmp++) if (*tmp == '.') *tmp = '_';
|
||||
|
||||
(*headerproc[abi])(f, phile);
|
||||
|
||||
if (phile->tmpl) CopyTmplEpilog (phile->tmpl, f);
|
||||
|
||||
(void) free (fileprotstr);
|
||||
(void) fclose (phile->tmpl);
|
||||
(void) fclose (f);
|
||||
}
|
||||
|
||||
static void WriteSourceLine (te, abi, fudge)
|
||||
TableEnt* te;
|
||||
int abi;
|
||||
{
|
||||
char* c;
|
||||
|
||||
for (c = te->right; *c; c++) (void) printf ("'%c',", *c);
|
||||
(void) printf ("%c", '0');
|
||||
if (te->next || fudge) (void) printf ("%c", ',');
|
||||
(void) printf ("%s", "\n");
|
||||
}
|
||||
|
||||
static char* const_string = "%s %sConst char %s[] = {\n";
|
||||
|
||||
static void IntelABIWriteSource (abi)
|
||||
int abi;
|
||||
{
|
||||
File* phile;
|
||||
|
||||
for (phile = file; phile; phile = phile->next) {
|
||||
Table* t;
|
||||
TableEnt* te;
|
||||
|
||||
for (t = phile->table; t; t = t->next) {
|
||||
(void) printf (const_string, externdefstr,
|
||||
conststr ? conststr : "", t->name);
|
||||
for (te = t->tableent; te; te = te->next)
|
||||
WriteSourceLine (te, abi, 0);
|
||||
(void) printf ("%s\n\n", "};");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void IntelABIBCWriteSource (abi)
|
||||
int abi;
|
||||
{
|
||||
File* phile;
|
||||
|
||||
for (phile = file; phile; phile = phile->next) {
|
||||
Table* t;
|
||||
TableEnt* te;
|
||||
|
||||
(void) printf (const_string, externdefstr,
|
||||
conststr ? conststr : "", phile->table->name);
|
||||
|
||||
for (t = phile->table; t; t = t->next)
|
||||
for (te = t->tableent; te; te = te->next)
|
||||
WriteSourceLine (te, abi, t->next ? 1 : 0);
|
||||
(void) printf ("%s\n\n", "};");
|
||||
|
||||
if (phile->table->next) {
|
||||
(void) printf (const_string, externdefstr,
|
||||
conststr ? conststr : "", phile->table->next->name);
|
||||
for (t = phile->table->next; t; t = t->next)
|
||||
for (te = t->tableent; te; te = te->next)
|
||||
WriteSourceLine (te, abi, 0);
|
||||
(void) printf ("%s\n\n", "};");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void FunctionWriteSource (abi)
|
||||
int abi;
|
||||
{
|
||||
File* phile;
|
||||
|
||||
for (phile = file; phile; phile = phile->next) {
|
||||
Table* t;
|
||||
TableEnt* te;
|
||||
|
||||
(void) printf ("static %sConst char _%s[] = {\n",
|
||||
conststr ? conststr : "", phile->table->name);
|
||||
|
||||
for (t = phile->table; t; t = t->next)
|
||||
for (te = t->tableent; te; te = te->next)
|
||||
WriteSourceLine (te, abi, t->next ? 1 : 0);
|
||||
(void) printf ("%s\n\n", "};");
|
||||
|
||||
(void) printf ("%sConst char* %s(index)\n int index;\n{\n return &_%s[index];\n}\n\n",
|
||||
conststr ? conststr : "",
|
||||
phile->table->name, phile->table->name);
|
||||
}
|
||||
}
|
||||
|
||||
static void ArrayperWriteSource (abi)
|
||||
int abi;
|
||||
{
|
||||
File* phile;
|
||||
static int done_atom;
|
||||
|
||||
for (phile = file; phile; phile = phile->next) {
|
||||
Table* t;
|
||||
TableEnt* te;
|
||||
|
||||
for (t = phile->table; t; t = t->next)
|
||||
for (te = t->tableent; te; te = te->next) {
|
||||
if (strcmp (te->left, "RAtom") == 0) {
|
||||
if (done_atom) return;
|
||||
done_atom = 1;
|
||||
}
|
||||
(void) printf ("%s %sConst char %s%s[] = \"%s\";\n",
|
||||
externdefstr, conststr ? conststr : prefixstr,
|
||||
te->left, te->right);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void DefaultWriteSource (abi)
|
||||
int abi;
|
||||
{
|
||||
File* phile;
|
||||
|
||||
for (phile = file; phile; phile = phile->next) {
|
||||
Table* t;
|
||||
TableEnt* te;
|
||||
|
||||
(void) printf (const_string, externdefstr, conststr ? conststr : "",
|
||||
phile->table->name);
|
||||
|
||||
for (t = phile->table; t; t = t->next)
|
||||
for (te = t->tableent; te; te = te->next)
|
||||
WriteSourceLine (te, abi, t->next ? 1 : 0);
|
||||
(void) printf ("%s\n\n", "};");
|
||||
}
|
||||
}
|
||||
|
||||
static void WriteSource(tagline, abi)
|
||||
char* tagline;
|
||||
int abi;
|
||||
{
|
||||
static void (*sourceproc[])() = {
|
||||
DefaultWriteSource, ArrayperWriteSource,
|
||||
IntelABIWriteSource, IntelABIBCWriteSource,
|
||||
DefaultWriteSource, FunctionWriteSource };
|
||||
|
||||
FILE* tmpl;
|
||||
|
||||
if (ctmplstr) {
|
||||
tmpl = fopen (ctmplstr, "r");
|
||||
|
||||
if (tmpl) CopyTmplProlog (tmpl, stdout);
|
||||
else {
|
||||
(void) fprintf (stderr, "Expected template %s, not found\n",
|
||||
ctmplstr);
|
||||
exit (1);
|
||||
}
|
||||
} else
|
||||
tmpl = NULL;
|
||||
|
||||
|
||||
(void) printf ("%s\n%s\n/* %s ABI version -- Do not edit */\n",
|
||||
"/* $TOG: makestrs.c /main/11 1998/02/06 11:24:15 kaleb $ */",
|
||||
"/* This file is automatically generated. */",
|
||||
abistring[abi]);
|
||||
|
||||
if (tagline) (void) printf ("/* %s */\n\n", tagline);
|
||||
|
||||
(*sourceproc[abi])(abi);
|
||||
|
||||
if (tmpl) CopyTmplEpilog (tmpl, stdout);
|
||||
}
|
||||
|
||||
static void DoLine(buf)
|
||||
char* buf;
|
||||
{
|
||||
#define X_NO_TOKEN 0
|
||||
#define X_FILE_TOKEN 1
|
||||
#define X_TABLE_TOKEN 2
|
||||
#define X_PREFIX_TOKEN 3
|
||||
#define X_FEATURE_TOKEN 4
|
||||
#define X_EXTERNREF_TOKEN 5
|
||||
#define X_EXTERNDEF_TOKEN 6
|
||||
#define X_CTMPL_TOKEN 7
|
||||
#define X_HTMPL_TOKEN 8
|
||||
#define X_CONST_TOKEN 9
|
||||
|
||||
int token;
|
||||
char lbuf[1024];
|
||||
static char* file_str = "#file";
|
||||
static char* table_str = "#table";
|
||||
static char* prefix_str = "#prefix";
|
||||
static char* feature_str = "#feature";
|
||||
static char* externref_str = "#externref";
|
||||
static char* externdef_str = "#externdef";
|
||||
static char* ctmpl_str = "#ctmpl";
|
||||
static char* htmpl_str = "#htmpl";
|
||||
static char* const_str = "#const";
|
||||
|
||||
if (strncmp (buf, file_str, strlen (file_str)) == 0)
|
||||
token = X_FILE_TOKEN;
|
||||
else if (strncmp (buf, table_str, strlen (table_str)) == 0)
|
||||
token = X_TABLE_TOKEN;
|
||||
else if (strncmp (buf, prefix_str, strlen (prefix_str)) == 0)
|
||||
token = X_PREFIX_TOKEN;
|
||||
else if (strncmp (buf, feature_str, strlen (feature_str)) == 0)
|
||||
token = X_FEATURE_TOKEN;
|
||||
else if (strncmp (buf, externref_str, strlen (externref_str)) == 0)
|
||||
token = X_EXTERNREF_TOKEN;
|
||||
else if (strncmp (buf, externdef_str, strlen (externdef_str)) == 0)
|
||||
token = X_EXTERNDEF_TOKEN;
|
||||
else if (strncmp (buf, ctmpl_str, strlen (ctmpl_str)) == 0)
|
||||
token = X_CTMPL_TOKEN;
|
||||
else if (strncmp (buf, htmpl_str, strlen (htmpl_str)) == 0)
|
||||
token = X_HTMPL_TOKEN;
|
||||
else if (strncmp (buf, const_str, strlen (const_str)) == 0)
|
||||
token = X_CONST_TOKEN;
|
||||
else
|
||||
token = X_NO_TOKEN;
|
||||
|
||||
switch (token) {
|
||||
case X_FILE_TOKEN:
|
||||
{
|
||||
File* phile;
|
||||
|
||||
if ((phile = (File*) malloc (sizeof(File))) == NULL)
|
||||
exit(1);
|
||||
if ((phile->name = malloc (strlen (buf + strlen (file_str)) + 1)) == NULL)
|
||||
exit(1);
|
||||
(void) strcpy (phile->name, buf + strlen (file_str) + 1);
|
||||
phile->table = NULL;
|
||||
phile->tablecurrent = NULL;
|
||||
phile->tabletail = &phile->table;
|
||||
phile->next = NULL;
|
||||
phile->tmpl = NULL;
|
||||
|
||||
*filetail = phile;
|
||||
filetail = &phile->next;
|
||||
filecurrent = phile;
|
||||
}
|
||||
break;
|
||||
case X_TABLE_TOKEN:
|
||||
{
|
||||
Table* table;
|
||||
if ((table = (Table*) malloc (sizeof(Table))) == NULL)
|
||||
exit(1);
|
||||
if ((table->name = malloc (strlen (buf + strlen (table_str)) + 1)) == NULL)
|
||||
exit(1);
|
||||
(void) strcpy (table->name, buf + strlen (table_str) + 1);
|
||||
table->tableent = NULL;
|
||||
table->tableentcurrent = NULL;
|
||||
table->tableenttail = &table->tableent;
|
||||
table->next = NULL;
|
||||
table->offset = 0;
|
||||
|
||||
*filecurrent->tabletail = table;
|
||||
filecurrent->tabletail = &table->next;
|
||||
filecurrent->tablecurrent = table;
|
||||
}
|
||||
break;
|
||||
case X_PREFIX_TOKEN:
|
||||
if ((prefixstr = malloc (strlen (buf + strlen (prefix_str)) + 1)) == NULL)
|
||||
exit(1);
|
||||
(void) strcpy (prefixstr, buf + strlen (prefix_str) + 1);
|
||||
break;
|
||||
case X_FEATURE_TOKEN:
|
||||
if ((featurestr = malloc (strlen (buf + strlen (feature_str)) + 1)) == NULL)
|
||||
exit(1);
|
||||
(void) strcpy (featurestr, buf + strlen (feature_str) + 1);
|
||||
break;
|
||||
case X_EXTERNREF_TOKEN:
|
||||
if ((externrefstr = malloc (strlen (buf + strlen (externref_str)) + 1)) == NULL)
|
||||
exit(1);
|
||||
(void) strcpy (externrefstr, buf + strlen (externref_str) + 1);
|
||||
break;
|
||||
case X_EXTERNDEF_TOKEN:
|
||||
if ((externdefstr = malloc (strlen (buf + strlen (externdef_str)) + 1)) == NULL)
|
||||
exit(1);
|
||||
(void) strcpy (externdefstr, buf + strlen (externdef_str) + 1);
|
||||
break;
|
||||
case X_CTMPL_TOKEN:
|
||||
if ((ctmplstr = malloc (strlen (buf + strlen (ctmpl_str)) + 1)) == NULL)
|
||||
exit(1);
|
||||
(void) strcpy (ctmplstr, buf + strlen (ctmpl_str) + 1);
|
||||
break;
|
||||
case X_HTMPL_TOKEN:
|
||||
if ((filecurrent->tmpl = fopen (buf + strlen (htmpl_str) + 1, "r")) == NULL) {
|
||||
(void) fprintf (stderr,
|
||||
"Expected template %s, not found\n", htmpl_str);
|
||||
exit (1);
|
||||
}
|
||||
break;
|
||||
case X_CONST_TOKEN:
|
||||
if ((conststr = malloc (strlen (buf + strlen (const_str)) + 1)) == NULL)
|
||||
exit(1);
|
||||
(void) strcpy (conststr, buf + strlen (const_str) + 1);
|
||||
break;
|
||||
default:
|
||||
{
|
||||
char* right;
|
||||
TableEnt* tableent;
|
||||
int llen;
|
||||
int rlen;
|
||||
int len;
|
||||
|
||||
if (right = index(buf, ' '))
|
||||
*right++ = 0;
|
||||
else
|
||||
right = buf + 1;
|
||||
if (buf[0] == 'H') {
|
||||
strcpy (lbuf, prefixstr);
|
||||
strcat (lbuf, right);
|
||||
right = lbuf;
|
||||
}
|
||||
|
||||
llen = len = strlen(buf) + 1;
|
||||
rlen = strlen(right) + 1;
|
||||
if (right != buf + 1) len += rlen;
|
||||
if ((tableent = (TableEnt*)malloc(sizeof(TableEnt) + len)) == NULL)
|
||||
exit(1);
|
||||
tableent->left = (char *)(tableent + 1);
|
||||
strcpy(tableent->left, buf);
|
||||
if (llen != len) {
|
||||
tableent->right = tableent->left + llen;
|
||||
strcpy(tableent->right, right);
|
||||
} else {
|
||||
tableent->right = tableent->left + 1;
|
||||
}
|
||||
tableent->next = NULL;
|
||||
|
||||
*filecurrent->tablecurrent->tableenttail = tableent;
|
||||
filecurrent->tablecurrent->tableenttail = &tableent->next;
|
||||
filecurrent->tablecurrent->tableentcurrent = tableent;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void IntelABIIndexEntries (file)
|
||||
File* file;
|
||||
{
|
||||
Table* t;
|
||||
TableEnt* te;
|
||||
|
||||
for (t = file->table; t; t = t->next)
|
||||
for (te = t->tableent; te; te = te->next) {
|
||||
te->offset = t->offset;
|
||||
t->offset += strlen (te->right);
|
||||
t->offset++;
|
||||
}
|
||||
}
|
||||
|
||||
static void DefaultIndexEntries (file)
|
||||
File* file;
|
||||
{
|
||||
Table* t;
|
||||
TableEnt* te;
|
||||
int offset = 0;
|
||||
|
||||
for (t = file->table; t; t = t->next)
|
||||
for (te = t->tableent; te; te = te->next) {
|
||||
te->offset = offset;
|
||||
offset += strlen (te->right);
|
||||
offset++;
|
||||
}
|
||||
}
|
||||
|
||||
static void IndexEntries (file,abi)
|
||||
File* file;
|
||||
int abi;
|
||||
{
|
||||
switch (abi) {
|
||||
case X_SPARC_ABI:
|
||||
break;
|
||||
case X_INTEL_ABI:
|
||||
case X_INTEL_ABI_BC:
|
||||
IntelABIIndexEntries (file);
|
||||
break;
|
||||
default:
|
||||
DefaultIndexEntries (file);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static char* DoComment (line)
|
||||
char* line;
|
||||
{
|
||||
char* tag;
|
||||
char* eol;
|
||||
char* ret;
|
||||
int len;
|
||||
|
||||
/* assume that the first line with two '$' in it is the RCS tag line */
|
||||
if ((tag = index (line, '$')) == NULL) return NULL;
|
||||
if ((eol = index (tag + 1, '$')) == NULL) return NULL;
|
||||
len = eol - tag;
|
||||
if ((ret = malloc (len)) == NULL)
|
||||
exit (1);
|
||||
(void) strncpy (ret, tag + 1, len - 1);
|
||||
ret[len - 2] = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int main(argc, argv)
|
||||
int argc;
|
||||
char** argv;
|
||||
{
|
||||
int len, i;
|
||||
char* tagline = NULL;
|
||||
File* phile;
|
||||
FILE *f;
|
||||
char buf[1024];
|
||||
int abi =
|
||||
#ifndef ARRAYPERSTR
|
||||
X_DEFAULT_ABI;
|
||||
#else
|
||||
X_ARRAYPER_ABI;
|
||||
#endif
|
||||
|
||||
f = stdin;
|
||||
if (argc > 1) {
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp (argv[i], "-f") == 0) {
|
||||
if (++i < argc)
|
||||
f = fopen (argv[i], "r");
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
if (strcmp (argv[i], "-sparcabi") == 0)
|
||||
abi = X_SPARC_ABI;
|
||||
if (strcmp (argv[i], "-intelabi") == 0)
|
||||
abi = X_INTEL_ABI;
|
||||
if (strcmp (argv[i], "-functionabi") == 0)
|
||||
abi = X_FUNCTION_ABI;
|
||||
if (strcmp (argv[i], "-earlyR6bc") == 0 && abi == X_INTEL_ABI)
|
||||
abi = X_INTEL_ABI_BC;
|
||||
if (strcmp (argv[i], "-arrayperabi") == 0)
|
||||
abi = X_ARRAYPER_ABI;
|
||||
#ifdef ARRAYPERSTR
|
||||
if (strcmp (argv[i], "-defaultabi") == 0)
|
||||
abi = X_DEFAULT_ABI;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (f == NULL) return 1;
|
||||
while (fgets(buf, sizeof buf, f)) {
|
||||
if (!buf[0] || buf[0] == '\n')
|
||||
continue;
|
||||
if (buf[0] == '!') {
|
||||
if (tagline) continue;
|
||||
tagline = DoComment (buf);
|
||||
continue;
|
||||
}
|
||||
if (buf[(len = strlen (buf) - 1)] == '\n') buf[len] = '\0';
|
||||
DoLine(buf);
|
||||
}
|
||||
for (phile = file; phile; phile = phile->next) {
|
||||
if (abi != X_ARRAYPER_ABI) IndexEntries (phile, abi);
|
||||
WriteHeader (tagline, phile, abi);
|
||||
}
|
||||
WriteSource(tagline, abi);
|
||||
return 0;
|
||||
}
|
||||
|
||||
208
cde/config/util/makestrs.man
Normal file
208
cde/config/util/makestrs.man
Normal file
@@ -0,0 +1,208 @@
|
||||
.\" $TOG: makestrs.man /main/4 1998/02/06 11:24:22 kaleb $
|
||||
.\" Copyright (c) 1993, 1994, 1998 The Open Group
|
||||
.\"
|
||||
.\" All Rights Reserved.
|
||||
.\"
|
||||
.\" The above copyright notice and this permission notice shall be included in
|
||||
.\" all copies or substantial portions of the Software.
|
||||
.\"
|
||||
.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
.\" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
.\" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
.\" THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
.\" WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
.\" OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
.\" SOFTWARE.
|
||||
.\"
|
||||
.\" Except as contained in this notice, the name of The Open Group shall not
|
||||
.\" be used in advertising or otherwise to promote the sale, use or other
|
||||
.\" dealing in this Software without prior written authorization from The
|
||||
.\" Open Group.
|
||||
.TH MAKESTRS 1 "Release 6.4" "X Version 11"
|
||||
.SH NAME
|
||||
makestrs \- makes string table C source and header(s)
|
||||
.SH SYNOPSIS
|
||||
.B makestrs [-f source] [-abioptions ...]
|
||||
.SH DESCRIPTION
|
||||
The
|
||||
.I makestrs
|
||||
command creates string table C source files and headers.
|
||||
If
|
||||
.I -f
|
||||
.I source
|
||||
is not specified
|
||||
.I makestrs
|
||||
will read from
|
||||
.I stdin.
|
||||
The C source file is always written to
|
||||
.I stdout.
|
||||
.I makestrs
|
||||
creates one or more C header files as specified in the source file.
|
||||
The following options may be specified:
|
||||
.I -sparcabi,
|
||||
.I -intelabi,
|
||||
.I -functionabi,
|
||||
.I -arrayperabi,
|
||||
and
|
||||
.I -defaultabi.
|
||||
.LP
|
||||
.I -sparcabi
|
||||
is used on SPARC platforms conforming to the SPARC
|
||||
Compliance Definition, i.e. SVR4/Solaris.
|
||||
.LP
|
||||
.I -intelabi
|
||||
is used on Intel platforms conforming to the System
|
||||
V Application Binary Interface, i.e. SVR4.
|
||||
.LP
|
||||
.I -earlyR6abi
|
||||
may be used in addition to
|
||||
.I -intelabi
|
||||
for situations
|
||||
where the vendor wishes to maintain binary compatiblity between
|
||||
X11R6 public-patch 11 (and earlier) and X11R6 public-patch 12 (and later).
|
||||
.LP
|
||||
.I -functionabi
|
||||
generates a functional abi to the string table. This
|
||||
mechanism imposes a severe performance penalty and it's recommended
|
||||
that you not use it.
|
||||
.LP
|
||||
.I -arrayperabi
|
||||
results in a separate array for each string. This is
|
||||
the default behavior if makestrs was compiled with -DARRAYPERSTR
|
||||
(it almost never is).
|
||||
.LP
|
||||
.I -defaultabi
|
||||
forces the generation of the "normal" string table even
|
||||
if makestrs was compiled with -DARRAYPERSTR. Since makestrs is almost
|
||||
never compiled with -DARRAYPERSTR this is the default behavior if
|
||||
no abioptions are specified.
|
||||
.SH SYNTAX
|
||||
The syntax for string-list file is (items in square brackets are optional):
|
||||
.RS 4
|
||||
#prefix <text>
|
||||
.RE
|
||||
.RS 4
|
||||
#feature <text>
|
||||
.RE
|
||||
.RS 4
|
||||
#externref <text>
|
||||
.RE
|
||||
.RS 4
|
||||
#externdef [<text>]
|
||||
.RE
|
||||
.RS 4
|
||||
[#ctempl <text>]
|
||||
.RE
|
||||
.LP
|
||||
.RS 4
|
||||
#file <filename>
|
||||
.RE
|
||||
.RS 4
|
||||
#table <tablename>
|
||||
.RE
|
||||
.RS 4
|
||||
[#htempl]
|
||||
.RE
|
||||
.RS 4
|
||||
<text>
|
||||
.RE
|
||||
.RS 4
|
||||
...
|
||||
.RE
|
||||
.RS 4
|
||||
<text>
|
||||
.RE
|
||||
.RS 4
|
||||
[#table <tablename>
|
||||
.RE
|
||||
.RS 4
|
||||
<text>
|
||||
.RE
|
||||
.RS 4
|
||||
...
|
||||
.RE
|
||||
.RS 4
|
||||
<text>
|
||||
.RE
|
||||
.RS 4
|
||||
...
|
||||
.RE
|
||||
.RS 4
|
||||
#table <tablename>
|
||||
.RE
|
||||
.RS 4
|
||||
...]
|
||||
.RE
|
||||
.RS 4
|
||||
[#file <filename>
|
||||
.RE
|
||||
.RS 4
|
||||
...]
|
||||
.RE
|
||||
.LP
|
||||
In words you may have one or more #file directives. Each #file may have
|
||||
one or more #table directives.
|
||||
.LP
|
||||
The #prefix directive determines the string that makestr will prefix
|
||||
to each definition.
|
||||
.LP
|
||||
The #feature directive determines the string that makestr will use
|
||||
for the feature-test macro, e.g. X[TM]STRINGDEFINES.
|
||||
.LP
|
||||
The #externref directive determines the string that makestr will use
|
||||
for the extern clause, typically this will be "extern" but Motif wants
|
||||
it to be "externalref"
|
||||
.LP
|
||||
The #externdef directive determines the string that makestr will use
|
||||
for the declaration, typically this will be the null string (note that
|
||||
makestrs requires a trailing space in this case, i.e. "#externdef "),
|
||||
and Motif will use "externaldef(_xmstrings).
|
||||
.LP
|
||||
The #ctmpl directive determines the name of the file used as a template
|
||||
for the C source file that is generated
|
||||
.LP
|
||||
Each #file <filename> directive will result in a corresponding header
|
||||
file by that name containing the appropriate definitions as specified
|
||||
by command line options. A single C source file containing the
|
||||
declarations for the definitions in all the headers will be printed
|
||||
to stdout.
|
||||
.LP
|
||||
The #htmpl directive determines the name of the file used as a template
|
||||
for the C header file that is generated.
|
||||
.LP
|
||||
Each #table <tablename> directive will be processed in accordance with
|
||||
the ABI. On most platforms all tables will be catenated into a single
|
||||
table with the name of the first table for that file. To conform to
|
||||
the Intel ABI separate tables will be generated with the names indicated.
|
||||
.LP
|
||||
The template files specified by the #ctmpl and #htmpl directives
|
||||
are processed by copying line for line from the template file to
|
||||
the appropriate output file. The line containing the string
|
||||
.I <<<STRING_TABLE_GOES_HERE>>>
|
||||
is not copied to the output file. The appropriate data is then
|
||||
copied to the output file and then the remainder of the template
|
||||
file is copied to the output file.
|
||||
.SH BUGS
|
||||
makestrs is not very forgiving of syntax errors. Sometimes you need
|
||||
a trailing space after # directives, other times they will mess you
|
||||
up. No warning messages are emitted.
|
||||
.SH SEE ALSO
|
||||
SPARC Compliance Definition 2.2., SPARC International Inc.,
|
||||
535 Middlefield Road, Suite 210, Menlo Park, CA 94025
|
||||
.LP
|
||||
System V Application Binary Interface, Third Edition,
|
||||
ISBN 0-13-100439-5
|
||||
UNIX Press, PTR Prentice Hall, 113 Sylvan Avenue, Englewood Cliffs,
|
||||
NJ 07632
|
||||
.LP
|
||||
System V Application Binary Interface, Third Edition, Intel386
|
||||
Architecture Processor Supplement
|
||||
ISBN 0-13-104670-5
|
||||
UNIX Press, PTR Prentice Hall, 113 Sylvan Avenue, Englewood Cliffs,
|
||||
NJ 07632
|
||||
.LP
|
||||
System V Application Binary Interface, Third Edition, SPARC
|
||||
Architecture Processor Supplement
|
||||
ISBN 0-13-104696-9
|
||||
UNIX Press, PTR Prentice Hall, 113 Sylvan Avenue, Englewood Cliffs,
|
||||
NJ 07632
|
||||
243
cde/config/util/mdepend.cpp
Normal file
243
cde/config/util/mdepend.cpp
Normal file
@@ -0,0 +1,243 @@
|
||||
XCOMM!/bin/sh
|
||||
XCOMM
|
||||
XCOMM $TOG: mdepend.cpp /main/13 1997/06/20 21:12:18 kaleb $
|
||||
XCOMM
|
||||
XCOMM Do the equivalent of the 'makedepend' program, but do it right.
|
||||
XCOMM
|
||||
XCOMM Usage:
|
||||
XCOMM
|
||||
XCOMM makedepend [cpp-flags] [-w width] [-s magic-string] [-f makefile]
|
||||
XCOMM [-o object-suffix]
|
||||
XCOMM
|
||||
XCOMM Notes:
|
||||
XCOMM
|
||||
XCOMM The C compiler used can be overridden with the environment
|
||||
XCOMM variable "CC".
|
||||
XCOMM
|
||||
XCOMM The "-v" switch of the "makedepend" program is not supported.
|
||||
XCOMM
|
||||
XCOMM
|
||||
XCOMM This script should
|
||||
XCOMM work on both USG and BSD systems. However, when System V.4 comes out,
|
||||
XCOMM USG users will probably have to change "silent" to "-s" instead of
|
||||
XCOMM "-" (at least, that is what the documentation implies).
|
||||
XCOMM
|
||||
CC=PREPROC
|
||||
|
||||
silent='-'
|
||||
|
||||
TMP=/tmp/mdep$$
|
||||
CPPCMD=${TMP}a
|
||||
DEPENDLINES=${TMP}b
|
||||
TMPMAKEFILE=${TMP}c
|
||||
MAGICLINE=${TMP}d
|
||||
ARGS=${TMP}e
|
||||
|
||||
trap "rm -f ${TMP}*; exit 1" 1 2 15
|
||||
trap "rm -f ${TMP}*; exit 0" 1 2 13
|
||||
|
||||
echo " \c" > $CPPCMD
|
||||
if [ `wc -c < $CPPCMD` -eq 1 ]
|
||||
then
|
||||
c="\c"
|
||||
n=
|
||||
else
|
||||
c=
|
||||
n="-n"
|
||||
fi
|
||||
|
||||
echo $n "$c" >$ARGS
|
||||
|
||||
files=
|
||||
makefile=
|
||||
magic_string='# DO NOT DELETE'
|
||||
objsuffix='.o'
|
||||
width=78
|
||||
endmarker=""
|
||||
verbose=n
|
||||
append=n
|
||||
|
||||
while [ $# != 0 ]
|
||||
do
|
||||
if [ "$endmarker"x != x ] && [ "$endmarker" = "$1" ]; then
|
||||
endmarker=""
|
||||
else
|
||||
case "$1" in
|
||||
-D*|-I*)
|
||||
echo $n " '$1'$c" >> $ARGS
|
||||
;;
|
||||
|
||||
-g|-O) # ignore so we can just pass $(CFLAGS) in
|
||||
;;
|
||||
|
||||
*)
|
||||
if [ "$endmarker"x = x ]; then
|
||||
case "$1" in
|
||||
-w)
|
||||
width="$2"
|
||||
shift
|
||||
;;
|
||||
-s)
|
||||
magic_string="$2"
|
||||
shift
|
||||
;;
|
||||
-f*)
|
||||
if [ "$1" = "-f-" ]; then
|
||||
makefile="-"
|
||||
else
|
||||
makefile="$2"
|
||||
shift
|
||||
fi
|
||||
;;
|
||||
-o)
|
||||
objsuffix="$2"
|
||||
shift
|
||||
;;
|
||||
|
||||
--*)
|
||||
echo "$1" | sed 's/^\-\-//' >${TMP}end
|
||||
endmarker="`cat ${TMP}end`"
|
||||
rm -f ${TMP}end
|
||||
if [ "$endmarker"x = x ]; then
|
||||
endmarker="--"
|
||||
fi
|
||||
;;
|
||||
-v)
|
||||
verbose="y"
|
||||
;;
|
||||
|
||||
-a)
|
||||
append="y"
|
||||
;;
|
||||
|
||||
-cc)
|
||||
CC="$2"
|
||||
shift
|
||||
;;
|
||||
|
||||
-*)
|
||||
echo "Unknown option '$1' ignored" 1>&2
|
||||
;;
|
||||
*)
|
||||
files="$files $1"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
shift
|
||||
done
|
||||
echo ' $*' >> $ARGS
|
||||
|
||||
echo "#!/bin/sh" > $CPPCMD
|
||||
echo "exec $CC `cat $ARGS`" >> $CPPCMD
|
||||
chmod +x $CPPCMD
|
||||
rm $ARGS
|
||||
|
||||
case "$makefile" in
|
||||
'')
|
||||
if [ -r makefile ]
|
||||
then
|
||||
makefile=makefile
|
||||
elif [ -r Makefile ]
|
||||
then
|
||||
makefile=Makefile
|
||||
else
|
||||
echo 'no makefile or Makefile found' 1>&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
-)
|
||||
makefile=$TMPMAKEFILE
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "$verbose"x = "y"x ]; then
|
||||
cat $CPPCMD
|
||||
fi
|
||||
|
||||
echo '' > $DEPENDLINES
|
||||
for i in $files
|
||||
do
|
||||
$CPPCMD $i \
|
||||
| sed -n "/^#/s;^;$i ;p"
|
||||
done \
|
||||
| sed -e 's|/[^/.][^/]*/\.\.||g' -e 's|/\.[^.][^/]*/\.\.||g' \
|
||||
-e 's|"||g' -e 's| \./| |' \
|
||||
| awk '{
|
||||
if ($1 != $4 && $2 != "#ident" && $2 != "#pragma")
|
||||
{
|
||||
ofile = substr ($1, 1, length ($1) - 2) "'"$objsuffix"'"
|
||||
print ofile, $4
|
||||
}
|
||||
}' \
|
||||
| sort -u \
|
||||
| awk '
|
||||
{
|
||||
newrec = rec " " $2
|
||||
if ($1 != old1)
|
||||
{
|
||||
old1 = $1
|
||||
if (rec != "")
|
||||
print rec
|
||||
rec = $1 ": " $2
|
||||
}
|
||||
else if (length (newrec) > '"$width"')
|
||||
{
|
||||
print rec
|
||||
rec = $1 ": " $2
|
||||
}
|
||||
else
|
||||
rec = newrec
|
||||
}
|
||||
END \
|
||||
{
|
||||
if (rec != "")
|
||||
print rec
|
||||
}' \
|
||||
| egrep -v '^[^:]*:[ ]*$' >> $DEPENDLINES
|
||||
|
||||
trap "" 1 2 13 15 # Now we are committed
|
||||
case "$makefile" in
|
||||
$TMPMAKEFILE)
|
||||
;;
|
||||
*)
|
||||
rm -f $makefile.bak
|
||||
cp $makefile $makefile.bak
|
||||
echo "Appending dependencies to $makefile"
|
||||
;;
|
||||
esac
|
||||
|
||||
XCOMM
|
||||
XCOMM If not -a, append the magic string and a blank line so that
|
||||
XCOMM /^$magic_string/+1,\$d can be used to delete everything from after
|
||||
XCOMM the magic string to the end of the file. Then, append a blank
|
||||
XCOMM line again and then the dependencies.
|
||||
XCOMM
|
||||
if [ "$append" = "n" ]
|
||||
then
|
||||
cat >> $makefile << END_OF_APPEND
|
||||
|
||||
$magic_string
|
||||
|
||||
END_OF_APPEND
|
||||
ed $silent $makefile << END_OF_ED_SCRIPT
|
||||
/^$magic_string/+1,\$d
|
||||
w
|
||||
q
|
||||
END_OF_ED_SCRIPT
|
||||
echo '' >>$makefile
|
||||
fi
|
||||
|
||||
cat $DEPENDLINES >>$makefile
|
||||
|
||||
case "$makefile" in
|
||||
$TMPMAKEFILE)
|
||||
cat $TMPMAKEFILE
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
rm -f ${TMP}*
|
||||
exit 0
|
||||
98
cde/config/util/mergelib.cpp
Executable file
98
cde/config/util/mergelib.cpp
Executable file
@@ -0,0 +1,98 @@
|
||||
XCOMM!/bin/sh
|
||||
XCOMM
|
||||
XCOMM $TOG: mergelib.cpp /main/5 1998/02/06 11:24:31 kaleb $
|
||||
XCOMM
|
||||
XCOMM Copyright (c) 1989, 1998 The Open Group
|
||||
XCOMM
|
||||
XCOMM All Rights Reserved
|
||||
XCOMM
|
||||
XCOMM The above copyright notice and this permission notice shall be included in
|
||||
XCOMM all copies or substantial portions of the Software.
|
||||
XCOMM
|
||||
XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
XCOMM IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
XCOMM FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
XCOMM OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
XCOMM AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
XCOMM CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
XCOMM
|
||||
XCOMM Except as contained in this notice, the name of The Open Group shall not be
|
||||
XCOMM used in advertising or otherwise to promote the sale, use or other dealings
|
||||
XCOMM in this Software without prior written authorization from The Open Group.
|
||||
XCOMM
|
||||
XCOMM Author: Jim Fulton, MIT X Consortium
|
||||
XCOMM
|
||||
XCOMM mergelib - merge one library into another; this is commonly used by X
|
||||
XCOMM to add the extension library into the base Xlib.
|
||||
XCOMM
|
||||
|
||||
usage="usage: $0 to-library from-library [object-filename-prefix]"
|
||||
objprefix=_
|
||||
|
||||
case $# in
|
||||
2) ;;
|
||||
3) objprefix=$3 ;;
|
||||
*) echo "$usage" 1>&2; exit 1 ;;
|
||||
esac
|
||||
|
||||
tolib=$1
|
||||
fromlib=$2
|
||||
|
||||
if [ ! -f $fromlib ]; then
|
||||
echo "$0: no such from-library $fromlib" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f $tolib ]; then
|
||||
echo "$0: no such to-library $tolib" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
XCOMM
|
||||
XCOMM Create a temp directory, and figure out how to reference the
|
||||
XCOMM object files from it (i.e. relative vs. absolute path names).
|
||||
XCOMM
|
||||
|
||||
tmpdir=tmp.$$
|
||||
origdir=..
|
||||
|
||||
mkdir $tmpdir
|
||||
|
||||
if [ ! -d $tmpdir ]; then
|
||||
echo "$0: unable to create temporary directory $tmpdir" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "$fromlib" in
|
||||
/?*) upfrom= ;;
|
||||
*) upfrom=../ ;;
|
||||
esac
|
||||
|
||||
case "$tolib" in
|
||||
/?*) upto= ;;
|
||||
*) upto=../ ;;
|
||||
esac
|
||||
|
||||
|
||||
XCOMM
|
||||
XCOMM In the temp directory, extract all of the object files and prefix
|
||||
XCOMM them with some symbol to avoid name clashes with the base library.
|
||||
XCOMM
|
||||
cd $tmpdir
|
||||
ar x ${upfrom}$fromlib
|
||||
for i in *.o; do
|
||||
mv $i ${objprefix}$i
|
||||
done
|
||||
|
||||
|
||||
XCOMM
|
||||
XCOMM Merge in the object modules, ranlib (if appropriate) and cleanup
|
||||
XCOMM
|
||||
ARCMD ${upto}$tolib *.o
|
||||
RANLIB ${upto}$tolib
|
||||
cd $origdir
|
||||
rm -rf $tmpdir
|
||||
|
||||
|
||||
|
||||
35
cde/config/util/mkdirhier.man
Normal file
35
cde/config/util/mkdirhier.man
Normal file
@@ -0,0 +1,35 @@
|
||||
.\" $TOG: mkdirhier.man /main/10 1998/02/06 11:24:42 kaleb $
|
||||
.\" Copyright (c) 1993, 1994, 1998 The Open Group
|
||||
.\"
|
||||
.\" All Rights Reserved.
|
||||
.\"
|
||||
.\" The above copyright notice and this permission notice shall be included in
|
||||
.\" all copies or substantial portions of the Software.
|
||||
.\"
|
||||
.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
.\" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
.\" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
.\" THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
.\" WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
.\" OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
.\" SOFTWARE.
|
||||
.\"
|
||||
.\" Except as contained in this notice, the name of The Open Group shall not
|
||||
.\" be used in advertising or otherwise to promote the sale, use or other
|
||||
.\" dealing in this Software without prior written authorization from The
|
||||
.\" Open Group.
|
||||
.TH MKDIRHIER 1 "Release 6.4" "X Version 11"
|
||||
.SH NAME
|
||||
mkdirhier \- makes a directory hierarchy
|
||||
.SH SYNOPSIS
|
||||
.B mkdirhier
|
||||
directory ...
|
||||
.SH DESCRIPTION
|
||||
The
|
||||
.I mkdirhier
|
||||
command creates the specified directories. Unlike
|
||||
.I mkdir
|
||||
if any of the parent directories of the specified directory
|
||||
do not exist, it creates them as well.
|
||||
.SH "SEE ALSO"
|
||||
mkdir(1)
|
||||
67
cde/config/util/mkdirhier.sh
Executable file
67
cde/config/util/mkdirhier.sh
Executable file
@@ -0,0 +1,67 @@
|
||||
#!/bin/sh
|
||||
# $XConsortium: mkdirhier.sh,v 1.7 94/03/24 15:46:34 gildea Exp $
|
||||
# Courtesy of Paul Eggert
|
||||
|
||||
newline='
|
||||
'
|
||||
IFS=$newline
|
||||
|
||||
case ${1--} in
|
||||
-*) echo >&2 "mkdirhier: usage: mkdirhier directory ..."; exit 1
|
||||
esac
|
||||
|
||||
status=
|
||||
|
||||
for directory
|
||||
do
|
||||
case $directory in
|
||||
'')
|
||||
echo >&2 "mkdirhier: empty directory name"
|
||||
status=1
|
||||
continue;;
|
||||
*"$newline"*)
|
||||
echo >&2 "mkdirhier: directory name contains a newline: \`\`$directory''"
|
||||
status=1
|
||||
continue;;
|
||||
///*) prefix=/;; # See Posix 2.3 "path".
|
||||
//*) prefix=//;;
|
||||
/*) prefix=/;;
|
||||
-*) prefix=./;;
|
||||
*) prefix=
|
||||
esac
|
||||
|
||||
IFS=/
|
||||
set x $directory
|
||||
case $2 in
|
||||
*/*) # IFS parsing is broken
|
||||
IFS=' '
|
||||
set x `echo $directory | tr / ' '`
|
||||
;;
|
||||
esac
|
||||
IFS=$newline
|
||||
shift
|
||||
|
||||
for filename
|
||||
do
|
||||
path=$prefix$filename
|
||||
prefix=$path/
|
||||
shift
|
||||
|
||||
test -d "$path" || {
|
||||
paths=$path
|
||||
for filename
|
||||
do
|
||||
if [ "$filename" != "." ]; then
|
||||
path=$path/$filename
|
||||
paths=$paths$newline$path
|
||||
fi
|
||||
done
|
||||
|
||||
mkdir $paths || status=$?
|
||||
|
||||
break
|
||||
}
|
||||
done
|
||||
done
|
||||
|
||||
exit $status
|
||||
5
cde/config/util/mkshadow/Imakefile
Normal file
5
cde/config/util/mkshadow/Imakefile
Normal file
@@ -0,0 +1,5 @@
|
||||
XCOMM $XConsortium: Imakefile,v 1.1 94/04/13 18:44:40 rws Exp $
|
||||
SRCS = mkshadow.c savedir.c wildmat.c
|
||||
OBJS = mkshadow.o savedir.o wildmat.o
|
||||
|
||||
ComplexProgramTarget(mkshadow)
|
||||
38
cde/config/util/mkshadow/README
Normal file
38
cde/config/util/mkshadow/README
Normal file
@@ -0,0 +1,38 @@
|
||||
The mkshadow programs makes a "shadow tree" of a directory tree.
|
||||
It logically copies all of the "MASTER" directory into ".".
|
||||
However, ordinary files, and RCS/SCCS directories are "copied"
|
||||
by creating a sybolic link to the corresponding file in MASTER.
|
||||
|
||||
The wildmat.c file is by Rich Salz, and from comp.sources.misc, volume 17.
|
||||
The savedir.c file is lightly modified from the version written
|
||||
by David MacKenzie for GNU fileutils; the Free Software Foundation
|
||||
has graciously agreed to waive their usual copyright so this
|
||||
program can be distributed by the X Consortium.
|
||||
|
||||
If you have problems compiling savedir.c, try setting the DIRENT make
|
||||
variable as suggested in the Makefile.
|
||||
|
||||
* Usage: mkshadow [-X exclude_file] [-x exclude_pattern] ... MASTER
|
||||
* Makes the current directory be a "shadow copy" of MASTER.
|
||||
* Sort of like a recursive copy of MASTER to .
|
||||
* However, symbolic links are used instead of actually
|
||||
* copying (non-directory) files.
|
||||
* Also, directories named RCS or SCCS are shared (with a symbolic link).
|
||||
* Warning messages are printed for files (and directories) in .
|
||||
* that don't match a corresponding file in MASTER (though
|
||||
* symbolic links are silently removed).
|
||||
* Also, a warning message is printed for non-directory files
|
||||
* under . that are not symbolic links.
|
||||
*
|
||||
* Files and directories can be excluded from the sharing
|
||||
* with the -X and -x flags. The flag `-x pattern' (or `-xpattern')
|
||||
* means that mkshadow should ignore any file whose name matches
|
||||
* the pattern. The pattern is a "globbing" pattern, i.e. the
|
||||
* characters *?[^-] are interpreted as by the shell.
|
||||
* If the pattern contains a '/' is is matched against the complete
|
||||
* current path (relative to '.'); otherwise, it is matched
|
||||
* against the last component of the path.
|
||||
* A `-X filename' flag means to read a set of exclusion patterns
|
||||
* from the named file, one pattern to a line.
|
||||
|
||||
Author: Per Bothner. bothner@cygnus.com. November 1990, 1993.
|
||||
378
cde/config/util/mkshadow/mkshadow.c
Normal file
378
cde/config/util/mkshadow/mkshadow.c
Normal file
@@ -0,0 +1,378 @@
|
||||
/* $XConsortium: mkshadow.c /main/2 1996/12/04 10:11:51 swick $ */
|
||||
/* mkshadow.c - make a "shadow copy" of a directory tree with symlinks.
|
||||
Copyright 1990, 1993 Free Software Foundation, Inc.
|
||||
|
||||
Permission to use, copy, modify, and distribute this program for
|
||||
any purpose and without fee is hereby granted, provided that this
|
||||
copyright and permission notice appear on all copies, and that
|
||||
notice be given that copying and distribution is by permission of
|
||||
the Free Software Foundation. The Free Software Foundation makes
|
||||
no representations about the suitability of this software for any
|
||||
purpose. It is provided "as is" without expressed or implied
|
||||
warranty.
|
||||
|
||||
(The FSF has modified its usual distribution terms, for this file,
|
||||
as a courtesy to the X project.) */
|
||||
|
||||
/*
|
||||
* Usage: mkshadow [-X exclude_file] [-x exclude_pattern] ... MASTER [SHADOW]
|
||||
* Makes SHADOW be a "shadow copy" of MASTER. SHADOW defaults to the current
|
||||
* directory. Sort of like a recursive copy of MASTER to SHADOW.
|
||||
* However, symbolic links are used instead of actually
|
||||
* copying (non-directory) files.
|
||||
* Also, directories named RCS or SCCS are shared (with a symbolic link).
|
||||
* Warning messages are printed for files (and directories) in .
|
||||
* that don't match a corresponding file in MASTER (though
|
||||
* symbolic links are silently removed).
|
||||
* Also, a warning message is printed for non-directory files
|
||||
* under SHADOW that are not symbolic links.
|
||||
*
|
||||
* Files and directories can be excluded from the sharing
|
||||
* with the -X and -x flags. The flag `-x pattern' (or `-xpattern')
|
||||
* means that mkshadow should ignore any file whose name matches
|
||||
* the pattern. The pattern is a "globbing" pattern, i.e. the
|
||||
* characters *?[^-] are interpreted as by the shell.
|
||||
* If the pattern contains a '/' is is matched against the complete
|
||||
* current path (relative to '.'); otherwise, it is matched
|
||||
* against the last component of the path.
|
||||
* A `-X filename' flag means to read a set of exclusion patterns
|
||||
* from the named file, one pattern to a line.
|
||||
*
|
||||
* Originally written by Per Bothner at University of Wisconsin-Madison,
|
||||
* inspired by the lndir script distributed with X11.
|
||||
* Modified by Per Bothner <bothner@cygnus.com> November 1993
|
||||
* to more-or-less follow Posix.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#ifdef BSD
|
||||
#include <strings.h>
|
||||
#define strchr index
|
||||
#else
|
||||
#include <string.h>
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
#if defined(S_IFDIR) && !defined(S_ISDIR)
|
||||
#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
|
||||
#endif
|
||||
#if defined(S_IFLNK) && !defined(S_ISLNK)
|
||||
#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
|
||||
#endif
|
||||
#ifndef S_ISLNK
|
||||
#define lstat stat
|
||||
#endif
|
||||
#ifndef MAXPATHLEN
|
||||
#define MAXPATHLEN 1024
|
||||
#endif
|
||||
#include <errno.h>
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
extern char * savedir();
|
||||
|
||||
fatal(msg)
|
||||
char *msg;
|
||||
{
|
||||
if (errno) perror(msg ? msg : "");
|
||||
else if (msg) fprintf(stderr, "mkshadow: %s\n", msg);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
/* When handling symbolic links to relative directories,
|
||||
* we need to prepend "../" to the "source".
|
||||
* We preallocate MAX_DEPTH repetations of "../" using a simple trick.
|
||||
*/
|
||||
#define MAX_DEPTH 20
|
||||
#define PREPEND_BUFFER_SIZE (MAX_DEPTH*3)
|
||||
char master_buffer[MAXPATHLEN+PREPEND_BUFFER_SIZE] =
|
||||
"../../../../../../../../../../../../../../../../../../../../";
|
||||
/* The logical start of the master_buffer is defined by
|
||||
* master_start, which skips the fixed prepend area.
|
||||
*/
|
||||
#define master_start (master_buffer+PREPEND_BUFFER_SIZE)
|
||||
char shadow_buffer[MAXPATHLEN];
|
||||
|
||||
void bad_args(msg)
|
||||
{
|
||||
if (msg) fprintf(stderr, "%s\n", msg);
|
||||
fprintf (stderr, "usage: mkshadow [-X exclude_file] [-x exclude_pattern]");
|
||||
fprintf (stderr, " master [shadow]\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
int exclude_count = 0;
|
||||
char **exclude_patterns = NULL;
|
||||
int exclude_limit = 0;
|
||||
|
||||
void add_exclude(pattern)
|
||||
char *pattern;
|
||||
{
|
||||
if (exclude_limit == 0) {
|
||||
exclude_limit = 100;
|
||||
exclude_patterns = (char**)malloc(exclude_limit * sizeof(char*));
|
||||
} else if (exclude_count + 1 >= exclude_limit) {
|
||||
exclude_limit += 100;
|
||||
exclude_patterns = (char**)realloc(exclude_patterns,
|
||||
exclude_limit * sizeof(char*));
|
||||
}
|
||||
exclude_patterns[exclude_count] = pattern;
|
||||
exclude_count++;
|
||||
}
|
||||
|
||||
void add_exclude_file(name)
|
||||
char *name;
|
||||
{
|
||||
char buf[MAXPATHLEN];
|
||||
FILE *file = fopen(name, "r");
|
||||
if (file == NULL) fatal("failed to find -X (exclude) file");
|
||||
for (;;) {
|
||||
int len;
|
||||
char *str = fgets(buf, MAXPATHLEN, file);
|
||||
if (str == NULL) break;
|
||||
len = strlen(str);
|
||||
if (len && str[len-1] == '\n') str[--len] = 0;
|
||||
if (!len) continue;
|
||||
str = (char*)malloc(len+1);
|
||||
strcpy(str, buf);
|
||||
add_exclude(str);
|
||||
}
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
main(argc, argv)
|
||||
char **argv;
|
||||
{
|
||||
char *master_name = NULL;
|
||||
char *shadow_name = NULL;
|
||||
int i;
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (argv[i][0] == '-') {
|
||||
switch(argv[i][1]) {
|
||||
case 'X':
|
||||
if (argv[i][2]) add_exclude_file(&argv[i][2]);
|
||||
else if (++i >= argc) bad_args(NULL);
|
||||
else add_exclude_file(argv[i]);
|
||||
break;
|
||||
case 'x':
|
||||
if (argv[i][2]) add_exclude(&argv[i][2]);
|
||||
else if (++i >= argc) bad_args(NULL);
|
||||
else add_exclude(argv[i]);
|
||||
break;
|
||||
default:
|
||||
bad_args(NULL);
|
||||
}
|
||||
} else if (master_name == NULL)
|
||||
master_name = argv[i];
|
||||
else if (shadow_name == NULL)
|
||||
shadow_name = argv[i];
|
||||
else bad_args (NULL);
|
||||
}
|
||||
|
||||
if (master_name == NULL) bad_args(NULL);
|
||||
if (shadow_name == NULL)
|
||||
shadow_name = ".";
|
||||
else if ((shadow_name[0] != '.' || shadow_name[1])
|
||||
&& master_name[0] != '/') {
|
||||
fprintf(stderr, "Shadowing a relative directory pathname to a \n");
|
||||
fprintf(stderr, "shadow other than '.' is not supported!\n");
|
||||
exit(-1);
|
||||
}
|
||||
strcpy(shadow_buffer, shadow_name);
|
||||
strcpy(master_start, master_name);
|
||||
DoCopy(master_start, shadow_buffer, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int compare_strings(ptr1, ptr2)
|
||||
char **ptr1, **ptr2;
|
||||
{
|
||||
return strcmp(*ptr1, *ptr2);
|
||||
}
|
||||
|
||||
void MakeLink(master, current, depth)
|
||||
char *master;
|
||||
char *current;
|
||||
int depth;
|
||||
{
|
||||
if (master[0] != '/') {
|
||||
/* Source directory was specified with a relative pathname. */
|
||||
if (master != master_start) {
|
||||
fatal("Internal bug: bad string buffer use");
|
||||
}
|
||||
/* Pre-pend "../" depth times. This compensates for
|
||||
* the directories we've entered. */
|
||||
master -= 3 * depth;
|
||||
}
|
||||
if (symlink(master, current)) {
|
||||
fprintf(stderr, "Failed to create symbolic link %s->%s\n",
|
||||
current, master);
|
||||
exit (-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Get a sorted NULL_terminator array of (char*) using 'names'
|
||||
* (created by save_dir) as data.
|
||||
*/
|
||||
char ** get_name_pointers(names)
|
||||
char *names;
|
||||
{
|
||||
int n_names = 0;
|
||||
int names_buf_size = 64;
|
||||
char *namep;
|
||||
char ** pointers = (char**)malloc(names_buf_size * sizeof(char*));
|
||||
if (!names || !pointers) fatal("virtual memory exhausted");
|
||||
|
||||
for (namep = names; *namep; namep += strlen(namep) + 1) {
|
||||
if (n_names + 1 >= names_buf_size) {
|
||||
names_buf_size *= 2;
|
||||
pointers = (char**)realloc(pointers,
|
||||
names_buf_size * sizeof(char*));
|
||||
if (!pointers) fatal("virtual memory exhausted");
|
||||
}
|
||||
pointers[n_names++] = namep;
|
||||
}
|
||||
pointers[n_names] = 0;
|
||||
qsort(pointers, n_names, sizeof(char*), compare_strings);
|
||||
return pointers;
|
||||
}
|
||||
|
||||
/* Recursively shadow the directory whose name is in MASTER
|
||||
* (which is == MASTER_START) into the destination directory named CURRENT.
|
||||
*/
|
||||
|
||||
DoCopy(master, current, depth)
|
||||
char *master; /* The source directory. */
|
||||
char *current; /* The destination directory. */
|
||||
int depth;
|
||||
{
|
||||
struct stat stat_master, stat_current;
|
||||
char **master_pointer, **current_pointer;
|
||||
char **master_names, **current_names;
|
||||
char *master_end, *current_end;
|
||||
char *master_name_buf, *current_name_buf;
|
||||
master_end = master + strlen(master);
|
||||
current_end = current + strlen(current);
|
||||
|
||||
/* Get rid of terminal '/' */
|
||||
if (master_end[-1] == '/' && master != master_end - 1)
|
||||
*--master_end = 0;
|
||||
if (current_end[-1] == '/' && current != current_end - 1)
|
||||
*--current_end = 0;
|
||||
|
||||
if (depth >= MAX_DEPTH) {
|
||||
fprintf(stderr,
|
||||
"Nesting too deep (depth %d at %s). Probable circularity.\n",
|
||||
depth, master);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
master_name_buf = savedir(master, 500);
|
||||
if (master_name_buf == NULL) {
|
||||
fprintf(stderr, "Not enough memory or no such directory: %s\n",
|
||||
master);
|
||||
exit(-1);
|
||||
}
|
||||
current_name_buf = savedir(current, 500);
|
||||
if (current_name_buf == NULL) {
|
||||
fprintf(stderr, "Not enough memory or no such directory: %s\n",
|
||||
current);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
master_names = get_name_pointers(master_name_buf);
|
||||
current_names = get_name_pointers(current_name_buf);
|
||||
|
||||
master_pointer = master_names;
|
||||
current_pointer = current_names;
|
||||
for (;;) {
|
||||
int cmp, ipat;
|
||||
int in_master, in_current;
|
||||
char *cur_name;
|
||||
if (*master_pointer == NULL && *current_pointer == NULL)
|
||||
break;
|
||||
if (*master_pointer == NULL) cmp = 1;
|
||||
else if (*current_pointer == NULL) cmp = -1;
|
||||
else cmp = strcmp(*master_pointer, *current_pointer);
|
||||
if (cmp < 0) { /* file only exists in master directory */
|
||||
in_master = 1; in_current = 0;
|
||||
} else if (cmp == 0) { /* file exists in both directories */
|
||||
in_master = 1; in_current = 1;
|
||||
} else { /* file only exists in current directory */
|
||||
in_current = 1; in_master = 0;
|
||||
}
|
||||
cur_name = in_master ? *master_pointer : *current_pointer;
|
||||
sprintf(master_end, "/%s", cur_name);
|
||||
sprintf(current_end, "/%s", cur_name);
|
||||
for (ipat = 0; ipat < exclude_count; ipat++) {
|
||||
char *pat = exclude_patterns[ipat];
|
||||
char *cur;
|
||||
if (strchr(pat, '/')) cur = current + 2; /* Skip initial "./" */
|
||||
else cur = cur_name;
|
||||
if (wildmat(cur, pat)) goto skip;
|
||||
}
|
||||
if (in_master)
|
||||
if (lstat(master, &stat_master) != 0) fatal("stat failed");
|
||||
if (in_current)
|
||||
if (lstat(current, &stat_current) != 0) fatal("stat failed");
|
||||
if (in_current && !in_master) {
|
||||
if (S_ISLNK(stat_current.st_mode))
|
||||
if (unlink(current)) {
|
||||
fprintf(stderr, "Failed to remove symbolic link %s.\n",
|
||||
current);
|
||||
}
|
||||
else
|
||||
fprintf(stderr, "Removed symbolic link %s.\n",
|
||||
current);
|
||||
else {
|
||||
fprintf(stderr,
|
||||
"The file %s does not exist in the master tree.\n",
|
||||
current);
|
||||
}
|
||||
}
|
||||
else if (S_ISDIR(stat_master.st_mode)
|
||||
&& strcmp(cur_name, "RCS") != 0
|
||||
&& strcmp(cur_name, "SCCS") != 0) {
|
||||
if (!in_current) {
|
||||
if (mkdir(current, 0775)) fatal("mkdir failed");
|
||||
}
|
||||
else if (stat(current, &stat_current)) fatal("stat failed");
|
||||
if (!in_current || stat_current.st_dev != stat_master.st_dev
|
||||
|| stat_current.st_ino != stat_master.st_ino)
|
||||
DoCopy(master, current, depth+1);
|
||||
else
|
||||
fprintf(stderr, "Link %s is the same as directory %s.\n",
|
||||
current, master);
|
||||
}
|
||||
else {
|
||||
if (!in_current)
|
||||
MakeLink(master, current, depth);
|
||||
else if (!S_ISLNK(stat_current.st_mode)) {
|
||||
fprintf(stderr, "Existing file %s is not a symbolc link.\n",
|
||||
current);
|
||||
} else {
|
||||
if (stat(current, &stat_current) || stat(master, &stat_master))
|
||||
fatal("stat failed");
|
||||
if (stat_current.st_dev != stat_master.st_dev
|
||||
|| stat_current.st_ino != stat_master.st_ino) {
|
||||
fprintf(stderr, "Fixing incorrect symbolic link %s.\n",
|
||||
current);
|
||||
if (unlink(current)) {
|
||||
fprintf(stderr, "Failed to remove symbolic link %s.\n",
|
||||
current);
|
||||
}
|
||||
else
|
||||
MakeLink(master, current, depth);
|
||||
}
|
||||
}
|
||||
}
|
||||
skip:
|
||||
if (in_master) master_pointer++;
|
||||
if (in_current) current_pointer++;
|
||||
}
|
||||
|
||||
free(master_names); free(current_names);
|
||||
free(master_name_buf); free(current_name_buf);
|
||||
}
|
||||
125
cde/config/util/mkshadow/savedir.c
Normal file
125
cde/config/util/mkshadow/savedir.c
Normal file
@@ -0,0 +1,125 @@
|
||||
/* $XConsortium: savedir.c,v 1.1 94/04/13 18:26:54 rws Exp $ */
|
||||
/* savedir.c -- save the list of files in a directory in a string
|
||||
Copyright 1990, 1993 Free Software Foundation, Inc.
|
||||
|
||||
Permission to use, copy, modify, and distribute this program for
|
||||
any purpose and without fee is hereby granted, provided that this
|
||||
copyright and permission notice appear on all copies, and that
|
||||
notice be given that copying and distribution is by permission of
|
||||
the Free Software Foundation. The Free Software Foundation makes
|
||||
no representations about the suitability of this software for any
|
||||
purpose. It is provided "as is" without expressed or implied
|
||||
warranty.
|
||||
|
||||
(The FSF has modified its usual distribution terms, for this file,
|
||||
as a courtesy to the X project.) */
|
||||
|
||||
/* Written by David MacKenzie <djm@ai.mit.edu>.
|
||||
Modified to use <dirent.h> by default. Per Bothner <bothner@cygnus.com>. */
|
||||
|
||||
#include <sys/types.h>
|
||||
#if !defined(DIRECT) && !defined(BSD)
|
||||
#include <dirent.h>
|
||||
#define NLENGTH(direct) (strlen((direct)->d_name))
|
||||
#else
|
||||
#undef dirent
|
||||
#define dirent direct
|
||||
#define NLENGTH(direct) ((direct)->d_namlen)
|
||||
#ifdef BSD
|
||||
#include <sys/dir.h>
|
||||
#else
|
||||
#ifdef SYSNDIR
|
||||
#include <sys/ndir.h>
|
||||
#else
|
||||
#include <ndir.h>
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(VOID_CLOSEDIR) || defined(BSD)
|
||||
/* Fake a return value. */
|
||||
#define CLOSEDIR(d) (closedir (d), 0)
|
||||
#else
|
||||
#define CLOSEDIR(d) closedir (d)
|
||||
#endif
|
||||
|
||||
#ifdef STDC_HEADERS
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#else
|
||||
char *malloc ();
|
||||
char *realloc ();
|
||||
int strlen ();
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
char *stpcpy ();
|
||||
|
||||
/* Return a freshly allocated string containing the filenames
|
||||
in directory DIR, separated by '\0' characters;
|
||||
the end is marked by two '\0' characters in a row.
|
||||
NAME_SIZE is the number of bytes to initially allocate
|
||||
for the string; it will be enlarged as needed.
|
||||
Return NULL if DIR cannot be opened or if out of memory. */
|
||||
|
||||
char *
|
||||
savedir (dir, name_size)
|
||||
char *dir;
|
||||
unsigned name_size;
|
||||
{
|
||||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
char *name_space;
|
||||
char *namep;
|
||||
|
||||
dirp = opendir (dir);
|
||||
if (dirp == NULL)
|
||||
return NULL;
|
||||
|
||||
name_space = (char *) malloc (name_size);
|
||||
if (name_space == NULL)
|
||||
{
|
||||
closedir (dirp);
|
||||
return NULL;
|
||||
}
|
||||
namep = name_space;
|
||||
|
||||
while ((dp = readdir (dirp)) != NULL)
|
||||
{
|
||||
/* Skip "." and ".." (some NFS filesystems' directories lack them). */
|
||||
if (dp->d_name[0] != '.'
|
||||
|| (dp->d_name[1] != '\0'
|
||||
&& (dp->d_name[1] != '.' || dp->d_name[2] != '\0')))
|
||||
{
|
||||
unsigned size_needed = (namep - name_space) + NLENGTH (dp) + 2;
|
||||
|
||||
if (size_needed > name_size)
|
||||
{
|
||||
char *new_name_space;
|
||||
|
||||
while (size_needed > name_size)
|
||||
name_size += 1024;
|
||||
|
||||
new_name_space = realloc (name_space, name_size);
|
||||
if (new_name_space == NULL)
|
||||
{
|
||||
closedir (dirp);
|
||||
return NULL;
|
||||
}
|
||||
namep += new_name_space - name_space;
|
||||
name_space = new_name_space;
|
||||
}
|
||||
strcpy (namep, dp->d_name);
|
||||
namep += strlen (namep) + 1;
|
||||
}
|
||||
}
|
||||
*namep = '\0';
|
||||
if (CLOSEDIR (dirp))
|
||||
{
|
||||
free (name_space);
|
||||
return NULL;
|
||||
}
|
||||
return name_space;
|
||||
}
|
||||
167
cde/config/util/mkshadow/wildmat.c
Normal file
167
cde/config/util/mkshadow/wildmat.c
Normal file
@@ -0,0 +1,167 @@
|
||||
/* $XConsortium: wildmat.c,v 1.2 94/04/13 18:40:59 rws Exp $ */
|
||||
/*
|
||||
**
|
||||
** Do shell-style pattern matching for ?, \, [], and * characters.
|
||||
** Might not be robust in face of malformed patterns; e.g., "foo[a-"
|
||||
** could cause a segmentation violation. It is 8bit clean.
|
||||
**
|
||||
** Written by Rich $alz, mirror!rs, Wed Nov 26 19:03:17 EST 1986.
|
||||
** Rich $alz is now <rsalz@bbn.com>.
|
||||
** April, 1991: Replaced mutually-recursive calls with in-line code
|
||||
** for the star character.
|
||||
**
|
||||
** Special thanks to Lars Mathiesen <thorinn@diku.dk> for the ABORT code.
|
||||
** This can greatly speed up failing wildcard patterns. For example:
|
||||
** pattern: -*-*-*-*-*-*-12-*-*-*-m-*-*-*
|
||||
** text 1: -adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1
|
||||
** text 2: -adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1
|
||||
** Text 1 matches with 51 calls, while text 2 fails with 54 calls. Without
|
||||
** the ABORT, then it takes 22310 calls to fail. Ugh. The following
|
||||
** explanation is from Lars:
|
||||
** The precondition that must be fulfilled is that DoMatch will consume
|
||||
** at least one character in text. This is true if *p is neither '*' nor
|
||||
** '\0'.) The last return has ABORT instead of FALSE to avoid quadratic
|
||||
** behaviour in cases like pattern "*a*b*c*d" with text "abcxxxxx". With
|
||||
** FALSE, each star-loop has to run to the end of the text; with ABORT
|
||||
** only the last one does.
|
||||
**
|
||||
** Once the control of one instance of DoMatch enters the star-loop, that
|
||||
** instance will return either TRUE or ABORT, and any calling instance
|
||||
** will therefore return immediately after (without calling recursively
|
||||
** again). In effect, only one star-loop is ever active. It would be
|
||||
** possible to modify the code to maintain this context explicitly,
|
||||
** eliminating all recursive calls at the cost of some complication and
|
||||
** loss of clarity (and the ABORT stuff seems to be unclear enough by
|
||||
** itself). I think it would be unwise to try to get this into a
|
||||
** released version unless you have a good test data base to try it out
|
||||
** on.
|
||||
*/
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#define ABORT -1
|
||||
|
||||
|
||||
/* What character marks an inverted character class? */
|
||||
#define NEGATE_CLASS '^'
|
||||
/* Is "*" a common pattern? */
|
||||
#define OPTIMIZE_JUST_STAR
|
||||
/* Do tar(1) matching rules, which ignore a trailing slash? */
|
||||
#undef MATCH_TAR_PATTERN
|
||||
|
||||
|
||||
/*
|
||||
** Match text and p, return TRUE, FALSE, or ABORT.
|
||||
*/
|
||||
static int
|
||||
DoMatch(text, p)
|
||||
register char *text;
|
||||
register char *p;
|
||||
{
|
||||
register int last;
|
||||
register int matched;
|
||||
register int reverse;
|
||||
|
||||
for ( ; *p; text++, p++) {
|
||||
if (*text == '\0' && *p != '*')
|
||||
return ABORT;
|
||||
switch (*p) {
|
||||
case '\\':
|
||||
/* Literal match with following character. */
|
||||
p++;
|
||||
/* FALLTHROUGH */
|
||||
default:
|
||||
if (*text != *p)
|
||||
return FALSE;
|
||||
continue;
|
||||
case '?':
|
||||
/* Match anything. */
|
||||
continue;
|
||||
case '*':
|
||||
while (*++p == '*')
|
||||
/* Consecutive stars act just like one. */
|
||||
continue;
|
||||
if (*p == '\0')
|
||||
/* Trailing star matches everything. */
|
||||
return TRUE;
|
||||
while (*text)
|
||||
if ((matched = DoMatch(text++, p)) != FALSE)
|
||||
return matched;
|
||||
return ABORT;
|
||||
case '[':
|
||||
reverse = p[1] == NEGATE_CLASS ? TRUE : FALSE;
|
||||
if (reverse)
|
||||
/* Inverted character class. */
|
||||
p++;
|
||||
for (last = 0400, matched = FALSE; *++p && *p != ']'; last = *p)
|
||||
/* This next line requires a good C compiler. */
|
||||
if (*p == '-' ? *text <= *++p && *text >= last : *text == *p)
|
||||
matched = TRUE;
|
||||
if (matched == reverse)
|
||||
return FALSE;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MATCH_TAR_PATTERN
|
||||
if (*text == '/')
|
||||
return TRUE;
|
||||
#endif /* MATCH_TAR_ATTERN */
|
||||
return *text == '\0';
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** User-level routine. Returns TRUE or FALSE.
|
||||
*/
|
||||
int
|
||||
wildmat(text, p)
|
||||
char *text;
|
||||
char *p;
|
||||
{
|
||||
#ifdef OPTIMIZE_JUST_STAR
|
||||
if (p[0] == '*' && p[1] == '\0')
|
||||
return TRUE;
|
||||
#endif /* OPTIMIZE_JUST_STAR */
|
||||
return DoMatch(text, p) == TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef TEST
|
||||
#include <stdio.h>
|
||||
|
||||
/* Yes, we use gets not fgets. Sue me. */
|
||||
extern char *gets();
|
||||
|
||||
|
||||
main()
|
||||
{
|
||||
char p[80];
|
||||
char text[80];
|
||||
|
||||
printf("Wildmat tester. Enter pattern, then strings to test.\n");
|
||||
printf("A blank line gets prompts for a new pattern; a blank pattern\n");
|
||||
printf("exits the program.\n");
|
||||
|
||||
for ( ; ; ) {
|
||||
printf("\nEnter pattern: ");
|
||||
(void)fflush(stdout);
|
||||
if (gets(p) == NULL || p[0] == '\0')
|
||||
break;
|
||||
for ( ; ; ) {
|
||||
printf("Enter text: ");
|
||||
(void)fflush(stdout);
|
||||
if (gets(text) == NULL)
|
||||
exit(0);
|
||||
if (text[0] == '\0')
|
||||
/* Blank line; go back and get a new pattern. */
|
||||
break;
|
||||
printf(" %s\n", wildmat(text, p) ? "YES" : "NO");
|
||||
}
|
||||
}
|
||||
|
||||
exit(0);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
#endif /* TEST */
|
||||
90
cde/config/util/syminst.sh
Executable file
90
cde/config/util/syminst.sh
Executable file
@@ -0,0 +1,90 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# syminst - install with a symbolic link back to the build tree
|
||||
#
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
doit="${DOITPROG-}"
|
||||
|
||||
|
||||
# put in absolute paths if you don't have them in your path; or use env. vars.
|
||||
|
||||
lnprog="${LNPROG-ln -s}"
|
||||
rmprog="${RMPROG-rm}"
|
||||
|
||||
instcmd="$lnprog"
|
||||
rmcmd="$rmprog -f"
|
||||
srcdir=`pwd`/
|
||||
src=""
|
||||
dst=""
|
||||
|
||||
while [ x"$1" != x ]; do
|
||||
case $1 in
|
||||
-c) shift
|
||||
continue;;
|
||||
|
||||
-m) shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-o) shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-g) shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-s) shift
|
||||
continue;;
|
||||
|
||||
-DIR) srcdir=`echo $2 | sed 's;/\./;/;g'`/
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
*) if [ x"$src" = x ]
|
||||
then
|
||||
src=$1
|
||||
else
|
||||
dst=$1
|
||||
fi
|
||||
shift
|
||||
continue;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ x"$src" = x ]
|
||||
then
|
||||
echo "syminst: no input file specified"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ x"$dst" = x ]
|
||||
then
|
||||
echo "syminst: no destination specified"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# if destination is a directory, append the input filename; if your system
|
||||
# does not like double slashes in filenames, you may need to add some logic
|
||||
|
||||
if [ -d $dst ]
|
||||
then
|
||||
dst="$dst"/`basename $src`
|
||||
fi
|
||||
|
||||
case $src in
|
||||
/*) srcdir=""
|
||||
instcmd=cp;;
|
||||
esac
|
||||
|
||||
# get rid of the old one and mode the new one in
|
||||
|
||||
$doit $rmcmd $dst
|
||||
$doit $instcmd $srcdir$src $dst
|
||||
|
||||
exit 0
|
||||
28
cde/config/util/x11mf.sh
Executable file
28
cde/config/util/x11mf.sh
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# generate a Makefile within the build tree
|
||||
#
|
||||
# usage: x11mf [treedir]
|
||||
#
|
||||
|
||||
if [ x$1 != x ]; then
|
||||
tree=$1
|
||||
else
|
||||
tree=/x11
|
||||
fi
|
||||
|
||||
dir=`pwd`
|
||||
top=`(cd $tree; /bin/pwd)`
|
||||
intree=no
|
||||
|
||||
case $dir in
|
||||
$top*) intree=yes;;
|
||||
esac
|
||||
|
||||
if [ $intree != yes ]; then
|
||||
echo "$0: Must be underneath $tree"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
(cd ..; make SUBDIRS=`basename $dir` Makefiles)
|
||||
58
cde/config/util/xmkmf.cpp
Normal file
58
cde/config/util/xmkmf.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
XCOMM!/bin/sh
|
||||
|
||||
XCOMM
|
||||
XCOMM make a Makefile from an Imakefile from inside or outside the sources
|
||||
XCOMM
|
||||
XCOMM $XConsortium: xmkmf.cpp /main/22 1996/09/28 16:17:05 rws $
|
||||
|
||||
usage="usage: $0 [-a] [top_of_sources_pathname [current_directory]]"
|
||||
|
||||
configdirspec=CONFIGDIRSPEC
|
||||
topdir=
|
||||
curdir=.
|
||||
do_all=
|
||||
|
||||
case "$1" in
|
||||
-a)
|
||||
do_all="yes"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
|
||||
case $# in
|
||||
0) ;;
|
||||
1) topdir=$1 ;;
|
||||
2) topdir=$1 curdir=$2 ;;
|
||||
*) echo "$usage" 1>&2; exit 1 ;;
|
||||
esac
|
||||
|
||||
case "$topdir" in
|
||||
-*) echo "$usage" 1>&2; exit 1 ;;
|
||||
esac
|
||||
|
||||
if [ -f Makefile ]; then
|
||||
echo mv -f Makefile Makefile.bak
|
||||
mv -f Makefile Makefile.bak
|
||||
fi
|
||||
|
||||
if [ "$topdir" = "" ]; then
|
||||
args="-DUseInstalled "$configdirspec
|
||||
else
|
||||
args="-I$topdir/config/cf -DTOPDIR=$topdir -DCURDIR=$curdir"
|
||||
fi
|
||||
|
||||
echo imake $args
|
||||
case "$do_all" in
|
||||
yes)
|
||||
imake $args &&
|
||||
echo "make Makefiles" &&
|
||||
make Makefiles &&
|
||||
echo "make includes" &&
|
||||
make includes &&
|
||||
echo "make depend" &&
|
||||
make depend
|
||||
;;
|
||||
*)
|
||||
imake $args
|
||||
;;
|
||||
esac
|
||||
82
cde/config/util/xmkmf.man
Normal file
82
cde/config/util/xmkmf.man
Normal file
@@ -0,0 +1,82 @@
|
||||
.\" $TOG: xmkmf.man /main/9 1998/02/06 11:25:04 kaleb $
|
||||
.\" Copyright (c) 1993, 1994, 1998 The Open Group
|
||||
.\"
|
||||
.\" All Rights Reserved.
|
||||
.\"
|
||||
.\" The above copyright notice and this permission notice shall be included in
|
||||
.\" all copies or substantial portions of the Software.
|
||||
.\"
|
||||
.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
.\" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
.\" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
.\" THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
.\" WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
.\" OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
.\" SOFTWARE.
|
||||
.\"
|
||||
.\" Except as contained in this notice, the name of The Open Group shall not
|
||||
.\" be used in advertising or otherwise to promote the sale, use or other
|
||||
.\" dealing in this Software without prior written authorization from The
|
||||
.\" Open Group.
|
||||
.TH XMKMF 1 "Release 6.4" "X Version 11"
|
||||
.SH NAME
|
||||
xmkmf \- create a Makefile from an Imakefile
|
||||
.SH SYNOPSIS
|
||||
.B xmkmf
|
||||
[ -a ] [
|
||||
.I topdir
|
||||
[
|
||||
.I curdir
|
||||
] ]
|
||||
.SH DESCRIPTION
|
||||
The
|
||||
.I xmkmf
|
||||
command is the normal way to create a
|
||||
.I Makefile
|
||||
from an
|
||||
.I Imakefile
|
||||
shipped with third-party software.
|
||||
.PP
|
||||
When invoked with no arguments in a directory containing an
|
||||
.I Imakefile,
|
||||
the
|
||||
.I imake
|
||||
program is run with arguments appropriate for your system
|
||||
(configured into
|
||||
.I xmkmf
|
||||
when X was built) and generates a
|
||||
.I Makefile.
|
||||
.PP
|
||||
When invoked with the
|
||||
.I \-a
|
||||
option,
|
||||
.I xmkmf
|
||||
builds the
|
||||
.I Makefile
|
||||
in the current directory, and then automatically executes
|
||||
``make Makefiles'' (in case there are subdirectories),
|
||||
``make includes'',
|
||||
and ``make depend'' for you.
|
||||
This is the normal way to configure software that is outside
|
||||
the X Consortium build tree.
|
||||
.PP
|
||||
If working inside the X Consortium build tree (unlikely unless you
|
||||
are an X developer, and even then this option is never really used), the
|
||||
.I topdir
|
||||
argument should be specified as the relative pathname from the
|
||||
current directory to the top of the build tree. Optionally,
|
||||
.I curdir
|
||||
may be specified as a relative pathname from the top of the build
|
||||
tree to the current directory. It is necessary to supply
|
||||
.I curdir
|
||||
if the current directory has subdirectories, or the
|
||||
.I Makefile
|
||||
will not be able to build the subdirectories.
|
||||
If a
|
||||
.I topdir
|
||||
is given,
|
||||
.I xmkmf
|
||||
assumes nothing is installed on your system and looks for files in
|
||||
the build tree instead of using the installed versions.
|
||||
.SH "SEE ALSO"
|
||||
imake(1)
|
||||
Reference in New Issue
Block a user