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