1*906afcb8SAndy Fiddaman/* 2*906afcb8SAndy Fiddaman * ksh makefile 3*906afcb8SAndy Fiddaman */ 4*906afcb8SAndy Fiddaman 5*906afcb8SAndy FiddamanSH := $(PWD:B:/[0-9]*$//:N=ksh*:-ksh) /* name of the shell program */ 6*906afcb8SAndy FiddamanVERSION = 1.1 7*906afcb8SAndy FiddamanLICENSE = since=1982,author=dgk 8*906afcb8SAndy FiddamanCATALOG = libshell 9*906afcb8SAndy FiddamanERROR_CONTEXT_T == Error_context_t /* workaround until switch from errorpush()/errorpop() => errorctx() */ 10*906afcb8SAndy FiddamanRELEASE := $(SH:/.*sh//) 11*906afcb8SAndy FiddamanSHCOMP := shcomp$(RELEASE) 12*906afcb8SAndy Fiddaman 13*906afcb8SAndy Fiddaman/* 14*906afcb8SAndy Fiddaman * set these variables to 1 to enable, 0 to disable, null to probe 15*906afcb8SAndy Fiddaman * override SHOPT_foo=1 can be placed one per line in the build dir Makeargs 16*906afcb8SAndy Fiddaman */ 17*906afcb8SAndy Fiddaman 18*906afcb8SAndy FiddamanSHOPT_2DMATCH == 1 /* two dimensional .sh.match for ${var//pat/str} */ 19*906afcb8SAndy FiddamanSHOPT_ACCT == /* accounting */ 20*906afcb8SAndy FiddamanSHOPT_ACCTFILE == /* per user accounting info */ 21*906afcb8SAndy FiddamanSHOPT_AUDIT == 1 /* enable auditing per SHOPT_AUDITFILE */ 22*906afcb8SAndy FiddamanSHOPT_AUDITFILE == "/etc/ksh_audit" /* auditing file */ 23*906afcb8SAndy FiddamanSHOPT_BASH == /* bash compatibility code */ 24*906afcb8SAndy FiddamanSHOPT_BGX == 1 /* one SIGCHLD trap per completed job */ 25*906afcb8SAndy FiddamanSHOPT_BRACEPAT == 1 /* C-shell {...,...} expansions (, required) */ 26*906afcb8SAndy FiddamanSHOPT_CMDLIB_HDR == /* -lcmd builtin list (<cmdlist.h>) */ 27*906afcb8SAndy FiddamanSHOPT_CMDLIB_DIR == /* SHOPT_CMDLIB_HDR directory prefix (default "/opt/ast/bin") */ 28*906afcb8SAndy FiddamanSHOPT_COSHELL == 1 /* build with connection to coshell */ 29*906afcb8SAndy FiddamanSHOPT_CRNL == /* accept <cr><nl> for <nl> */ 30*906afcb8SAndy FiddamanSHOPT_DYNAMIC == 1 /* dynamic loading for builtins */ 31*906afcb8SAndy FiddamanSHOPT_ECHOPRINT == /* make echo equivalent to print */ 32*906afcb8SAndy FiddamanSHOPT_EDPREDICT == 1 /* predictive editing */ 33*906afcb8SAndy FiddamanSHOPT_ESH == 1 /* emacs/gmacs edit mode */ 34*906afcb8SAndy FiddamanSHOPT_FILESCAN == 1 /* fast file scan */ 35*906afcb8SAndy FiddamanSHOPT_FIXEDARRAY == 1 /* fixed dimension indexed array */ 36*906afcb8SAndy FiddamanSHOPT_FS_3D == /* 3d file system */ 37*906afcb8SAndy FiddamanSHOPT_HISTEXPAND == 1 /* csh-style history file expansions */ 38*906afcb8SAndy FiddamanSHOPT_KIA == 1 /* shell information database generation */ 39*906afcb8SAndy FiddamanSHOPT_MULTIBYTE == 1 /* multibyte character handling */ 40*906afcb8SAndy FiddamanSHOPT_NAMESPACE == 1 /* allow namespaces */ 41*906afcb8SAndy FiddamanSHOPT_OLDTERMIO == /* support both TCGETA and TCGETS */ 42*906afcb8SAndy FiddamanSHOPT_OPTIMIZE == 1 /* optimize loop invariants */ 43*906afcb8SAndy FiddamanSHOPT_PFSH == 1 /* solaris exec_attr(4) profile execution */ 44*906afcb8SAndy FiddamanSHOPT_P_SUID == /* real uid's that require -p for set[ug]id */ 45*906afcb8SAndy FiddamanSHOPT_RAWONLY == 1 /* make viraw the only vi mode */ 46*906afcb8SAndy FiddamanSHOPT_REGRESS == /* enable __regress__ builtin and instrumented intercepts for testing */ 47*906afcb8SAndy FiddamanSHOPT_REMOTE == /* enable --rc if running as a remote shell */ 48*906afcb8SAndy FiddamanSHOPT_SEVENBIT == /* strip the eigth bit from characters */ 49*906afcb8SAndy FiddamanSHOPT_SPAWN == /* use spawnveg for fork/exec */ 50*906afcb8SAndy FiddamanSHOPT_STATS == 1 /* add .sh.stats variable */ 51*906afcb8SAndy FiddamanSHOPT_SUID_EXEC == 1 /* allow (safe) suid/sgid shell scripts */ 52*906afcb8SAndy FiddamanSHOPT_SYSRC == /* attempt . /etc/ksh.kshrc if interactive */ 53*906afcb8SAndy FiddamanSHOPT_TIMEOUT == /* number of seconds for shell timeout */ 54*906afcb8SAndy FiddamanSHOPT_TYPEDEF == 1 /* enable typeset type definitions */ 55*906afcb8SAndy FiddamanSHOPT_VSH == 1 /* vi edit mode */ 56*906afcb8SAndy Fiddaman 57*906afcb8SAndy Fiddamanif CC.HOSTTYPE == "linux.alpha" 58*906afcb8SAndy Fiddaman /* workaround for "BUG IN DYNAMIC LINKER ld.so" */ 59*906afcb8SAndy Fiddaman :PACKAGE: - m:static:noinclude /*noCC.EXPORT.DYNAMIC*/ 60*906afcb8SAndy Fiddamanend 61*906afcb8SAndy Fiddaman 62*906afcb8SAndy Fiddamanif CC.HOSTTYPE == "*.s390-64" 63*906afcb8SAndy Fiddaman CC.DLL = $(CC.DLLBIG) 64*906afcb8SAndy Fiddamanend 65*906afcb8SAndy Fiddaman 66*906afcb8SAndy Fiddamanif SHOPT_DYNAMIC && ( "$(CC.DIALECT:N=EXPORT=DLL)" || "$(PACKAGE_OPTIONS:N=optimize-space)" ) 67*906afcb8SAndy Fiddaman if "$(PACKAGE_OPTIONS:N=optimize-space)" && ! SHOPT_CMDLIB_HDR 68*906afcb8SAndy Fiddaman SHOPT_CMDLIB_HDR == <cmdlist.h> 69*906afcb8SAndy Fiddaman end 70*906afcb8SAndy Fiddaman CCFLAGS += $$(CC.DLL) $$(CC.SUFFIX.DEBUG:+$$(CC.DEBUG)) 71*906afcb8SAndy Fiddaman LIBS_req = -lshell$(RELEASE) 72*906afcb8SAndy Fiddamanelse 73*906afcb8SAndy Fiddaman if VARIANT 74*906afcb8SAndy Fiddaman SHOPT_DYNAMIC = 1 75*906afcb8SAndy Fiddaman else 76*906afcb8SAndy Fiddaman libtype = :static 77*906afcb8SAndy Fiddaman end 78*906afcb8SAndy Fiddaman if SHOPT_DYNAMIC 79*906afcb8SAndy Fiddaman CCLDFLAGS += $$(CC.EXPORT.DYNAMIC) 80*906afcb8SAndy Fiddaman end 81*906afcb8SAndy Fiddaman LIBS_req = +lshell$(RELEASE) 82*906afcb8SAndy Fiddamanend 83*906afcb8SAndy Fiddaman 84*906afcb8SAndy Fiddaman:PACKAGE: ast$(libtype):20100309 coshell:order --clobber=!($(SH)) 85*906afcb8SAndy Fiddaman 86*906afcb8SAndy Fiddaman.SOURCE : edit sh bltins data tests fun 87*906afcb8SAndy Fiddaman.SOURCE.h : include 88*906afcb8SAndy Fiddaman 89*906afcb8SAndy Fiddaman/* documentation files */ 90*906afcb8SAndy FiddamanDOCFILES = sh.memo builtins.mm README RELEASE TYPES PROMO.mm COMPATIBILITY \ 91*906afcb8SAndy Fiddaman DESIGN OBSOLETE RELEASE93 RELEASE88 92*906afcb8SAndy Fiddaman 93*906afcb8SAndy FiddamanKSHELL == 1 /* this is ksh */ 94*906afcb8SAndy Fiddaman 95*906afcb8SAndy FiddamanSH_CMDLIB_DIR == /* SHOPT_CMDLIB_DIR dir prefix */ 96*906afcb8SAndy FiddamanSH_DICT == /* message catalog */ 97*906afcb8SAndy FiddamanDEBUG == /* debugging purposes only */ 98*906afcb8SAndy Fiddaman 99*906afcb8SAndy Fiddamanif CC.HOSTTYPE == "win32*" 100*906afcb8SAndy Fiddaman SHOPT_CRNL == 1 /* <cr><nl> is eqivalent to <nl> */ 101*906afcb8SAndy Fiddamanend 102*906afcb8SAndy Fiddaman 103*906afcb8SAndy Fiddamanif SHOPT_BASH 104*906afcb8SAndy Fiddaman BASH_HOSTTYPE == "$(CC.HOSTTYPE:S:/\.//)" 105*906afcb8SAndy Fiddaman BASH_MACHTYPE == "$(BASH_HOSTTYPE)-unknown-$(CC.HOSTTYPE:B)" 106*906afcb8SAndy Fiddamanend 107*906afcb8SAndy Fiddaman 108*906afcb8SAndy Fiddaman/* use the following libraries only if they exist */ 109*906afcb8SAndy FiddamanLIBS_opt := +ljobs +li 110*906afcb8SAndy Fiddaman 111*906afcb8SAndy Fiddamanif CC.HOSTTYPE == "sol([89]|[1-9][0-9]).*" 112*906afcb8SAndy Fiddaman LDFLAGS += $(CC.LD.LAZY) $(CC.LD.NORECORD) 113*906afcb8SAndy Fiddamanend 114*906afcb8SAndy Fiddaman 115*906afcb8SAndy Fiddamanif "$(-mam:N=static*)" 116*906afcb8SAndy Fiddaman LIBS_opt += -lsocket -lnsl 117*906afcb8SAndy Fiddamanelif CC.HOSTTYPE == "sol?([789]|[1-9][0-9]).*" 118*906afcb8SAndy Fiddaman LIBS_opt += +lsocket -lnsl 119*906afcb8SAndy Fiddamanelif CC.HOSTTYPE != "sgi.mips*" 120*906afcb8SAndy Fiddaman LIBS_opt += +lsocket +lnsl 121*906afcb8SAndy Fiddamanend 122*906afcb8SAndy Fiddamanif CC.HOSTTYPE == "linux.sparc*" 123*906afcb8SAndy Fiddaman /* the linux.sparc linker still has some problems */ 124*906afcb8SAndy Fiddaman LIBS_opt += -ldll 125*906afcb8SAndy Fiddamanend 126*906afcb8SAndy FiddamanLIBS_opt += -lsecdb 127*906afcb8SAndy Fiddamanif CC.HOSTTYPE == "sol.*" 128*906afcb8SAndy Fiddaman LIBS_opt += -lw 129*906afcb8SAndy Fiddamanend 130*906afcb8SAndy Fiddaman$(LIBS_opt) : .DONTCARE 131*906afcb8SAndy Fiddaman 132*906afcb8SAndy FiddamanLDLIBRARIES = $(LIBS_opt) 133*906afcb8SAndy Fiddaman 134*906afcb8SAndy FiddamanFILES_opt = /* optional file list enabled by vars above */ 135*906afcb8SAndy Fiddamanif SHOPT_ESH 136*906afcb8SAndy Fiddaman FILES_opt += emacs.c 137*906afcb8SAndy Fiddamanend 138*906afcb8SAndy Fiddamanif SHOPT_VSH 139*906afcb8SAndy Fiddaman FILES_opt += vi.c 140*906afcb8SAndy Fiddamanend 141*906afcb8SAndy Fiddamanif SHOPT_BASH 142*906afcb8SAndy Fiddaman FILES_opt += bash.c bash_pre_rc.c 143*906afcb8SAndy Fiddaman SHOPT_HISTEXPAND == 1 144*906afcb8SAndy Fiddamanend 145*906afcb8SAndy Fiddamanif SHOPT_HISTEXPAND 146*906afcb8SAndy Fiddaman FILES_opt += hexpand.c 147*906afcb8SAndy Fiddamanend 148*906afcb8SAndy Fiddamanif SHOPT_DYNAMIC 149*906afcb8SAndy Fiddaman FILES_opt += -ldll 150*906afcb8SAndy Fiddamanend 151*906afcb8SAndy Fiddamanif SHOPT_X 152*906afcb8SAndy Fiddaman LDFLAGS += -u _XtAppInitialize -L/usr/add-on/X11/lib 153*906afcb8SAndy Fiddamanend 154*906afcb8SAndy Fiddaman 155*906afcb8SAndy Fiddaman:ALL: $(SH) $(SHCOMP) $(SHOPT_SUID_EXEC:+suid_exec) $(SHOPT_BASH:+bash$(RELEASE)) 156*906afcb8SAndy Fiddaman 157*906afcb8SAndy Fiddaman$(SH) :: sh.1 pmain.c $(LIBS_req) 158*906afcb8SAndy Fiddaman 159*906afcb8SAndy FiddamanDATAFILES = limits.c msg.c strdata.c testops.c keywords.c options.c \ 160*906afcb8SAndy Fiddaman signals.c aliases.c builtins.c variables.c lexstates.c 161*906afcb8SAndy Fiddaman 162*906afcb8SAndy Fiddamanshell$(RELEASE) $(VERSION) id=shell :LIBRARY: shell.3 nval.3 alarm.c cd_pwd.c cflow.c deparse.c \ 163*906afcb8SAndy Fiddaman enum.c getopts.c hist.c misc.c print.c read.c sleep.c trap.c test.c \ 164*906afcb8SAndy Fiddaman typeset.c ulimit.c umask.c whence.c main.c nvdisc.c nvtype.c \ 165*906afcb8SAndy Fiddaman arith.c args.c array.c completion.c defs.c edit.c expand.c regress.c \ 166*906afcb8SAndy Fiddaman fault.c fcin.c history.c init.c io.c jobs.c lex.c macro.c name.c \ 167*906afcb8SAndy Fiddaman nvtree.c parse.c path.c string.c streval.c subshell.c tdump.c timers.c \ 168*906afcb8SAndy Fiddaman trestore.c waitevent.c xec.c env.c $(DATAFILES) $(FILES_opt) \ 169*906afcb8SAndy Fiddaman $(SHOPT_COSHELL:+-lcoshell) -lcmd -last -lm 170*906afcb8SAndy Fiddaman 171*906afcb8SAndy Fiddaman"sol*.i386*" :NOOPTIMIZE: main.c 172*906afcb8SAndy Fiddaman"win32*" :NOOPTIMIZE: strdata.c trestore.c 173*906afcb8SAndy Fiddaman 174*906afcb8SAndy Fiddamanif CC.HOSTTYPE == "win32*" 175*906afcb8SAndy Fiddaman:DLL: $(CC.DEBUG) 176*906afcb8SAndy Fiddamanelse 177*906afcb8SAndy Fiddaman:DLL: $(CC.OPTIMIZE) 178*906afcb8SAndy Fiddamanend 179*906afcb8SAndy Fiddaman 180*906afcb8SAndy Fiddaman:READONLY: $(DATAFILES) 181*906afcb8SAndy Fiddaman 182*906afcb8SAndy Fiddaman$(INCLUDEDIR) :INSTALLPROTO: nval.h shell.h history.h 183*906afcb8SAndy Fiddaman 184*906afcb8SAndy FiddamanLIBCMD = $(.LIB.NAME. cmd:T=F) 185*906afcb8SAndy Fiddaman 186*906afcb8SAndy Fiddamanif SHOPT_SUID_EXEC && ! "$(RELEASE)" 187*906afcb8SAndy Fiddamansuid_exec :: CC.DLL= suid_exec.c +last 188*906afcb8SAndy Fiddamanend 189*906afcb8SAndy Fiddaman 190*906afcb8SAndy Fiddaman$(SHCOMP) :: CC.DLL= SH_DICT='"libshell"' shcomp.c $(LIBS_req) 191*906afcb8SAndy Fiddaman 192*906afcb8SAndy Fiddaman$(FUNDIR) :INSTALLDIR: mode=+x dirs popd pushd 193*906afcb8SAndy Fiddaman 194*906afcb8SAndy Fiddamanshcomp.o : _BLD_DLL= $(CC.HOSTTYPE:N=cygwin.*:??_BLD_shell=?) 195*906afcb8SAndy Fiddaman 196*906afcb8SAndy Fiddamanif SHOPT_BASH 197*906afcb8SAndy Fiddaman 198*906afcb8SAndy Fiddamanbash$(RELEASE) :LINK: $(SH) 199*906afcb8SAndy Fiddaman 200*906afcb8SAndy Fiddamanbash_pre_rc.c : bash_pre_rc.sh 201*906afcb8SAndy Fiddaman echo "const char bash_pre_rc[] = " > $(<) 202*906afcb8SAndy Fiddaman sed -e 's/\\/\\\\/g' -e 's/"/\\"/g' -e 's/'"'"'/\\'"'"'/g' -e 's/^[[:space:]]*\(.*\)$/\"\1\\n\"/' $(*) >> $(<) 203*906afcb8SAndy Fiddaman echo ";" >> $(<) 204*906afcb8SAndy Fiddaman 205*906afcb8SAndy Fiddamanend 206*906afcb8SAndy Fiddaman 207*906afcb8SAndy Fiddaman:: math.tab syscall.s mamexec mamstate.c $(DOCFILES) \ 208*906afcb8SAndy Fiddaman bash.c bash_pre_rc.sh hexpand.c mkservice.c \ 209*906afcb8SAndy Fiddaman shopen.mk shopen.c 210*906afcb8SAndy Fiddaman 211*906afcb8SAndy Fiddaman:: shtests \ 212*906afcb8SAndy Fiddaman alias.sh append.sh arith.sh arrays.sh arrays2.sh \ 213*906afcb8SAndy Fiddaman attributes.sh basic.sh bracket.sh builtins.sh case.sh \ 214*906afcb8SAndy Fiddaman comvar.sh comvario.sh coprocess.sh cubetype.sh enum.sh exit.sh \ 215*906afcb8SAndy Fiddaman expand.sh functions.sh glob.sh grep.sh heredoc.sh io.sh \ 216*906afcb8SAndy Fiddaman leaks.sh locale.sh math.sh nameref.sh namespace.sh options.sh \ 217*906afcb8SAndy Fiddaman path.sh pointtype.sh pty.sh quoting.sh quoting2.sh readcsv.sh \ 218*906afcb8SAndy Fiddaman recttype.sh restricted.sh return.sh select.sh shtests \ 219*906afcb8SAndy Fiddaman sigchld.sh signal.sh statics.sh subshell.sh substring.sh \ 220*906afcb8SAndy Fiddaman tilde.sh timetype.sh treemove.sh types.sh variables.sh \ 221*906afcb8SAndy Fiddaman vartree1.sh vartree2.sh 222*906afcb8SAndy Fiddaman 223*906afcb8SAndy Fiddaman:: ksh-regress.rt ksh-regress.tst 224*906afcb8SAndy Fiddaman 225*906afcb8SAndy Fiddamanif "$(PWD:B:N=cc-*)" 226*906afcb8SAndy Fiddaman 227*906afcb8SAndy Fiddamantest : .NULL 228*906afcb8SAndy Fiddaman 229*906afcb8SAndy Fiddamanelse 230*906afcb8SAndy Fiddaman 231*906afcb8SAndy Fiddamantest : test.ksh 232*906afcb8SAndy Fiddaman 233*906afcb8SAndy Fiddamantest.ksh : $(BINDIR)/$(SH) $(SH) shtests 234*906afcb8SAndy Fiddaman $(SILENT) $(CMP) $(CMPFLAGS) $(*:O=1) $(*:O=2) 2>/dev/null || 235*906afcb8SAndy Fiddaman echo "make install to run the tests on the latest $(SH)" >&2 236*906afcb8SAndy Fiddaman cd $(*:O=3:P=L!:D) 237*906afcb8SAndy Fiddaman SHELL=$(*:O=1:P=A) $(*:O=1:P=A) $(*:O=3:B) $(SHTESTSFLAGS) 238*906afcb8SAndy Fiddaman 239*906afcb8SAndy Fiddamantest.% : %.sh COSHELL_OPTIONS=separate $(BINDIR)/$(SH) $(SH) shtests 240*906afcb8SAndy Fiddaman $(SILENT) $(CMP) $(CMPFLAGS) $(*:O=2) $(*:O=3) 2>/dev/null || 241*906afcb8SAndy Fiddaman echo "make install to run the tests on the latest $(SH)" >&2 242*906afcb8SAndy Fiddaman cd $(*:O=4:P=L!:D) 243*906afcb8SAndy Fiddaman SHELL=$(*:O=2:P=A) $(*:O=2:P=A) $(*:O=4:B) $(SHTESTSFLAGS) $(*:O=1:P=A) 244*906afcb8SAndy Fiddaman 245*906afcb8SAndy Fiddamanif RELEASE 246*906afcb8SAndy Fiddaman 247*906afcb8SAndy Fiddaman.INSTALL : .CLEAR $(*.INSTALL:N=*$(RELEASE)*([!/])) 248*906afcb8SAndy Fiddaman 249*906afcb8SAndy Fiddamanend 250*906afcb8SAndy Fiddaman 251*906afcb8SAndy Fiddamanend 252