1 # 2 # 3 # CDDL HEADER START 4 # 5 # The contents of this file are subject to the terms of the 6 # Common Development and Distribution License (the "License"). 7 # You may not use this file except in compliance with the License. 8 # 9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 # or http://www.opensolaris.org/os/licensing. 11 # See the License for the specific language governing permissions 12 # and limitations under the License. 13 # 14 # When distributing Covered Code, include this CDDL HEADER in each 15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 # If applicable, add the following below this CDDL HEADER, with the 17 # fields enclosed by brackets "[]" replaced with your own identifying 18 # information: Portions Copyright [yyyy] [name of copyright owner] 19 # 20 # CDDL HEADER END 21 # 22 # Copyright 2007 Sun Microsystems, Inc. All rights reserved. 23 # Use is subject to license terms. 24 # 25 #ident "@(#)Makefile.lib 1.7 07/02/21 SMI" 26 # 27 # lib/Makefile.lib 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 # 33 include $(SRC)/Makefile.master 34 35 LIBS= $(LIBRARY) $(LIBRARYCCC) 36 MACHLIBS= $(LIBS:%=$(MACH)/%) 37 MACHLIBS64= $(LIBS:%=$(MACH64)/%) 38 DYNLIB= $(LIBRARY:.a=.so$(VERS)) 39 DYNLIBPSR= $(LIBRARY:.a=_psr.so$(VERS)) 40 DYNLIBCCC= $(LIBRARYCCC:.a=.so$(VERS)) 41 LIBLINKS= $(LIBRARY:.a=.so) 42 LIBLINKSCCC= $(LIBRARYCCC:.a=.so) 43 LIBNAME= $(LIBRARY:lib%.a=%) 44 LIBLINKPATH= 45 LIBNULL= null.a 46 ROOTLIBDIR= $(ROOT)/usr/lib 47 ROOTLIBDIR64= $(ROOT)/usr/lib/$(MACH64) 48 ROOTLIBS= $(LIBS:%=$(ROOTLIBDIR)/%) 49 ROOTLIBS64= $(LIBS:%=$(ROOTLIBDIR64)/%) 50 ROOTLINKS= $(ROOTLIBDIR)/$(LIBLINKS) 51 ROOTLINKS64= $(ROOTLIBDIR64)/$(LIBLINKS) 52 ROOTLINKSCCC= $(ROOTLIBDIR)/$(LIBLINKSCCC) 53 ROOTLINKSCCC64= $(ROOTLIBDIR64)/$(LIBLINKSCCC) 54 ROOTSFWLIBDIR= $(ROOT)/usr/sfw/lib 55 ROOTSFWLIBDIR64= $(ROOT)/usr/sfw/lib/$(MACH) 56 ROOTSFWLIBS= $(LIBS:%=$(ROOTSFWLIBDIR)/%) 57 ROOTSFWLIBS64= $(LIBS:%=$(ROOTSFWLIBDIR64)/%) 58 ROOTSFWLINKS= $(ROOTSFWLIBDIR)/$(LIBLINKS) 59 ROOTSFWLINKS64= $(ROOTSFWLIBDIR64)/$(LIBLINKS) 60 61 LINTLIB= llib-l$(LIBNAME).ln 62 LINTFLAGS= -uaxs 63 LINTFLAGS64= -uaxs 64 LINTOUT= lint.out 65 ARFLAGS= r 66 SONAME= $(DYNLIB) 67 # For most libraries, we should be able to resolve all symbols at link time, 68 # either within the library or as dependencies, all text should be pure, and 69 # combining relocations into one relocation table reduces startup costs. 70 # All options are tunable to allow overload/omission from lower makefiles. 71 ZDEFS= -z defs 72 ZTEXT= -z text 73 ZCOMBRELOC= -z combreloc 74 HSONAME= -h $(SONAME) 75 DYNFLAGS= $(HSONAME) $(ZTEXT) $(ZDEFS) $(ZCOMBRELOC) 76 77 LDLIBS= $(LDLIBS.lib) 78 79 OBJS= $(OBJECTS:%=objs/%) 80 PICS= $(OBJECTS:%=pics/%) 81 82 # Declare that all library .o's can all be made in parallel. 83 # The DUMMY target is for those instances where OBJS and PICS 84 # are empty (to avoid an unconditional .PARALLEL declaration). 85 .PARALLEL: $(OBJS) $(PICS) DUMMY 86 87 # default value for "portable" source 88 SRCS= $(OBJECTS:.o=.c) 89 90 # default build of an archive and a shared object, 91 # overridden locally when extra processing is needed 92 BUILD.AR= $(AR) $(ARFLAGS) $@ $(AROBJS) 93 BUILD.SO= $(CC) -o $@ -G $(DYNFLAGS) $(PICS) $(LDLIBS) 94 BUILDCCC.SO= $(CCC) -o $@ -G $(DYNFLAGS) $(PICS) $(LDLIBS) 95 96 # default dynamic library symlink 97 INS.liblink= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKS)$(VERS) $@ 98 INS.liblinkccc= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKSCCC)$(VERS) $@ 99 100 # default 64-bit dynamic library symlink 101 INS.liblink64= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKS)$(VERS) $@ 102 INS.liblinkccc64= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKSCCC)$(VERS) $@ 103 104 # default dynamic library symlink for /usr/sfw libraries 105 INS.liblinksfw= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKS)$(VERS) $@ 106 107 # Handle different PIC models on different ISAs 108 # (May be overridden by lower-level Makefiles) 109 110 sparc_C_PICFLAGS = -K pic 111 i386_C_PICFLAGS = -K pic 112 sparcv9_C_PICFLAGS = -K pic 113 amd64_C_PICFLAGS = -K pic 114 115 # should be -K pic but the CC driver is currently broken 116 sparc_CC_PICFLAGS = -pic 117 i386_CC_PICFLAGS = -pic 118 sparcv9_CC_PICFLAGS = -KPIC 119 amd64_CC_PICFLAGS = -KPIC 120 121 # conditional assignments 122 123 $(OBJS) := sparc_CFLAGS += $(sparc_XREGSFLAG) 124 125 $(PICS) := sparc_CFLAGS += $(sparc_XREGSFLAG) $(sparc_C_PICFLAGS) 126 $(PICS) := i386_CFLAGS += $(i386_C_PICFLAGS) 127 $(PICS) := sparcv9_CFLAGS += $(sparcv9_XREGSFLAG) $(sparcv9_C_PICFLAGS) 128 $(PICS) := amd64_CFLAGS += $(amd64_C_PICFLAGS) 129 # should be -K pic but the CC driver is currently broken 130 $(PICS) := CCFLAGS += -pic 131 $(PICS) := CPPFLAGS += -DPIC -D_TS_ERRNO 132 $(PICS) := sparcv9_CCFLAGS += $(sparcv9_XREGSFLAG) $(sparcv9_CC_PICFLAGS) 133 $(PICS) := amd64_CCFLAGS += $(amd64_CC_PICFLAGS) 134 135 $(LINTLIB):= LOG = -DLOGGING 136 $(LIBRARY):= AROBJS = $(OBJS) 137 $(LIBRARY):= DIR = objs 138 $(DYNLIB):= DIR = pics 139 $(DYNLIBCCC):= DIR = pics 140 141 SONAMECCC= $(DYNLIBCCC) 142 HSONAMECCC= -h $(SONAMECCC) 143 $(DYNLIBCCC):= DYNFLAGS = $(HSONAMECCC) $(ZTEXT) $(ZDEFS) $(ZCOMBRELOC) \ 144 -norunpath -nolib 145 146 # build rule for "portable" source 147 objs/%.o pics/%.o: %.c 148 $(COMPILE.c) -o $@ $< 149 $(POST_PROCESS_O) 150 151 objs/%.o pics/%.o: %.cc 152 $(COMPILE.cc) -o $@ $< 153 $(POST_PROCESS_O) 154 155 .PRECIOUS: $(LIBS) $(PLIB) 156 157 # Define the majority text domain in this directory. 158 TEXT_DOMAIN= SUNW_OST_OSLIB 159 160 $(ROOTMAN3)/%: %.sunman 161 $(INS.rename) 162