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 Free Software Foundation, Inc.
23 # This file is part of GNU Emacs.
25 # GNU Emacs is free software; you can redistribute it and/or modify
26 # it under the terms of the GNU General Public License as published by
27 # the Free Software Foundation; either version 2, or (at your option)
30 # GNU Emacs is distributed in the hope that it will be useful,
31 # but WITHOUT ANY WARRANTY; without even the implied warranty of
32 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 # GNU General Public License for more details.
35 # You should have received a copy of the GNU General Public License
36 # along with GNU Emacs; see the file COPYING. If not, write to the
37 # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
38 # Boston, MA 02111-1307, USA.
40 # Contributed by Steven Tamm (steventamm@mac.com).
47 ## Default location to place it is /usr/local
66 if test -n "$ac_prev"; then
72 -help |
--help |
--hel |
--he |
-h)
74 -p |
-prefix |
--p |
--prefix)
76 -p=* |
-prefix=* |
--p=* |
--prefix=*)
77 prefix
=`expr "x$1" : 'x[^=]*=\(.*\)'` ;;
78 --build-in-place |
--build-in-place )
80 --build-dir |
-build-dir |
--builddir |
-build-dir)
83 --build-dir=* |
-build-dir=* |
-builddir=* |
--builddir=*)
85 builddir
=`expr "x$1" : 'x[^=]*=\(.*\)'`;;
86 -no-configure |
-no-conf |
--no-configure |
--no-conf |
--without-config)
88 -no-app |
--no-app |
-without-app |
--without-app)
90 -without-x |
--without-x)
95 --without-full-dist |
-without-full-dist |
-no-full-dist |
-no-full)
97 --self-contained |
-self-contained |
--with-self-contained-app |
-sc)
99 -app-symlink |
--app-symlink |
-symlink |
--symlink |
--asl)
102 keep_directory
=yes ;;
104 config_options
="$config_options `expr "x
$1" : 'x[^,]*,\(.*\)'`" ;;
106 make_options
="$make_options `expr "x
$1" : 'x[^,]*,\(.*\)'`" ;;
113 if test "$with_x" = "no"; then
114 config_options
="--without-x $config_options"
117 if test "$display_usage" = "yes"; then
119 \`make-package' generates a Mac OS X installer package from an Emacs
120 distribution. By default, this first runs ./configure on the emacs
121 directory. Then make install to create the emacs distribution.
122 Then some mac-specific commands to generate the required information
123 for the mac package. The installer will, by default, create a
124 Carbon application called Emacs in the ${appsdir} directory, with the
125 shared emacs files in /usr/local
130 -h, --help display this help and exit
131 --prefix=DIR Set install location for the Mac OS X package
132 of the emacs related file. By default /usr/local
133 --no-conf Do not run the configure script before running
135 --without-app Do not create the Emacs application bundle
136 --with-x Setup the install to use X Windows for its
137 windowed display, instead of carbon. Implies
139 --without-full-dist Do not include all the .el files in the distribution.
140 This is discouraged except if disk space is critical.
141 --app-symlink Have the Emacs.app executable be a symlink
142 to the install in [prefix]/bin/emacs and have
143 the emacs executable link to emacs-${version}
144 --self-contained Create an Emacs.app that is self-contained;
145 prefix will be ignored and all files installed
146 inside the application
147 --build-in-place Build the application in the source directory
148 instead of a temporary directory.
149 --build-dir=DIR Build the application in the specified directory
150 instead of a temporary directory. Mutually exclusive
151 with --build-in-place.
152 -C,option Pass option to configure
153 -M,option Pass option to make
158 ### Exit if a command fails.
161 ### Print out each line we read, for debugging's sake.
168 export LANGUAGE LC_ALL LC_MESSAGES LANG
170 ## Don't restrict access to any files.
173 ### Make sure we're running in the right place.
174 if [ -f Emacs.pkg
]; then
175 echo "${progname}: Package Emacs.pkg already exists.
176 Perhaps a previous invocation of \`${progname}' failed to clean up after
177 itself. Move or delete Emacs.pkg and try again." >&2
181 if test $with_app == "yes" && [ ! -f ${emapp}/Contents
/PkgInfo
]; then
182 echo "${progname}: Can't find \`${emapp}/Contents/PkgInfo'" >&2
183 echo "${progname} must be run in the \`mac' directory of the Emacs" >&2
184 echo "distribution tree. cd to that directory and try again." >&2
188 ### Check whether file ../lisp/version.el exists.
189 if [ ! -f ..
/lisp
/version.el
]; then
190 echo "${progname}: Can't find \`../lisp/version.el'" >&2
194 ### Find out which version of Emacs this is.
195 shortversion
=`grep 'defconst[ ]*emacs-version' ../lisp/version.el \
196 | sed -e 's/^.*"\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/'`
197 version
=`grep 'defconst[ ]*emacs-version' ../lisp/version.el \
198 | sed -e 's/^[^"]*"\([^"]*\)".*$/\1/'`
199 if [ ! "${version}" ]; then
200 echo "${progname}: can't find current Emacs version in \`./lisp/version.el'" >&2
204 echo Version numbers are
$version and
$shortversion
206 ### Make sure we don't already have a directory emacs-${version}.
208 emacsname
="emacs-${version}${new_extension}"
210 if [ -d ${emacsname} ]
212 echo Directory
"${emacsname}" already exists
>&2
216 ### Make sure the subdirectory is available.
217 tempparent
="make-package.tmp.$$"
218 if [ -d ${tempparent} ]; then
219 echo "${progname}: staging directory \`${tempparent}' already exists.
220 Perhaps a previous invocation of \`${progname}' failed to clean up after
221 itself. Check that directories whose names are of the form
222 \`make-dist.tmp.NNNNN' don't contain any important information, remove
223 them, and try again." >&2
227 if [ -d /Volumes
/Emacs
]; then
228 echo "${progname}: Already have an Emacs disc image mounted. Please
229 eject that disc image and try again." >&2
233 tempparentfull
="`pwd`/${tempparent}"
234 tempparentdist
=${tempparentfull}/dist
236 if test "$build_in_place" = "no"; then
239 tempbuild
="make-package.build.$$"
240 builddir
="`pwd`/${tempbuild}"
241 removable_build_dir
=${builddir}
244 [\\/]* | ?
:[\\/]* ) #Absolutepath.
249 builddir
=`cd $builddir && pwd`
253 # Location of install package
254 packagedir
=${builddir}/mac
/Emacs.pkg
256 echo Building
in directory
${builddir}
257 echo Installing into directory
${tempparentfull} >&2
259 ### This trap ensures that the staging directory will be cleaned up even
260 ### when the script is interrupted in mid-career.
261 trap "echo 'Interrupted...cleaning up the staging directory'; rm -rf ${tempparent} ${removable_build_dir} ${packagedir}; exit 1" 1 2 15
263 # Run configure in the new tempparent directory
264 if test "$with_config" = "yes"; then
265 (cd ${builddir}; ${srcdir}/configure ${config_options} --prefix=${prefix})
268 installprefix
=${tempparentfull}${prefix}
269 if test "$self_contained" = "yes"; then
270 # If selfcontained, the local directory is Resources directory
271 installprefix
=$tempparentfull/$appsdir/$emapp/Contents
/Resources
275 make_options
="prefix=${installprefix} $make_options"
277 if test "$with_app" = "yes"; then
278 make_options
="carbon_appdir=${tempparentfull}/Applications $make_options"
281 ## Make bootstrap if .elc files are missing from distribution
282 if [ ! -f ${srcdir}/lisp
/abbrev.elc
]; then
283 echo "Required .elc files missing; making bootstrap..."
284 if ! (cd ${builddir}; make bootstrap
$make_options); then
285 echo "Make bootstrap failed... Aborting make-package."
290 if ! (cd ${builddir}; make install $make_options); then
291 echo "Make failed... Aborting make-package."
295 if test "$full_dist" == "no"; then
296 echo "Removing unneeded .el files"
297 sharedir
=$installprefix/share
/emacs
/$version
298 find $sharedir/lisp
$sharedir/leim
-name "*.elc" -print |
sed 's|\(.*\)\.elc$|/bin/rm -f \1.el|' |
/bin
/sh
-s
301 if test "$with_app" == "yes"; then
302 echo "Creating Emacs.app application"
303 tempappdir
=${tempparentfull}${appsdir}
304 tempemapp
=${tempappdir}/${emapp}/Contents
/MacOS
/Emacs
305 ## Delete any CVS files
306 find ${tempappdir} -name "CVS" -type d
-exec rm -rf {} \
;
308 ## Have application be a symlink to ${prefix}/bin/emacs
309 if test "$app_symlink" == "yes"; then
310 echo "Creating application symlink"
312 ln -s ${prefix}/bin/${emacsname} ${tempemapp}
316 if test "$self_contained" = "yes"; then
317 # Move shared files down to Resources directory
318 mv $installprefix/share
/emacs
/$version/* $installprefix
319 rm -rf $installprefix/share
320 # These directories might remain in Resources
321 mv $installprefix/bin
$installprefix/..
/MacOS
/bin
322 mv $installprefix/libexec
$installprefix/..
/MacOS
/libexec
323 # Make the application binary a hard link
324 rm $installprefix/..
/MacOS
/Emacs
325 ln $installprefix/..
/MacOS
/bin
/emacs
$installprefix/..
/MacOS
/Emacs
329 # Remove unnecessary .el files
330 #if test "$full_dist" = no; then
333 echo "Creating Package Info file"
335 mkdir
-p ${packagedir}
336 mkdir
${packagedir}/Contents
337 mkdir
${packagedir}/Contents
/Resources
338 mkdir
${packagedir}/Contents
/Resources
/English.lproj
339 echo -n 'pmkrpkg1' > ${packagedir}/Contents
/PkgInfo
341 # Create ReadMe and License files
342 cp ${srcdir}/COPYING
${packagedir}/Contents
/Resources
/License.txt
343 cp ${srcdir}/mac
/README
${packagedir}/Contents
/Resources
/ReadMe.txt
345 infofile
=${packagedir}/Contents
/Resources
/English.lproj
/Emacs.info
347 echo 'Title GNU Emacs' > ${infofile}
348 echo "Version ${version}" >> ${infofile}
349 echo "Description Install GNU Emacs ${version} as a command-line app and a Mac OS Application" >> ${infofile}
350 echo 'DefaultLocation /' >> ${infofile}
351 echo 'DeleteWarning' >> ${infofile}
352 echo 'NeedsAuthorization YES' >> ${infofile}
353 echo 'Required NO' >> ${infofile}
354 echo 'Relocatable NO' >> ${infofile}
355 echo 'RequiresReboot NO' >> ${infofile}
356 echo 'UseUserMask NO' >> ${infofile}
357 echo 'OverwritePermissions NO' >> ${infofile}
358 echo 'InstallFat NO' >> ${infofile}
360 ### Set the install directory to install files as root...
361 ### Not sure if this is a good diea
362 # echo "Setting owner to root"
363 # chown -Rh 0 ${tempparentfull}
365 echo "Creating pax file"
366 (cd ${tempparentfull}; pax
-w -f ${packagedir}/Contents
/Resources
/Emacs.pax .
)
367 echo "Compressing pax file"
368 gzip ${packagedir}/Contents
/Resources
/Emacs.pax
370 echo "Creating bom file"
371 mkbom
${tempparentfull} ${packagedir}/Contents
/Resources
/Emacs.bom
373 echo "Generating sizes file"
374 sizesfile
=${packagedir}/Contents
/Resources
/Emacs.sizes
376 numFiles
=`du -a ${tempparent} | wc -l`
377 installedSize
=`du -s ${tempparent} | cut -f1`
378 compressedSize
=`du -s ${packagedir} | cut -f1`
380 echo "NumFiles ${numFiles}" > ${sizesfile}
381 echo "InstalledSize ${installedSize}" >> ${sizesfile}
382 echo "CompressedSize ${compressedSize}" >> ${sizesfile}
385 echo "Creating Disc Image"
386 ## Allocate an extra 5000 sectors (about 2.5 mg)
387 ## Note a sector appears to be 512k
388 sectorsAlloced
=`echo 2*${compressedSize}+20|bc`
389 hdiutil create
-ov ${builddir}/mac
/EmacsRW
-sectors ${sectorsAlloced}
390 ## Need to format the disc image before mounting
391 mountLoc
=`hdid -nomount ${builddir}/mac/EmacsRW.dmg | grep HFS | cut -f1`
392 /sbin
/newfs_hfs
-v Emacs
${mountLoc}
393 hdiutil eject
${mountLoc}
394 echo "Copying Package to Disc Image"
395 hdid
${builddir}/mac
/EmacsRW.dmg
397 if test "$keep_directory" = "no"; then
398 rm -rf ${tempparentfull}
400 mv ${tempparentfull} ${emacsname}
403 if [ ! -d /Volumes
/Emacs
]; then
404 echo "Could not create disc image. The Emacs installer package (Emacs.pkg)
405 in this directory should be correct. Please use the Disc Copy program to
406 create a disc image." >&2
410 cp -R ${packagedir} /Volumes
/Emacs
412 ## Converting Disk Image to read-only
413 echo 'Converting Disc Image to read-only'
414 hdiutil eject
${mountLoc}
415 hdiutil resize
${builddir}/mac
/EmacsRW.dmg
-sectors min
416 if test "$comp_diskimage" = "yes"; then
417 hdiutil convert
${builddir}/mac
/EmacsRW.dmg
-format UDZO
-imagekey zlib-level
=2 -o ${srcdir}/mac
/EmacsInstaller.dmg
419 hdiutil convert
${builddir}/mac
/EmacsRW.dmg
-format UDRO
-o ${srcdir}/mac
/EmacsInstaller.dmg
421 rm ${builddir}/mac
/EmacsRW.dmg
423 echo "Cleaning up the staging directory"
424 rm -rf ${builddir}/mac
/Emacs.pkg
${removable_build_dir}
426 ### make-package ends here