Skip to content

Instantly share code, notes, and snippets.

@takaxp
Last active February 27, 2017 00:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takaxp/53fc9e9df6017124824d11ddccc7ce89 to your computer and use it in GitHub Desktop.
Save takaxp/53fc9e9df6017124824d11ddccc7ce89 to your computer and use it in GitHub Desktop.
Build self-contained EMP with some custom variables (25.1 and RCs for 25.2)
#!/bin/sh
# The original script is here: https://gist.githubusercontent.com/railwaycat/10988446/raw/990dde69ea728b9ceff68dd649ad2112c5692ef0/build-emacs.app.sh
rootdir=$HOME/Desktop/emacs_mac_port
if [ ! -d $rootdir ]; then
mkdir $rootdir
fi
installprefix=$rootdir/build
app_dir=$installprefix/Emacs.app/Contents/Resources
source_url=ftp://alpha.gnu.org/gnu/emacs/pretest
version=25.2 # 25.1
version_postfix="-rc2" # ".90"
patch_version=25.2-rc1-mac-6.2
#source_url=http://ftpmirror.gnu.org/emacs
#version=25.1
#patch_version=25.1-mac-6.1
compver=x86_64-apple-darwin`uname -r`
if [ -d $installprefix ]; then
echo "target directory $installprefix exists, exit."
exit
fi
cd $rootdir
find . -name *.elc | xargs rm
if [ -d $installprefix ]; then
rm -rf $installprefix
fi
mkdir $installprefix
#
curl -LO $source_url/emacs-$version$version_postfix.tar.xz
curl -LO ftp://ftp.math.s.chiba-u.ac.jp/emacs/emacs-$patch_version.tar.gz
curl -LO https://gist.githubusercontent.com/takaxp/fc5ae440b3279679dc854e5b9adbfe08/raw/3178aa953b840da47e55f2cef32ffd7a71e1cf0b/emacs-mac-custom.patch
#curl -LO https://gist.githubusercontent.com/takaxp/fc5ae440b3279679dc854e5b9adbfe08/raw/651a2da9dbb273f8e18841197b5cd9fb5bf96992/emacs-mac-custom.patch
# curl -LO https://gist.githubusercontent.com/takaxp/d2137e0add397440229f3b309643ec3a/raw/68b6266fc0af96d34924d1e4d98993594809596d/my-emacs-mac.patch
if [ ! -f emacs-$version$version_postfix.tar.xz ]; then
echo "emacs-$version$version_postfix.tar.xz missing."
exit
fi
tar zxvf emacs-$version$version_postfix.tar.xz
if [ ! -f emacs-$patch_version.tar.gz ]; then
echo "EMP patch messing."
exit
fi
tar zxvf emacs-$patch_version.tar.gz
cd $rootdir/emacs-$version
patch -p1 < ../emacs-$patch_version/patch-mac
cp -r ../emacs-$patch_version/mac mac
cp ../emacs-$patch_version/src/* src
cp ../emacs-$patch_version/lisp/term/mac-win.el lisp/term
if [ -f ../emacs-mac-custom.patch ]; then
patch -p1 < ../emacs-mac-custom.patch
fi
sleep 5
cp -f nextstep/Cocoa/Emacs.base/Contents/Resources/Emacs.icns mac/Emacs.app/Contents/Resources/Emacs.icns
./configure --without-x --with-mac --with-modules --with-rsvg --with-imagemagick --enable-mac-app=$installprefix --prefix=$installprefix
sleep 5
make bootstrap -j1
make install -j1
# self-containing
mv $installprefix/share/emacs/$version/* $app_dir
mv $installprefix/share/info $app_dir
mv $installprefix/share/man $app_dir
rm -rf $installprefix/share
mv $installprefix/var $app_dir
mv $installprefix/bin $app_dir/../MacOS/bin
mv $installprefix/libexec/emacs/$version/$compver $app_dir/../MacOS/libexec
rm -rf $installprefix/libexec
cd $installprefix
open .
echo '--------'
echo 'enjoy!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment