ESD
ESD

Reputation: 544

Make file for multi-directory project

I am trying to do a makefile for a java project that pretty much compiles the whole project and place the compiled files in a bin directory. This is my file architectures : file architecture

This is my makefile at the root directory :

BIN=./bin/
SOURCE=./src/

all:
    cd src; make
clean:
    rm -f $(BIN)*.class

and this is my makefile in the src directory :

BIN=../bin/

sourcefiles = \
MessageMondial.class \
Bonjour.class

classfiles  = $(sourcefiles:.java=.class)

all: $(classfiles)
$(BIN)%.class: /src/%.java
    javac -d $(BIN) -classpath . $<

if I go in the src directory and run the make all command everything gets compiled and is putted in the bin directory like it should.

However when I run the make all command from the root directory of the project I get this error :

error message

How can I run the make all command from the root directory of the project?

Upvotes: 0

Views: 345

Answers (1)

Elliott Frisch
Elliott Frisch

Reputation: 201487

This

sourcefiles = \
MessageMondial.class \
Bonjour.class

should be

sourcefiles = \
MessageMondial.java \
Bonjour.java

but I would also recommend you use maven, ant, gradle or sbt instead of make. Make was not a tool designed for building Java projects.

Upvotes: 1

Related Questions