diff options
Diffstat (limited to 'nextstep/compile')
| -rwxr-xr-x | nextstep/compile | 223 |
1 files changed, 223 insertions, 0 deletions
diff --git a/nextstep/compile b/nextstep/compile new file mode 100755 index 00000000000..e48accbfe73 --- /dev/null +++ b/nextstep/compile | |||
| @@ -0,0 +1,223 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # This script configures and builds Emacs to the subdirectory ./build . | ||
| 4 | # | ||
| 5 | # If --shared-lisp 'install_prefix' is given, lisp files will be installed to | ||
| 6 | # install_prefix/share/emacs/23.0.0. This option must be run with 'sudo'. | ||
| 7 | # | ||
| 8 | # Otherwise (default) lisp will be installed under Emacs.app/Contents/Resources. | ||
| 9 | # It does this by configuring it to install there, and running "make install". | ||
| 10 | # | ||
| 11 | # Some setup is different for GNUstep vs. Cocoa, and it determines which one | ||
| 12 | # it's on using 'uname'. | ||
| 13 | |||
| 14 | # After it is run, Emacs can be run directly from the .app, which itself | ||
| 15 | # can be placed anywhere. | ||
| 16 | |||
| 17 | # Further C development can be done using Xcode on OS X (not tested recently), | ||
| 18 | # or by typing './remake' in the '../src' directory. Further Lisp | ||
| 19 | # development can be done by either copying the files you modify | ||
| 20 | # into install location, or running this script again. | ||
| 21 | |||
| 22 | |||
| 23 | # Set up path and config variables. | ||
| 24 | |||
| 25 | PREFIX="" | ||
| 26 | while [ $# -gt 0 ]; do | ||
| 27 | case "$1" in | ||
| 28 | --shared-lisp=*) | ||
| 29 | PREFIX=`echo "$1" | sed s/--shared-lisp=//` | ||
| 30 | shift | ||
| 31 | ;; | ||
| 32 | --enable-local-lisp-path=*) | ||
| 33 | locallisppath=`echo "$1" | sed s/--enable-local-lisp-path=//` | ||
| 34 | shift | ||
| 35 | ;; | ||
| 36 | *) | ||
| 37 | echo "Usage: $0 [--shared-lisp='install_root' --enable-local-lisp-path='some path(s)']" | ||
| 38 | exit | ||
| 39 | esac | ||
| 40 | done | ||
| 41 | |||
| 42 | DISTDIR=`pwd`/.. | ||
| 43 | |||
| 44 | #OPTFLAGS='-g -O2' | ||
| 45 | OPTFLAGS='-g' | ||
| 46 | |||
| 47 | # MAC OS X | ||
| 48 | if [ `uname` == "Darwin" ]; then | ||
| 49 | BASEDIR=`pwd`/build/Emacs.app/Contents | ||
| 50 | BINDIR=${BASEDIR}/MacOS | ||
| 51 | if [ "x$PREFIX" == "x" ]; then | ||
| 52 | PREFIX=${BASEDIR}/Resources | ||
| 53 | fi | ||
| 54 | # If you want to try experimental enhanced Ctrl-g support, add to NS_CFG_OPTS: | ||
| 55 | # --enable-cocoa-experimental-ctrl-g | ||
| 56 | # (See bottom of USAGE.txt) | ||
| 57 | NS_CFG_OPTS="--with-ns --without-x --without-freetype --prefix=${PREFIX} --exec_prefix=${BASEDIR}/MacOS --libexecdir=${BASEDIR}/MacOS/libexec" | ||
| 58 | # --enable-cocoa-experimental-ctrl-g" | ||
| 59 | # MAKE="make -j3" | ||
| 60 | steve=`/usr/sbin/sysctl hw.ncpu | awk '{print $NF}'` | ||
| 61 | MAKE="make -j`expr $steve + 1`" | ||
| 62 | export CC=gcc-4.0 | ||
| 63 | export MACOSX_DEPLOYMENT_TARGET=10.3 | ||
| 64 | export MACOSX_DEPLOYMENT_TARGET_ppc=10.3 | ||
| 65 | export MACOSX_DEPLOYMENT_TARGET_i386=10.4 | ||
| 66 | export CFLAGS="$OPTFLAGS -arch ppc -arch i386" | ||
| 67 | # -universal -sdk /Developer/SDKs/MacOSX10.4u.sdk | ||
| 68 | # -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk | ||
| 69 | |||
| 70 | # GNUSTEP | ||
| 71 | else | ||
| 72 | |||
| 73 | # Currently must pass three dirs into Make process via environment variables. | ||
| 74 | source /etc/GNUstep/GNUstep.conf | ||
| 75 | if [ "x$GNUSTEP_MAKEFILES" == "x" ]; then | ||
| 76 | if [ "x$GNUSTEP_SYSTEM_ROOT" == "x" ]; then | ||
| 77 | echo "Failed to obtain any useful information from /etc/GNUstep/GNUstep.conf." | ||
| 78 | echo "Please make sure GNUstep is installed on your system." | ||
| 79 | exit | ||
| 80 | fi | ||
| 81 | GNUSTEP_MAKEFILES=${GNUSTEP_SYSTEM_ROOT}/Library/Makefiles | ||
| 82 | GNUSTEP_SYSTEM_HEADERS=${GNUSTEP_SYSTEM_ROOT}/Library/Headers | ||
| 83 | GNUSTEP_SYSTEM_LIBRARIES=${GNUSTEP_SYSTEM_ROOT}/Library/Libraries | ||
| 84 | fi | ||
| 85 | export GNUSTEP_MAKEFILES | ||
| 86 | export GNUSTEP_SYSTEM_HEADERS | ||
| 87 | export GNUSTEP_SYSTEM_LIBRARIES | ||
| 88 | |||
| 89 | BASEDIR=`pwd`/build/Emacs.app | ||
| 90 | BINDIR=${BASEDIR} | ||
| 91 | if [ "x${PREFIX}" == "x" ]; then | ||
| 92 | PREFIX=${BASEDIR}/Resources | ||
| 93 | fi | ||
| 94 | NS_CFG_OPTS="--with-ns --without-x --without-freetype --prefix=${PREFIX} --exec-prefix=${BASEDIR} --libexecdir=${BASEDIR}/libexec" | ||
| 95 | # --enable-cocoa-experimental-ctrl-g | ||
| 96 | |||
| 97 | if [ "x$MAKE" == "x" ]; then | ||
| 98 | if [ "`gmake 2>&1`" == "gmake: *** No targets specified and no makefile found. Stop." ]; then | ||
| 99 | MAKE=gmake | ||
| 100 | else | ||
| 101 | MAKE=make | ||
| 102 | fi | ||
| 103 | export MAKE | ||
| 104 | CFLAGS="$OPTFLAGS" | ||
| 105 | export CFLAGS | ||
| 106 | fi | ||
| 107 | |||
| 108 | # PENDING: Not sure why this is needed | ||
| 109 | export EMACSLOADPATH="${DISTDIR}/lisp:${DISTDIR}/lisp/emacs-lisp:${DISTDIR}/leim" | ||
| 110 | fi | ||
| 111 | |||
| 112 | # End variable setup. | ||
| 113 | ############################################################################### | ||
| 114 | |||
| 115 | # Prepare a clean slate | ||
| 116 | rm -fr build/Emacs.app | ||
| 117 | |||
| 118 | # Configure if needed | ||
| 119 | cd .. | ||
| 120 | if [ ! -f Makefile ]; then | ||
| 121 | echo "./configure ${NS_CFG_OPTS}" | ||
| 122 | ./configure <<EOF ${NS_CFG_OPTS} | ||
| 123 | EOF | ||
| 124 | # ./configure ${NS_CFG_OPTS} | ||
| 125 | if [ $? != 0 ]; then | ||
| 126 | echo "*** Configure run failed. ***" | ||
| 127 | echo "Please examine the above output to determine what went wrong," | ||
| 128 | echo "edit this script (\'compile\') to fix it, and rerun." | ||
| 129 | # These are written BEFORE the job is compete, then it won't get done | ||
| 130 | # next time, causing errors about CTLau-b5, tsang-b5, PY, etc.. | ||
| 131 | rm -f leim/changed.misc leim/changed.tit | ||
| 132 | exit 1 | ||
| 133 | fi | ||
| 134 | fi | ||
| 135 | |||
| 136 | # Pete's addition for local lisp load-path | ||
| 137 | if [ "x$locallisppath" != "x" ]; then | ||
| 138 | echo " * Local lisp path is being enabled" | ||
| 139 | (cd src | ||
| 140 | if [ -r epaths.h-orig ]; then | ||
| 141 | # mv ../src/epaths.h-orig ../src/epaths.h | ||
| 142 | echo "### src/epaths.h-orig already exists, no further change ###" | ||
| 143 | else | ||
| 144 | mv epaths.h epaths.h-orig | ||
| 145 | printf "s,\(#define PATH_LOADSEARCH \"\),\\\1%s:,\n" "$ | ||
| 146 | {locallisppath}" > locallisppath.sed | ||
| 147 | cat epaths.h-orig | sed -f locallisppath.sed > epaths.h | ||
| 148 | rm locallisppath.sed | ||
| 149 | fi) | ||
| 150 | fi | ||
| 151 | |||
| 152 | # Clean up to avoid DOC-xxx and emacs-xxx out-of-controlness | ||
| 153 | rm -f ../etc/DOC-* ../src/emacs-* | ||
| 154 | |||
| 155 | |||
| 156 | # Go (installs binaries to ./build/Emacs.app, lisp to there or PREFIX) | ||
| 157 | echo "make install" | ||
| 158 | $MAKE | ||
| 159 | status=$? | ||
| 160 | |||
| 161 | if [ -f src/epaths.h-orig ]; then | ||
| 162 | mv src/epaths.h-orig src/epaths.h | ||
| 163 | fi | ||
| 164 | |||
| 165 | if [ $status != 0 ]; then | ||
| 166 | echo "*** Compilation failed. ***" | ||
| 167 | echo "Please examine the above output to determine what went wrong," | ||
| 168 | echo "edit the configure options in this script (\'compile\') to fix it, and rerun." | ||
| 169 | # rm -f leim/changed.misc leim/changed.tit | ||
| 170 | exit 1 | ||
| 171 | fi | ||
| 172 | |||
| 173 | $MAKE install | ||
| 174 | if [ $? != 0 ]; then | ||
| 175 | echo "*** Compilation succeeded, but .app assembly failed. ***" | ||
| 176 | echo "Please examine the above output to determine what went wrong," | ||
| 177 | echo "edit the configure options in this script (\'compile\') to fix it, and rerun." | ||
| 178 | # rm -f leim/changed.misc leim/changed.tit | ||
| 179 | exit 1 | ||
| 180 | fi | ||
| 181 | |||
| 182 | # Move version stuff up to Resources | ||
| 183 | cd ${BASEDIR}/Resources | ||
| 184 | if [ -d share/emacs ]; then | ||
| 185 | # clean up self-contained build | ||
| 186 | mv -f share/emacs/*/* . | ||
| 187 | fi | ||
| 188 | |||
| 189 | if [ ! -d info ]; then | ||
| 190 | # happens on GNUstep, not OS X | ||
| 191 | mv -f share/info . | ||
| 192 | fi | ||
| 193 | rm -fr share | ||
| 194 | |||
| 195 | # Get rid of .el.gz when .elc is present.. purists will complain, but this | ||
| 196 | # knocks the app size down substantially. | ||
| 197 | cd lisp | ||
| 198 | #for f in `find . -name '*.elc' -print | sed -e s/.elc/.{el,el.gz}/` | ||
| 199 | #do | ||
| 200 | # rm -f $f | ||
| 201 | #done | ||
| 202 | |||
| 203 | # Bin cleanup | ||
| 204 | cd $BINDIR/bin | ||
| 205 | rm -f emacs emacs-23* | ||
| 206 | |||
| 207 | # Move libexec stuff up, and link it from bin | ||
| 208 | cd ../libexec | ||
| 209 | mv -f emacs/*/*/* . | ||
| 210 | rm -fr emacs | ||
| 211 | cd ../bin | ||
| 212 | ln -sf ../libexec/* . | ||
| 213 | |||
| 214 | # On OS X, install the bundled ispell | ||
| 215 | #if [ `uname` == "Darwin" ]; then | ||
| 216 | # cd $DISTDIR | ||
| 217 | # cp ispell-3.3.01/bin/ispell* ${BINDIR}/libexec | ||
| 218 | # cp -R ispell-3.3.01/lib ${BINDIR}/libexec | ||
| 219 | #fi | ||
| 220 | |||
| 221 | echo "" | ||
| 222 | echo "Build successful." | ||
| 223 | echo "" | ||