How can i have makefile/shell script call /Applications/application.app?

OS Mac OS X 10.6.6 emacs 23.2.1

I'm currently trying to install magit on carbon emacs using their proposed make solution. I'm an almost complete makefile newby so I might be on the complete wrong path altogether. Makefile displays:

%.elc: %.el
$(BATCH) --eval '(byte-compile-file "$<")'

which gets expanded to:

emacs -batch -q -no-site-file -eval "(setq load-path (cons (expand-file-name \".\") load-path))" --eval '(byte-compile-file "magit.el")'

What I do understand. However it comes back with:

Cannot open load file: subst-ksc

What after a bit of googling reveals some missing libraries. I also realized that the emacs referenced in the expanded command is pointing to /usr/bin/emacs which is one big file, I don't see the normal lisp / site-lisp / etc directories. I also know that my prefered emacs is carbon emacs located in /Application/Emacs.app which just opens when clicking on it, or alternatively, I can open it in with the terminal:

open /Application/MyApp.app

Finally the title question: How can I make Makefile using the Emacs.app on the applications directory? I hope someone here knows the answer, or can point me to alternatives.

regards, Jeroen.


To use the Emacs.app from shell you need the unix executable embedded inside it. It is at Emacs.app/Contents/MacOS/Emacs (I don't have this version of emacs so the capitalisation might differ)

An alternative is to use open to start any app from the workspace using open.

e.g.

open -a Emacs.app --args <all those passed to emacs>

I'm answering an older question in case anyone else happens across it via Google like I did.

As Mark pointed out, to byte-compile a file using the Emacs.app executable you need to replace emacs or /usr/bin/emacs in the Makefile with /Applications/Emacs.app/Contents/MacOS/Emacs. I believe that in general byte-compiled files are not compatible across different versions of Emacs, so when installing a package for use with Emacs.app you should byte-compile it using this executable, not with the default Apple-installed /usr/bin/emacs (which is a version 22 emacs on my 10.6 system).

If you do need to run the /usr/bin/emacs for some other reason, take care that EMACSLOADPATH doesn't contain files belonging to a newer Emacs. This is one potential cause of error messages such as

Cannot open load file: subst-ksc

Invoking emacs from the shell as

EMACSLOADPATH=/usr/share/emacs/22.1/leim:/usr/share/emacs/22.1/lisp:/usr/share/emacs/22.1/site-lisp emacs

should do the trick.

Hope this helps someone else!