xref: /illumos-gate/usr/src/cmd/ast/Makefile.ast (revision 9b9d39d2a32ff806d2431dbcc50968ef1e6d46b2)
1#
2# CDDL HEADER START
3#
4# The contents of this file are subject to the terms of the
5# Common Development and Distribution License (the "License").
6# You may not use this file except in compliance with the License.
7#
8# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9# or http://www.opensolaris.org/os/licensing.
10# See the License for the specific language governing permissions
11# and limitations under the License.
12#
13# When distributing Covered Code, include this CDDL HEADER in each
14# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15# If applicable, add the following below this CDDL HEADER, with the
16# fields enclosed by brackets "[]" replaced with your own identifying
17# information: Portions Copyright [yyyy] [name of copyright owner]
18#
19# CDDL HEADER END
20#
21
22#
23# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24# Copyright 2021 OmniOS Community Edition (OmniOSce) Association.
25#
26
27C_AST =		$(CONTRIB)/ast
28C_ASTINIT =	$(C_AST)/src/cmd/INIT
29
30AST=		$(SRC)/cmd/ast
31
32AST_TOOLS =	$(AST)/tools
33AST_LCGEN =	$(AST_TOOLS)/lcgen
34AST_PROTO =	$(AST_TOOLS)/proto -p -s -l $(C_AST)/lib/package/ast.lic \
35		-o '$(AST_LICENSE)'
36
37# Override this top level flag so the compiler builds in its native C99 mode.
38CSTD= $(CSTD_GNU99)
39
40#
41# Shell feature flags.
42# * - the upstream build configuration can be viewed at
43#     $(CONTRIB)/ast/src/cmd/ksh93/Makefile
44#
45
46# These options are enabled, and are also enabled by default in the upstream
47# build framework*:
48#
49#	SHOPT_2DMATCH		two dimensional .sh.match for ${var//pat/str}
50#	SHOPT_BGX		one SIGCHLD trap per completed job
51#	SHOPT_BRACEPAT		C-shell {...,...} expansions (, required)
52#	SHOPT_DYNAMIC		dynamic loading for builtins
53#	SHOPT_ESH		emacs/gmacs edit mode
54#	SHOPT_FILESCAN		fast file scan
55#	SHOPT_FIXEDARRAY	fixed dimension indexed array
56#	SHOPT_HISTEXPAND	csh-style history file expansions
57#	SHOPT_KIA		shell information database generation
58#	SHOPT_MULTIBYTE		multibyte character handling
59#	SHOPT_NAMESPACE		allow namespaces
60#	SHOPT_OPTIMIZE		optimize loop invariants
61#	SHOPT_RAWONLY		make viraw the only vi mode
62#	SHOPT_STATS		add .sh.stats variable
63#	SHOPT_SUID_EXEC		allow (safe) suid/sgid shell scripts
64#	SHOPT_TYPEDEF		enable typeset type definitions
65#	SHOPT_VSH		vi edit mode
66
67# These options are enabled but are not enabled by default in the upstream
68# build framework*:
69#
70#	SHOPT_SYSRC		attempt . /etc/ksh.kshrc if interactive
71
72# These options are NOT enabled but are enabled by default in the upstream
73# build framework*:
74#
75#	SHOPT_AUDIT		enable auditing per SHOPT_AUDITFILE
76#	SHOPT_COSHELL		build with connection to coshell
77#	SHOPT_EDPREDICT		predictive editing
78
79# These options are NOT enabled and are also NOT enabled in the upstream
80# build framework*:
81#
82#	SHOPT_ACCT		accounting
83#	SHOPT_ACCTFILE		per user accounting info
84#	SHOPT_AUDITFILE		"/etc/ksh_audit" auditing file
85#	SHOPT_BASH		bash compatibility code
86#	SHOPT_CRNL		accept <cr><nl> for <nl>
87#	SHOPT_ECHOPRINT		make echo equivalent to print
88#	SHOPT_FS_3D		3d file system
89#	SHOPT_OLDTERMIO		support both TCGETA and TCGETS
90#	SHOPT_P_SUID		real uid's that require -p for set[ug]id
91#	SHOPT_PFSH		solaris exec_attr(5) profile execution
92#	SHOPT_REGRESS		enable __regress__ builtin
93#	SHOPT_REMOTE		enable --rc if running as a remote shell
94#	SHOPT_SEVENBIT		strip the eigth bit from characters
95#	SHOPT_SPAWN		use spawnveg for fork/exec
96#	SHOPT_TIMEOUT		number of seconds for shell timeout
97
98LIBSHELLFEATUREFLAGS= \
99	-DSHOPT_2DMATCH \
100	-DSHOPT_BGX \
101	-DSHOPT_BRACEPAT \
102	-DSHOPT_DYNAMIC \
103	-DSHOPT_ESH \
104	-DSHOPT_FILESCAN \
105	-DSHOPT_FIXEDARRAY \
106	-DSHOPT_HISTEXPAND \
107	-DSHOPT_KIA \
108	-DSHOPT_MULTIBYTE \
109	-DSHOPT_NAMESPACE \
110	-DSHOPT_OPTIMIZE \
111	-DSHOPT_PFSH=0 \
112	-DSHOPT_RAWONLY \
113	-DSHOPT_STATS \
114	-DSHOPT_SUID_EXEC \
115	-DSHOPT_SYSRC \
116	-DSHOPT_TYPEDEF \
117	-DSHOPT_VSH
118
119#
120# common CPP flags for libshell consumers (ksh, shcomp etc.)
121#
122
123LIBSHELLCPPFLAGS= \
124	-I$(LIBSHELLBASE)/$(LIBSHELLMACH) \
125	-I$(ASTSRC)/include \
126	-I$(ROOT)/usr/include/ast \
127	-I$(ROOT)/usr/include \
128	\
129	-DSHOPT_CMDLIB_BLTIN=0 \
130	'-DSH_CMDLIB_DIR="/usr/ast/bin"' \
131	'-DSHOPT_CMDLIB_HDR="../common/illumos_cmdlist.h"' \
132	\
133	$(LIBSHELLFEATUREFLAGS) \
134	\
135	-DKSHELL \
136	-D_BLD_shell \
137	-D_PACKAGE_ast \
138	-D_API_ast=20100309 \
139	'-DERROR_CATALOG="libshell"' \
140	-DERROR_CONTEXT_T=Error_context_t \
141	'-DUSAGE_LICENSE=\
142	    "[-author?David Korn <dgk@research.att.com>]" \
143	    "[-copyright?Copyright (c) 1982-2012 AT&T Intellectual Property]" \
144	    "[-license?http://www.eclipse.org/org/documents/epl-v10.html]" \
145	    "[--catalog?libshell]"'
146
147# Default CFLAGS/CFLAGS64 for AST sources
148ASTCFLAGS= $(CCVERBOSE)
149ASTCFLAGS64= $(CCVERBOSE)
150
151# Generated header files generated using this system have a number of
152# artifacts that are cleaned up by the following action.
153#
154# They include a 'generated by' header which includes the full path to
155# the source file. The path to the root of the gate is removed, leaving only
156# the relative part of the path.
157#
158# They have trailing whitespace, which is removed.
159
160# Unfortunately, due to differences in the "sed" command implemented in
161# various illumos distributions, we can't portably use 'sed -i' here.
162
163SEDPATTERN= \
164	s^$(SRC)/^^g; \
165	s/  *$$//; \
166	/def.* _def_.*_$(MACH64)/s/$(MACH64)/$(HDRGUARD)/; \
167	/def.* _def_.*_$(MACH)/s/$(MACH)/$(HDRGUARD)/;
168
169POST_PROCESS_AST= \
170	{ \
171		tf=$$(mktemp /tmp/ast.XXXXXXXXXX) && \
172		$(SED) < "$@" > "$$tf" '$(SEDPATTERN)' && \
173		$(CP) -p "$$tf" "$@" && \
174		$(RM) "$$tf"; \
175	}
176