xref: /illumos-gate/usr/src/cmd/ast/ksh/Makefile.com (revision 6446bd46ed1b4e9f69da153665f82181ccaedad5)
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#
25# Copyright (c) 2018, Joyent, Inc.
26# Copyright 2021 OmniOS Community Edition (OmniOSce) Association.
27
28SHELL=/usr/bin/ksh93
29
30PROG= ksh
31
32USRKSH_ALIAS_LIST=ksh ksh93 rksh rksh93
33
34# Set common AST build flags (e.g., needed to support the math stuff).
35include ../../Makefile.ast
36
37OBJECTS= pmain.o
38
39ASTSRC= $(C_AST)/src/cmd/ksh93
40LIBSHELLBASE= ../../libshell
41LIBSHELLSRC= $(ASTSRC)/sh
42
43SRCS=	$(OBJECTS:%.o=$(LIBSHELLSRC)/%.c)
44
45LDLIBS += -lshell -lumem
46
47# We use "=" here since using $(CPPFLAGS.master) is very tricky in our
48# case - it MUST come as the last element but future changes in -D options
49# may then cause silent breakage in the AST sources because the last -D
50# option specified overrides previous -D options so we prefer the current
51# way to explicitly list each single flag.
52CPPFLAGS= \
53	$(DTEXTDOM) $(DTS_ERRNO) \
54	$(LIBSHELLCPPFLAGS)
55
56CFLAGS += $(ASTCFLAGS)
57CFLAGS64 += $(ASTCFLAGS64)
58
59# Workaround for CR#6628728 ("|memcntl()| prototype not available for C99/XPG6")
60pmain.o	:= CERRWARN += -_gcc=-Wno-implicit-function-declaration
61
62# not linted
63SMATCH=off
64
65.KEEP_STATE:
66
67%.o:	$(LIBSHELLSRC)/%.c
68	$(COMPILE.c) -c -o $@ $<
69	$(POST_PROCESS_O)
70
71all:	$(PROG)
72
73# We explicitly delete "ksh" and "ksh93" to catch changes in
74# BUILD_KSH93_AS_BINKSH (see Makefile.ksh93switch)
75# and soft-link $(PROG) to ksh/ksh93 below because ksh93 test
76# suite seems to require that ksh93 is available as "ksh" in
77# ${PATH} (see comment about "io.sh" in Makefile.testshell).
78$(PROG):	$(OBJECTS)
79	$(RM) ksh ksh93
80	$(LINK.c) $(OBJECTS) -o $@ $(LDLIBS)
81	$(POST_PROCESS)
82	(set +o errexit ; \
83	[[ ! -x ksh93 ]] && ln $(PROG) ksh93 ; \
84	[[ ! -x ksh   ]] && ln $(PROG) ksh   ; \
85	true \
86	)
87
88clean:
89	$(RM) $(OBJECTS)
90
91# We explicitly delete "ksh" and "ksh93" to catch changes in
92# BUILD_KSH93_AS_BINKSH (see Makefile.ksh93switch)
93CLOBBERFILES += ksh ksh93
94
95# Install rule for $(MACH)/Makefile (32bit)
96INSTALL.ksh.32bit=@ \
97	(print "$(POUND_SIGN) Installing 32bit $(PROG) aliases $(USRKSH_ALIAS_LIST)" ; \
98	set -o xtrace ; \
99	for i in $(USRKSH_ALIAS_LIST) ; do \
100		[[ "$$i" == "$(PROG)" ]] && continue ; \
101		$(RM) "$(ROOTBIN32)/$$i" ; \
102		$(LN) "$(ROOTBIN32)/$(PROG)" "$(ROOTBIN32)/$$i" ; \
103	done \
104	)
105
106# Install rule for $(MACH64)/Makefile (64bit)
107INSTALL.ksh.64bit=@ \
108	(print "$(POUND_SIGN) Installing 64bit $(PROG) aliases $(USRKSH_ALIAS_LIST)" ; \
109	set -o xtrace ; \
110	for i in $(USRKSH_ALIAS_LIST) ; do \
111		[[ "$$i" == "$(PROG)" ]] && continue ; \
112		$(RM) "$(ROOTBIN64)/$$i" ; \
113		$(LN) "$(ROOTBIN64)/$(PROG)" "$(ROOTBIN64)/$$i" ; \
114	done \
115	)
116
117include ../Makefile.testshell
118