1## 2# Makefile for Apple Release Control (Archive Extraction & Patch) 3# 4# Copyright (c) 2005-2008 Apple Inc. 5# 6# @APPLE_LICENSE_HEADER_START@ 7# 8# Portions Copyright (c) 2005-2008 Apple Inc. All Rights Reserved. 9# This file contains Original Code and/or Modifications of Original Code 10# as defined in and that are subject to the Apple Public Source License 11# Version 2.0 (the 'License'). You may not use this file except in 12# compliance with the License. Please obtain a copy of the License at 13# http://www.opensource.apple.com/apsl/ and read it before using this 14# file. 15# 16# The Original Code and all software distributed under the License are 17# distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 18# EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 19# INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 20# FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 21# Please see the License for the specific language governing rights and 22# limitations under the License. 23# @APPLE_LICENSE_HEADER_END@ 24## 25# This header must be included after GNUsource.make or Common.make 26# 27# Set these variables as needed before including this file: 28# AEP_Version - open source project version, used in archive name and 29# extracted directory 30# AEP_Patches - list of file names (from patches subdirectory) to 31# run thru patch and apply to extracted sources 32# AEP_LicenseFile - full path to license file 33# AEP_BuildInSources - override default BuildDirectory and set to Sources; 34# this would be necessary if the project should be built 35# in the extracted source directory because the real 36# sources (with configure) are located there. 37# 38# The following variables will be defined if empty: 39# AEP_Project [ $(Project) ] 40# AEP_Version [ <no default> ] 41# AEP_ProjVers [ $(AEP_Project)-$(AEP_Version) ] 42# AEP_Filename [ $(AEP_ProjVers).tar.[bg]z* ] 43# AEP_ExtractDir [ $(AEP_ProjVers) ] 44# AEP_Patches [ <list of patch file to apply> ] 45# AEP_LicenseFile [ $(SRCROOT)/$(ProjectName).txt ] 46# AEP_ConfigDir [ $(ETCDIR) ] 47# 48# Additionally, the following variables may also be defined before 49# including this file: 50# AEP_LaunchdConfigs - launchd config files in SRCROOT to be installed 51# into LAUNCHDDIR 52# AEP_StartupItem - startup items name to be installed into 53# SYSTEM_STARTUP_DIR; assumes existence of 54# StartupParameters.plist and Localizable.strings 55# AEP_ManPages - man pages provided outside the extracted project 56# AEP_ConfigFiles - standard set of configuration files; ".default" versions 57# will be created as well 58## 59 60GnuAfterInstall += install-startup-files install-open-source-files 61GnuAfterInstall += install-top-level-man-pages install-configuration-files 62 63 64# 65# Define AEP variables 66# 67ifndef AEP_Project 68 AEP_Project = $(Project) 69endif 70 71ifndef AEP_ProjVers 72 ifdef AEP_Version 73 AEP_ProjVers = $(AEP_Project)-$(AEP_Version) 74 else 75 AEP_ProjVers = $(AEP_Project) 76 endif 77endif 78 79ifndef AEP_Filename 80 AEP_Filename = $(wildcard $(AEP_ProjVers).tar.gz $(AEP_ProjVers).tar.bz2) 81endif 82ifeq ($(suffix $(AEP_Filename)),.bz2) 83 AEP_ExtractOption = j 84else 85 AEP_ExtractOption = z 86endif 87 88ifndef AEP_ExtractDir 89 AEP_ExtractDir = $(AEP_ProjVers) 90endif 91ifndef AEP_Patches 92 AEP_Patches = 93endif 94 95ifndef AEP_LicenseFile 96 AEP_LicenseFile = $(SRCROOT)/$(ProjectName).txt 97endif 98 99ifndef AEP_ManPages 100 AEP_ManPages := $(wildcard *.[1-9] man/*.[1-9]) 101endif 102 103ifndef AEP_ConfigDir 104 AEP_ConfigDir = $(ETCDIR) 105endif 106 107#AEP_ExtractRoot = $(SRCROOT) 108AEP_ExtractRoot = $(OBJROOT) 109 110# Redefine the Sources directory defined elsewhere 111# ...but save the version of ConfigStamp (based on Sources) 112# GNUSource.make uses. 113GNUConfigStamp := $(ConfigStamp) 114Sources = $(AEP_ExtractRoot)/$(AEP_Project) 115 116ifeq ($(AEP_BuildInSources),YES) 117 BuildDirectory = $(Sources) 118endif 119 120 121# Open Source configuration directories 122OSVDIR = $(USRDIR)/local/OpenSourceVersions 123OSLDIR = $(USRDIR)/local/OpenSourceLicenses 124 125# Launchd / startup item paths 126LAUNCHDDIR = $(NSSYSTEMDIR)$(NSLIBRARYSUBDIR)/LaunchDaemons 127SYSTEM_STARTUP_DIR = $(NSSYSTEMDIR)$(NSLIBRARYSUBDIR)/StartupItems 128 129 130# 131# AEP targets 132# 133.PHONY: extract-source install-open-source-files install-startup-files install-top-level-man-pages 134 135$(GNUConfigStamp): extract-source 136 137extract-source:: 138ifeq ($(AEP),YES) 139 @echo "Extracting source for $(Project)..." 140 $(MKDIR) $(AEP_ExtractRoot) 141 $(TAR) -C $(AEP_ExtractRoot) -$(AEP_ExtractOption)xf $(SRCROOT)/$(AEP_Filename) 142 $(RMDIR) $(Sources) 143 $(_v) $(RM) $(GNUConfigStamp) 144 $(MV) $(AEP_ExtractRoot)/$(AEP_ExtractDir) $(Sources) 145 for patchfile in $(AEP_Patches); do \ 146 echo "Applying $$patchfile..."; \ 147 cd $(Sources) && patch -lp1 < $(SRCROOT)/patches/$$patchfile; \ 148 done 149endif 150 151install-startup-files:: 152ifdef AEP_LaunchdConfigs 153 @echo "Installing launchd configuration files..." 154 $(INSTALL_DIRECTORY) $(DSTROOT)$(LAUNCHDDIR) 155 $(INSTALL_FILE) $(AEP_LaunchdConfigs) $(DSTROOT)$(LAUNCHDDIR) 156endif 157ifdef AEP_StartupItem 158 @echo "Installing StartupItem..." 159 $(INSTALL_DIRECTORY) $(DSTROOT)$(SYSTEM_STARTUP_DIR)/$(AEP_StartupItem) 160 $(INSTALL_SCRIPT) $(StartupItem) $(DSTROOT)$(SYSTEM_STARTUP_DIR)/$(AEP_StartupItem) 161 $(INSTALL_FILE) StartupParameters.plist $(DSTROOT)$(SYSTEM_STARTUP_DIR)/$(AEP_StartupItem) 162 $(INSTALL_DIRECTORY) $(DSTROOT)$(SYSTEM_STARTUP_DIR)/$(AEP_StartupItem)/Resources/English.lproj 163 $(INSTALL_FILE) Localizable.strings $(DSTROOT)$(SYSTEM_STARTUP_DIR)/$(AEP_StartupItem)/Resources/English.lproj 164endif 165 166install-open-source-files:: 167 @echo "Installing Apple-internal open-source documentation..." 168 $(MKDIR) $(DSTROOT)/$(OSVDIR) 169 $(INSTALL_FILE) $(SRCROOT)/$(ProjectName).plist $(DSTROOT)/$(OSVDIR)/$(ProjectName).plist 170ifneq ($(AEP_LicenseFile),) 171 $(MKDIR) $(DSTROOT)/$(OSLDIR) 172 $(INSTALL_FILE) $(AEP_LicenseFile) $(DSTROOT)/$(OSLDIR)/$(ProjectName).txt 173endif 174 175 176# 177# Install any man pages at the top-level directory or its "man" subdirectory 178# 179install-top-level-man-pages:: 180ifdef AEP_ManPages 181 @echo "Installing top-level man pages..." 182 for _page in $(AEP_ManPages); do \ 183 _section_dir=$(Install_Man)/man$${_page##*\.}; \ 184 $(INSTALL_DIRECTORY) $(DSTROOT)$${_section_dir}; \ 185 $(INSTALL_FILE) $${_page} $(DSTROOT)$${_section_dir}; \ 186 done 187endif 188 189 190# 191# Install configuration files and their corresponding ".default" files 192# to one standard location. 193# 194install-configuration-files:: 195ifdef AEP_ConfigFiles 196 @echo "Installing configuration files..." 197 $(INSTALL_DIRECTORY) $(DSTROOT)$(AEP_ConfigDir) 198 for file in $(AEP_ConfigFiles); \ 199 do \ 200 $(INSTALL_FILE) $${file} $(DSTROOT)$(AEP_ConfigDir); \ 201 $(CHMOD) u+w $(DSTROOT)$(AEP_ConfigDir)/$${file}; \ 202 if [ "${file##*.}" != "default" ]; then \ 203 $(INSTALL_FILE) $${file} $(DSTROOT)$(AEP_ConfigDir)/$${file}.default; \ 204 fi; \ 205 done 206endif 207 208 209clean:: 210 $(_v) if [ -d $(Sources) ]; then \ 211 cd $(Sources) && make clean; \ 212 fi 213