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