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