xref: /illumos-gate/usr/src/lib/libumem/Makefile.com (revision b1e2e3fb17324e9ddf43db264a0c64da7756d9e6)
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#
25*b1e2e3fbSRobert Mustacchi# Copyright (c) 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 \
54*b1e2e3fbSRobert 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
59*b1e2e3fbSRobert MustacchiSRCS_common_library = \
60*b1e2e3fbSRobert Mustacchi	$(ISASRCDIR)/umem_genasm.c
61*b1e2e3fbSRobert Mustacchi
62*b1e2e3fbSRobert 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 = \
74*b1e2e3fbSRobert Mustacchi	asm_subr.o
757c478bd9Sstevel@tonic-gate
767c478bd9Sstevel@tonic-gateSRCS_common_isadep = \
77*b1e2e3fbSRobert Mustacchi	$(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)
1157c478bd9Sstevel@tonic-gateLIBS_library = $(DYNLIB) $(LINTLIB)
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
12324da5b34SrieLDFLAGS_standalone = $(ZNOVERSION) $(BREDUCE) -M../common/mapfile-vers \
1247c478bd9Sstevel@tonic-gate	-M$(MAPFILE_SUPPLEMENTAL) -dy -r
1257c478bd9Sstevel@tonic-gateLDFLAGS = $(LDFLAGS_$(CURTYPE))
1267c478bd9Sstevel@tonic-gate
1277c478bd9Sstevel@tonic-gateASFLAGS_standalone = -DUMEM_STANDALONE
1287c478bd9Sstevel@tonic-gateASFLAGS_library =
1297c478bd9Sstevel@tonic-gateASFLAGS += -P $(ASFLAGS_$(CURTYPE)) -D_ASM
1307c478bd9Sstevel@tonic-gate
1317c478bd9Sstevel@tonic-gate$(LINTLIB) := SRCS = ../common/$(LINTSRC)
1327c478bd9Sstevel@tonic-gate
1337c478bd9Sstevel@tonic-gate# We want the thread-specific errno in the library, but we don't want it in
1347c478bd9Sstevel@tonic-gate# the standalone.  $(DTS_ERRNO) is designed to add -D_TS_ERRNO to $(CPPFLAGS),
1357c478bd9Sstevel@tonic-gate# in order to enable this feature.  Conveniently, -D_REENTRANT does the same
1367c478bd9Sstevel@tonic-gate# thing.  As such, we null out $(DTS_ERRNO) to ensure that the standalone
1377c478bd9Sstevel@tonic-gate# doesn't get it.
1387c478bd9Sstevel@tonic-gateDTS_ERRNO=
1397c478bd9Sstevel@tonic-gate
1407c478bd9Sstevel@tonic-gate# We need to rename some standard functions so we can easily implement them
1417c478bd9Sstevel@tonic-gate# in consumers.
1427c478bd9Sstevel@tonic-gateSTAND_RENAMED_FUNCS= \
1437257d1b4Sraf	atomic_add_64 \
1447257d1b4Sraf	atomic_add_32_nv \
1454f364e7cSRobert Mustacchi	atomic_swap_64 \
1467c478bd9Sstevel@tonic-gate	snprintf \
1477c478bd9Sstevel@tonic-gate	vsnprintf
1487c478bd9Sstevel@tonic-gate
1497c478bd9Sstevel@tonic-gateCPPFLAGS_standalone = -DUMEM_STANDALONE $(STAND_RENAMED_FUNCS:%=-D%=umem_%)
1507c478bd9Sstevel@tonic-gateCPPFLAGS_library = -D_REENTRANT
1517c478bd9Sstevel@tonic-gateCPPFLAGS +=	-I../common -I../../common/inc $(CPPFLAGS_$(CURTYPE))
1527c478bd9Sstevel@tonic-gate
1537c478bd9Sstevel@tonic-gateCFLAGS_standalone = $(STAND_FLAGS_32)
1547c478bd9Sstevel@tonic-gateCFLAGS_common =
1557c478bd9Sstevel@tonic-gateCFLAGS += $(CFLAGS_$(CURTYPE)) $(CFLAGS_common)
1567c478bd9Sstevel@tonic-gate
1577c478bd9Sstevel@tonic-gateCFLAGS64_standalone = $(STAND_FLAGS_64)
1587c478bd9Sstevel@tonic-gateCFLAGS64 += $(CCVERBOSE) $(CFLAGS64_$(CURTYPE)) $(CFLAGS64_common)
1597c478bd9Sstevel@tonic-gate
1607c478bd9Sstevel@tonic-gateINSTALL_DEPS_library =		$(ROOTLINKS) $(ROOTLINT) $(ROOTLIBS)
1617c478bd9Sstevel@tonic-gate
1627c478bd9Sstevel@tonic-gate#
1637c478bd9Sstevel@tonic-gate# turn off ptr-cast warnings, since we do them all the time
1647c478bd9Sstevel@tonic-gate#
1657c478bd9Sstevel@tonic-gateLINTFLAGS +=	-erroff=E_BAD_PTR_CAST_ALIGN
1667c478bd9Sstevel@tonic-gateLINTFLAGS64 +=	-erroff=E_BAD_PTR_CAST_ALIGN
1677c478bd9Sstevel@tonic-gate
1681d530678SrafDYNFLAGS +=     $(ZINTERPOSE)
1697c478bd9Sstevel@tonic-gate
1707c478bd9Sstevel@tonic-gate.KEEP_STATE:
171