1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

Build system: make SHOPT_* editable again; allow indenting Mamfiles

The build system is adapted to make SHOPT_* compile-time options
editable without nmake. We can now easily change ksh's compile-time
options by editing src/cmd/ksh93/SHOPT.sh. The bin/package script
is adapted to turn these into compile flags. This resolves the most
important drawback of not using nmake.

Also, mamake now has support for indented Mam (Make Abstract
Machine) code. Only one type of block (make...done) is supported in
Mamfiles, so they are easy to indent automatically. A script to
(re)do this is included.

Since nmake is not going to be restored (it has too many problems
that no one is interested in fixing), this at least makes mamake
significantly easier to work with.

The Makefiles are deleted. They may still be handy for reference to
understand the Mamfiles, but they haven't actually matched the
Mamfiles for a while -- and you can still look in the git history.

Deleting them requires some adaptations to bin/package and mamake.c
because, even though they do not use those files, they still looked
for them to decide whether to build code in a directory.

Finally, this commit incorporates some #pragmas for clang to
suppress annoying warnings about the coding style used in this
historic code base. (gcc does not complain so much.)

src/cmd/ksh93/SHOPT.sh:
- Added.

bin/package, src/cmd/INIT/package.sh:
- cd into our own directory in case we were run from another dir.
- $makefiles: only look for Mamfiles.
- Add ksh compile-options via KSH_SHOPTFLAGS. Include SHOPT.sh.
- make_recurse(): Do not write a missing Makefile.
- finalize environment: Look for Mamfiles instead of Makefiles.

src/cmd/INIT/mamake.c:
- Tell clang to suppress annoying warnings about coding style.
- Update version string and self-documentation.
- input(): Add support for indented Mam code by skipping initial
  whitespace on each input line.
- files[]: Instead of looking for various of Makefiles to decide
  where to build, only look for Mamfiles.

src/Makefile, src/cmd/INIT/Makefile, src/cmd/Makefile,
src/cmd/builtin/Makefile, src/cmd/ksh93/Makefile, src/lib/Makefile,
src/lib/libast/Makefile, src/lib/libcmd/Makefile,
src/lib/libdll/Makefile, src/lib/libsum/Makefile:
- Removed.

src/Mamfile, src/cmd/INIT/Mamfile, src/cmd/Mamfile,
src/cmd/builtin/Mamfile, src/cmd/ksh93/Mamfile, src/lib/Mamfile,
src/lib/libast/Mamfile, src/lib/libcmd/Mamfile,
src/lib/libdll/Mamfile, src/lib/libsum/Mamfile:
- Indent the code with tabs.
- In ksh93/Mamfile, add ${KSH_SHOPT_FLAGS} to every $CC command.
- In ksh93/Mamfile, add "prev SHOPT.sh" for every *.o file
  so they are rebuilt whenever SHOPT.sh changes.

bin/Mamfile_indent:
- Added, in case someone wants to re-indent a Mamfile.

src/cmd/INIT/proto.c, src/cmd/INIT/ratz.c, src/cmd/INIT/release.c,
src/lib/libast/features/common, src/lib/libast/include/ast.h:
- Tell clang to suppress annoying warnings about coding style that
  it disapproves of (mainly concerning the use of parentheses).

src/cmd/INIT/cc.darwin, src/cmd/INIT/cc.freebsd,
src/cmd/INIT/cc.openbsd:
- Remove now-redundant clang warning suppression flags.

Resolves: https://github.com/ksh93/ksh/issues/60
This commit is contained in:
Martijn Dekker 2021-01-22 23:23:14 +00:00
parent 47468f56c2
commit 6cc2f6a0af
35 changed files with 11768 additions and 12763 deletions

View file

