xref: /illumos-gate/usr/src/lib/libumem/Makefile.com (revision 5d9d9091f564c198a760790b0bfa72c44e17912b)
17c478bd9Sstevel@tonic-gate#
27c478bd9Sstevel@tonic-gate# CDDL HEADER START
37c478bd9Sstevel@tonic-gate#
47c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the
5f808c858Sraf# Common Development and Distribution License (the "License").
6f808c858Sraf# You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate#
87c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate# and limitations under the License.
127c478bd9Sstevel@tonic-gate#
137c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate#
197c478bd9Sstevel@tonic-gate# CDDL HEADER END
207c478bd9Sstevel@tonic-gate#
217c478bd9Sstevel@tonic-gate#
227257d1b4Sraf# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate# Use is subject to license terms.
247c478bd9Sstevel@tonic-gate#
25efe51d0cSJohn Levon# Copyright 2019 Joyent, Inc.
264f364e7cSRobert Mustacchi#
277c478bd9Sstevel@tonic-gate
287c478bd9Sstevel@tonic-gate#
297c478bd9Sstevel@tonic-gate# The build process for libumem is sightly different from that used by other
307c478bd9Sstevel@tonic-gate# libraries, because libumem must be built in two flavors - as a standalone
317c478bd9Sstevel@tonic-gate# for use by kmdb and as a normal library.  We use $(CURTYPE) to indicate the
327c478bd9Sstevel@tonic-gate# current flavor being built.
337c478bd9Sstevel@tonic-gate#
347c478bd9Sstevel@tonic-gate
357c478bd9Sstevel@tonic-gateLIBRARY = libumem.a
367c478bd9Sstevel@tonic-gateSTANDLIBRARY = libstandumem.so
377c478bd9Sstevel@tonic-gateVERS = .1
387c478bd9Sstevel@tonic-gate
397c478bd9Sstevel@tonic-gate# By default, we build the shared library.  Construction of the standalone
407c478bd9Sstevel@tonic-gate# is specifically requested by architecture-specific Makefiles.
417c478bd9Sstevel@tonic-gateTYPES = library
427c478bd9Sstevel@tonic-gateCURTYPE = library
437c478bd9Sstevel@tonic-gate
447c478bd9Sstevel@tonic-gate# This would be much prettier if a) Makefile.lib didn't reqire both $(SRCS) and
457c478bd9Sstevel@tonic-gate# $(OBJECTS) to be set or b) make gave us a nice way to do basename in pattern
467c478bd9Sstevel@tonic-gate# replacement definitions.
477c478bd9Sstevel@tonic-gate
487c478bd9Sstevel@tonic-gate# Files specific to the library version of libumem
497c478bd9Sstevel@tonic-gateOBJECTS_library = \
507c478bd9Sstevel@tonic-gate	init_lib.o \
517c478bd9Sstevel@tonic-gate	umem_agent_support.o \
527c478bd9Sstevel@tonic-gate	umem_fail.o \
537c478bd9Sstevel@tonic-gate	umem_fork.o \
54b1e2e3fbSRobert Mustacchi	umem_genasm.o \
557c478bd9Sstevel@tonic-gate	umem_update_thread.o \
567c478bd9Sstevel@tonic-gate	vmem_mmap.o \
577c478bd9Sstevel@tonic-gate	vmem_sbrk.o
587c478bd9Sstevel@tonic-gate
59b1e2e3fbSRobert MustacchiSRCS_common_library = \
60b1e2e3fbSRobert Mustacchi	$(ISASRCDIR)/umem_genasm.c
61b1e2e3fbSRobert Mustacchi
62b1e2e3fbSRobert MustacchiSRCS_library = $(OBJECTS_library:%.o=../common/%.c) $(SRC_common_library)
637c478bd9Sstevel@tonic-gate
647c478bd9Sstevel@tonic-gate# Files specific to the standalone version of libumem
657c478bd9Sstevel@tonic-gateOBJECTS_standalone = \
667c478bd9Sstevel@tonic-gate	init_stand.o \
677c478bd9Sstevel@tonic-gate	stub_stand.o \
687c478bd9Sstevel@tonic-gate	vmem_stand.o
697c478bd9Sstevel@tonic-gate
707c478bd9Sstevel@tonic-gateSRCS_standalone = $(OBJECTS_standalone:%.o=../common/%.c)
717c478bd9Sstevel@tonic-gate
727c478bd9Sstevel@tonic-gate# Architecture-dependent files common to both versions of libumem
737c478bd9Sstevel@tonic-gateOBJECTS_common_isadep = \
74b1e2e3fbSRobert Mustacchi	asm_subr.o
757c478bd9Sstevel@tonic-gate
767c478bd9Sstevel@tonic-gateSRCS_common_isadep = \
77*5d9d9091SRichard Lowe	$(ISASRCDIR)/asm_subr.S
787c478bd9Sstevel@tonic-gate
797c478bd9Sstevel@tonic-gate# Architecture-independent files common to both versions  of libumem
807c478bd9Sstevel@tonic-gateOBJECTS_common_common = \
817c478bd9Sstevel@tonic-gate	envvar.o \
827c478bd9Sstevel@tonic-gate	getpcstack.o \
837c478bd9Sstevel@tonic-gate	malloc.o \
847c478bd9Sstevel@tonic-gate	misc.o \
857c478bd9Sstevel@tonic-gate	vmem_base.o \
867c478bd9Sstevel@tonic-gate	umem.o \
877c478bd9Sstevel@tonic-gate	vmem.o
887c478bd9Sstevel@tonic-gate
897c478bd9Sstevel@tonic-gateSRCS_common_common = $(OBJECTS_common_common:%.o=../common/%.c)
907c478bd9Sstevel@tonic-gate
917c478bd9Sstevel@tonic-gateOBJECTS = \
927c478bd9Sstevel@tonic-gate	$(OBJECTS_$(CURTYPE)) \
937c478bd9Sstevel@tonic-gate	$(OBJECTS_common_isadep) \
947c478bd9Sstevel@tonic-gate	$(OBJECTS_common_common)
957c478bd9Sstevel@tonic-gate
967c478bd9Sstevel@tonic-gateinclude ../../Makefile.lib
977c478bd9Sstevel@tonic-gateinclude ../../Makefile.rootfs
987c478bd9Sstevel@tonic-gate
997c478bd9Sstevel@tonic-gateSRCS = \
1007c478bd9Sstevel@tonic-gate	$(SRCS_$(CURTYPE)) \
1017c478bd9Sstevel@tonic-gate	$(SRCS_common_common)
1027c478bd9Sstevel@tonic-gate
1037c478bd9Sstevel@tonic-gateSRCDIR = ../common
1047c478bd9Sstevel@tonic-gate
1057c478bd9Sstevel@tonic-gate#
1067c478bd9Sstevel@tonic-gate# Used to verify that the standalone doesn't have any unexpected external
1077c478bd9Sstevel@tonic-gate# dependencies.
1087c478bd9Sstevel@tonic-gate#
1097c478bd9Sstevel@tonic-gateLINKTEST_OBJ = objs/linktest_stand.o
1107c478bd9Sstevel@tonic-gate
1117c478bd9Sstevel@tonic-gateCLOBBERFILES_standalone = $(LINKTEST_OBJ)
1127c478bd9Sstevel@tonic-gateCLOBBERFILES += $(CLOBBERFILES_$(CURTYPE))
1137c478bd9Sstevel@tonic-gate
1147c478bd9Sstevel@tonic-gateLIBS_standalone = $(STANDLIBRARY)
115efe51d0cSJohn LevonLIBS_library = $(DYNLIB)
1167c478bd9Sstevel@tonic-gateLIBS =	$(LIBS_$(CURTYPE))
1177c478bd9Sstevel@tonic-gate
1187c478bd9Sstevel@tonic-gateMAPFILE_SUPPLEMENTAL_standalone = ../common/stand_mapfile
1197c478bd9Sstevel@tonic-gateMAPFILE_SUPPLEMENTAL = $(MAPFILE_SUPPLEMENTAL_$(CURTYPE))
1207c478bd9Sstevel@tonic-gate
1217c478bd9Sstevel@tonic-gateLDLIBS +=	-lc
1227c478bd9Sstevel@tonic-gate
12385f4cb87SRichard LoweLDFLAGS_standalone = $(ZNOVERSION) $(BREDUCE) -Wl,-M../common/mapfile-vers \
12485f4cb87SRichard Lowe	-Wl,-M$(MAPFILE_SUPPLEMENTAL) -dy -r
1257c478bd9Sstevel@tonic-gateLDFLAGS = $(LDFLAGS_$(CURTYPE))
1267c478bd9Sstevel@tonic-gate
1277c478bd9Sstevel@tonic-gateASFLAGS_standalone = -DUMEM_STANDALONE
1287c478bd9Sstevel@tonic-gateASFLAGS_library =
129*5d9d9091SRichard LoweASFLAGS += $(ASFLAGS_$(CURTYPE)) -D_ASM
130*5d9d9091SRichard LoweASFLAGS64 += $(ASFLAGS_$(CURTYPE)) -D_ASM
1317c478bd9Sstevel@tonic-gate
1327c478bd9Sstevel@tonic-gate# We want the thread-specific errno in the library, but we don't want it in
1337c478bd9Sstevel@tonic-gate# the standalone.  $(DTS_ERRNO) is designed to add -D_TS_ERRNO to $(CPPFLAGS),
1347c478bd9Sstevel@tonic-gate# in order to enable this feature.  Conveniently, -D_REENTRANT does the same
1357c478bd9Sstevel@tonic-gate# thing.  As such, we null out $(DTS_ERRNO) to ensure that the standalone
1367c478bd9Sstevel@tonic-gate# doesn't get it.
1377c478bd9Sstevel@tonic-gateDTS_ERRNO=
1387c478bd9Sstevel@tonic-gate
1397c478bd9Sstevel@tonic-gate# We need to rename some standard functions so we can easily implement them
1407c478bd9Sstevel@tonic-gate# in consumers.
1417c478bd9Sstevel@tonic-gateSTAND_RENAMED_FUNCS= \
1427257d1b4Sraf	atomic_add_64 \
1437257d1b4Sraf	atomic_add_32_nv \
1444f364e7cSRobert Mustacchi	atomic_swap_64 \
1457c478bd9Sstevel@tonic-gate	snprintf \
1467c478bd9Sstevel@tonic-gate	vsnprintf
1477c478bd9Sstevel@tonic-gate
1487c478bd9Sstevel@tonic-gateCPPFLAGS_standalone = -DUMEM_STANDALONE $(STAND_RENAMED_FUNCS:%=-D%=umem_%)
1497c478bd9Sstevel@tonic-gateCPPFLAGS_library = -D_REENTRANT
1507c478bd9Sstevel@tonic-gateCPPFLAGS +=	-I../common -I../../common/inc $(CPPFLAGS_$(CURTYPE))
1517c478bd9Sstevel@tonic-gate
1527c478bd9Sstevel@tonic-gateCFLAGS_standalone = $(STAND_FLAGS_32)
1537c478bd9Sstevel@tonic-gateCFLAGS_common =
1547c478bd9Sstevel@tonic-gateCFLAGS += $(CFLAGS_$(CURTYPE)) $(CFLAGS_common)
1557c478bd9Sstevel@tonic-gate
1567c478bd9Sstevel@tonic-gateCFLAGS64_standalone = $(STAND_FLAGS_64)
1577c478bd9Sstevel@tonic-gateCFLAGS64 += $(CCVERBOSE) $(CFLAGS64_$(CURTYPE)) $(CFLAGS64_common)
1587c478bd9Sstevel@tonic-gate
1595a0af816SRobert Mustacchi#
1605a0af816SRobert Mustacchi# For the standalone environment, disable the stack protector for the
1615a0af816SRobert Mustacchi# time being.
1625a0af816SRobert Mustacchi#
1635a0af816SRobert Mustacchi$(STANDLIBRARY) := STACKPROTECT = none
1645a0af816SRobert Mustacchi
165efe51d0cSJohn Levon# false positive for umem_alloc_sizes_add()
166efe51d0cSJohn Levonpics/umem.o := SMOFF += index_overflow
167efe51d0cSJohn Levonobjs/umem.o := SMOFF += index_overflow
1687c478bd9Sstevel@tonic-gate
169cd61ae21SRichard LoweINSTALL_DEPS_library =	$(ROOTLINKS) $(ROOTLIBS) $(ROOTCOMPATLINKS)
1707c478bd9Sstevel@tonic-gate
1711d530678SrafDYNFLAGS +=     $(ZINTERPOSE)
1727c478bd9Sstevel@tonic-gate
1737c478bd9Sstevel@tonic-gate.KEEP_STATE:
174