Add arch tagline
[emacs.git] / nextstep / compile
blob4f42330edc80e5adc1bf67b80fe326b36df58707
1 #!/bin/sh
3 # This script configures and builds Emacs to the subdirectory ./build .
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'.
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".
11 # Some setup is different for GNUstep vs. Cocoa, and it determines which one
12 # it's on using 'uname'.
14 # After it is run, Emacs can be run directly from the .app, which itself
15 # can be placed anywhere.
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.
23 # Set up path and config variables.
25 PREFIX=""
26 while [ $# -gt 0 ]; do
27 case "$1" in
28 --shared-lisp=*)
29 PREFIX=`echo "$1" | sed s/--shared-lisp=//`
30 shift
32 --enable-local-lisp-path=*)
33 locallisppath=`echo "$1" | sed s/--enable-local-lisp-path=//`
34 shift
37 echo "Usage: $0 [--shared-lisp='install_root' --enable-local-lisp-path='some path(s)']"
38 exit
39 esac
40 done
42 DISTDIR=`pwd`/..
44 #OPTFLAGS='-g -O2'
45 OPTFLAGS='-g'
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
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
70 # GNUSTEP
71 else
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
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
85 export GNUSTEP_MAKEFILES
86 export GNUSTEP_SYSTEM_HEADERS
87 export GNUSTEP_SYSTEM_LIBRARIES
89 BASEDIR=`pwd`/build/Emacs.app
90 BINDIR=${BASEDIR}
91 if [ "x${PREFIX}" == "x" ]; then
92 PREFIX=${BASEDIR}/Resources
94 NS_CFG_OPTS="--with-ns --without-x --without-freetype --prefix=${PREFIX} --exec-prefix=${BASEDIR} --libexecdir=${BASEDIR}/libexec"
95 # --enable-cocoa-experimental-ctrl-g
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
103 export MAKE
104 CFLAGS="$OPTFLAGS"
105 export CFLAGS
108 # PENDING: Not sure why this is needed
109 export EMACSLOADPATH="${DISTDIR}/lisp:${DISTDIR}/lisp/emacs-lisp:${DISTDIR}/leim"
112 # End variable setup.
113 ###############################################################################
115 # Prepare a clean slate
116 rm -fr build/Emacs.app
118 # Configure if needed
119 cd ..
120 if [ ! -f Makefile ]; then
121 echo "./configure ${NS_CFG_OPTS}"
122 ./configure <<EOF ${NS_CFG_OPTS}
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
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
152 # Clean up to avoid DOC-xxx and emacs-xxx out-of-controlness
153 rm -f ../etc/DOC-* ../src/emacs-*
156 # Go (installs binaries to ./build/Emacs.app, lisp to there or PREFIX)
157 echo "make install"
158 $MAKE
159 status=$?
161 if [ -f src/epaths.h-orig ]; then
162 mv src/epaths.h-orig src/epaths.h
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
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
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/*/* .
189 if [ ! -d info ]; then
190 # happens on GNUstep, not OS X
191 mv -f share/info .
193 rm -fr share
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}/`
200 # rm -f $f
201 #done
203 # Bin cleanup
204 cd $BINDIR/bin
205 rm -f emacs emacs-23*
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/* .
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
221 echo ""
222 echo "Build successful."
223 echo ""
225 # arch-tag: 1fda51a1-d908-4e60-ad5e-47ffbb39f18d