@ -1,346 +0,0 @@
/*
* initialization for all packages
*/
ID = ast
SILENT = /* this component builds silent -- this prevents us from using it while building it */
:PACKAGE: license=$(ID)
LICENSE = since=1994,author=gsf
PACKAGEROOT = $(INSTALLROOT:T=F:P=L*:O=n)
hurl :: hurl.sh LICENSE=since=2003,author=gsf
iffe :: iffe.sh LICENSE=since=1994,author=gsf+kpv
mktest :: mktest.sh LICENSE=since=2005,author=gsf
package :: package.sh
regress :: regress.sh LICENSE=since=1995,author=gsf
rt :: rt.sh LICENSE=since=2005,author=gsf
$(PACKAGEROOT)/bin :INSTALLDIR: execrate ignore mamprobe package silent
crossexec :: crossexec.sh
ditto :: ditto.sh LICENSE=since=2001,author=gsf+ek
execrate :: execrate.sh LICENSE=since=2002,author=gsf
filter :: filter.sh
ignore :: ignore.sh
silent :: silent.sh
$(PACKAGEROOT)/lib/package :INSTALLDIR: package.mk CONVERT.mk
$(LIBDIR)/make :INSTALLDIR: package.mk PROBE.mk TEST.mk WWW.mk \
MSGFUN.mk MSGKEY.mk MAPLIB.mk
:TEST: iffe mamake
cc ld ldd :PACKAGE_INIT: mamake.c proto.c ratz.c release.c
:: RELEASE hosttype.tst p.c hello.c \
ar.ibm.risc \
cc.specialize cc.pentium4 \
ldd.cygwin.i386 \
cc.darwin.i386 cc.darwin.i386-64 cc.darwin ldd.darwin \
cc.hp.ia64 cc.hp.pa cc.hp.pa64 ld.hp.pa ldd.hp.pa \
cc.ibm.risc cc.ibm.risc.gcc ldd.ibm.risc \
cc.linux.ia64-icc cc.linux.i386-icc cc.linux.i386-64-icc \
cc.lynxos.i386 cc.lynxos.ppc ldd.lynxos \
cc.mvs.390 cc.next.i386 cc.next.m68k ldd.mvs.390 \
cc.osf.alpha \
cc.sco.i386 \
cc.sgi.mips2 cc.sgi.mips3 cc.sgi.mips3-o32 cc.sgi.mips4 \
cc.sgi.mips4-n32 ldd.sgi \
cc.unix.mc68k cc.unixware.i386
LICENSE : .DONTCARE
if ! CC.HOSTTYPE
CC.HOSTTYPE := $(_hosttype_|HOSTTYPE)
end
$(BINDIR)/mkdir :INSTALL: mkdir.sh
if test ! -x $(<) -a -x /bin/mkdir
then mkdir -p 2>/dev/null || :
if test -d ./-p
then rmdir ./-p
cp $(*) $(<)
chmod +x $(<)
fi
fi
/*
* ksh93 function search on PATH
* ksh93 builtin command library -lcmd
* ksh93 ld library path search on PATH
*/
$(BINDIR)/.paths :INSTALL: (CC.DIALECT)
if test ! -f $(<) -o -w $(<)
then N='$("\n")'
H=$(CC.HOSTTYPE)
P="$(-mam:??$(.GETCONF LIBPATH:/:/ /G:/,/ : /G:Q)?)"
b= f= h= l= n= p= u= B= L=
set : $P
while :
do while :
do case $1 in
'') break 2 ;;
:) shift; break ;;
esac
shift
done
case $# in
0|1) break ;;
esac
case $L in
?*) L="$L|" ;;
esac
L="$L$2=*"
B=$1
done
if test -f $(<)
then while read x
do case $x in
*\$\(\"*) break # to fix 2012-06-18 edit botch #
;;
'#'?*) case $h in
'') h=$x ;;
esac
;;
$L) l=$x
;;
*BUILTIN_LIB=*) b=$x
;;
*FPATH=*) f=$x
;;
*PLUGIN_LIB=*) p=$x
;;
*) case $u in
?*) u=$u$N ;;
esac
u=$u$x
;;
esac
done < $(<)
fi
ifs=$IFS
m=
case $p in
?*) b=
;;
esac
case $b in
?*) IFS='='
set $b
IFS=$ifs
shift
p="PLUGIN_LIB=$*"
case $b in
[Nn][Oo]*) p=no$p ;;
esac
m=1
;;
esac
case $f in
'') f="FPATH=../fun"
m=1
;;
esac
case $h in
'') h='# use { no NO } prefix to permanently disable #' ;;
esac
case $l in
'') set x x : $P
l=
while :
do while :
do case $# in
0) break ;;
esac
x=$1
shift
case $x in
:) break ;;
esac
done
case $# in
0|1) break
;;
2) l=$2
;;
*) case "$H" in
$3) l=$2; break ;;
esac
;;
esac
done
case $l in
'') if test -x /lib/dld.sl
then l=SHLIB_PATH
elif test -x /usr/lib/dyld
then l=DYLD_LIBRARY_PATH
else case "$H" in
ibm.*|mvs.*)
l=LIBPATH
;;
sgi.mips3)
l=LD_LIBRARYN32_PATH
;;
sgi.mips4)
l=LD_LIBRARYN64_PATH
;;
*) l=LD_LIBRARY_PATH
;;
esac
fi
;;
esac
case $l in
?*) case $B in
'') B=lib ;;
esac
l="$l=../$B"
m=1
;;
esac
;;
esac
case $p in
'') p="PLUGIN_LIB=cmd"
case '$(CC.DIALECT:N=*EXPORT=[AD]LL*)' in
'') p=no$p ;;
esac
m=1
;;
esac
case $m in
1) case $u in
?*) u=$N$u ;;
esac
echo "$h$N$p$N$f$N$l$u" > $(<)
;;
esac
fi
/*
* probe initialization
*/
for T C+probe C+make+probe.lcl C+pp+probe.lcl
if T == "*.lcl"
$(T) : .DONTCARE
end
$(LIBDIR)/probe/$(T:C,+,/,G) :INSTALL: $(T)
end
$(LIBDIR)/probe/C/mam/probe :INSTALL: mprobe
mprobe :: mprobe.sh
$(LIBDIR)/probe/C/make :INSTALLDIR: probe probe.ini
probe.sh : C+probe make.probe
cat $(*) > $(<)
probe :: probe.sh
probe.ini : (CC.HOSTTYPE) probe.win32
t=$(CC.HOSTTYPE)
ifs=$IFS
IFS=.
set x $t
IFS=$ifs
t=$2
set x $(*)
while :
do shift
case $# in
0) break ;;
esac
case $1 in
*probe.$t)
break
esac
done
case $1 in
?*) cmp -s $1 $(<) || cp $1 $(<) ;;
*) : > $(<)
esac
/*
* proto initialization
*/
$(INCLUDEDIR)/$(ID) :INSTALLDIR: prototyped.h
prototyped.h : $(BINDIR)/proto
proto -f /dev/null > h.$(tmp).h
if $(CMP) -s h.$(tmp).h $(<)
then $(RM) -f h.$(tmp).h
else $(MV) h.$(tmp).h $(<)
fi
/*
* check if -ldl is required
* this allows makefiles to use -ldl on all systems
*
* NOTE: this works around the sgi botch:
* (1) irix 5.* made -ldl optional but warned
* (2) irix 6.* has no -ldl
* (3) dynamic progs built on irix 5.* and using -ldl fail
* at runtime on irix 6.* because -ldl is not there
*/
dl :MAPLIB: dl.c
/*
* requiring these is a botch
*/
iconv :MAPLIB: iconv.c
w :MAPLIB: w.c w2.c
/*
* miscellaneous -l* checks
*/
intl :MAPLIB: intl.c
m :MAPLIB: m.c m2.c m3.c m4.c m5.c m6.c
nsl :MAPLIB: nsl.c
/*
* what was sco smoking
* almost all of gethost* are in -lnsl except gethostbyname which
* is in -lsocket which isn't needed to resolve socket() but seems
* to do the -lnsl job
*/
socket :MAPLIB: socket.c nsl.c
/*
* more substance abuse
* gdbm's ndbm "compatibility" doesn't supply <ndbm.h>, instead supplies
* <gdbm/ndbm.h> which provides K&R prototypes *and* it requires -lgdbm
* some <ndbm.h> implementations use -lndbm, others -ldbm, still others -lc
* this is why unix is starting to look like windows
* this map allows makefiles to use -ldbm on all systems
*
* and this just in: sometimes it's <gdbm-ndbm.h> and possibly -lgdbm_compat
*
* at least the -l* buck stops here
*/
dbm db - gdbm_compat - gdbm - ndbm - dbm :MAPLIB: db.c gdbm.c gdbm1.c gdbm2.c

