xref: /illumos-gate/usr/src/cmd/getconf/Makefile (revision 55fea89dcaa64928bed4327112404dcb3e07b79f)
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, Version 1.0 only
6# (the "License").  You may not use this file except in compliance
7# with the License.
8#
9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10# or http://www.opensolaris.org/os/licensing.
11# See the License for the specific language governing permissions
12# and limitations under the License.
13#
14# When distributing Covered Code, include this CDDL HEADER in each
15# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16# If applicable, add the following below this CDDL HEADER, with the
17# fields enclosed by brackets "[]" replaced with your own identifying
18# information: Portions Copyright [yyyy] [name of copyright owner]
19#
20# CDDL HEADER END
21#
22#
23# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24# Use is subject to license terms.
25#
26
27PROG= getconf
28XPG4PROG= getconf
29XPG6PROG= getconf
30X4= objs.xpg4
31X6= objs.xpg6
32OBJS= getconf.o
33XPG4EXOBJS= $(X4)/getconf.o
34XPG6EXOBJS= $(X6)/getconf.o
35
36include ../Makefile.cmd
37
38XPG4EXOBJS += values-xpg4.o
39CFLAGS += $(CCVERBOSE)
40# XPG4
41$(XPG4) := CFLAGS += -D_XOPEN_SOURCE -I$(SRC)/lib/libc/inc
42
43# XPG6MODE:  Depending on the version of the compiler, the value of
44# __STDC_VERSION__ may differ even in the presence of the same compilation
45# options. The default compilation mode for Sun compilers that support the
46# C99 standard is -xc99=all,no_lib. CSTD= is equivalent to -xc99=all,no_lib.
47# This translates to C99 semantics without the C99 library specific behaviors
48# and dependencies.
49#
50# For pre-5.7 compilers (unless patched with 117551-04 or 117552-05), in the
51# default compilation mode, __STDC_VERSION__ was defined to be 199901L. For
52# 5.7 and on compilers, __STDC_VERSION__ defaults to 199409L in order to
53# maintain source compatibility. Neither of these cases results in the
54# importing of /usr/lib/values-xpg6.o, so we need to either manually import
55# it via linking with a local version of the object, or set -xc99=%all which
56# by default imports /usr/lib/values-xpg6.o. CSTD=CSTD_GNU99 is equivalent
57# to -xc99=all. If CSTD_GNU99 is defined and we also attempt to link with a
58# local version of values-xpg6.o, an error will occur due to multiple
59# definitions for __xpg4 and __xpg6. Because /usr/lib/values-xpg6.o was
60# delivered in Solaris 10 and is a stable interface, there is no need to
61# build and link with a local version of the object.
62#
63# The gcc compiler behaves differently and requires -std=gnu99.
64#
65# For XPG4, we need to link with a local version of values-xpg4.o because
66# the compiler only imports this by default (from /usr/lib/values-xpg4.o)
67# if we use the c89 utility as opposed to cc.
68
69XPG6MODE = $(CSTD_GNU99)
70$(XPG6) := CSTD = $(XPG6MODE)
71$(XPG6) := CFLAGS += -D_XOPEN_SOURCE=600 -I$(SRC)/lib/libc/inc
72
73.KEEP_STATE:
74
75all: $(PROG) $(XPG4) $(XPG6)
76
77$(PROG):	$(OBJS)
78	$(LINK.c) -o $@ $(OBJS) $(LDLIBS)
79	$(POST_PROCESS)
80
81$(XPG4):	$(X4) $(XPG4EXOBJS)
82	$(LINK.c) -o $@ $(XPG4EXOBJS) $(LDLIBS)
83	$(POST_PROCESS)
84
85$(XPG6):	$(X6) $(XPG6EXOBJS)
86	$(LINK.c) -o $@ $(XPG6EXOBJS) $(LDLIBS)
87	$(POST_PROCESS)
88
89
90$(XPG4EXOBJS):	$(X4)
91
92
93$(X4)/%.o:	%.c
94	$(COMPILE.c) -o $@ $<
95
96
97$(X4):
98	-@mkdir -p $@
99
100
101$(XPG6EXOBJS):	$(X6)
102
103
104$(X6)/%.o:	%.c
105	$(COMPILE.c) -o $@ $<
106
107
108$(X6):
109	-@mkdir -p $@
110
111
112install: all $(ROOTPROG) $(ROOTXPG4PROG) $(ROOTXPG6PROG)
113
114values-xpg4.o: ../../lib/crt/common/values-xpg4.c
115	$(COMPILE.c) -o $@ ../../lib/crt/common/values-xpg4.c
116
117clean:
118	-@rm -rf $(OBJS) $(XPG4EXOBJS) $(XPG6EXOBJS) $(X4) $(X6) \
119		$(PROG) $(XPG4) $(XPG6)
120
121lint:	lint_PROG
122
123include ../Makefile.targ
124