Results 1 to 3 of 3
Probably I am stupid but can not get it...
I want to compile different projects within one Makefile.
Something like that:
#my makefile
project.id = 01
lesson$(project.id).class: lesson$(project.id).java
javac lesson$(project.id).java
...
- 12-25-2008 #1Just Joined!
- Join Date
- Dec 2008
- Posts
- 11
making makefile
Probably I am stupid but can not get it...
I want to compile different projects within one Makefile.
Something like that:
#my makefile
project.id = 01
lesson$(project.id).class: lesson$(project.id).java
javac lesson$(project.id).java
clean:
rm -f *.class
So, is it possible to assign the $(project.id) from command line?
I mean externally not internally like it was in above example.
Just like
>make 'write here something simple to assign project id'
Any ideas? Thank you
- 12-25-2008 #2
Well, the simplest solution would be to simply have a different target for each lesson. So you have a target called "lesson01", a target called "lesson02", etc. Then you just call "make lesson01", "make lesson02", etc.
The problem with this is that whenever you add a new lesson, you need to add a new line to the Makefile. Furthermore, each line in the Makefile will be very similar.
The other approach is to use the ID variable and give it a value in the commandline:
GNU Make - How to Run @code{make}
This allows me to say:
The variable "project.id" is now 1 in the Makefile, and may be used accordingly.Code:make project.id=1
Does this help?DISTRO=Arch
Registered Linux User #388732
- 12-25-2008 #3Just Joined!
- Join Date
- Dec 2008
- Posts
- 11
It works perfectly. Thanks!Code:make project.id=1


Reply With Quote