🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.programmer
Article #3771

Re: Makefile : %.class: %.java

#3771
From: brinkleybw
Date: Tue, 05 Jun 2001 19:03
51 lines
2838 bytes
Make doesn't always like directories (and changing to them).  It is much easier
to create a makefile for each directory, and then write one 'master' makefile
that calls the others (called a recursive makefile; check the O'Reilly book).

Also, did you provide a list of targets?  You may want to add a macro, such as
${CLASSES} in this example:

#Begin makefile
CLASSES = DbKnn.class \
Knn.class

all : ${CLASSES}

%.class : %.java
javac $?
#End makefile

Now you only have to add the class name to the ${CLASSES} macro for each new
class.  IF you want to get fancy, jar the classes using the same technique.

GoodLuck!!

-Brandon



In article <9fc4e2$cko$1@jik.kamens.brookline.ma.us>, Jonathan Kamens says...
>
>In article <sa8snhiepqq.fsf_-_@sun_tong_001.personal.yahoo.com>,
> * Tong * <sun_tong_001@yahoo.com> writes:
>>Here is an example of explicit rule:
>>
>>${CLASSFDIR}/knn/DbKnn.class: knn/DbKnn.java
>>        javac -d ${CLASSFDIR} knn/DbKnn.java
>>
>>${CLASSFDIR}/knn/Knn.class: knn/Knn.java
>>        javac -d ${CLASSFDIR} knn/Knn.java
>>
>>Any idea that can make 'make' work this way? 
>
>I am not sure what the problem is.  The rule I already gave you should
>work just fine:
>
>${CLASSFDIR}/%.class: %.java
>	javac -d ${CLASSFDIR} $<
>
>Note that there's nothing special about slashes as far as '%' is
>concerned -- it's a generic wildcard.  In the examples you gave above,
>it would match "knn/DbKnn" the first time or "knn/Knn" the second time.
>
>Perhaps there's something wrong with your example?
Technical Details
Message-ID: <L1aT6.999$SQ2.49646@www.newsranger.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!newsfeed.mesh.ad.jp!newsranger.com!www.newsranger.com!not-for-mail
References: <3B03B870.2168B36C@bigfoot.com> <p5lmnwukdf.fsf@lemming.engeast.baynetworks.com> <p5bsosui8e.fsf@lemming.engeast.baynetworks.com> <sa8vgmls6pf.fsf@sun_tong_001.personal.yahoo.com> <9f4aia$bda$1@jik.kamens.brookline.ma.us> <sa8snhiepqq.fsf_-_@sun_tong_001.personal.yahoo.com> <9fc4e2$cko$1@jik.kamens.brookline.ma.us>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 109f73,4f4561c76a5fff83
X-Google-Attributes: gid109f73,public
X-Google-Thread: fc89c,4f4561c76a5fff83
X-Google-Attributes: gidfc89c,public
X-Google-ArrivalTime: 2001-06-05 12:03:55 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!newsfeed.mesh.ad.jp!newsranger.com!www.newsranger.com!not-for-mail
Newsgroups: comp.unix.programmer,gnu.utils.help
From: brinkleybw@hotmail.com
References: <3B03B870.2168B36C@bigfoot.com> <p5lmnwukdf.fsf@lemming.engeast.baynetworks.com> <p5bsosui8e.fsf@lemming.engeast.baynetworks.com> <sa8vgmls6pf.fsf@sun_tong_001.personal.yahoo.com> <9f4aia$bda$1@jik.kamens.brookline.ma.us> <sa8snhiepqq.fsf_-_@sun_tong_001.personal.yahoo.com> <9fc4e2$cko$1@jik.kamens.brookline.ma.us>
Subject: Re: Makefile : %.class: %.java
Lines: 53
Message-ID: <L1aT6.999$SQ2.49646@www.newsranger.com>
X-Abuse-Info: When contacting newsranger.com regarding abuse please
X-Abuse-Info: forward the entire news article including headers or
X-Abuse-Info: else we will not be able to process your request
X-Complaints-To: abuse@newsranger.com
NNTP-Posting-Date: Tue, 05 Jun 2001 15:03:07 EDT
Organization: http://www.newsranger.com
Date: Tue, 05 Jun 2001 19:03:07 GMT