1702941cdSRichard Lowe#
2702941cdSRichard Lowe# CDDL HEADER START
3702941cdSRichard Lowe#
4702941cdSRichard Lowe# The contents of this file are subject to the terms of the
5702941cdSRichard Lowe# Common Development and Distribution License (the "License").
6702941cdSRichard Lowe# You may not use this file except in compliance with the License.
7702941cdSRichard Lowe#
8702941cdSRichard Lowe# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9702941cdSRichard Lowe# or http://www.opensolaris.org/os/licensing.
10702941cdSRichard Lowe# See the License for the specific language governing permissions
11702941cdSRichard Lowe# and limitations under the License.
12702941cdSRichard Lowe#
13702941cdSRichard Lowe# When distributing Covered Code, include this CDDL HEADER in each
14702941cdSRichard Lowe# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15702941cdSRichard Lowe# If applicable, add the following below this CDDL HEADER, with the
16702941cdSRichard Lowe# fields enclosed by brackets "[]" replaced with your own identifying
17702941cdSRichard Lowe# information: Portions Copyright [yyyy] [name of copyright owner]
18702941cdSRichard Lowe#
19702941cdSRichard Lowe# CDDL HEADER END
20702941cdSRichard Lowe#
21702941cdSRichard Lowe#
22702941cdSRichard Lowe# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23702941cdSRichard Lowe# Use is subject to license terms.
24702941cdSRichard Lowe#
2592c1a611SBryan Cantrill# Copyright (c) 2019, Joyent, Inc.
26702941cdSRichard Lowe
27702941cdSRichard Lowe#
28702941cdSRichard Lowe# The build process for libsaveargs is sightly different from that used by other
29702941cdSRichard Lowe# libraries, because libsaveargs must be built in two flavors - as a standalone
30702941cdSRichard Lowe# for use by kmdb and as a normal library.  We use $(CURTYPE) to indicate the
31702941cdSRichard Lowe# current flavor being built.
32702941cdSRichard Lowe#
33702941cdSRichard Lowe
34702941cdSRichard LoweLIBRARY=	libsaveargs.a
35702941cdSRichard LoweSTANDLIBRARY=	libstandsaveargs.so
36702941cdSRichard LoweVERS=		.1
37702941cdSRichard Lowe
38702941cdSRichard Lowe# By default, we build the shared library.  Construction of the standalone
39702941cdSRichard Lowe# is specifically requested by architecture-specific Makefiles.
40702941cdSRichard LoweTYPES=		library
41702941cdSRichard LoweCURTYPE=	library
42702941cdSRichard Lowe
43702941cdSRichard LoweCOMDIR=		$(SRC)/lib/libsaveargs/common
44702941cdSRichard Lowe
45702941cdSRichard LoweOBJECTS_common_amd64	= saveargs.o
46702941cdSRichard LoweSRCS_common_amd64	= $(OBJECTS_common_amd64:%.o=../amd64/%.c)
47702941cdSRichard Lowe
48702941cdSRichard LoweOBJECTS= $(OBJECTS_common_$(MACH)) $(OBJECTS_common_$(MACH64)) $(OBJECTS_common_common)
49702941cdSRichard Lowe
50702941cdSRichard Loweinclude $(SRC)/lib/Makefile.lib
51702941cdSRichard Lowe
52702941cdSRichard LoweSRCS=	$(SRCS_common_$(MACH)) $(SRCS_common_$(MACH64)) $(SRC_common_common)
53702941cdSRichard Lowe
54702941cdSRichard Lowe#
55702941cdSRichard Lowe# Used to verify that the standalone doesn't have any unexpected external
56702941cdSRichard Lowe# dependencies.
57702941cdSRichard Lowe#
58702941cdSRichard LoweLINKTEST_OBJ = objs/linktest_stand.o
59702941cdSRichard Lowe
60702941cdSRichard LoweCLOBBERFILES_standalone = $(LINKTEST_OBJ)
61702941cdSRichard LoweCLOBBERFILES += $(CLOBBERFILES_$(CURTYPE))
62702941cdSRichard Lowe
635a0af816SRobert Mustacchi#
645a0af816SRobert Mustacchi# The standalone environment currently does not support the stack
655a0af816SRobert Mustacchi# protector.
665a0af816SRobert Mustacchi#
675a0af816SRobert Mustacchi$(STANDLIBRARY) := STACKPROTECT = none
685a0af816SRobert Mustacchi
69702941cdSRichard LoweLIBS_standalone	= $(STANDLIBRARY)
70241c90a0SRichard LoweLIBS_library = $(DYNLIB)
71702941cdSRichard LoweLIBS = $(LIBS_$(CURTYPE))
72702941cdSRichard Lowe
73702941cdSRichard LoweMAPFILES =	$(COMDIR)/mapfile-vers
74702941cdSRichard Lowe
75702941cdSRichard LoweLDLIBS +=	-lc -ldisasm
76702941cdSRichard Lowe
77702941cdSRichard LoweLDFLAGS_standalone = $(ZNOVERSION) $(BREDUCE) -dy -r
78702941cdSRichard LoweLDFLAGS = $(LDFLAGS_$(CURTYPE))
79702941cdSRichard Lowe
80702941cdSRichard LoweASFLAGS_standalone = -DDIS_STANDALONE
81702941cdSRichard LoweASFLAGS_library =
82*5d9d9091SRichard LoweASFLAGS += $(ASFLAGS_$(CURTYPE)) -D_ASM
83702941cdSRichard Lowe
84702941cdSRichard Lowe
85702941cdSRichard Lowe# We want the thread-specific errno in the library, but we don't want it in
86702941cdSRichard Lowe# the standalone.  $(DTS_ERRNO) is designed to add -D_TS_ERRNO to $(CPPFLAGS),
87702941cdSRichard Lowe# in order to enable this feature.  Conveniently, -D_REENTRANT does the same
88702941cdSRichard Lowe# thing.  As such, we null out $(DTS_ERRNO) to ensure that the standalone
89702941cdSRichard Lowe# doesn't get it.
90702941cdSRichard LoweDTS_ERRNO=
91702941cdSRichard Lowe
92702941cdSRichard LoweCPPFLAGS_standalone = -DDIS_STANDALONE
93702941cdSRichard LoweCPPFLAGS_library = -D_REENTRANT
94702941cdSRichard LoweCPPFLAGS +=	-I$(COMDIR) $(CPPFLAGS_$(CURTYPE))
95702941cdSRichard Lowe
96702941cdSRichard LoweCFLAGS_standalone = $(STAND_FLAGS_32)
97702941cdSRichard LoweCFLAGS_common =
98702941cdSRichard LoweCFLAGS += $(CFLAGS_$(CURTYPE)) $(CFLAGS_common)
99702941cdSRichard Lowe
100702941cdSRichard LoweCFLAGS64_standalone = $(STAND_FLAGS_64)
101702941cdSRichard LoweCFLAGS64 += $(CCVERBOSE) $(CFLAGS64_$(CURTYPE)) $(CFLAGS64_common)
102702941cdSRichard Lowe
103702941cdSRichard LoweDYNFLAGS +=     $(ZINTERPOSE)
104702941cdSRichard Lowe
105702941cdSRichard Lowe.KEEP_STATE:
106