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# 22564a4557Sraf# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate# Use is subject to license terms. 247c478bd9Sstevel@tonic-gate# 257c478bd9Sstevel@tonic-gate# ident "%Z%%M% %I% %E% SMI" 267c478bd9Sstevel@tonic-gate# 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 \ 547c478bd9Sstevel@tonic-gate umem_update_thread.o \ 557c478bd9Sstevel@tonic-gate vmem_mmap.o \ 567c478bd9Sstevel@tonic-gate vmem_sbrk.o 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gateSRCS_library = $(OBJECTS_library:%.o=../common/%.c) 597c478bd9Sstevel@tonic-gate 607c478bd9Sstevel@tonic-gate# Files specific to the standalone version of libumem 617c478bd9Sstevel@tonic-gateOBJECTS_standalone = \ 627c478bd9Sstevel@tonic-gate init_stand.o \ 637c478bd9Sstevel@tonic-gate stub_stand.o \ 647c478bd9Sstevel@tonic-gate vmem_stand.o 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gateSRCS_standalone = $(OBJECTS_standalone:%.o=../common/%.c) 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate# Architecture-dependent files common to both versions of libumem 697c478bd9Sstevel@tonic-gateOBJECTS_common_isadep = \ 707c478bd9Sstevel@tonic-gate asm_subr.o 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gateSRCS_common_isadep = \ 737c478bd9Sstevel@tonic-gate $(ISASRCDIR)/asm_subr.s 747c478bd9Sstevel@tonic-gate 757c478bd9Sstevel@tonic-gate# Architecture-independent files common to both versions of libumem 767c478bd9Sstevel@tonic-gateOBJECTS_common_common = \ 777c478bd9Sstevel@tonic-gate envvar.o \ 787c478bd9Sstevel@tonic-gate getpcstack.o \ 797c478bd9Sstevel@tonic-gate malloc.o \ 807c478bd9Sstevel@tonic-gate misc.o \ 817c478bd9Sstevel@tonic-gate vmem_base.o \ 827c478bd9Sstevel@tonic-gate umem.o \ 837c478bd9Sstevel@tonic-gate vmem.o 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gateSRCS_common_common = $(OBJECTS_common_common:%.o=../common/%.c) 867c478bd9Sstevel@tonic-gate 877c478bd9Sstevel@tonic-gateOBJECTS = \ 887c478bd9Sstevel@tonic-gate $(OBJECTS_$(CURTYPE)) \ 897c478bd9Sstevel@tonic-gate $(OBJECTS_common_isadep) \ 907c478bd9Sstevel@tonic-gate $(OBJECTS_common_common) 917c478bd9Sstevel@tonic-gate 927c478bd9Sstevel@tonic-gateinclude ../../Makefile.lib 937c478bd9Sstevel@tonic-gateinclude ../../Makefile.rootfs 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gateSRCS = \ 967c478bd9Sstevel@tonic-gate $(SRCS_$(CURTYPE)) \ 977c478bd9Sstevel@tonic-gate $(SRCS_common_isadep) \ 987c478bd9Sstevel@tonic-gate $(SRCS_common_common) 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gateSRCDIR = ../common 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate# 1037c478bd9Sstevel@tonic-gate# Used to verify that the standalone doesn't have any unexpected external 1047c478bd9Sstevel@tonic-gate# dependencies. 1057c478bd9Sstevel@tonic-gate# 1067c478bd9Sstevel@tonic-gateLINKTEST_OBJ = objs/linktest_stand.o 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gateCLOBBERFILES_standalone = $(LINKTEST_OBJ) 1097c478bd9Sstevel@tonic-gateCLOBBERFILES += $(CLOBBERFILES_$(CURTYPE)) 1107c478bd9Sstevel@tonic-gate 1117c478bd9Sstevel@tonic-gateLIBS_standalone = $(STANDLIBRARY) 1127c478bd9Sstevel@tonic-gateLIBS_library = $(DYNLIB) $(LINTLIB) 1137c478bd9Sstevel@tonic-gateLIBS = $(LIBS_$(CURTYPE)) 1147c478bd9Sstevel@tonic-gate 1157c478bd9Sstevel@tonic-gateMAPFILE_SUPPLEMENTAL_standalone = ../common/stand_mapfile 1167c478bd9Sstevel@tonic-gateMAPFILE_SUPPLEMENTAL = $(MAPFILE_SUPPLEMENTAL_$(CURTYPE)) 1177c478bd9Sstevel@tonic-gate 1187c478bd9Sstevel@tonic-gateLDLIBS += -lc 1197c478bd9Sstevel@tonic-gate 120*24da5b34SrieLDFLAGS_standalone = $(ZNOVERSION) $(BREDUCE) -M../common/mapfile-vers \ 1217c478bd9Sstevel@tonic-gate -M$(MAPFILE_SUPPLEMENTAL) -dy -r 1227c478bd9Sstevel@tonic-gateLDFLAGS = $(LDFLAGS_$(CURTYPE)) 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gateASFLAGS_standalone = -DUMEM_STANDALONE 1257c478bd9Sstevel@tonic-gateASFLAGS_library = 1267c478bd9Sstevel@tonic-gateASFLAGS += -P $(ASFLAGS_$(CURTYPE)) -D_ASM 1277c478bd9Sstevel@tonic-gate 1287c478bd9Sstevel@tonic-gate$(LINTLIB) := SRCS = ../common/$(LINTSRC) 1297c478bd9Sstevel@tonic-gate 1307c478bd9Sstevel@tonic-gate# We want the thread-specific errno in the library, but we don't want it in 1317c478bd9Sstevel@tonic-gate# the standalone. $(DTS_ERRNO) is designed to add -D_TS_ERRNO to $(CPPFLAGS), 1327c478bd9Sstevel@tonic-gate# in order to enable this feature. Conveniently, -D_REENTRANT does the same 1337c478bd9Sstevel@tonic-gate# thing. As such, we null out $(DTS_ERRNO) to ensure that the standalone 1347c478bd9Sstevel@tonic-gate# doesn't get it. 1357c478bd9Sstevel@tonic-gateDTS_ERRNO= 1367c478bd9Sstevel@tonic-gate 1377c478bd9Sstevel@tonic-gate# We need to rename some standard functions so we can easily implement them 1387c478bd9Sstevel@tonic-gate# in consumers. 1397c478bd9Sstevel@tonic-gateSTAND_RENAMED_FUNCS= \ 1407c478bd9Sstevel@tonic-gate _atomic_add_64 \ 1417c478bd9Sstevel@tonic-gate _atomic_add_32_nv \ 1427c478bd9Sstevel@tonic-gate snprintf \ 1437c478bd9Sstevel@tonic-gate vsnprintf 1447c478bd9Sstevel@tonic-gate 1457c478bd9Sstevel@tonic-gateCPPFLAGS_standalone = -DUMEM_STANDALONE $(STAND_RENAMED_FUNCS:%=-D%=umem_%) 1467c478bd9Sstevel@tonic-gateCPPFLAGS_library = -D_REENTRANT 1477c478bd9Sstevel@tonic-gateCPPFLAGS += -I../common -I../../common/inc $(CPPFLAGS_$(CURTYPE)) 1487c478bd9Sstevel@tonic-gate 1497c478bd9Sstevel@tonic-gateCFLAGS_standalone = $(STAND_FLAGS_32) 1507c478bd9Sstevel@tonic-gateCFLAGS_common = 1517c478bd9Sstevel@tonic-gateCFLAGS += $(CFLAGS_$(CURTYPE)) $(CFLAGS_common) 1527c478bd9Sstevel@tonic-gate 1537c478bd9Sstevel@tonic-gateCFLAGS64_standalone = $(STAND_FLAGS_64) 1547c478bd9Sstevel@tonic-gateCFLAGS64 += $(CCVERBOSE) $(CFLAGS64_$(CURTYPE)) $(CFLAGS64_common) 1557c478bd9Sstevel@tonic-gate 1567c478bd9Sstevel@tonic-gateINSTALL_DEPS_library = $(ROOTLINKS) $(ROOTLINT) $(ROOTLIBS) 1577c478bd9Sstevel@tonic-gate 1587c478bd9Sstevel@tonic-gate# 1597c478bd9Sstevel@tonic-gate# turn off ptr-cast warnings, since we do them all the time 1607c478bd9Sstevel@tonic-gate# 1617c478bd9Sstevel@tonic-gateLINTFLAGS += -erroff=E_BAD_PTR_CAST_ALIGN 1627c478bd9Sstevel@tonic-gateLINTFLAGS64 += -erroff=E_BAD_PTR_CAST_ALIGN 1637c478bd9Sstevel@tonic-gate 1641d530678SrafDYNFLAGS += $(ZINTERPOSE) 1657c478bd9Sstevel@tonic-gate 1667c478bd9Sstevel@tonic-gate.KEEP_STATE: 167