1#
2# Copyright (c) 2008-2012 Apple Inc. All Rights Reserved.
3#
4
5# General project info
6Project         = freetype
7UserType        = Developer
8ToolType        = Library
9
10# Project-specific additions.
11#Extra_Environment	= 
12Extra_Configure_Flags	= --enable-static --disable-shared \
13				--without-ats --without-fsref --without-fsspec \
14				--without-old-mac-fonts \
15				--without-png \
16				--without-quickdraw-carbon --without-quickdraw-toolbox
17Extra_Make_Flags        =
18# Required or AEP parts won't be picked up.
19GnuAfterInstall		= install-macosx
20
21# Override defaults because we do want this in /usr/local...
22Install_Prefix	= $(USRDIR)/local
23Install_Man	= $(Install_Prefix)/share/man
24Install_Info	= $(Install_Prefix)/info
25
26# Automatic Extract & Patch
27AEP			= YES
28AEP_Version		= 2.5.0.1
29# License file must be empty as this is a subproject.
30AEP_LicenseFile		=
31AEP_Patches		=
32
33
34# Local targets that must be defined before including the following
35# files to get the dependency order correct
36.PHONY: $(GnuAfterInstall)
37
38install::
39
40# Include common makefile targets for B&I
41include $(MAKEFILEPATH)/CoreOS/ReleaseControl/GNUSource.make
42#GnuAfterInstall += archive-strip-binaries
43GnuAfterInstall += install-startup-files install-open-source-files
44GnuAfterInstall += install-top-level-man-pages install-configuration-files
45
46
47#
48# Define AEP variables
49#
50ifndef AEP_Project
51    AEP_Project		= $(Project)
52endif
53
54ifndef AEP_ProjVers
55  ifdef AEP_Version
56    AEP_ProjVers	= $(AEP_Project)-$(AEP_Version)
57  else
58    AEP_ProjVers	= $(AEP_Project)
59  endif
60endif
61
62ifndef AEP_Filename
63    AEP_Filename	= $(wildcard $(AEP_ProjVers).tar.gz $(AEP_ProjVers).tar.bz2)
64endif
65ifeq ($(suffix $(AEP_Filename)),.bz2)
66    AEP_ExtractOption	= j
67else
68    AEP_ExtractOption	= z
69endif
70
71ifndef AEP_ExtractDir
72    AEP_ExtractDir	= $(AEP_ProjVers)
73endif
74
75ifndef AEP_LicenseFile
76    AEP_LicenseFile	= $(SRCROOT)/$(ProjectName).txt
77endif
78
79ifndef AEP_ManPages
80    AEP_ManPages := $(wildcard *.[1-9] man/*.[1-9])
81endif
82
83ifndef AEP_ConfigDir
84    AEP_ConfigDir	= $(ETCDIR)
85endif
86
87ifndef AEP_Binaries
88    AEP_Binaries	= $(subst ./,/,$(shell cd $(DSTROOT) && $(FIND) . -type f -perm +0111 -exec $(SHELL) -c 'test \"`file -b --mime-type {}`\" = \"application/octet-stream\"' \; -print))
89endif
90
91#AEP_ExtractRoot		= $(SRCROOT)
92AEP_ExtractRoot		= $(OBJROOT)
93
94# Redefine the Sources directory defined elsewhere
95# ...but save the version of ConfigStamp (based on Sources)
96# GNUSource.make uses.
97GNUConfigStamp		:= $(ConfigStamp)
98Sources			= $(AEP_ExtractRoot)/$(AEP_Project)
99
100# Redefine Configure to allow extra "helper" environment variables.
101# This logic was moved to GNUSource.make in 10A251, so only override the setting
102# if building on an earlier system. (Make_Flags is only defined with that patch.)
103ifndef Make_Flags
104ifdef Extra_Configure_Environment
105      Configure		:= $(Extra_Configure_Environment) $(Configure)
106endif
107endif
108
109
110# Open Source configuration directories
111OSVDIR	= $(USRDIR)/local/OpenSourceVersions
112OSLDIR	= $(USRDIR)/local/OpenSourceLicenses
113
114# Launchd / startup item paths
115LAUNCHDDIR		= $(NSSYSTEMDIR)$(NSLIBRARYSUBDIR)/LaunchDaemons
116SYSTEM_STARTUP_DIR	= $(NSSYSTEMDIR)$(NSLIBRARYSUBDIR)/StartupItems
117
118
119#
120# AEP targets
121#
122.PHONY: extract-source build-dependencies archive-strip-binaries
123.PHONY: install-open-source-files install-startup-files
124.PHONY: install-top-level-man-pages install-configuration-files
125
126ifdef ConfigStamp
127$(GNUConfigStamp): extract-source build-dependencies
128else
129build:: extract-source build-dependencies
130endif
131
132# Because GNUSource's ConfigStamp's rules are processed before this file is included,
133# it's easier to copy the sources to the build directory and work from there.
134extract-source::
135ifeq ($(AEP),YES)
136	@echo "Extracting source for $(Project)..."
137	$(MKDIR) $(AEP_ExtractRoot)
138	$(TAR) -C $(AEP_ExtractRoot) -$(AEP_ExtractOption)xf $(SRCROOT)/$(AEP_Filename)
139	$(RMDIR) $(Sources)
140	$(_v) $(RM) $(GNUConfigStamp)
141	$(MV) $(AEP_ExtractRoot)/$(AEP_ExtractDir) $(Sources)
142ifdef AEP_Patches
143	for patchfile in $(AEP_Patches); do \
144	   echo "Applying $$patchfile..."; \
145	   cd $(Sources) && $(PATCH) -lp1 < $(SRCROOT)/patches/$$patchfile; \
146	done
147endif
148ifeq ($(AEP_BuildInSources),YES)
149ifneq ($(Sources),$(BuildDirectory))
150	@echo "Copying sources to build directory..."
151	$(_v) $(CP) $(Sources) $(BuildDirectory)
152endif
153endif
154else
155	@echo "Source extraction for $(Project) skipped!"
156endif
157
158# Common.make's recurse doesn't reset SRCROOT and misdefines Sources
159build-dependencies:
160ifdef Dependencies
161	$(_v) for Dependency in $(Dependencies); do			\
162		$(MKDIR) $(SYMROOT)/$${Dependency};			\
163		$(MAKE) -C $${Dependency} $(TARGET)			\
164			SRCROOT=$(SRCROOT)/$${Dependency}		\
165			OBJROOT=$(OBJROOT)				\
166			SYMROOT=$(SYMROOT)/$${Dependency}		\
167			DSTROOT=$(DSTROOT)				\
168			BuildDirectory=$(OBJROOT)/Build/$${Dependency}	\
169			Sources=$(OBJROOT)/$${Dependency}		\
170			CoreOSMakefiles=$(CoreOSMakefiles)		\
171			$(Extra_Dependency_Flags);			\
172		done
173endif
174
175archive-strip-binaries:: $(SYMROOT)
176ifdef AEP_Binaries
177	@echo "Archiving and stripping binaries..."
178	$(_v) for file in $(addprefix $(DSTROOT),$(AEP_Binaries));	\
179	do \
180		_type=`file -b --mime-type $${file}`;			\
181		if [ "$${_type}" = "application/octet-stream" ]; then	\
182			echo "\tProcessing $${file}...";			\
183			$(CP) $${file} $(SYMROOT);				\
184			$(DSYMUTIL) --out=$(SYMROOT)/$${file##*/}.dSYM $${file};\
185			$(STRIP) -S $${file};					\
186		else	\
187			echo "\tSkipped non-binary $${file}; type is $${_type}";\
188		fi	\
189	done
190endif
191
192install-startup-files::
193ifdef AEP_LaunchdConfigs
194	@echo "Installing launchd configuration files..."
195	$(INSTALL_DIRECTORY) $(DSTROOT)$(LAUNCHDDIR)
196	$(INSTALL_FILE) $(AEP_LaunchdConfigs) $(DSTROOT)$(LAUNCHDDIR)
197endif
198ifdef AEP_StartupItem
199	@echo "Installing StartupItem..."
200	$(INSTALL_DIRECTORY) $(DSTROOT)$(SYSTEM_STARTUP_DIR)/$(AEP_StartupItem)
201	$(INSTALL_SCRIPT) $(StartupItem) $(DSTROOT)$(SYSTEM_STARTUP_DIR)/$(AEP_StartupItem)
202	$(INSTALL_FILE) StartupParameters.plist $(DSTROOT)$(SYSTEM_STARTUP_DIR)/$(AEP_StartupItem)
203	$(INSTALL_DIRECTORY) $(DSTROOT)$(SYSTEM_STARTUP_DIR)/$(AEP_StartupItem)/Resources/English.lproj
204	$(INSTALL_FILE) Localizable.strings $(DSTROOT)$(SYSTEM_STARTUP_DIR)/$(AEP_StartupItem)/Resources/English.lproj
205endif
206
207install-open-source-files::
208	@echo "Installing Apple-internal open-source documentation..."
209	if [ -e $(SRCROOT)/$(ProjectName).plist ]; then	\
210		$(MKDIR) $(DSTROOT)/$(OSVDIR);	   	\
211		$(INSTALL_FILE) $(SRCROOT)/$(ProjectName).plist $(DSTROOT)/$(OSVDIR)/$(ProjectName).plist;	\
212	else	\
213		echo "WARNING: No open-source file for this project!";	\
214	fi
215	if [ -e $(AEP_LicenseFile) ]; then	\
216		$(MKDIR) $(DSTROOT)/$(OSLDIR);	\
217		$(INSTALL_FILE) $(AEP_LicenseFile) $(DSTROOT)/$(OSLDIR)/$(ProjectName).txt;	\
218	else	\
219		echo "WARNING: No open-source file for this project!";	\
220	fi
221
222
223#
224# Install any man pages at the top-level directory or its "man" subdirectory
225#
226install-top-level-man-pages::
227ifdef AEP_ManPages
228	@echo "Installing top-level man pages..."
229	for _page in $(AEP_ManPages); do				\
230		_section_dir=$(Install_Man)/man$${_page##*\.};		\
231		$(INSTALL_DIRECTORY) $(DSTROOT)$${_section_dir};	\
232		$(INSTALL_FILE) $${_page} $(DSTROOT)$${_section_dir};	\
233	done
234endif
235
236
237#
238# Install configuration files and their corresponding ".default" files
239# to one standard location.
240#
241install-configuration-files::
242ifdef AEP_ConfigFiles
243	@echo "Installing configuration files..."
244	$(INSTALL_DIRECTORY) $(DSTROOT)$(AEP_ConfigDir)
245	for file in $(AEP_ConfigFiles); \
246	do \
247		$(INSTALL_FILE) $${file} $(DSTROOT)$(AEP_ConfigDir); \
248		$(CHMOD) u+w $(DSTROOT)$(AEP_ConfigDir)/$${file}; \
249		if [ "${file##*.}" != "default" ]; then \
250			$(INSTALL_FILE) $${file} $(DSTROOT)$(AEP_ConfigDir)/$${file}.default; \
251		fi; \
252	done
253endif
254
255
256clean::
257	$(_v) if [ -d $(Sources) ]; then \
258	    cd $(Sources) && make clean; \
259	fi
260
261$(DSTROOT) $(DSTROOT)$(AEP_ConfigDir) $(SYMROOT) $(TMPDIR):
262	$(MKDIR) $@
263
264# Override settings from above include
265ifndef MACOSX_DEPLOYMENT_TARGET
266	MACOSX_DEPLOYMENT_TARGET = $(shell sw_vers -productVersion | cut -d. -f1-2)
267endif
268DESTDIR	= $(DSTROOT)
269
270# This needs to be overridden because the project properly uses DESTDIR.
271Install_Flags	= DESTDIR="$(DSTROOT)"
272# This project does not support the default "install-strip" target.
273Install_Target	= install
274
275
276install-macosx:
277	@echo "Reorganizing install for Mac OS X..."
278	$(RMDIR) $(DSTROOT)/usr/local/share
279	$(RMDIR) $(DSTROOT)/usr/local/bin
280