Michael Doherty wrote:
>
> browsing the web and getting mail. Still haven't gotten Makefile to
> work, but I get some ideas for that when I get back to work Monday.
> (Any sample Makefiles for java would be appreciated - TIA)

Hi Michael

I've included four sample files that I tend to use over and over
again for my projects.  Hope this is usefull:

.makefile.projectX - this lives in my home directory and contains
various variables.  A good way to get around operating system
specifics, for example developing in Linux and deploying on Solaris.

Makefile.common - located at the root of the source tree.
this makefile template is included by every other makefile
in the source tree.

Makefile - this is located at the root of the source tree.  I
use it to generate a jar file for deployment, to generate
the project javadoc and to build the whole project.  you can
modify it to be used at every branch node in your source tree.

Makefile.leaf - (rename this to Makefile) sits in a leaf node
directory of your source tree and lists the source files.  use
to to build other stuff specific to the directory.

Chris

Dynamic Solutions Pty Ltd      http://www.dynamic.net.au/christos
414 Gilbert Road               [EMAIL PROTECTED]
Preston, Victoria 3072         61 3 94718224 - voice
Australia                      61 3 94711622 - fax
CP_JDK=/usr/local/jdk/lib/classes.zip
CP_SOURCE=/home/christos/work
CP_JSDK=/usr/local/jsdk/lib/servclasses.zip
CP_JDBC=/usr/share/postgresql/postgresql.jar
CP_EJB=/usr/local/classes/ejbhome.jar

JAVA=/usr/local/jdk/bin/java
JAVAC=/usr/local/bin/jikes
RMIC=/usr/local/jdk/bin/rmic
RMIREGISTRY=/usr/local/jdk/bin/rmiregistry
ECHO=/bin/echo


HAVE_SUBDIRS = true
SUBDIRS      = au com docs
SOURCES      =
CLASSES      = $(SOURCES:.java=.class)
DOCDIR       = docs
DEPLOYDIR    = deploy

all:    subdirs $(SOURCES)

include Makefile.common

javadoc:
        rm -f $(DOCDIR)/*.html
        javadoc -d $(DOCDIR) -author -private -version      \
        au.net.dynamic.projectX                             \
        com.beeble.misc
        chmod g+w $(DOCDIR)/*.html

deploy:
        @$(ECHO) -n "Creating jar file ..."
        @jar cf $(DEPLOYDIR)/projectX.jar `find au com -name "*.class" -print`
        @$(ECHO) "done."


.SUFFIXES: .java .class $(SUFFIXES)

.java.class:
        @echo "compiling $<"
        @$(JAVAC) -classpath $(CLASSPATH) $<

CLASSPATH=.:$(CP_JDK):$(CP_SOURCE):$(CP_JSDK):$(CP_JDBC):$(CP_EJB)

# Set some global variables that are used to construct the CLASSPATH
# and that are also used in the leaf-node Makefiles.

include $(HOME)/.makefile.projectX

subdirs:
        @if $(HAVE_SUBDIRS); then                               \
                for i in ""$(SUBDIRS);                          \
                do ( cd $$i; make );                            \
                done;                                                   \
        fi

clean:
        @rm -f *.class $(JUNK)

cleanall:       clean
        @if $(HAVE_SUBDIRS); then                               \
                for i in ""$(SUBDIRS);                          \
                do ( cd $$i; make cleanall );           \
                done;                                                   \
        fi


HAVE_SUBDIRS = false
SUBDIRS      = 
SOURCES      = Main.java ProjectX.java
CLASSES      = $(SOURCES:.java=.class)
JUNK         = test

all:    subdirs $(CLASSES) scripts

# This target generates a script for testing our project

scripts:
        @$(ECHO) -n "Building scripts .... "
        @rm -f $(JUNK)
        @$(ECHO) "CLASSPATH=$(CLASSPATH)" > test
        @$(ECHO) "export CLASSPATH" >> test
        @$(ECHO) "$(JAVA) au.net.dynamic.projectX" >> test
        @chmod 750 test
        @$(ECHO) "done."

include ../../../../Makefile.common

Reply via email to