xref: /illumos-gate/usr/src/lib/libumem/Makefile.com (revision 9b9d39d2a32ff806d2431dbcc50968ef1e6d46b2)
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# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23# Use is subject to license terms.
24#
25# Copyright 2019 Joyent, Inc.
26#
27
28#
29# The build process for libumem is sightly different from that used by other
30# libraries, because libumem must be built in two flavors - as a standalone
31# for use by kmdb and as a normal library.  We use $(CURTYPE) to indicate the
32# current flavor being built.
33#
34
35LIBRARY = libumem.a
36STANDLIBRARY = libstandumem.so
37VERS = .1
38
39# By default, we build the shared library.  Construction of the standalone
40# is specifically requested by architecture-specific Makefiles.
41TYPES = library
42CURTYPE = library
43
44# This would be much prettier if a) Makefile.lib didn't reqire both $(SRCS) and
45# $(OBJECTS) to be set or b) make gave us a nice way to do basename in pattern
46# replacement definitions.
47
48# Files specific to the library version of libumem
49OBJECTS_library = \
50	init_lib.o \
51	umem_agent_support.o \
52	umem_fail.o \
53	umem_fork.o \
54	umem_genasm.o \
55	umem_update_thread.o \
56	vmem_mmap.o \
57	vmem_sbrk.o
58
59SRCS_common_library = \
60	$(ISASRCDIR)/umem_genasm.c
61
62SRCS_library = $(OBJECTS_library:%.o=../common/%.c) $(SRC_common_library)
63
64# Files specific to the standalone version of libumem
65OBJECTS_standalone = \
66	init_stand.o \
67	stub_stand.o \
68	vmem_stand.o
69
70SRCS_standalone = $(OBJECTS_standalone:%.o=../common/%.c)
71
72# Architecture-dependent files common to both versions of libumem
73OBJECTS_common_isadep = \
74	asm_subr.o
75
76SRCS_common_isadep = \
77	$(ISASRCDIR)/asm_subr.S
78
79# Architecture-independent files common to both versions  of libumem
80OBJECTS_common_common = \
81	envvar.o \
82	getpcstack.o \
83	malloc.o \
84	misc.o \
85	vmem_base.o \
86	umem.o \
87	vmem.o
88
89SRCS_common_common = $(OBJECTS_common_common:%.o=../common/%.c)
90
91OBJECTS = \
92	$(OBJECTS_$(CURTYPE)) \
93	$(OBJECTS_common_isadep) \
94	$(OBJECTS_common_common)
95
96include ../../Makefile.lib
97include ../../Makefile.rootfs
98
99SRCS = \
100	$(SRCS_$(CURTYPE)) \
101	$(SRCS_common_common)
102
103SRCDIR = ../common
104
105#
106# Used to verify that the standalone doesn't have any unexpected external
107# dependencies.
108#
109LINKTEST_OBJ = objs/linktest_stand.o
110
111CLOBBERFILES_standalone = $(LINKTEST_OBJ)
112CLOBBERFILES += $(CLOBBERFILES_$(CURTYPE))
113
114LIBS_standalone = $(STANDLIBRARY)
115LIBS_library = $(DYNLIB)
116LIBS =	$(LIBS_$(CURTYPE))
117
118MAPFILE_SUPPLEMENTAL_standalone = ../common/stand_mapfile
119MAPFILE_SUPPLEMENTAL = $(MAPFILE_SUPPLEMENTAL_$(CURTYPE))
120
121LDLIBS +=	-lc
122
123LDFLAGS_standalone = $(ZNOVERSION) $(BREDUCE) -Wl,-M../common/mapfile-vers \
124	-Wl,-M$(MAPFILE_SUPPLEMENTAL) -dy -r
125LDFLAGS = $(LDFLAGS_$(CURTYPE))
126
127ASFLAGS_standalone = -DUMEM_STANDALONE
128ASFLAGS_library =
129ASFLAGS += $(ASFLAGS_$(CURTYPE)) -D_ASM
130ASFLAGS64 += $(ASFLAGS_$(CURTYPE)) -D_ASM
131
132# We want the thread-specific errno in the library, but we don't want it in
133# the standalone.  $(DTS_ERRNO) is designed to add -D_TS_ERRNO to $(CPPFLAGS),
134# in order to enable this feature.  Conveniently, -D_REENTRANT does the same
135# thing.  As such, we null out $(DTS_ERRNO) to ensure that the standalone
136# doesn't get it.
137DTS_ERRNO=
138
139# We need to rename some standard functions so we can easily implement them
140# in consumers.
141STAND_RENAMED_FUNCS= \
142	atomic_add_64 \
143	atomic_add_32_nv \
144	atomic_swap_64 \
145	snprintf \
146	vsnprintf
147
148CPPFLAGS_standalone = -DUMEM_STANDALONE $(STAND_RENAMED_FUNCS:%=-D%=umem_%)
149CPPFLAGS_library = -D_REENTRANT
150CPPFLAGS +=	-I../common -I../../common/inc $(CPPFLAGS_$(CURTYPE))
151
152CFLAGS_standalone = $(STAND_FLAGS_32)
153CFLAGS_common =
154CFLAGS += $(CFLAGS_$(CURTYPE)) $(CFLAGS_common)
155
156CFLAGS64_standalone = $(STAND_FLAGS_64)
157CFLAGS64 += $(CCVERBOSE) $(CFLAGS64_$(CURTYPE)) $(CFLAGS64_common)
158
159#
160# For the standalone environment, disable the stack protector for the
161# time being.
162#
163$(STANDLIBRARY) := STACKPROTECT = none
164
165# false positive for umem_alloc_sizes_add()
166pics/umem.o := SMOFF += index_overflow
167objs/umem.o := SMOFF += index_overflow
168
169INSTALL_DEPS_library =	$(ROOTLINKS) $(ROOTLIBS) $(ROOTCOMPATLINKS)
170
171DYNFLAGS +=     $(ZINTERPOSE)
172
173.KEEP_STATE:
174