I've got a quick and dirty little make file that does out-of-source builds for a relatively small java project:
default: bin/classes/EntryPoint.class bin/classes/manifest jar cvfm ./bin/output.jar ./bin/classes/manifest -C ./bin/classes EntryPoint.class bin/classes/EntryPoint.class: ./src/EntryPoint.java bin javac -sourcepath ./src -d ./bin/classes ./src/EntryPoint.java bin/classes/manifest: src/manifest cp bin/classes/manifest src/manifest bin: mkdir ./bin; mkdir ./bin/classes; clean: rm -rf bin
The downside here is that if I want to add a new java file, I need to add a target for it, and add dependencies to the jar packaging step, and the path to the jar packaging step's command line. Adding the same thing in 3 places is going to result in unmaintainable mess for anything more than 4-5 files.
What I would like to do is simply add a "SOURCEFILES= files here"
definition and list the files, and not have to mess with the commands and such. Can this be done?
NOTE: I know there are probably better tools for this (such as ant
), but this is something I'm turning in as a homework assignment, and I cannot require the grader to have anything but the jdk amd make
installed.