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# Copyright 2019 OmniOS Community Edition (OmniOSce) Association. 22# Copyright 2015 Gary Mills 23# Copyright 2015 Igor Kozhukhov <ikozhukhov@gmail.com> 24# Copyright 2016 RackTop Systems. 25# Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. 26# Copyright 2019, Joyent, Inc. 27# 28# 29# Definitions common to libraries. 30# 31# include global definitions; SRC should be defined in the shell. 32# SRC is needed until RFE 1026993 is implemented. 33 34include $(SRC)/Makefile.master 35 36LORDER= lorder 37TSORT= tsort 38 39# 40# By default, we define the source directory for libraries to be 41# one level up from the ISA-specific directory, where the code is 42# actually built. Many libraries define a 'common' directory to 43# contain the source. These libraries must redefine SRCDIR as: 44# SRCDIR = ../common 45# Other variations are possible (../port, ../src, etc). 46# 47SRCDIR = .. 48 49# 50# We define MAPFILES here for the benefit of most libraries, those that 51# follow the convention of having source files and other common files 52# in the $(SRCDIR) directory. Libraries that do not follow this 53# convention must define MAPFILES, or MAPFILEDIR for themselves. 54# Libraries that do follow this convention but that need supplemental 55# ISA-specific mapfiles can augment MAPFILES like this: 56# MAPFILES += mapfile-vers 57# 58MAPFILEDIR = $(SRCDIR) 59MAPFILES = $(MAPFILEDIR)/mapfile-vers 60 61# 62# If HDRDIR is left unset, then it's possible for the $(ROOTHDRDIR)/% 63# install rule in lib/Makefile.targ to generate false matches if there 64# are any common directory names between / and /usr/include (`xfn' is 65# one common example). To prevent this, we set HDRDIR to a directory 66# name that will almost surely not exist on the build machine. 67# 68HDRDIR= /__nonexistent_directory__ 69 70# 71# We don't build archive (*.a) libraries by default anymore. 72# If a component of the build needs to build an archive library 73# for its own internal purposes, it can define LIBS for itself 74# after including Makefile.lib, like this: 75# LIBS = $(LIBRARY) 76# or: 77# LIBS = $(LIBRARYCCC) 78# Archive libraries must not be installed in the proto area. 79# 80LIBS= 81MACHLIBS= $(LIBS:%=$(MACH)/%) 82MACHLIBS64= $(LIBS:%=$(MACH64)/%) 83DYNLIB= $(LIBRARY:.a=.so$(VERS)) 84DYNLIBPSR= $(LIBRARY:.a=_psr.so$(VERS)) 85DYNLIBCCC= $(LIBRARYCCC:.a=.so$(VERS)) 86LIBLINKS= $(LIBRARY:.a=.so) 87LIBLINKSCCC= $(LIBRARYCCC:.a=.so) 88LIBNAME= $(LIBRARY:lib%.a=%) 89LIBLINKPATH= 90LIBNULL= null.a 91ROOTHDRDIR= $(ROOT)/usr/include 92ROOTLIBDIR= $(ROOT)/usr/lib 93ROOTLIBDIR64= $(ROOT)/usr/lib/$(MACH64) 94ROOTFS_LIBDIR= $(ROOT)/lib 95ROOTFS_LIBDIR64= $(ROOT)/lib/$(MACH64) 96ROOTHDRS= $(HDRS:%=$(ROOTHDRDIR)/%) 97HDRSRCS= $(HDRS:%=$(HDRDIR)/%) 98CHECKHDRS= $(HDRSRCS:%.h=%.check) 99ROOTLIBS= $(LIBS:%=$(ROOTLIBDIR)/%) 100ROOTLIBS64= $(LIBS:%=$(ROOTLIBDIR64)/%) 101ROOTFS_LIBS= $(DYNLIB:%=$(ROOTFS_LIBDIR)/%) 102ROOTFS_LIBS64= $(DYNLIB:%=$(ROOTFS_LIBDIR64)/%) 103ROOTLINKS= $(ROOTLIBDIR)/$(LIBLINKS) 104ROOTLINKS64= $(ROOTLIBDIR64)/$(LIBLINKS) 105ROOTFS_LINKS= $(ROOTFS_LIBDIR)/$(LIBLINKS) 106ROOTFS_LINKS64= $(ROOTFS_LIBDIR64)/$(LIBLINKS) 107ROOTLINKSCCC= $(ROOTLIBDIR)/$(LIBLINKSCCC) 108ROOTLINKSCCC64= $(ROOTLIBDIR64)/$(LIBLINKSCCC) 109ROOTFS_LINKSCCC= $(ROOTFS_LIBDIR)/$(LIBLINKSCCC) 110ROOTFS_LINKSCCC64= $(ROOTFS_LIBDIR64)/$(LIBLINKSCCC) 111 112# Demo rules 113DEMOFILES= 114DEMOFILESRCDIR= common 115ROOTDEMODIRBASE= __nonexistent_directory__ 116ROOTDEMODIRS= 117ROOTDEMOFILES= $(DEMOFILES:%=$(ROOTDEMODIRBASE)/%) 118$(ROOTDEMODIRS) := DIRMODE = 755 119 120ARFLAGS= r 121SONAME= $(DYNLIB) 122 123# For most libraries, we should be able to resolve all symbols at link time, 124# either within the library or as dependencies, all text should be pure, and 125# combining relocations into one relocation table reduces startup costs. 126# All options are tunable to allow overload/omission from lower makefiles. 127HSONAME= -Wl,-h$(SONAME) 128DYNFLAGS= $(HSONAME) $(ZTEXT) $(ZDEFS) $(BDIRECT) \ 129 $(MAPFILES:%=-Wl,-M%) $(MAPFILE.PGA:%=-Wl,-M%) $(MAPFILE.NED:%=-Wl,-M%) \ 130 $(LDCHECKS) 131 132LDLIBS= $(LDLIBS.lib) 133 134OBJS= $(OBJECTS:%=objs/%) 135PICS= $(OBJECTS:%=pics/%) 136 137# Declare that all library .o's can all be made in parallel. 138# The DUMMY target is for those instances where OBJS and PICS 139# are empty (to avoid an unconditional .PARALLEL declaration). 140.PARALLEL: $(OBJS) $(PICS) DUMMY 141 142# default value for "portable" source 143SRCS= $(OBJECTS:%.o=$(SRCDIR)/%.c) 144 145# default build of an archive and a shared object, 146# overridden locally when extra processing is needed 147BUILD.AR= $(AR) $(ARFLAGS) $@ $(AROBJS) 148BUILD.SO= $(CC) $(CFLAGS) -o $@ $(GSHARED) $(DYNFLAGS) \ 149 $(PICS) $(EXTPICS) $(LDLIBS) 150BUILD64.SO= $(CC64) $(CFLAGS64) -o $@ $(GSHARED) $(DYNFLAGS) \ 151 $(PICS) $(EXTPICS) $(LDLIBS) 152BUILDCCC.SO= $(CCC) $(CCFLAGS) -o $@ $(GSHARED) $(DYNFLAGS) \ 153 $(PICS) $(EXTPICS) $(LDLIBS) $(CCNEEDED) 154BUILDCCC64.SO= $(CCC64) $(CCFLAGS64) -o $@ $(GSHARED) $(DYNFLAGS) \ 155 $(PICS) $(EXTPICS) $(LDLIBS) $(CCNEEDED64) 156 157# default dynamic library symlink 158INS.liblink= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKS)$(VERS) $@ 159INS.liblinkccc= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKSCCC)$(VERS) $@ 160 161# default 64-bit dynamic library symlink 162INS.liblink64= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKS)$(VERS) $@ 163INS.liblinkccc64= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKSCCC)$(VERS) $@ 164 165# 166# Default to adding stack protection to all libraries. 167# 168CFLAGS += $(CCSTACKPROTECT) 169CFLAGS64 += $(CCSTACKPROTECT) 170LDLIBS += $(LDSTACKPROTECT) 171 172# 173# If appropriate, augment POST_PROCESS_O and POST_PROCESS_SO to do CTF 174# processing. We'd like to just conditionally append to POST_PROCESS_O and 175# POST_PROCESS_SO, but ParallelMake has a bug which causes the same value to 176# sometimes get appended more than once, which will cause ctfconvert to fail. 177# So, instead we introduce CTFCONVERT_POST and CTFMERGE_POST, which are always 178# appended to POST_PROCESS_O and POST_PROCESS_SO but are no-ops unless CTF 179# processing should be done. 180# 181CTFCONVERT_POST = : 182CTFMERGE_POST = : 183POST_PROCESS_O += ; $(CTFCONVERT_POST) 184POST_PROCESS_SO += ; $(CTFMERGE_POST) 185 186CTFMERGE_LIB = $(CTFMERGE) $(CTFMRGFLAGS) -t -f -L VERSION -o $@ $(PICS) 187 188# conditional assignments 189 190$(OBJS) := sparc_CFLAGS += -xregs=no%appl 191 192$(PICS) := sparc_CFLAGS += -xregs=no%appl $(sparc_C_PICFLAGS) 193$(PICS) := sparcv9_CFLAGS += -xregs=no%appl $(sparcv9_C_PICFLAGS) 194$(PICS) := i386_CFLAGS += $(i386_C_PICFLAGS) 195$(PICS) := amd64_CFLAGS += $(amd64_C_PICFLAGS) 196$(PICS) := CCFLAGS += $(CC_PICFLAGS) 197$(PICS) := CPPFLAGS += -DPIC -D_REENTRANT 198$(PICS) := sparcv9_CCFLAGS += -xregs=no%appl $(sparcv9_CC_PICFLAGS) 199$(PICS) := amd64_CCFLAGS += $(amd64_CC_PICFLAGS) 200$(PICS) := CFLAGS += $(CTF_FLAGS) 201$(PICS) := CFLAGS64 += $(CTF_FLAGS) 202$(PICS) := CTFCONVERT_POST = $(CTFCONVERT_O) 203$(DYNLIB) := CTFMERGE_POST = $(CTFMERGE_LIB) 204 205$(LIBRARY):= AROBJS = $(OBJS) 206$(LIBRARY):= DIR = objs 207$(DYNLIB):= DIR = pics 208$(DYNLIBCCC):= DIR = pics 209 210SONAMECCC= $(DYNLIBCCC) 211HSONAMECCC= -Wl,-h$(SONAMECCC) 212# 213# Keep in sync with the standard DYNFLAGS 214# 215$(DYNLIBCCC):= DYNFLAGS = $(HSONAMECCC) $(ZTEXT) $(ZDEFS) \ 216 $(MAPFILES:%=-Wl,-M%) $(MAPFILE.PGA:%=-Wl,-M%) $(MAPFILE.NED:%=-Wl,-M%) \ 217 $(BDIRECT) $(NORUNPATH) 218 219 220# build rule for "portable" source 221objs/%.o pics/%.o: %.c 222 $(COMPILE.c) -o $@ $< 223 $(POST_PROCESS_O) 224 225objs/%.o pics/%.o: %.cc 226 $(COMPILE.cc) -o $@ $< 227 $(POST_PROCESS_CC_O) 228 229.PRECIOUS: $(LIBS) 230 231# Define the majority text domain in this directory. 232TEXT_DOMAIN= SUNW_OST_OSLIB 233 234# 235# Target Architecture 236# 237TARGETMACH= $(MACH) 238 239# 240# Allow people to define their own clobber rules. Normal makefiles 241# shouldn't override this - they should override $(CLOBBERFILES) instead. 242# 243CLOBBERTARGFILES= $(LIBS) $(DYNLIB) $(CLOBBERFILES) 244 245# 246# Define the default ctfdiff invocation used to check a list of types 247# supplied by a user of a library. The goal is to validate that a given 248# series of types is the same in both a 32-bit and 64-bit artifact. This 249# is only defined if we have a 64-bit build to do. 250# 251TYPECHECK_LIB32 = $(TYPECHECK_LIB:%=$(MACH)/%) 252TYPECHECK_LIB64 = $(TYPECHECK_LIB:%=$(MACH64)/%) 253TYPECHECK_LIST= $(TYPELIST:%=-T %) 254$(BUILD64)TYPECHECK.lib = $(CTFDIFF) -t -I $(TYPECHECK_LIST) \ 255 $(TYPECHECK_LIB32) $(TYPECHECK_LIB64) 256TYPECHECK = $(TYPECHECK_LIB:%=%.typecheck) 257 258# Links we need to create for compatibility 259COMPATLINKS= 260COMPATLINKS64= 261ROOTCOMPATLINKS= $(COMPATLINKS:%=$(ROOT)/%) 262ROOTCOMPATLINKS64= $(COMPATLINKS64:%=$(ROOT)/%) 263 264# So if someone doesn't set the target-specific variable they get a clue what 265# went wrong. 266COMPATLINKTARGET= /__you_didnt_use_COMPATLINKS_properly__ 267