Makefile revision 7b07063d906859b2be1e88791f801b3c96e432f6
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync#
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# CDDL HEADER START
01bceecc7f7484a8820c77b884bb91cdefc97390vboxsync#
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# The contents of this file are subject to the terms of the
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# Common Development and Distribution License (the "License").
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# You may not use this file except in compliance with the License.
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync#
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# or http://www.opensolaris.org/os/licensing.
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# See the License for the specific language governing permissions
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# and limitations under the License.
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync#
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# When distributing Covered Code, include this CDDL HEADER in each
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# If applicable, add the following below this CDDL HEADER, with the
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# fields enclosed by brackets "[]" replaced with your own identifying
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# information: Portions Copyright [yyyy] [name of copyright owner]
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync#
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# CDDL HEADER END
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync#
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync#
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync# Use is subject to license terms.
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync# Copyright 2015 Igor Kozhukhov <ikozhukhov@gmail.com>
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync#
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsyncinclude $(SRC)/Makefile.master
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsyncFILES= \
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync $(MACH)_cc_map.noexeglobs \
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync $(MACH)_gcc_map.noexeglobs
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync$(BUILD64)FILES += \
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync $(MACH64)_cc_map.noexeglobs \
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync $(MACH64)_gcc_map.noexeglobs
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsyncSYMS1= syms.1
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsyncSYMS2= syms.2
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsyncMAIN1= main.1
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsyncMAIN2= main.2
65e414244531b340b49a1a58f225e7915fe9222dvboxsync
65e414244531b340b49a1a58f225e7915fe9222dvboxsyncTEMPLATE1= map.noexeglobs.1.template
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsyncTEMPLATE2= map.noexeglobs.2.template
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsyncall install: $(FILES)
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsynclint:
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsyncclean:
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync $(RM) $(SYMS1) $(SYMS2) $(MAIN1) $(MAIN2)
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsyncclobber: clean
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync $(RM) $(FILES)
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync# A number of dynamic executables have their own definitions of interfaces that
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync# exist in system libraries. To prevent name-space pollution it is desirable
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync# to demote the interfaces within these executable to locals. However, various
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync# symbols defined by the compiler drivers crt/values files need to remain
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync# global in any dynamic object that includes these files. These symbols
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync# interpose on symbols in libc, or provide call backs for other system
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync# libraries. The various compiler drivers (cc and gcc), and the crt/values
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync# files that these drivers are configured to include, differ between the
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync# various compilations environments (platform, 32/64-bit). Therefore, the
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync# only means of creating a mapfile to demote symbols is to dynamically generate
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync# the mapfile for a specific compilation environment.
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync#
c8ef03d2caac857c97f629d0ddd6eba0b8eb209dvboxsync# Here, template mapfiles are used to generate a number of compilation specific
c8ef03d2caac857c97f629d0ddd6eba0b8eb209dvboxsync# mapfiles. These mapfiles are referenced by components of the build through
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync# the MAPFILE.NGB macro defined in Makefile.master. These dynamically created
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync# mapfiles are not delivered into the $ROOT area, and therefore are not
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# delivered as packaged components of the OSNet.
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync$(MACH)_cc_map.noexeglobs := LINK = $(LINK.c)
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync$(MACH64)_cc_map.noexeglobs := LINK = $(LINK64.c)
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync$(MACH)_gcc_map.noexeglobs := CC = $(ONBLD_TOOLS)/bin/$(MACH)/cw -_gcc
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync$(MACH)_gcc_map.noexeglobs := LINK = $(LINK.c)
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync$(MACH64)_gcc_map.noexeglobs := CC = $(ONBLD_TOOLS)/bin/$(MACH)/cw -_gcc
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync$(MACH64)_gcc_map.noexeglobs := LINK = $(LINK64.c)
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# This generic target creates two dynamic executables from an empty "main"
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# program. These objects are not executed, but are analyzed to determine the
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# global symbols each provides.
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync#
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# The first executable demotes a family of known interfaces to local and allows
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# all other symbol definitions to remain global. This executables provides the
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# base for discovering all symbol definitions provided by the various
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# compilation environments. The second executable demotes all symbols to
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# locals. Within both executables, some symbols remain globals (_end, _etext,
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# etc.) as the link-editor has special knowledge of these symbols and their
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# expected visibility requirements. By inspecting the deferences between the
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# global symbols within the two executables, a mapfile can be generated to
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# ensure the symbols defined by the compilation environments files remain
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# global.
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync%map.noexeglobs:main.c $(TEMPLATE1) $(TEMPLATE2)
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync $(LINK) -o $(MAIN1) -M$(TEMPLATE1) main.c
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync $(ELFDUMP) -s -N.dynsym $(MAIN1) | $(EGREP) "WEAK|GLOB" | \
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync $(GREP) -v UNDEF | $(AWK) '{print $$9 }' | $(SORT) > $(SYMS1)
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync $(LINK) -o $(MAIN2) -M$(TEMPLATE2) main.c
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync $(ELFDUMP) -s -N.dynsym $(MAIN2) | $(EGREP) "WEAK|GLOB" | \
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync $(GREP) -v UNDEF | $(AWK) '{print $$9 }' | $(SORT) > $(SYMS2)
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync $(ECHO) "# GENERATED FILE - DO NOT EDIT" > $@
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync $(GREP) MAP-HEAD $(TEMPLATE2) | \
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync $(SED) -e "s/ *# MAP-HEAD//" >> $@
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync $(DIFF) $(SYMS1) $(SYMS2) | $(GREP) "^<" | \
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync $(SED) -e "s/^< \(.*\)/ \1;/" >> $@
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync $(GREP) MAP-TAIL $(TEMPLATE2) | \
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync $(SED) -e "s/ *# MAP-TAIL//" >> $@
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync $(RM) $(SYMS1) $(SYMS2) $(MAIN1) $(MAIN2)
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync