From a44896e3f5402d2526f50eebcf5e4382e37dc993 Mon Sep 17 00:00:00 2001 From: Apple Date: Tue, 27 Mar 2007 00:09:23 +0000 Subject: [PATCH] CoreOSMakefiles-40.tar.gz --- Makefile | 1 + ReleaseControl/BSD.make | 4 +- ReleaseControl/Common.make | 10 ++- ReleaseControl/GNUSource.make | 14 ++--- Standard/Commands.make | 2 + Standard/Variables.make | 2 +- bin/ar.sh | 113 ++++++++++++++++++++++++++++++++++ bin/compress-man-pages.pl | 94 ++++++++++++++++++++++++++++ bin/version.pl | 53 ++++++++++++++++ 9 files changed, 279 insertions(+), 14 deletions(-) create mode 100755 bin/ar.sh create mode 100755 bin/compress-man-pages.pl create mode 100755 bin/version.pl diff --git a/Makefile b/Makefile index f484e72..55bc272 100644 --- a/Makefile +++ b/Makefile @@ -9,3 +9,4 @@ Destination = $(MAKEFILEPATH)/CoreOS install_headers:: @$(MAKE) install_source SRCROOT=$(DSTROOT)$(Destination) $(_v) $(RM) -f $(DSTROOT)$(Destination)/Makefile + $(_v) $(MV) -f $(DSTROOT)$(Destination)/bin $(DSTROOT)$(MAKEFILEPATH) diff --git a/ReleaseControl/BSD.make b/ReleaseControl/BSD.make index cc1be56..84f5007 100644 --- a/ReleaseControl/BSD.make +++ b/ReleaseControl/BSD.make @@ -61,7 +61,7 @@ Install_Target = install .PHONY: bsd_install -BSD_Install_Targets = $(BSD_Before_Install) BSD_install_dirs BSD_install BSD_clean_dirs $(BSD_After_Install) +BSD_Install_Targets = $(BSD_Before_Install) BSD_install_dirs BSD_install BSD_clean_dirs $(BSD_After_Install) compress_man_pages install:: $(BSD_Install_Targets) @@ -76,7 +76,7 @@ BSD_install:: build $(_v) umask $(Install_Mask) ; $(Environment) $(BSDMAKE) $(Install_Environment) $(Install_Target) BSD_clean_dirs:: - -$(_v) $(FIND) -d $(DSTROOT) -type d -print0 | $(XARGS) -0 rmdir 2> /dev/null + -$(_v) $(FIND) -d $(DSTROOT) -type d -exec rmdir "{}" \; 2> /dev/null BSD_Build_Targets = $(BSD_Before_Build) BSD_build $(BSD_After_Build) diff --git a/ReleaseControl/Common.make b/ReleaseControl/Common.make index 2fd64a7..4c9aaec 100644 --- a/ReleaseControl/Common.make +++ b/ReleaseControl/Common.make @@ -105,6 +105,8 @@ Environment += $(Extra_Environment) VPATH=$(Sources) +ManPageDirectories = /usr/share/man + ## # Targets ## @@ -134,7 +136,7 @@ ifneq ($(wildcard $(PAX)),) else $(_v) $(TAR) cf - . | (cd "$(SRCROOT)" ; $(TAR) xfp -) endif - $(_v) $(FIND) "$(SRCROOT)" $(Find_Cruft) | $(XARGS) $(RMDIR) + $(_v) $(FIND) "$(SRCROOT)" $(Find_Cruft) -depth -exec $(RMDIR) "{}" \; endif ifndef ShadowTestFile @@ -177,3 +179,9 @@ endif rshowvar: showvar $(_v) $(MAKE) recurse TARGET=rshowvar + +compress_man_pages: +ifneq "$(strip $(ManPageDirectories))" "" + @echo "Compressing man pages for $(Project)..." + $(_v) $(COMPRESSMANPAGES) $(ManPageDirectories) +endif diff --git a/ReleaseControl/GNUSource.make b/ReleaseControl/GNUSource.make index a0f312d..c7295f9 100644 --- a/ReleaseControl/GNUSource.make +++ b/ReleaseControl/GNUSource.make @@ -54,8 +54,6 @@ include $(CoreOSMakefiles)/ReleaseControl/Common.make Sources = $(SRCROOT)/$(Project) ConfigStamp = $(BuildDirectory)/configure-stamp -Workaround_3678855 = /BogusHTMLInstallationDir - ifndef Install_Prefix Install_Prefix = $(USRDIR) endif @@ -67,7 +65,7 @@ Install_Info = $(SHAREDIR)/info endif ifndef Install_HTML ifeq "$(UserType)" "Developer" -Install_HTML = $(Workaround_3678855) +Install_HTML = $(SYSTEM_DEVELOPER_TOOLS_DOC_DIR)/$(ProjectName) else Install_HTML = $(NSDOCUMENTATIONDIR)/$(ToolType)/$(ProjectName) endif @@ -117,8 +115,8 @@ install:: build ifneq ($(GnuNoInstall),YES) @echo "Installing $(Project)..." $(_v) umask $(Install_Mask) ; $(MAKE) -C $(BuildDirectory) $(Environment) $(Install_Flags) $(Install_Target) - $(_v) $(FIND) $(DSTROOT) $(Find_Cruft) | $(XARGS) $(RMDIR) - $(_v) $(FIND) $(SYMROOT) $(Find_Cruft) | $(XARGS) $(RMDIR) + $(_v) $(FIND) $(DSTROOT) $(Find_Cruft) -depth -exec $(RMDIR) "{}" \; + $(_v) $(FIND) $(SYMROOT) $(Find_Cruft) -depth -exec $(RMDIR) "{}" \; ifneq ($(GnuNoChown),YES) $(_v)- $(CHOWN) -R $(Install_User):$(Install_Group) $(DSTROOT) $(SYMROOT) endif @@ -126,11 +124,7 @@ endif ifdef GnuAfterInstall $(_v) $(MAKE) $(GnuAfterInstall) endif - $(_v) if [ -d "$(DSTROOT)$(Workaround_3678855)" ]; then \ - $(INSTALL_DIRECTORY) "$(DSTROOT)$(SYSTEM_DEVELOPER_TOOLS_DOC_DIR)"; \ - $(MV) "$(DSTROOT)$(Workaround_3678855)" \ - "$(DSTROOT)$(SYSTEM_DEVELOPER_TOOLS_DOC_DIR)/$(ProjectName)"; \ - fi + $(_v) $(MAKE) compress_man_pages build:: configure ifneq ($(GnuNoBuild),YES) diff --git a/Standard/Commands.make b/Standard/Commands.make index 26e2b41..9560395 100644 --- a/Standard/Commands.make +++ b/Standard/Commands.make @@ -46,6 +46,7 @@ ZCAT = $(GZCAT) # Compilers and Binary Tools ## AR = /usr/bin/ar +ARSH = $(MAKEFILEPATH)/bin/ar.sh BISON = /usr/bin/bison BSDMAKE = /usr/bin/bsdmake CC = /usr/bin/cc @@ -117,6 +118,7 @@ PACKAGE = /usr/bin/package # Miscellaneous ## ARCH = /usr/bin/arch +COMPRESSMANPAGES = $(MAKEFILEPATH)/bin/compress-man-pages.pl -d $(DSTROOT) FALSE = /usr/bin/false PWD = /bin/pwd SLEEP = /bin/sleep diff --git a/Standard/Variables.make b/Standard/Variables.make index 16ff107..0f1a667 100644 --- a/Standard/Variables.make +++ b/Standard/Variables.make @@ -137,7 +137,7 @@ USRSBINDIR = $(USRDIR)/sbin VARDIR = /private/var VARTMPDIR = $(VARDIR)/tmp -SYSTEM_DEVELOPER_TOOLS_DOC_DIR = $(NSDEVELOPERDIR)/ADC Reference Library/documentation/DeveloperTools +SYSTEM_DEVELOPER_TOOLS_DOC_DIR = $(NSDEVELOPERDIR)/Documentation/DocSets/com.apple.ADC_Reference_Library.DeveloperTools.docset/Contents/Resources/Documents/documentation/DeveloperTools ## # Targets diff --git a/bin/ar.sh b/bin/ar.sh new file mode 100755 index 0000000..9bad047 --- /dev/null +++ b/bin/ar.sh @@ -0,0 +1,113 @@ +#!/bin/sh +# Copyright (c) 2005 Apple Computer, Inc. All rights reserved. +# +# @APPLE_LICENSE_HEADER_START@ +# +# This file contains Original Code and/or Modifications of Original Code +# as defined in and that are subject to the Apple Public Source License +# Version 2.0 (the 'License'). You may not use this file except in +# compliance with the License. Please obtain a copy of the License at +# http://www.opensource.apple.com/apsl/ and read it before using this +# file. +# +# The Original Code and all software distributed under the License are +# distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +# EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +# INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +# Please see the License for the specific language governing rights and +# limitations under the License. +# +# @APPLE_LICENSE_HEADER_END@ +## +# Wrapper around ar which behaves more like ar. +# Problem is Rhapsody's ar doesn't work on a file that's been ranlib'ed +# and some makefiles want to edit ranlib'ed archives. +# +# The interesting and functional routine here in unranlib(). +# The "main" code, which wraps ar, is a hack and may not parse the +# arguments correctly, but seems to work for most uses of ar, where +# the library is argv[2]. +## +# Wilfredo Sanchez Jr. | wsanchez@apple.com +# Copyright 1998 Apple Computer, Inc. +## + +## +# Set up PATH +## + +MyPath=/usr/bin:/bin; + +if [ -z "${PATH}" ]; then + export PATH=${MyPath}; +else + export PATH=${PATH}:${MyPath}; +fi + +## +# Functions +## + +unranlib () +{ + local archive; + + for archive in $*; do + + local name="$(basename ${archive})"; + local dir="/tmp/unranlib.$$/${name}"; + local ofiles=""; + local archs="$(file ${archive} | \ + grep '(for architecture' | \ + awk '{print $4}' | \ + sed 's/)://')"; + + for arch in ${archs}; do + local archdir="${dir}/${arch}"; + mkdir -p "${archdir}"; + + lipo -thin "${arch}" "${archive}" -o "${archdir}/${name}"; + + ( cd "${archdir}" && ar -xo "./${name}"; ); + + local ofile; + for ofile in `find "${archdir}" -name \*.o`; do + ofiles="${ofiles} $(basename ${ofile})"; + done + + done + + ofiles=$(echo ${ofiles} | tr ' ' '\012' | sort | uniq); + + local ofile; + for ofile in ${ofiles}; do + lipo -create $(find "${dir}" -name "${ofile}" -print) -o "${dir}/${ofile}"; + done + + ( cd "${dir}" && ar -cr "${name}" ${ofiles}; ); + + mv "${dir}/${name}" "${archive}"; + + rm -rf "${dir}"; + + done + + rm -rf "/tmp/unranlib.$$"; +} + +## +# Handle command line +## + +# This is totally bogus, but enough for now. +archive=$2; + +if [ -f "${archive}" ] && + file "${archive}" | grep -E 'Mach-O (fat file|universal binary)' > /dev/null; then + + # File is fat. Undo ranlib. + unranlib "${archive}"; +fi + +ar $*; diff --git a/bin/compress-man-pages.pl b/bin/compress-man-pages.pl new file mode 100755 index 0000000..7daea4a --- /dev/null +++ b/bin/compress-man-pages.pl @@ -0,0 +1,94 @@ +#!/usr/bin/perl +# Copyright (c) 2005 Apple Computer, Inc. All rights reserved. +# +# @APPLE_LICENSE_HEADER_START@ +# +# This file contains Original Code and/or Modifications of Original Code +# as defined in and that are subject to the Apple Public Source License +# Version 2.0 (the 'License'). You may not use this file except in +# compliance with the License. Please obtain a copy of the License at +# http://www.opensource.apple.com/apsl/ and read it before using this +# file. +# +# The Original Code and all software distributed under the License are +# distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +# EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +# INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +# Please see the License for the specific language governing rights and +# limitations under the License. +# +# @APPLE_LICENSE_HEADER_END@ + +use strict; +use File::Basename (); +use File::Find (); +use Getopt::Std (); + +my $MyName = File::Basename::basename($0); +my $N = 100; +my $MinSize = 64; +my %inodes; +my @symlinks; +our $opt_d = ''; + +sub wanted { + return unless /\.[\dn][a-z]*$/; + if(-l $_) { + push(@symlinks, $_); + } elsif(-f _) { + return if -s _ < $MinSize; + my($dev, $ino) = stat(_); + my $list = $inodes{$ino}; + $list = $inodes{$ino} = [] unless defined($list); + push(@$list, $_); + } +} + +sub usage { + die "Usage: $MyName [-d prefix] dir ...\n"; +} + +Getopt::Std::getopts('d:'); +usage() unless scalar(@ARGV) > 0; + +for my $dir (@ARGV) { + $dir = $opt_d . $dir if $opt_d ne ''; + next unless -e $dir; + die "$dir: no such directory\n" unless -d _; + + %inodes = (); + @symlinks = (); + File::Find::find({ + wanted => \&wanted, + no_chdir => 1, + }, $dir); + + my(@compress, @links); + for(values(%inodes)) { + push(@compress, $_->[0]); + push(@links, $_) if scalar(@$_) > 1; + } + + my $count; + while(($count = scalar(@compress)) > 0) { + $_ = $count > $N ? $N : $count; + my @args = splice(@compress, 0, $_); + print "gzip -f @args\n"; + system('gzip', '-f', @args) == 0 or die "gzip failed\n";; + } + foreach my $list (@links) { + my $main = shift(@$list); + for(@$list) { + printf "rm $_; ln $main.gz $_.gz\n"; + unlink $_ or die "Can't unlink: $!\n"; + link("$main.gz", "$_.gz") or die "Can't link: $!\n";; + } + } + for(@symlinks) { + my $link = readlink($_); + printf "rm $_; ln -s $link.gz $_.gz\n"; + unlink $_ or die "Can't unlink: $!\n"; + symlink("$link.gz", "$_.gz") or die "Can't symlink: $!\n"; + } +} diff --git a/bin/version.pl b/bin/version.pl new file mode 100755 index 0000000..46b611b --- /dev/null +++ b/bin/version.pl @@ -0,0 +1,53 @@ +#!/usr/bin/perl +# +# Copyright (c) 2005 Apple Computer, Inc. All rights reserved. +# +# @APPLE_LICENSE_HEADER_START@ +# +# This file contains Original Code and/or Modifications of Original Code +# as defined in and that are subject to the Apple Public Source License +# Version 2.0 (the 'License'). You may not use this file except in +# compliance with the License. Please obtain a copy of the License at +# http://www.opensource.apple.com/apsl/ and read it before using this +# file. +# +# The Original Code and all software distributed under the License are +# distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +# EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +# INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +# Please see the License for the specific language governing rights and +# limitations under the License. +# +# @APPLE_LICENSE_HEADER_END@ + +use strict; +use POSIX (); + +# Create a version string from various environment variables, from the +# argument list, or the current directory + +my $name = $ARGV[0]; +$name = $ENV{RC_ProjectName} unless defined($name) && $name ne ''; +$name = $ENV{PROJECT_NAME} unless defined($name) && $name ne ''; +my $vers = $ENV{RC_ProjectNameAndSourceVersion}; +$vers = "$name-$ENV{RC_ProjectSourceVersion}" unless defined($vers) && $vers ne '' && defined($ENV{RC_ProjectSourceVersion}) && $ENV{RC_ProjectSourceVersion} ne ''; +if(defined($vers) && $vers ne '') { + if(defined($name) && $name ne '') { + $vers =~ s/^[^-]*-/$name-/; + } else { + ($name = $vers) =~ s/-.*//; + } + my $build = $ENV{RC_ProjectBuildVersion}; + $vers .= "~$build" if defined($build) && $build ne ''; +} else { + if(defined($name) && $name ne '') { + $vers = $name; + } else { + require Cwd; + $vers = Cwd::cwd(); + $name = time(); + } +} +printf "const char __%s_version[] = \"@(#) %s %s\";\n", $name, $vers, + POSIX::strftime("%x %X %Z", localtime()); -- 2.45.2