3 #### make-package: create a Mac OS X package for use by the installer.
4 #### The installer will place the Emacs OSX application in
5 #### /Application/Emacs and the rest of emacs in the usual unix places
6 #### under /usr/local or some other location if specified as the first
7 #### argument. The disc image will be in the file EmacsInstaller.dmg.
9 #### Upon installation, this will leave two versions of emacs on the
10 #### computer, 20.7 and 21.1.
14 #### Will create an installer that will place the emacs support
15 #### files inside /usr/local.
16 #### ./make-package /usr
17 #### Will create an installer that will place the emacs support
18 #### files inside /usr. This will replace the default version of
19 #### emacs included with Mac OS X.
21 # Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008
22 # Free Software Foundation, Inc.
24 # This file is part of GNU Emacs.
26 # GNU Emacs is free software; you can redistribute it and/or modify
27 # it under the terms of the GNU General Public License as published by
28 # the Free Software Foundation; either version 3, or (at your option)
31 # GNU Emacs is distributed in the hope that it will be useful,
32 # but WITHOUT ANY WARRANTY; without even the implied warranty of
33 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34 # GNU General Public License for more details.
36 # You should have received a copy of the GNU General Public License
37 # along with GNU Emacs; see the file COPYING. If not, write to the
38 # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
39 # Boston, MA 02110-1301, USA.
41 # Contributed by Steven Tamm (steventamm@mac.com).
48 ## Default location to place it is /usr/local
68 if test -n "$ac_prev"; then
74 -help |
--help |
--hel |
--he |
-h)
76 -p |
-prefix |
--p |
--prefix)
78 -p=* |
-prefix=* |
--p=* |
--prefix=*)
79 prefix
=`expr "x$1" : 'x[^=]*=\(.*\)'` ;;
80 --build-in-place |
--build-in-place )
82 --build-dir |
-build-dir |
--builddir |
-build-dir)
85 --build-dir=* |
-build-dir=* |
-builddir=* |
--builddir=*)
87 builddir
=`expr "x$1" : 'x[^=]*=\(.*\)'`;;
88 -no-configure |
-no-conf |
--no-configure |
--no-conf |
--without-config)
90 -no-app |
--no-app |
-without-app |
--without-app)
92 -without-x |
--without-x)
97 --without-full-dist |
-without-full-dist |
-no-full-dist |
-no-full)
100 compressed_dist
=yes ;;
101 --self-contained |
-self-contained |
--with-self-contained-app |
-sc)
102 self_contained
=yes ;;
103 -app-symlink |
--app-symlink |
-symlink |
--symlink |
--asl)
106 keep_directory
=yes ;;
108 config_options
="$config_options `expr "x
$1" : 'x[^,]*,\(.*\)'`" ;;
110 make_options
="$make_options `expr "x
$1" : 'x[^,]*,\(.*\)'`" ;;
117 if test "$with_x" = "no"; then
118 config_options
="--without-x $config_options"
121 if test "$display_usage" = "yes"; then
123 \`make-package' generates a Mac OS X installer package from an Emacs
124 distribution. By default, this first runs ./configure on the emacs
125 directory. Then make install to create the emacs distribution.
126 Then some mac-specific commands to generate the required information
127 for the mac package. The installer will, by default, create a
128 Carbon application called Emacs in the ${appsdir} directory, with the
129 shared emacs files in /usr/local
134 -h, --help display this help and exit
135 --prefix=DIR Set install location for the Mac OS X package
136 of the emacs related file. By default /usr/local
137 --no-conf Do not run the configure script before running
139 --without-app Do not create the Emacs application bundle
140 --with-x Setup the install to use X Windows for its
141 windowed display, instead of carbon. Implies
143 --without-full-dist Do not include all the .el files in the distribution.
144 This is discouraged except if disk space is critical.
145 --compressed-dist Compress .el and info files in the distribution.
146 --app-symlink Have the Emacs.app executable be a symlink
147 to the install in [prefix]/bin/emacs and have
148 the emacs executable link to emacs-${version}
149 --self-contained Create an Emacs.app that is self-contained;
150 prefix will be ignored and all files installed
151 inside the application
152 --build-in-place Build the application in the source directory
153 instead of a temporary directory.
154 --build-dir=DIR Build the application in the specified directory
155 instead of a temporary directory. Mutually exclusive
156 with --build-in-place.
157 -C,option Pass option to configure
158 -M,option Pass option to make
163 ### Exit if a command fails.
166 ### Print out each line we read, for debugging's sake.
173 export LANGUAGE LC_ALL LC_MESSAGES LANG
175 ## Don't restrict access to any files.
178 ### Make sure we're running in the right place.
179 if [ -f Emacs.pkg
]; then
180 echo "${progname}: Package Emacs.pkg already exists.
181 Perhaps a previous invocation of \`${progname}' failed to clean up after
182 itself. Move or delete Emacs.pkg and try again." >&2
186 if test $with_app == "yes" && [ ! -f ${emapp}/Contents
/PkgInfo
]; then
187 echo "${progname}: Can't find \`${emapp}/Contents/PkgInfo'" >&2
188 echo "${progname} must be run in the \`mac' directory of the Emacs" >&2
189 echo "distribution tree. cd to that directory and try again." >&2
193 ### Check whether file ../lisp/version.el exists.
194 if [ ! -f ..
/lisp
/version.el
]; then
195 echo "${progname}: Can't find \`../lisp/version.el'" >&2
199 ### Find out which version of Emacs this is.
200 shortversion
=`grep 'defconst[ ]*emacs-version' ../lisp/version.el \
201 | sed -e 's/^.*"\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/'`
202 version
=`grep 'defconst[ ]*emacs-version' ../lisp/version.el \
203 | sed -e 's/^[^"]*"\([^"]*\)".*$/\1/'`
204 if [ ! "${version}" ]; then
205 echo "${progname}: can't find current Emacs version in \`./lisp/version.el'" >&2
209 echo Version numbers are
$version and
$shortversion
211 ### Make sure we don't already have a directory emacs-${version}.
213 emacsname
="emacs-${version}${new_extension}"
215 if [ -d ${emacsname} ]
217 echo Directory
"${emacsname}" already exists
>&2
221 ### Make sure the subdirectory is available.
222 tempparent
="make-package.tmp.$$"
223 if [ -d ${tempparent} ]; then
224 echo "${progname}: staging directory \`${tempparent}' already exists.
225 Perhaps a previous invocation of \`${progname}' failed to clean up after
226 itself. Check that directories whose names are of the form
227 \`make-dist.tmp.NNNNN' don't contain any important information, remove
228 them, and try again." >&2
232 if [ -d /Volumes
/Emacs
]; then
233 echo "${progname}: Already have an Emacs disc image mounted. Please
234 eject that disc image and try again." >&2
238 tempparentfull
="`pwd`/${tempparent}"
239 tempparentdist
=${tempparentfull}/dist
241 if test "$build_in_place" = "no"; then
244 tempbuild
="make-package.build.$$"
245 builddir
="`pwd`/${tempbuild}"
246 removable_build_dir
=${builddir}
249 [\\/]* | ?
:[\\/]* ) #Absolutepath.
254 builddir
=`cd $builddir && pwd`
258 # Location of install package
259 packagedir
=${builddir}/mac
/Emacs.pkg
261 echo Building
in directory
${builddir}
262 echo Installing into directory
${tempparentfull} >&2
264 ### This trap ensures that the staging directory will be cleaned up even
265 ### when the script is interrupted in mid-career.
266 trap "echo 'Interrupted...cleaning up the staging directory'; rm -rf ${tempparent} ${removable_build_dir} ${packagedir}; exit 1" 1 2 15
268 # Run configure in the new tempparent directory
269 if test "$with_config" = "yes"; then
270 (cd ${builddir}; ${srcdir}/configure ${config_options} --prefix=${prefix})
273 installprefix
=${tempparentfull}${prefix}
274 if test "$self_contained" = "yes"; then
275 # If selfcontained, the local directory is Resources directory
276 installprefix
=$tempparentfull/$appsdir/$emapp/Contents
/Resources
280 make_options
="prefix=${installprefix} $make_options"
282 if test "$with_app" = "yes"; then
283 make_options
="carbon_appdir=${tempparentfull}/Applications $make_options"
286 ## Make bootstrap if .elc files are missing from distribution
287 if [ ! -f ${srcdir}/lisp
/abbrev.elc
]; then
288 echo "Required .elc files missing; making bootstrap..."
289 if ! (cd ${builddir}; make bootstrap
$make_options); then
290 echo "Make bootstrap failed... Aborting make-package."
295 if ! (cd ${builddir}; make install $make_options); then
296 echo "Make failed... Aborting make-package."
300 if test "$full_dist" == "no"; then
301 echo "Removing unneeded .el files"
302 sharedir
=$installprefix/share
/emacs
/$version
303 find $sharedir/lisp
$sharedir/leim
-name "*.elc" -print |
sed 's|\(.*\)\.elc$|/bin/rm -f \1.el|' |
/bin
/sh
-s
306 if test "$compressed_dist" == "yes" -a "$full_dist" == "yes"; then
307 echo "Compressing .el files"
308 sharedir
=$installprefix/share
/emacs
/$version
309 find $sharedir/lisp
$sharedir/leim
-name "*.elc" -print |
sed 's|\(.*\)\.elc$|/usr/bin/gzip -9 \1.el|' |
/bin
/sh
-s
310 echo "Compressing info files"
311 find $installprefix/info
-type f
! -name dir
-print |
sed 's|\(.*\)$|/usr/bin/gzip -9 \1|' |
/bin
/sh
-s
314 if test "$with_app" == "yes"; then
315 echo "Creating Emacs.app application"
316 tempappdir
=${tempparentfull}${appsdir}
317 tempemapp
=${tempappdir}/${emapp}/Contents
/MacOS
/Emacs
318 ## Delete any CVS files
319 find ${tempappdir} -name "CVS" -type d
-exec rm -rf {} \
;
321 ## Have application be a symlink to ${prefix}/bin/emacs
322 if test "$app_symlink" == "yes"; then
323 echo "Creating application symlink"
325 ln -s ${prefix}/bin/${emacsname} ${tempemapp}
329 compver
=`uname -p`-apple-darwin`uname -r`
331 if test "$self_contained" = "yes"; then
332 # Move shared files down to Resources directory
333 mv $installprefix/share
/emacs
/$version/* $installprefix
334 mv $installprefix/share
/info
$installprefix
335 mv $installprefix/share
/man
$installprefix
336 rm -rf $installprefix/share
337 # These directories might remain in Resources
338 mv $installprefix/bin
$installprefix/..
/MacOS
/bin
339 mv $installprefix/libexec
/emacs
/$version/$compver $installprefix/..
/MacOS
/libexec
340 # Make the application binary a hard link
341 rm $installprefix/..
/MacOS
/Emacs
342 ln $installprefix/..
/MacOS
/bin
/emacs
$installprefix/..
/MacOS
/Emacs
346 # Remove unnecessary .el files
347 #if test "$full_dist" = no; then
350 echo "Creating Package Info file"
352 mkdir
-p ${packagedir}
353 mkdir
${packagedir}/Contents
354 mkdir
${packagedir}/Contents
/Resources
355 mkdir
${packagedir}/Contents
/Resources
/English.lproj
356 echo -n 'pmkrpkg1' > ${packagedir}/Contents
/PkgInfo
358 # Create ReadMe and License files
359 cp ${srcdir}/COPYING
${packagedir}/Contents
/Resources
/License.txt
360 cp ${srcdir}/mac
/README
${packagedir}/Contents
/Resources
/ReadMe.txt
362 infofile
=${packagedir}/Contents
/Resources
/English.lproj
/Emacs.info
364 echo 'Title GNU Emacs' > ${infofile}
365 echo "Version ${version}" >> ${infofile}
366 echo "Description Install GNU Emacs ${version} as a command-line app and a Mac OS Application" >> ${infofile}
367 echo 'DefaultLocation /' >> ${infofile}
368 echo 'DeleteWarning' >> ${infofile}
369 echo 'NeedsAuthorization YES' >> ${infofile}
370 echo 'Required NO' >> ${infofile}
371 echo 'Relocatable NO' >> ${infofile}
372 echo 'RequiresReboot NO' >> ${infofile}
373 echo 'UseUserMask NO' >> ${infofile}
374 echo 'OverwritePermissions NO' >> ${infofile}
375 echo 'InstallFat NO' >> ${infofile}
377 ### Set the install directory to install files as root...
378 ### Not sure if this is a good diea
379 # echo "Setting owner to root"
380 # chown -Rh 0 ${tempparentfull}
382 echo "Creating pax file"
383 (cd ${tempparentfull}; pax
-w -f ${packagedir}/Contents
/Resources
/Emacs.pax .
)
384 echo "Compressing pax file"
385 gzip ${packagedir}/Contents
/Resources
/Emacs.pax
387 echo "Creating bom file"
388 mkbom
${tempparentfull} ${packagedir}/Contents
/Resources
/Emacs.bom
390 echo "Generating sizes file"
391 sizesfile
=${packagedir}/Contents
/Resources
/Emacs.sizes
393 numFiles
=`du -a ${tempparent} | wc -l`
394 installedSize
=`du -s ${tempparent} | cut -f1`
395 compressedSize
=`du -s ${packagedir} | cut -f1`
397 echo "NumFiles ${numFiles}" > ${sizesfile}
398 echo "InstalledSize ${installedSize}" >> ${sizesfile}
399 echo "CompressedSize ${compressedSize}" >> ${sizesfile}
402 echo "Creating Disc Image"
403 ## From hdiutil man page, a sector is 512k. Allocate an extra 5% for
404 ## directories and partition tables.
405 sectorsAlloced
=`echo 2.1*${compressedSize}|bc`
406 hdiutil create
-ov ${builddir}/mac
/EmacsRW
-sectors ${sectorsAlloced}
407 ## Need to format the disc image before mounting
408 mountLoc
=`hdid -nomount ${builddir}/mac/EmacsRW.dmg | grep HFS | cut -f1`
409 /sbin
/newfs_hfs
-v Emacs
${mountLoc}
410 hdiutil eject
${mountLoc}
411 echo "Copying Package to Disc Image"
412 hdid
${builddir}/mac
/EmacsRW.dmg
414 if test "$keep_directory" = "no"; then
415 rm -rf ${tempparentfull}
417 mv ${tempparentfull} ${emacsname}
420 if [ ! -d /Volumes
/Emacs
]; then
421 echo "Could not create disc image. The Emacs installer package (Emacs.pkg)
422 in this directory should be correct. Please use the Disc Copy program to
423 create a disc image." >&2
427 cp -R ${packagedir} /Volumes
/Emacs
429 ## Converting Disk Image to read-only
430 echo 'Converting Disc Image to read-only'
431 hdiutil eject
${mountLoc}
432 hdiutil resize
${builddir}/mac
/EmacsRW.dmg
-sectors min
433 if test "$comp_diskimage" = "yes"; then
434 hdiutil convert
${builddir}/mac
/EmacsRW.dmg
-format UDZO
-imagekey zlib-level
=2 -o ${srcdir}/mac
/EmacsInstaller.dmg
436 hdiutil convert
${builddir}/mac
/EmacsRW.dmg
-format UDRO
-o ${srcdir}/mac
/EmacsInstaller.dmg
438 rm ${builddir}/mac
/EmacsRW.dmg
440 echo "Cleaning up the staging directory"
441 rm -rf ${builddir}/mac
/Emacs.pkg
${removable_build_dir}
443 # arch-tag: 1b631d0d-9fde-4f71-80c0-33e0e5815515
444 ### make-package ends here