[TxMt] Compile java using make within TM

Jim Menard jimm at io.com
Thu Nov 18 12:46:30 UTC 2004

Ivar Åsell wrote:
> I'm not that creative so I haven't figured out how to do this yet.
> I have the following structure
> project/
> project/classes/
> project/src/
> projekt/Makefile
> I usually create a TM-project for the source-folder.
> How can I make a macro that executes the makefile?

I've written a shell script called "makeup" that searches for a Makefile in 
the current directory. If it doesn't find one, it keeps searching up the 
directory structure. That way, I can type "makeup" in any directory in the 
project and it will find the Makefile.

You can create a command that runs "makeup" and that should do what you want. 
Here's makeup:

#! /bin/sh
# usage: makeup [args...]
# Finds the first makefile in the current directory or any directory above and
# then runs make, passing on any args given to this script.


while [ /bin/true ] ; do
     if [ -f Makefile || -f makefile ] ; then
	# If we've found a makefile, go back to the original directory and use
	# the -C flag to tell make to run from the directory where we found
	# the makefile. We do this so that error messages produced during the
	# make process are relative to the current directory. I think.
	cd $start_dir
	make -C $here $*

     # Stop if we're in the top directory.
     if [ "/" == `pwd` ] ; then
	# No parent directory
	echo no makefile found
	exit 1

     # Keep swimming...keep swimming...swimming, swimming, swimming...
     cd ..

Jim Menard, jimm at io.com, http://www.io.com/~jimm

More information about the textmate mailing list