xref: /titanic_51/usr/src/cmd/ast/libast/Makefile.com (revision b4dd7d09880f14016feece03929a224eca1cf39a)
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) 2019, Joyent, Inc.
26# Copyright 2021 OmniOS Community Edition (OmniOSce) Association.
27
28SHELL= /usr/bin/ksh93
29
30LIBRARY= libast.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)
43LDLIBS += -lm -lc -lsocket
44
45# We use "=" here since using $(CPPFLAGS.master) is very tricky in our
46# case - it MUST come as the last element but future changes in -D options
47# may then cause silent breakage in the AST sources because the last -D
48# option specified overrides previous -D options so we prefer the current
49# way to explicitly list each single flag.
50# Notes:
51#   - "-D_BLD_DLL" comes from ${mam_cc_DLL} in Mamfile
52#   - Be careful with "-D__OBSOLETE__=xxx". Make sure this is in sync with
53#     upstream (see Mamfile) and do not change the |__OBSOLETE__| value
54#     without examining the symbols that will be removed, and evaluating
55#     whether that breaks compatibility with upstream binaries.
56CPPFLAGS= \
57	$(DTEXTDOM) $(DTS_ERRNO) \
58	$(ASTPLATFORMCPPFLAGS) \
59	-Iast -I. \
60	-I$(ASTSRC) \
61	-I$(ASTSRC)/comp \
62	-I$(ASTSRC)/include \
63	-I$(ASTSRC)/std \
64	-I$(ASTSRC)/dir \
65	-I$(ASTSRC)/port \
66	-I$(ASTSRC)/sfio \
67	-I$(ASTSRC)/misc \
68	-I$(ASTSRC)/string \
69	-I$(ROOT)/usr/include \
70	'-DCONF_LIBSUFFIX=".so"' \
71	'-DCONF_LIBPREFIX="lib"' \
72	-DERROR_CATALOG=\""libast"\" \
73	-D__OBSOLETE__=20120101 \
74	-D_BLD_ast \
75	-D_PACKAGE_ast \
76	-D_BLD_DLL \
77	-D_AST_std_malloc=1
78
79CFLAGS += $(ASTCFLAGS)
80CFLAGS64 += $(ASTCFLAGS64)
81
82CERRWARN += -_gcc=-Wno-parentheses
83CERRWARN += $(CNOWARN_UNINIT)
84CERRWARN += -_gcc=-Wno-char-subscripts
85CERRWARN += -_gcc=-Wno-clobbered
86CERRWARN += -_gcc=-Wno-unused-variable
87CERRWARN += -_gcc=-Wno-unused-value
88CERRWARN += -_gcc=-Wno-unused-function
89CERRWARN += -_gcc=-Wno-unused-label
90CERRWARN += -_gcc=-Wno-implicit-function-declaration
91CERRWARN += -_gcc=-Wno-empty-body
92CERRWARN += -_gcc=-Wno-type-limits
93CERRWARN += -_gcc=-Wno-address
94
95SMATCH= off
96
97all: install_h mkpicdirs .WAIT $(LIBS)
98
99mkpicdirs:
100	mkdir -p $(LOBJDIRS:%=pics/%)
101
102include $(SRC)/lib/Makefile.targ
103
104pics/%.o: $(ASTSRC)/%.c
105	$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
106	$(POST_PROCESS_O)
107
108######################################################################
109# Header file generation
110
111ast/prototyped.h: FRC
112	$(MKDIR) -p $(@D)
113	$(AST_TOOLS)/proto -f /dev/null > $@
114
115ast/ast_common.h: ast/prototyped.h
116	$(AST_PROTO) FEATURE/common | $(GREP) -v 'define _def_map_' > $@
117	$(POST_PROCESS_AST) $@
118	$(CP) $@ .
119
120ast/lc.h: lc.h
121	$(AST_PROTO) lc.h > ast/lc.h
122
123# The HEADERGEN headers are generated from the corresponding FEATURE/ file
124# with any ast_ prefix removed.
125$(HEADERGEN:%=ast/%): FRC
126	src=`echo $(@F:%.h=%) | sed 's/^ast_//'`; \
127	    $(AST_PROTO) FEATURE/$$src > $@
128	$(POST_PROCESS_AST) $@
129
130$(HEADERSRC:%=ast/%): FRC
131	src=$(@F) ;\
132	[[ $$src = ast_namval.h ]] && src=namval.h ;\
133	for d in include $(LOBJDIRS) std; do \
134		if [[ -f $(ASTSRC)/$$d/$$src ]]; then \
135			echo "$$d/$$src -> $@"; \
136			cp $(ASTSRC)/$$d/$$src $@; \
137			$(POST_PROCESS_AST) $@; \
138			break; \
139		fi; \
140	done
141
142CLOBBERFILES += ast_common.h t.c
143CLOBBERFILES += ast/*
144
145install_h: ast/prototyped.h ast/ast_common.h ast/lc.h \
146	$(HEADERGEN:%=ast/%) $(HEADERSRC:%=ast/%)
147
148.PARALLEL: $(HEADERGEN:%=ast/%) $(HEADERSRC:%=ast/%)
149
150_feature: FRC
151	$(MAKE) -f Makefile.iffe generate
152
153include ../../Makefile.astmsg
154
155FRC:
156