File diff suppressed because it is too large Load diff

View file

@ -43,8 +43,7 @@ init) echo "cc: arguments expected" >&2
;;
cpp) $CC -E "$@"
;;
cc) $CC -D_ast_int8_t=int64_t -D_lib_memccpy \
-Wno-unused-value -Wno-parentheses -Wno-macro-redefined "$@"
cc) $CC -D_ast_int8_t=int64_t -D_lib_memccpy "$@"
;;
dll) $CC -Wl,-flat_namespace -dynamiclib -undefined dynamic_lookup "$@"
;;

View file

@ -6,7 +6,4 @@ case " $* " in
*" -dumpmachine "*) echo $HOSTTYPE; exit ;;
esac
exec /usr/bin/cc -P \
-Wno-unused-value \
-Wno-parentheses \
"$@"
exec /usr/bin/cc -P "$@"

View file

@ -6,7 +6,4 @@ case " $* " in
*" -dumpmachine "*) echo $HOSTTYPE; exit ;;
esac
exec /usr/bin/cc -P \
-Wno-unused-value \
-Wno-parentheses \
"$@"
exec /usr/bin/cc -P "$@"

View file

@ -18,6 +18,8 @@
* *
***********************************************************************/
#pragma prototyped
#pragma clang diagnostic ignored "-Wparentheses"
#pragma clang diagnostic ignored "-Wunused-value"
/*
* mamake -- MAM make
@ -25,7 +27,8 @@
* coded for portability
*/
static char id[] = "\n@(#)$Id: mamake (AT&T Research) 2011-08-31 $\0\n";
#define RELEASE_DATE "2021-01-21"
static char id[] = "\n@(#)$Id: mamake (AT&T Research/ksh93) " RELEASE_DATE " $\0\n";
#if _PACKAGE_ast
@ -33,17 +36,15 @@ static char id[] = "\n@(#)$Id: mamake (AT&T Research) 2011-08-31 $\0\n";
#include <error.h>
static const char usage[] =
"[-?\n@(#)$Id: mamake (AT&T Research) 2011-08-31 $\n]"
"[-?\n@(#)$Id: mamake (AT&T Research/ksh93) " RELEASE_DATE " $\n]"
USAGE_LICENSE
"[+NAME?mamake - make abstract machine make]"
"[+DESCRIPTION?\bmamake\b reads \amake abstract machine\a target and"
" prerequisite file descriptions from a mamfile (see \b-f\b) and executes"
" actions to update targets that are older than their prerequisites."
" Mamfiles are generated by the \b--mam\b option of \bnmake\b(1) and"
" \bgmake\b(1) and are portable to environments that only have"
" Mamfiles are portable to environments that only have"
" \bsh\b(1) and \bcc\b(1).]"
"[+?In practice \bmamake\b is used to bootstrap build \bnmake\b(1) and"
" \bksh\b(1) in new environments. Mamfiles are used rather than"
"[+?Mamfiles are used rather than"
" old-\bmake\b makefiles because some features are not reliably supported"
" across all \bmake\b variants:]{"
" [+action execution?Multi-line actions are executed as a"
@ -1127,7 +1128,10 @@ input(void)
else if (*state.input && *(e = state.input + strlen(state.input) - 1) == '\n')
*e = 0;
state.sp->line++;
return state.input;
e = state.input;
while (isspace(*e))
e++; /* allow indentation */
return e;
}
/*
@ -1795,10 +1799,13 @@ scan(Dict_item_t* item, void* handle)
static char* files[] =
{
"Nmakefile",
"nmakefile",
"Makefile",
"makefile"
"Mamfile"
/* ksh 93u+m no longer uses these:
* "Nmakefile",
* "nmakefile",
* "Makefile",
* "makefile"
*/
};
/*

View file

@ -30,6 +30,29 @@ Bad*) echo "Cannot be run by zsh in native mode; use a sh symlink to zsh" >&2
exit 1 ;;
esac
unset CDPATH
case $0 in
-*)
echo "dodgy \$0: $0" >&2
exit 1 ;;
*/package)
mydir=`echo "$0" | sed 's,/package$,,'`
cd "$mydir" || exit
case $PWD in
*/bin) ;;
*) echo "this script must live in bin/" >&2
exit 1 ;;
esac
cd .. || exit
unset mydir ;;
package)
echo "this script must be invoked with a direct path, e.g. bin/package" >&2
exit 1 ;;
*)
echo "this script must be named 'package'" >&2
exit 1 ;;
esac
# shell checks
checksh()
{
@ -63,7 +86,7 @@ usr="/home"
lib="" # nee /usr/local/lib /usr/local/shlib
ccs="/usr/kvm /usr/ccs/bin"
org="gnu GNU"
makefiles="Mamfile Nmakefile nmakefile Makefile makefile"
makefiles="Mamfile" # ksh 93u+m no longer uses these: Nmakefile nmakefile Makefile makefile
env="HOSTTYPE NPROC PACKAGEROOT INSTALLROOT PATH"
checksum=md5sum
checksum_commands="$checksum md5"
@ -1404,6 +1427,20 @@ case $ksh_relflags in
assign="${assign:+$assign }KSH_RELFLAGS=\"\$ksh_relflags\"" ;;
esac
# Add ksh compile-options via KSH_SHOPTFLAGS.
SHOPT()
{
case $1 in
*=?*) ksh_shoptflags="${ksh_shoptflags:+$ksh_shoptflags }-DSHOPT_$1" ;;
esac
}
ksh_shoptflags=
. src/cmd/ksh93/SHOPT.sh # this script calls SHOPT() to set options
case $ksh_shoptflags in
?*) # add the extra flags as an argument to mamake
assign="${assign:+$assign }KSH_SHOPTFLAGS=\"\$ksh_shoptflags\"" ;;
esac
# grab action specific args
case $action in
@ -4036,12 +4073,6 @@ make_recurse() # dir
then return
fi
done
if test -d $1
then case $exec in
'') echo :MAKE: > $1/Makefile || exit ;;
*) $exec "echo :MAKE: > $1/Makefile" ;;
esac
fi
}
get() # host path [ file size ]
@ -7217,7 +7248,7 @@ update) # download the latest release.version for selected packages
use) # finalize the environment
x=:..
for d in `( cd $PACKAGEROOT; ls src/*/Makefile src/*/Nmakefile 2>/dev/null | sed 's,/[^/]*$,,' | sort -u )`
for d in `( cd $PACKAGEROOT; ls src/*/Mamfile 2>/dev/null | sed 's,/[^/]*$,,' | sort -u )`
do x=$x:$INSTALLROOT/$d
done
x=$x:$INSTALLROOT

