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# For most libraries, we should be able to resolve all symbols at link time, 123# either within the library or as dependencies, all text should be pure, and 124# combining relocations into one relocation table reduces startup costs. 125# All options are tunable to allow overload/omission from lower makefiles. 126 127 128HSONAME= -h$(SONAME) 129DYNFLAGS= $(HSONAME) $(ZTEXT) $(ZDEFS) $(BDIRECT) \ 130 $(MAPFILES:%=-M%) $(MAPFILE.PGA:%=-M%) $(MAPFILE.NED:%=-M%) \ 131 $(LDCHECKS) 132 133LDLIBS= $(LDLIBS.lib) 134 135OBJS= $(OBJECTS:%=objs/%) 136PICS= $(OBJECTS:%=pics/%) 137 138# Declare that all library .o's can all be made in parallel. 139# The DUMMY target is for those instances where OBJS and PICS 140# are empty (to avoid an unconditional .PARALLEL declaration). 141.PARALLEL: $(OBJS) $(PICS) DUMMY 142 143# default value for "portable" source 144SRCS= $(OBJECTS:%.o=$(SRCDIR)/%.c) 145 146# default build of an archive and a shared object, 147# overridden locally when extra processing is needed 148BUILD.AR= $(AR) $(ARFLAGS) $@ $(AROBJS) 149BUILD.SO= $(CC) $(CFLAGS) -o $@ $(GSHARED) $(DYNFLAGS) \ 150 $(PICS) $(EXTPICS) $(LDLIBS) 151BUILD64.SO= $(CC64) $(CFLAGS64) -o $@ $(GSHARED) $(DYNFLAGS) \ 152 $(PICS) $(EXTPICS) -L $(ROOTLIBDIR64) $(LDLIBS) 153BUILDCCC.SO= $(CCC) $(CCFLAGS) -o $@ $(GSHARED) $(DYNFLAGS) \ 154 $(PICS) $(EXTPICS) $(LDLIBS) 155BUILDCCC64.SO= $(CCC64) $(CCFLAGS64) -o $@ $(GSHARED) $(DYNFLAGS) \ 156 $(PICS) $(EXTPICS) $(LDLIBS) $(CCNEEDED64) 157 158# default dynamic library symlink 159INS.liblink= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKS)$(VERS) $@ 160INS.liblinkccc= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKSCCC)$(VERS) $@ 161 162# default 64-bit dynamic library symlink 163INS.liblink64= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKS)$(VERS) $@ 164INS.liblinkccc64= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKSCCC)$(VERS) $@ 165 166# 167# If appropriate, augment POST_PROCESS_O and POST_PROCESS_SO to do CTF 168# processing. We'd like to just conditionally append to POST_PROCESS_O and 169# POST_PROCESS_SO, but ParallelMake has a bug which causes the same value to 170# sometimes get appended more than once, which will cause ctfconvert to fail. 171# So, instead we introduce CTFCONVERT_POST and CTFMERGE_POST, which are always 172# appended to POST_PROCESS_O and POST_PROCESS_SO but are no-ops unless CTF 173# processing should be done. 174# 175CTFCONVERT_POST = : 176CTFMERGE_POST = : 177POST_PROCESS_O += ; $(CTFCONVERT_POST) 178POST_PROCESS_SO += ; $(CTFMERGE_POST) 179 180CTFMERGE_LIB = $(CTFMERGE) $(CTFMRGFLAGS) -t -f -L VERSION -o $@ $(PICS) 181 182# conditional assignments 183 184$(OBJS) := sparc_CFLAGS += -xregs=no%appl 185 186$(PICS) := sparc_CFLAGS += -xregs=no%appl $(sparc_C_PICFLAGS) 187$(PICS) := sparcv9_CFLAGS += -xregs=no%appl $(sparcv9_C_PICFLAGS) 188$(PICS) := i386_CFLAGS += $(i386_C_PICFLAGS) 189$(PICS) := amd64_CFLAGS += $(amd64_C_PICFLAGS) 190$(PICS) := CCFLAGS += $(CC_PICFLAGS) 191$(PICS) := CPPFLAGS += -DPIC -D_REENTRANT 192$(PICS) := sparcv9_CCFLAGS += -xregs=no%appl $(sparcv9_CC_PICFLAGS) 193$(PICS) := amd64_CCFLAGS += $(amd64_CC_PICFLAGS) 194$(PICS) := CFLAGS += $(CTF_FLAGS) 195$(PICS) := CFLAGS64 += $(CTF_FLAGS) 196$(PICS) := CTFCONVERT_POST = $(CTFCONVERT_O) 197$(DYNLIB) := CTFMERGE_POST = $(CTFMERGE_LIB) 198 199$(LIBRARY):= AROBJS = $(OBJS) 200$(LIBRARY):= DIR = objs 201$(DYNLIB):= DIR = pics 202$(DYNLIBCCC):= DIR = pics 203 204SONAMECCC= $(DYNLIBCCC) 205HSONAMECCC= -h $(SONAMECCC) 206# 207# Keep in sync with the standard DYNFLAGS 208# 209$(DYNLIBCCC):= DYNFLAGS = $(HSONAMECCC) $(ZTEXT) $(ZDEFS) \ 210 $(MAPFILES:%=-M%) $(MAPFILE.PGA:%=-M%) $(MAPFILE.NED:%=-M%) \ 211 $(BDIRECT) $(NORUNPATH) 212 213 214# build rule for "portable" source 215objs/%.o pics/%.o: %.c 216 $(COMPILE.c) -o $@ $< 217 $(POST_PROCESS_O) 218 219objs/%.o pics/%.o: %.cc 220 $(COMPILE.cc) -o $@ $< 221 $(POST_PROCESS_CC_O) 222 223.PRECIOUS: $(LIBS) 224 225# Define the majority text domain in this directory. 226TEXT_DOMAIN= SUNW_OST_OSLIB 227 228# 229# Target Architecture 230# 231TARGETMACH= $(MACH) 232 233# 234# Allow people to define their own clobber rules. Normal makefiles 235# shouldn't override this - they should override $(CLOBBERFILES) instead. 236# 237CLOBBERTARGFILES= $(LIBS) $(DYNLIB) $(CLOBBERFILES) 238 239# 240# Define the default ctfdiff invocation used to check a list of types 241# supplied by a user of a library. The goal is to validate that a given 242# series of types is the same in both a 32-bit and 64-bit artifact. This 243# is only defined if we have a 64-bit build to do. 244# 245TYPECHECK_LIB32 = $(TYPECHECK_LIB:%=$(MACH)/%) 246TYPECHECK_LIB64 = $(TYPECHECK_LIB:%=$(MACH64)/%) 247TYPECHECK_LIST= $(TYPELIST:%=-T %) 248$(BUILD64)TYPECHECK.lib = $(CTFDIFF) -t -I $(TYPECHECK_LIST) $(TYPECHECK_LIB32) $(TYPECHECK_LIB64) 249TYPECHECK = $(TYPECHECK_LIB:%=%.typecheck) 250