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# 22# Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. 23# 24# 25 26LIBBASENAME= libc 27LIBRARY= $(LIBBASENAME:%=%.a) 28VERS= .1 29 30# Note that we build libc_pic.a for the benefit of building 31# ld.so.1, but we do not install it. Only ld.so.1 needs it 32# and it must be built in the same workspace as libc. 33LIB_PIC= libc_pic.a 34 35ROOTLIB= $(ROOT)/usr/lib 36ROOTFS_LIB= $(ROOT)/lib 37ROOTLIB64= $(ROOTLIB)/$(MACH64) 38ROOTFS_LIB64= $(ROOTFS_LIB)/$(MACH64) 39 40ROOTVARIANTDIR= $(ROOTLIB)/libc 41ROOTVARIANTDIR64= $(ROOTLIB64)/libc 42 43ROOTFS_LINTDIR= $(ROOTFS_LIB) 44ROOTFS_LINTDIR64= $(ROOTFS_LIB64) 45ROOTFS_LINTLIB= $(ROOTFS_LINTDIR)/$(LINTLIB) 46ROOTFS_LINTLIB64= $(ROOTFS_LINTDIR64)/$(LINTLIB) 47 48# include common library definitions 49include ../Makefile.lib 50 51# 52# on some architectures, we build multiple libc variants 53# 54VAR1 = hwcap1 55VAR2 = hwcap2 56VAR3 = hwcap3 57 58VARBLD_1= $(MACH:sparc=sparc) 59VARBLD= $(VARBLD_1:i386=) 60 61VARBLD64_1= $(MACH:sparc=sparcv9) 62VARBLD64= $(VARBLD64_1:i386=) 63 64VAR1_DYNLIB = $(LIBRARY:%.a=%_$(VAR1).so$(VERS)) 65VAR1_BLDDIR = $(MACH)_$(VAR1)/$(VARBLD) 66VAR2_DYNLIB = $(LIBRARY:%.a=%_$(VAR2).so$(VERS)) 67VAR2_BLDDIR = $(MACH)_$(VAR2)/$(VARBLD) 68VAR3_DYNLIB = $(LIBRARY:%.a=%_$(VAR3).so$(VERS)) 69VAR3_BLDDIR = $(MACH)_$(VAR3)/$(VARBLD) 70 71VAR1_DYNLIB64 = $(LIBRARY:%.a=%_$(VAR1).so$(VERS)) 72VAR1_BLDDIR64 = $(MACH)_$(VAR1)/$(VARBLD64) 73 74i386_VARIANTS= $(VAR1) $(VAR2) $(VAR3) 75sparc_VARIANTS= 76sparcv9_VARIANTS= 77 78i386_COMP= 79sparc_COMP= capabilities 80 81MACH_COMP= $($(MACH)_COMP) 82 83i386_ETC= $(MACH)/etc 84sparc_ETC= 85 86VARIANTS= $($(MACH)_VARIANTS) 87VARIANT_SUBDIRS = $(VARIANTS:%=$(MACH)_%/$(VARBLD)) 88 89VARIANTS64= $($(MACH64)_VARIANTS) 90VARIANT_SUBDIRS64 = $(VARIANTS64:%=$(MACH)_%/$(VARBLD64)) 91 92SUBDIRS= $(MACH_CAP) $(MACH) $(MACH_ETC) $(VARIANT_SUBDIRS) 93$(BUILD64)SUBDIRS += $(MACH64) $(VARIANT_SUBDIRS64) 94 95LIBS = $(DYNLIB) $(LINTLIB) 96 97ROOTLIBS64= $(ROOTLIBDIR64)/$(DYNLIB) $(ROOTLIBDIR64)/$(LINTLIB) 98MACHLIBS64= $(MACH64)/$(DYNLIB) $(MACH64)/$(LINTLIB) 99VARIANTLIBS= $(VARIANTS:%=$(MACH)_%/$(VARBLD)/$(LIBBASENAME)_%.so.1) 100VARIANTLIBS64= $(VARIANTS64:%=$(MACH)_%/$(VARBLD64)/$(LIBBASENAME)_%.so.1) 101ROOTVARIANTLIBS= $(VARIANTS:%=$(ROOTVARIANTDIR)/$(LIBBASENAME)_%.so.1) 102ROOTVARIANTLIBS64= $(VARIANTS64:%=$(ROOTVARIANTDIR64)/$(LIBBASENAME)_%.so.1) 103 104# definitions for install_h target 105BASEHDRS= getxby_door.h 106CHECKHDRS= $(BASEHDRS:%.h=port/gen/%.check) 107HDRS= $(BASEHDRS) 108 109# install rules for install_h target 110$(ROOTHDRDIR)/%: port/gen/% 111 $(INS.file) 112 113$(ROOTLIBDIR)/$(DYNLIB) := FILEMODE = 755 114$(ROOTLIBDIR64)/$(DYNLIB) := FILEMODE = 755 115$(ROOTFS_LIBDIR)/$(DYNLIB) := FILEMODE = 755 116$(ROOTFS_LIBDIR64)/$(DYNLIB) := FILEMODE = 755 117 118$(ROOTVARIANTDIR) := FILEMODE= 755 119$(ROOTVARIANTDIR)/$(VAR1_DYNLIB) := FILEMODE= 755 120$(ROOTVARIANTDIR)/$(VAR2_DYNLIB) := FILEMODE= 755 121$(ROOTVARIANTDIR)/$(VAR3_DYNLIB) := FILEMODE= 755 122 123$(ROOTVARIANTDIR64) := FILEMODE= 755 124$(ROOTVARIANTDIR64)/$(VAR1_DYNLIB64) := FILEMODE= 755 125 126.KEEP_STATE: 127 128all: check_i18n .WAIT lib32 $(BUILD64) .WAIT lib64 .WAIT etc 129 130check_i18n: 131 @if [ ! -f $(ROOTFS_LIBDIR)/libc_i18n.a -o \ 132 ! -f $(ROOTFS_LIBDIR64)/libc_i18n.a ]; then \ 133 if [ "$$CLOSED_IS_PRESENT" = no ]; then \ 134 $(ECHO) "Warning: closed binaries not" \ 135 "properly unpacked." >&2;\ 136 $(ECHO) "Missing libc_i18n.a" >&2; \ 137 exit 1; \ 138 else \ 139 $(ECHO) "Warning: libc_i18n.a must be built" \ 140 "before libc can be built." >&2; \ 141 exit 1; \ 142 fi \ 143 fi 144 145etc: $($(MACH)_ETC) 146 147lib32: $(MACH_COMP) $(MACHLIBS) $(MACH)/$(LIB_PIC) $(VARIANTLIBS) 148 mkdir -p $(MACH)/i18n_pics 149 cd $(MACH)/i18n_pics ; $(AR) -x $(ROOTFS_LIBDIR)/libc_i18n.a 150 @if $(ELFDUMP) -r $(MACH)/$(DYNLIB) | $(GREP) -w environ ; then \ 151 $(ECHO) "Error: Invalid reference to environ" ; \ 152 $(ECHO) "Error: See comments in port/gen/env_data.c" ; \ 153 exit 1; \ 154 fi 155 156$(MACHLIBS): $(MACH_COMP) 157 158lib64: $(MACH_COMP) $(MACHLIBS64) $(MACH64)/$(LIB_PIC) $(VARIANTLIBS64) 159 mkdir -p $(MACH64)/i18n_pics 160 cd $(MACH64)/i18n_pics ; $(AR) -x $(ROOTFS_LIBDIR64)/libc_i18n.a 161 @if $(ELFDUMP) -r $(MACH64)/$(DYNLIB) | $(GREP) -w environ ; then \ 162 $(ECHO) "Error: Invalid reference to environ" ; \ 163 $(ECHO) "Error: See comments in port/gen/env_data.c" ; \ 164 exit 1; \ 165 fi 166 167$(MACHLIBS64): $(MACH_COMP) 168 169$(VARIANTLIBS): FRC 170 @cd $(@D); pwd; VERSION='$(VERSION)' $(MAKE) $(@F) 171 172$(VARIANTLIBS64): FRC 173 @cd $(@D); pwd; VERSION='$(VERSION)' $(MAKE) $(@F) 174 175$($(MACH)_ETC): FRC 176 @cd $(@); pwd; $(MAKE) $(TARGET) 177 178$($(MACH)_COMP): FRC 179 @cd $(@); pwd; $(MAKE) $(TARGET) 180 181install: all \ 182 etc \ 183 inslib32 \ 184 $(BUILD64) inslib64 185 186inslib32: $(ROOTFS_LIBS) $(ROOTFS_LINKS) $(ROOTFS_LINT) \ 187 $(ROOTFS_LINTLIB) \ 188 $(ROOTVARIANTLIBS) 189 190inslib64: $(ROOTFS_LIBS64) $(ROOTFS_LINKS64) \ 191 $(ROOTFS_LINTLIB64) \ 192 $(ROOTVARIANTLIBS64) 193 194install_h: $(ROOTHDRS) 195 196check: $(CHECKHDRS) 197 198$(ROOTFS_LIB)/%: $(MACH)/% 199 $(INS.file) 200$(ROOTFS_LIBDIR)/$(LIBLINKS): $(ROOTFS_LIBDIR)/$(LIBLINKS)$(VERS) 201 $(INS.liblink) 202$(ROOTFS_LIB64)/%: $(MACH64)/% 203 $(INS.file) 204$(ROOTFS_LIBDIR64)/$(LIBLINKS): $(ROOTFS_LIBDIR64)/$(LIBLINKS)$(VERS) 205 $(INS.liblink) 206 207$(ROOTVARIANTDIR): $(ROOTLIB) 208 $(INS.dir) 209$(ROOTVARIANTDIR)/%: $(ROOTVARIANTDIR) $(VAR1_BLDDIR)/% 210 $(INS.file) 211$(ROOTVARIANTDIR)/%: $(ROOTVARIANTDIR) $(VAR2_BLDDIR)/% 212 $(INS.file) 213$(ROOTVARIANTDIR)/%: $(ROOTVARIANTDIR) $(VAR3_BLDDIR)/% 214 $(INS.file) 215 216$(ROOTVARIANTDIR64): $(ROOTLIB64) 217 $(INS.dir) 218$(ROOTVARIANTDIR64)/%: $(ROOTVARIANTDIR64) $(VAR1_BLDDIR64)/% 219 $(INS.file) 220 221# install rule for lint library target 222$(ROOTFS_LINTDIR)/%: port/% 223 $(INS.file) 224$(ROOTFS_LINTDIR64)/%: port/% 225 $(INS.file) 226$(ROOTFS_LINTDIR)/%: $(MACH)/% 227 $(INS.file) 228$(ROOTFS_LINTDIR64)/%: $(MACH64)/% 229 $(INS.file) 230 231$(LINTLIB): 232 @cd $(MACH); pwd; VERSION='$(VERSION)' $(MAKE) $@ 233$(LINTLIB64): 234 @cd $(MACH64); pwd; VERSION='$(VERSION)' $(MAKE) $@ 235 236$(MACH)/$(LIB_PIC): FRC 237 @cd $(MACH); pwd; VERSION='$(VERSION)' $(MAKE) $(LIB_PIC) 238$(MACH64)/$(LIB_PIC): FRC 239 @cd $(MACH64); pwd; VERSION='$(VERSION)' $(MAKE) $(LIB_PIC) 240 241all := TARGET= all 242install := TARGET= install 243clean := TARGET= clean 244clobber := TARGET= clobber 245lint := TARGET= lint 246 247.PARALLEL: $(SUBDIRS) 248 249$(SUBDIRS): FRC 250 @cd $@; pwd; VERSION='$(VERSION)' $(MAKE) $(TARGET) 251 252clean clobber: $(SUBDIRS) 253 $(RM) -r $(MACH)/i18n_pics 254 $(BUILD64)$(RM) -r $(MACH64)/i18n_pics 255 256lint: $(SUBDIRS) 257 258_msg: $(MSGDOMAIN) catalog 259 260catalog: 261 sh ./makelibccatalog.sh $(MSGDOMAIN) 262 263$(MSGDOMAIN): 264 $(INS.dir) 265 266cscope.out tags: FRC 267 $(XREF) -x $@ 268 269FRC: 270# include MACH-specific library targets 271include ../Makefile.mach 272