View file

@ -17,6 +17,9 @@
* Glenn Fowler <gsf@research.att.com> *
* *
***********************************************************************/
#pragma clang diagnostic ignored "-Wparentheses"
#pragma clang diagnostic ignored "-Wunused-value"
#pragma clang diagnostic ignored "-Wstring-plus-int"
/* : : generated by proto : : */

View file

@ -4,6 +4,7 @@
* coded for portability
* _SEAR_* macros for win32 self extracting archives -- see sear(1).
*/
#pragma clang diagnostic ignored "-Wparentheses"
static char id[] = "\n@(#)$Id: ratz (Jean-loup Gailly, Mark Adler, Glenn Fowler) 1.2.3 2010-10-10 $\0\n";

View file

@ -18,6 +18,7 @@
* *
***********************************************************************/
#pragma prototyped
#pragma clang diagnostic ignored "-Wparentheses"
/*
* release -- list recent release changes

View file

@ -1 +0,0 @@
:MAKE:

View file

@ -1,7 +1,7 @@
info mam static
note component level :MAKE: equivalent
make install
make all
exec - ${MAMAKE} -r '*' ${MAMAKEARGS}
done all virtual
make all
exec - ${MAMAKE} -r '*' ${MAMAKEARGS}
done all virtual
done install virtual

View file

@ -1,90 +0,0 @@
/*
* standalone versions of -lcmd builtins
*/
:PACKAGE: ast cmd:space
LICENSE = since=1992,author=gsf+dgk
:ALL:
:: cmdlib.h builtin.c
CMD_BUILTIN ==
CMD_DYNAMIC ==
CMD_STANDALONE ==
LINKS = cp: ln mv cksum: md5sum sum
NOBIN = getconf
CAT = $(STDCAT|"cat")
CMP = $(STDCMP|"cmp") 2>/dev/null
CP = $(STDCP|"cp")
LN = $(STDLN|"ln")
RM = $(STDRM|"rm")
BUILTINS :COMMAND: cmdlist.h
$(SED) -e '/^CMDLIST(.*)$/!d' -e 's/CMDLIST(\(.*\))/\1/' $(NOBIN:C,.*,-e '/^&$/d',) $(LINKS:N!=*[:]:C,.*,-e '/^&$/d',) $(*)
.INIT : .builtin
.builtin : .MAKE .VIRTUAL .FORCE
local T I
if T = "$(NOBIN:D=$(BINDIR):B:S:T=F)"
{ $(RM) $(RMFLAGS) $(T) }
end
:ALL: $(BUILTINS)
T = -lcmd
if "$(PACKAGE_OPTIONS:N=optimize-space)" && "$(T:T=F)" == "-lcmd"
T := $(BUILTINS:O=1)
$(T) :: CMD_BUILTIN=1 CMD_DYNAMIC=1 builtin.c -lcmd -ldll
for I $(BUILTINS:O>1)
$(I) :LINK: $(T)
end
for I $(LINKS)
if I != "*:"
$(I) :LINK: $(T)
end
end
else
$(BINDIR) :INSTALLDIR: $(BUILTINS)
$(BUILTINS) : .COMMAND $(&$("%.c":T=SM%)) CMD_BUILTIN=b_$$(<:B) builtin.c $(*$("%.c":T=SM%))
$(CAT) $(*:N=*builtin.c) > $(<).c
$(RM) $(RMFLAGS) $(<)
$(@$("%.c":T=SM%):/.*builtin.c$/$(<).c/)
$(RM) $(RMFLAGS) $(<).c
for I $(LINKS)
if I == "*:"
T := $(I:/.$//)
else
$(I) :LINK: $(T)
end
end
end
":BUILTIN:" : .MAKE .OPERATOR
local T P
for T $(>)
if T == "*=*"
$(P).o : $(T)
elif T == "[-+]l*"
$(P) : $(T)
else
eval
$(T) :: CMD_STANDALONE=b_$(T) $(T).c
end
P := $(T)
end
end
:BUILTIN: dlls LICENSE=since=2002,author=gsf -ldll look mime \
pty LICENSE=since=2001,author=gsf+dgk -lutil \
nl LICENSE=since=2003,author=dgk asa od pr \
strings tr uudecode -luu uuencode -luu what who
dontcare -lutil
:: PROMO.mm RELEASE
:TEST: asa cat chmod chown cksum cmp cp cut date expr fmt head join ln \
look mkdir mkfifo mktemp mv nl od paste rm tail tr uniq uuencode wc

View file

@ -41,56 +41,56 @@ setv YACCFLAGS -d
make ${PACKAGEROOT}/lib/package/ast.lic
done ${PACKAGEROOT}/lib/package/ast.lic
make .INIT
make ${PACKAGE_ast_INCLUDE}/cmdlist.h
make ${PACKAGE_ast_INCLUDE}/prototyped.h implicit
done ${PACKAGE_ast_INCLUDE}/prototyped.h dontcare
done ${PACKAGE_ast_INCLUDE}/cmdlist.h
exec - sed -e '/^CMDLIST(.*)$/!d' -e 's/CMDLIST(\(.*\))/\1/' -e '/^getconf$/d' -e '/^ln$/d' -e '/^mv$/d' -e '/^md5sum$/d' -e '/^sum$/d' ${PACKAGE_ast_INCLUDE}/cmdlist.h
bind -lcmd
make ${PACKAGE_ast_INCLUDE}/cmdlist.h
make ${PACKAGE_ast_INCLUDE}/prototyped.h implicit
done ${PACKAGE_ast_INCLUDE}/prototyped.h dontcare
done ${PACKAGE_ast_INCLUDE}/cmdlist.h
exec - sed -e '/^CMDLIST(.*)$/!d' -e 's/CMDLIST(\(.*\))/\1/' -e '/^getconf$/d' -e '/^ln$/d' -e '/^mv$/d' -e '/^md5sum$/d' -e '/^sum$/d' ${PACKAGE_ast_INCLUDE}/cmdlist.h
bind -lcmd
done .INIT dontcare virtual
make install
make pty
make pty.o
make pty.c
make FEATURE/pty implicit
meta FEATURE/pty features/%>FEATURE/% features/pty pty
make features/pty
done features/pty
exec - iffe -v -c '${CC} ${mam_cc_FLAGS} ${KSH_RELFLAGS} ${CCFLAGS} ${LDFLAGS} -lm' ref ${mam_cc_L+-L${INSTALLROOT}/lib} -I${PACKAGE_ast_INCLUDE} -I${INSTALLROOT}/include ${mam_libast} ${mam_libcmd} : run features/pty
done FEATURE/pty generated
make ${PACKAGE_ast_INCLUDE}/ast_time.h implicit
done ${PACKAGE_ast_INCLUDE}/ast_time.h
prev ${PACKAGE_ast_INCLUDE}/vmalloc.h implicit
prev ${PACKAGE_ast_INCLUDE}/regex.h implicit
make ${PACKAGE_ast_INCLUDE}/proc.h implicit
prev ${PACKAGE_ast_INCLUDE}/ast.h implicit
prev ${PACKAGE_ast_INCLUDE}/prototyped.h implicit
done ${PACKAGE_ast_INCLUDE}/proc.h
prev ${PACKAGE_ast_INCLUDE}/error.h implicit
prev ${PACKAGE_ast_INCLUDE}/cmd.h implicit
done pty.c
meta pty.o %.c>%.o pty.c pty
prev pty.c
setv CMD_STANDALONE -DCMD_STANDALONE="b_pty"
setv LICENSE -DLICENSE="since=2001,author=gsf+dgk"
exec - ${CC} ${mam_cc_FLAGS} ${KSH_RELFLAGS} ${CCFLAGS} -I. -I${PACKAGE_ast_INCLUDE} -DERROR_CATALOG=\""builtin"\" -D_PACKAGE_ast -DCMD_STANDALONE=b_pty -DUSAGE_LICENSE=\""[-author?Glenn Fowler <gsf@research.att.com>][-author?David Korn <dgk@research.att.com>][-copyright?Copyright (c) 2001-2012 AT&T Intellectual Property][-license?http://www.eclipse.org/org/documents/epl-v10.html][--catalog?builtin]"\" -c pty.c
done pty.o generated
bind -lutil dontcare
setv CMD_STANDALONE -DCMD_STANDALONE="b_pty"
exec - ${CC} ${CCLDFLAGS} ${mam_cc_FLAGS} ${KSH_RELFLAGS} ${CCFLAGS} ${LDFLAGS} -lm ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -o pty pty.o ${mam_libutil} ${mam_libast} ${mam_libcmd}
done pty generated
make ${INSTALLROOT}/bin
exec - if silent test ! -d ${INSTALLROOT}/bin
exec - then mkdir -p ${INSTALLROOT}/bin
exec - fi
done ${INSTALLROOT}/bin generated
make ${INSTALLROOT}/bin/pty
prev pty
exec - test '' = 'pty' || ${STDCMP} 2>/dev/null -s pty ${INSTALLROOT}/bin/pty || { ${STDMV} ${INSTALLROOT}/bin/pty ${INSTALLROOT}/bin/pty.old 2>/dev/null || true; ${STDCP} pty ${INSTALLROOT}/bin/pty ;}
done ${INSTALLROOT}/bin/pty generated
make ${INSTALLROOT}/bin
exec - if silent test ! -d ${INSTALLROOT}/bin
exec - then mkdir -p ${INSTALLROOT}/bin
exec - fi
done ${INSTALLROOT}/bin virtual
make pty
make pty.o
make pty.c
make FEATURE/pty implicit
meta FEATURE/pty features/%>FEATURE/% features/pty pty
make features/pty
done features/pty
exec - iffe -v -c '${CC} ${mam_cc_FLAGS} ${KSH_RELFLAGS} ${CCFLAGS} ${LDFLAGS} -lm' ref ${mam_cc_L+-L${INSTALLROOT}/lib} -I${PACKAGE_ast_INCLUDE} -I${INSTALLROOT}/include ${mam_libast} ${mam_libcmd} : run features/pty
done FEATURE/pty generated
make ${PACKAGE_ast_INCLUDE}/ast_time.h implicit
done ${PACKAGE_ast_INCLUDE}/ast_time.h
prev ${PACKAGE_ast_INCLUDE}/vmalloc.h implicit
prev ${PACKAGE_ast_INCLUDE}/regex.h implicit
make ${PACKAGE_ast_INCLUDE}/proc.h implicit
prev ${PACKAGE_ast_INCLUDE}/ast.h implicit
prev ${PACKAGE_ast_INCLUDE}/prototyped.h implicit
done ${PACKAGE_ast_INCLUDE}/proc.h
prev ${PACKAGE_ast_INCLUDE}/error.h implicit
prev ${PACKAGE_ast_INCLUDE}/cmd.h implicit
done pty.c
meta pty.o %.c>%.o pty.c pty
prev pty.c
setv CMD_STANDALONE -DCMD_STANDALONE="b_pty"
setv LICENSE -DLICENSE="since=2001,author=gsf+dgk"
exec - ${CC} ${mam_cc_FLAGS} ${KSH_RELFLAGS} ${CCFLAGS} -I. -I${PACKAGE_ast_INCLUDE} -DERROR_CATALOG=\""builtin"\" -D_PACKAGE_ast -DCMD_STANDALONE=b_pty -DUSAGE_LICENSE=\""[-author?Glenn Fowler <gsf@research.att.com>][-author?David Korn <dgk@research.att.com>][-copyright?Copyright (c) 2001-2012 AT&T Intellectual Property][-license?http://www.eclipse.org/org/documents/epl-v10.html][--catalog?builtin]"\" -c pty.c
done pty.o generated
bind -lutil dontcare
setv CMD_STANDALONE -DCMD_STANDALONE="b_pty"
exec - ${CC} ${CCLDFLAGS} ${mam_cc_FLAGS} ${KSH_RELFLAGS} ${CCFLAGS} ${LDFLAGS} -lm ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -o pty pty.o ${mam_libutil} ${mam_libast} ${mam_libcmd}
done pty generated
make ${INSTALLROOT}/bin
exec - if silent test ! -d ${INSTALLROOT}/bin
exec - then mkdir -p ${INSTALLROOT}/bin
exec - fi
done ${INSTALLROOT}/bin generated
make ${INSTALLROOT}/bin/pty
prev pty
exec - test '' = 'pty' || ${STDCMP} 2>/dev/null -s pty ${INSTALLROOT}/bin/pty || { ${STDMV} ${INSTALLROOT}/bin/pty ${INSTALLROOT}/bin/pty.old 2>/dev/null || true; ${STDCP} pty ${INSTALLROOT}/bin/pty ;}
done ${INSTALLROOT}/bin/pty generated
make ${INSTALLROOT}/bin
exec - if silent test ! -d ${INSTALLROOT}/bin
exec - then mkdir -p ${INSTALLROOT}/bin
exec - fi
done ${INSTALLROOT}/bin virtual
done install virtual

View file

@ -1,232 +0,0 @@
/*
* ksh makefile
*
* NOTE: since ksh 93u+m does not use/include nmake for various reasons,
* any changes here are ineffective and this is for reference only. Edit
* Mamfile instead (though it might still be good to update this too).
*/
SH := $(PWD:B:/[0-9]*$//:N=ksh*:-ksh) /* name of the shell program */
VERSION = 1.1
LICENSE = since=1982,author=dgk
CATALOG = libshell
ERROR_CONTEXT_T == Error_context_t /* workaround until switch from errorpush()/errorpop() => errorctx() */
RELEASE := $(SH:/.*sh//)
SHCOMP := shcomp$(RELEASE)
/*
* set these variables to 1 to enable, 0 to disable, null to probe
* override SHOPT_foo=1 can be placed one per line in the build dir Makeargs
*/
SHOPT_2DMATCH == 1 /* two dimensional .sh.match for ${var//pat/str} */
SHOPT_ACCT == /* accounting */
SHOPT_ACCTFILE == /* per user accounting info */
SHOPT_AUDIT == 1 /* enable auditing per SHOPT_AUDITFILE */
SHOPT_AUDITFILE == "/etc/ksh_audit" /* auditing file */
SHOPT_BGX == 1 /* one SIGCHLD trap per completed job */
SHOPT_BRACEPAT == 1 /* C-shell {...,...} expansions (, required) */
SHOPT_CMDLIB_HDR == /* -lcmd builtin list (<cmdlist.h>) */
SHOPT_CMDLIB_DIR == /* SHOPT_CMDLIB_HDR directory prefix (default "/opt/ast/bin") */
SHOPT_CRNL == /* accept <cr><nl> for <nl> */
SHOPT_DYNAMIC == 1 /* dynamic loading for builtins */
SHOPT_ECHOPRINT == /* make echo equivalent to print */
SHOPT_EDPREDICT == 1 /* predictive editing */
SHOPT_ESH == 1 /* emacs/gmacs edit mode */
SHOPT_FILESCAN == 1 /* fast file scan */
SHOPT_FIXEDARRAY == 1 /* fixed dimension indexed array */
SHOPT_HISTEXPAND == 1 /* csh-style history file expansions */
SHOPT_KIA == 1 /* shell information database generation */
SHOPT_MULTIBYTE == 1 /* multibyte character handling */
SHOPT_NAMESPACE == 1 /* allow namespaces */
SHOPT_OLDTERMIO == /* support both TCGETA and TCGETS */
SHOPT_OPTIMIZE == 1 /* optimize loop invariants */
SHOPT_PFSH == 0 /* solaris exec_attr(4) profile execution */
SHOPT_P_SUID == /* real uid's that require -p for set[ug]id */
SHOPT_RAWONLY == 1 /* make viraw the only vi mode */
SHOPT_REGRESS == /* enable __regress__ builtin and instrumented intercepts for testing */
SHOPT_REMOTE == /* enable --rc if running as a remote shell */
SHOPT_SEVENBIT == /* strip the eighth bit from characters */
SHOPT_SPAWN == /* use spawnveg for fork/exec */
SHOPT_STATS == 1 /* add .sh.stats variable */
SHOPT_SUID_EXEC == 1 /* allow (safe) suid/sgid shell scripts */
SHOPT_SYSRC == /* attempt . /etc/ksh.kshrc if interactive */
SHOPT_TIMEOUT == /* number of seconds for shell timeout */
SHOPT_TYPEDEF == 1 /* enable typeset type definitions */
SHOPT_VSH == 1 /* vi edit mode */
if CC.HOSTTYPE == "linux.alpha"
/* workaround for "BUG IN DYNAMIC LINKER ld.so" */
:PACKAGE: - m:static:noinclude /*noCC.EXPORT.DYNAMIC*/
end
if CC.HOSTTYPE == "*.s390-64"
CC.DLL = $(CC.DLLBIG)
end
if SHOPT_DYNAMIC && ( "$(CC.DIALECT:N=EXPORT=DLL)" || "$(PACKAGE_OPTIONS:N=optimize-space)" )
if "$(PACKAGE_OPTIONS:N=optimize-space)" && ! SHOPT_CMDLIB_HDR
SHOPT_CMDLIB_HDR == <cmdlist.h>
end
CCFLAGS += $$(CC.DLL) $$(CC.SUFFIX.DEBUG:+$$(CC.DEBUG))
LIBS_req = -lshell$(RELEASE)
else
if VARIANT
SHOPT_DYNAMIC = 1
else
libtype = :static
end
if SHOPT_DYNAMIC
CCLDFLAGS += $$(CC.EXPORT.DYNAMIC)
end
LIBS_req = +lshell$(RELEASE)
end
:PACKAGE: ast$(libtype):20100309 --clobber=!($(SH))
.SOURCE : edit sh bltins data tests fun
.SOURCE.h : include
/* documentation files */
DOCFILES = sh.memo builtins.mm README RELEASE TYPES PROMO.mm COMPATIBILITY \
DESIGN OBSOLETE RELEASE93 RELEASE88
KSHELL == 1 /* this is ksh */
SH_CMDLIB_DIR == /* SHOPT_CMDLIB_DIR dir prefix */
SH_DICT == /* message catalog */
DEBUG == /* debugging purposes only */
if CC.HOSTTYPE == "win32*"
SHOPT_CRNL == 1 /* <cr><nl> is equivalent to <nl> */
end
/* use the following libraries only if they exist */
LIBS_opt := +ljobs +li
if CC.HOSTTYPE == "sol([89]|[1-9][0-9]).*"
LDFLAGS += $(CC.LD.LAZY) $(CC.LD.NORECORD)
end
if "$(-mam:N=static*)"
LIBS_opt += -lsocket -lnsl
elif CC.HOSTTYPE == "sol?([789]|[1-9][0-9]).*"
LIBS_opt += +lsocket -lnsl
elif CC.HOSTTYPE != "sgi.mips*"
LIBS_opt += +lsocket +lnsl
end
if CC.HOSTTYPE == "linux.sparc*"
/* the linux.sparc linker still has some problems */
LIBS_opt += -ldll
end
LIBS_opt += -lsecdb
if CC.HOSTTYPE == "sol.*"
LIBS_opt += -lw
end
$(LIBS_opt) : .DONTCARE
LDLIBRARIES = $(LIBS_opt)
FILES_opt = /* optional file list enabled by vars above */
if SHOPT_ESH
FILES_opt += emacs.c
end
if SHOPT_VSH
FILES_opt += vi.c
end
if SHOPT_HISTEXPAND
FILES_opt += hexpand.c
end
if SHOPT_DYNAMIC
FILES_opt += -ldll
end
if SHOPT_X
LDFLAGS += -u _XtAppInitialize -L/usr/add-on/X11/lib
end
:ALL: $(SH) $(SHCOMP) $(SHOPT_SUID_EXEC:+suid_exec)
$(SH) :: sh.1 pmain.c $(LIBS_req)
DATAFILES = limits.c msg.c strdata.c testops.c keywords.c options.c \
signals.c aliases.c builtins.c variables.c lexstates.c
shell$(RELEASE) $(VERSION) id=shell :LIBRARY: shell.3 nval.3 alarm.c cd_pwd.c cflow.c deparse.c \
enum.c getopts.c hist.c misc.c print.c read.c sleep.c trap.c test.c \
typeset.c ulimit.c umask.c whence.c main.c nvdisc.c nvtype.c \
arith.c args.c array.c completion.c defs.c edit.c expand.c regress.c \
fault.c fcin.c history.c init.c io.c jobs.c lex.c macro.c name.c \
nvtree.c parse.c path.c string.c streval.c subshell.c tdump.c timers.c \
trestore.c waitevent.c xec.c $(DATAFILES) $(FILES_opt) \
-lcmd -last -lm
"sol*.i386*" :NOOPTIMIZE: main.c
"win32*" :NOOPTIMIZE: strdata.c trestore.c
if CC.HOSTTYPE == "win32*"
:DLL: $(CC.DEBUG)
else
:DLL: $(CC.OPTIMIZE)
end
:READONLY: $(DATAFILES)
$(INCLUDEDIR) :INSTALLPROTO: nval.h shell.h history.h
LIBCMD = $(.LIB.NAME. cmd:T=F)
if SHOPT_SUID_EXEC && ! "$(RELEASE)"
suid_exec :: CC.DLL= suid_exec.c +last
end
$(SHCOMP) :: CC.DLL= SH_DICT='"libshell"' shcomp.c $(LIBS_req)
$(FUNDIR) :INSTALLDIR: mode=+x dirs popd pushd
shcomp.o : _BLD_DLL= $(CC.HOSTTYPE:N=cygwin.*:??_BLD_shell=?)
:: math.tab syscall.s mamexec mamstate.c $(DOCFILES) \
hexpand.c mkservice.c \
shopen.mk shopen.c
:: shtests \
alias.sh append.sh arith.sh arrays.sh arrays2.sh \
attributes.sh basic.sh bracket.sh builtins.sh case.sh \
comvar.sh comvario.sh coprocess.sh cubetype.sh enum.sh exit.sh \
expand.sh functions.sh glob.sh grep.sh heredoc.sh io.sh \
leaks.sh locale.sh math.sh nameref.sh namespace.sh options.sh \
path.sh pointtype.sh pty.sh quoting.sh quoting2.sh readcsv.sh \
recttype.sh restricted.sh return.sh select.sh shtests \
sigchld.sh signal.sh statics.sh subshell.sh substring.sh \
tilde.sh timetype.sh treemove.sh types.sh variables.sh \
vartree1.sh vartree2.sh
:: ksh-regress.rt ksh-regress.tst
if "$(PWD:B:N=cc-*)"
test : .NULL
else
test : test.ksh
test.ksh : $(BINDIR)/$(SH) $(SH) shtests
$(SILENT) $(CMP) $(CMPFLAGS) $(*:O=1) $(*:O=2) 2>/dev/null ||
echo "make install to run the tests on the latest $(SH)" >&2
cd $(*:O=3:P=L!:D)
SHELL=$(*:O=1:P=A) $(*:O=1:P=A) $(*:O=3:B) $(SHTESTSFLAGS)
test.% : %.sh $(BINDIR)/$(SH) $(SH) shtests
$(SILENT) $(CMP) $(CMPFLAGS) $(*:O=2) $(*:O=3) 2>/dev/null ||
echo "make install to run the tests on the latest $(SH)" >&2
cd $(*:O=4:P=L!:D)
SHELL=$(*:O=2:P=A) $(*:O=2:P=A) $(*:O=4:B) $(SHTESTSFLAGS) $(*:O=1:P=A)
if RELEASE
.INSTALL : .CLEAR $(*.INSTALL:N=*$(RELEASE)*([!/]))
end
end

File diff suppressed because it is too large Load diff

40
src/cmd/ksh93/SHOPT.sh Normal file
View file

@ -0,0 +1,40 @@
#
# Compile-time SHOPT_* options for ksh93.
# 1 to enable, 0 to disable, empty value to probe.
#
SHOPT 2DMATCH=1 # two dimensional ${.sh.match} for ${var//pat/str}
SHOPT ACCT= # accounting
SHOPT ACCTFILE= # per-user accounting info
SHOPT AUDIT=1 # enable auditing per SHOPT_AUDITFILE
SHOPT AUDITFILE='\"/etc/ksh_audit\"' # auditing file
SHOPT BGX=1 # one SIGCHLD trap per completed job
SHOPT BRACEPAT=1 # C-shell {...,...} expansions (, required)
SHOPT CMDLIB_HDR= # '<cmdlist.h>' # custom -lcmd list for path-bound builtins
SHOPT CMDLIB_DIR= # '\"/opt/ast/bin\"' # virtual directory prefix for path-bound builtins
SHOPT CRNL= # accept MS Windows newlines (<cr><nl>) for <nl>
SHOPT DYNAMIC=1 # dynamic loading for builtins
SHOPT ECHOPRINT= # make echo equivalent to print
SHOPT EDPREDICT=1 # predictive editing
SHOPT ESH=1 # emacs/gmacs edit mode
SHOPT FILESCAN=1 # fast file scan
SHOPT FIXEDARRAY=1 # fixed dimension indexed array
SHOPT HISTEXPAND=1 # csh-style history file expansions
SHOPT KIA=1 # shell information database generation
SHOPT MULTIBYTE=1 # multibyte character handling
SHOPT NAMESPACE=1 # allow namespaces
SHOPT OLDTERMIO= # support both TCGETA and TCGETS
SHOPT OPTIMIZE=1 # optimize loop invariants
SHOPT PFSH=0 # solaris exec_attr(4) profile execution (obsolete)
SHOPT P_SUID= # real uid's that require -p for set[ug]id
SHOPT RAWONLY=1 # make viraw the only vi mode
SHOPT REGRESS= # enable __regress__ builtin and instrumented intercepts for testing
SHOPT REMOTE= # enable --rc if running as a remote shell
SHOPT SEVENBIT= # strip the eighth bit from characters
SHOPT SPAWN= # use spawnveg for fork/exec
SHOPT STATS=1 # add .sh.stats variable
SHOPT SUID_EXEC=1 # allow (safe) suid/sgid shell scripts
SHOPT SYSRC= # attempt . /etc/ksh.kshrc if interactive
SHOPT TIMEOUT= # number of seconds for shell timeout
SHOPT TYPEDEF=1 # enable typeset type definitions
SHOPT VSH=1 # vi edit mode