xref: /illumos-gate/usr/src/cmd/ast/libcmd/Makefile.com (revision 44ce9f4b)
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
30LIBRARY= libcmd.a
31VERS= .1
32
33include ../Makefile.defs
34
35OBJECTS += $(LIBOBJS)
36
37include $(SRC)/lib/Makefile.lib
38include ../../Makefile.ast
39
40MAPFILES= ../mapfile-vers
41
42LIBS= $(DYNLIB)
43
44LDLIBS += -lsum -last -lsocket -lnsl -lc
45
46# We use "=" here since using $(CPPFLAGS.master) is very tricky in our
47# case - it MUST come as the last element but future changes in -D options
48# may then cause silent breakage in the AST sources because the last -D
49# option specified overrides previous -D options so we prefer the current
50# way to explicitly list each single flag.
51CPPFLAGS= \
52	$(DTEXTDOM) $(DTS_ERRNO) \
53	-I$(ASTSRC) \
54	-Iast -I. \
55	-I$(ROOT)/usr/include/ast \
56	-I$(ROOT)/usr/include \
57	-D_BLD_cmd \
58	-D_PACKAGE_ast \
59	-D_BLD_DLL \
60	'-DERROR_CATALOG="libcmd"' \
61	'-DUSAGE_LICENSE=\
62	    "[-author?Glenn Fowler <gsf@research.att.com>]"\
63	    "[-author?David Korn <dgk@research.att.com>]"\
64	    "[-copyright?Copyright (c) 1992-2012 AT&T Intellectual Property]"\
65	    "[-license?http://www.eclipse.org/org/documents/epl-v10.html]"\
66	    "[--catalog?libcmd]"'
67
68CFLAGS += $(ASTCFLAGS)
69CFLAGS64 += $(ASTCFLAGS64)
70
71CERRWARN	+= -_gcc=-Wno-unused-value
72CERRWARN	+= -_gcc=-Wno-parentheses
73CERRWARN	+= $(CNOWARN_UNINIT)
74CERRWARN	+= -_gcc=-Wno-unused-variable
75CERRWARN	+= -_gcc=-Wno-implicit-function-declaration
76
77# not linted
78SMATCH=off
79
80.KEEP_STATE:
81
82all: install_h .WAIT $(LIBS)
83
84include $(SRC)/lib/Makefile.targ
85
86pics/%.o: $(ASTSRC)/%.c
87	$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
88	$(POST_PROCESS_O)
89
90######################################################################
91# Header file generation
92
93$(HEADERSRC:%=ast/%): $(HEADERSRC:%=$(ASTSRC)/%)
94	$(MKDIR) -p $(@D)
95	$(CP) $(ASTSRC)/$(@F) $@
96
97# This rule is derived from $(CONTRIB)/ast/src/lib/libcmd/Makefile
98ast/cmdext.h: $(OBJECTS:%.o=$(ASTSRC)/%.c)
99	$(MKDIR) -p $(@D)
100	echo '#include <shcmd.h>' > $@.tmp
101	$(SED) \
102	    -e '/^b_[a-z_][a-z_0-9]*(/!d' \
103	    -e 's/^b_//' \
104	    -e 's/(.*//' \
105	    -e 's/.*/extern int     b_&(int, char**, Shbltin_t*);/' \
106	    $(OBJECTS:%.o=$(ASTSRC)/%.c) | \
107	    $(SORT) -u \
108	    >> $@.tmp
109	$(AST_PROTO) -f $@.tmp >> $@
110	rm -f $@.tmp
111	$(POST_PROCESS_AST)
112
113CLOBBERFILES += ast/*
114
115install_h: $(HEADERSRC:%=ast/%) $(HEADERGEN:%=ast/%)
116
117.PARALLEL: $(HEADERSRC:%=ast/%) $(HEADERGEN:%=ast/%)
118
119_feature: FRC
120	$(MAKE) -f Makefile.iffe generate
121
122include ../../Makefile.astmsg
123
124FRC:
125