?
Solved

Make file is not working properly.

Posted on 2000-05-15
3
Medium Priority
?
216 Views
Last Modified: 2010-04-21
I written the following make file.

Makefile

SOURCE=GenLog.java\
        GenMessageItem.java\
        GenMessageCollection.java\
        GenErrorLogger.java\
        GenComponentLogger.java

CLASSES=GenLog.class\
        GenMessageItem.class\
        GenMessageCollection.class\
        GenErrorLogger.class\
        GenComponentLogger.class

$(CLASSES):$(SOURCE)
        javac $(SOURCE)

clean :
        rm $(CLASSES)

1. make - This generated .class files.
2. I changed one source code
3. make - I am expecting that, it need to compile only that .java file.
                 all java files are independent.
   Instead of compiling changed file it is compiling all .java files.

what is the problem?

I am using  GNU make
0
Comment
Question by:polimetla
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 40

Expert Comment

by:jlevie
ID: 2812699
Well, the Makefile is just following instructions. You told it that the class files depended on the sources ($(CLASSES):$(SOURCE)) and then you told it what to do, i.e. "javac $(SOURCE). Since $(SOURCE) expands to everything listed in "SOURCE:" it compiled everything.

What you wnat it to tell it how to compile a single object from its corresponding source. A rule likke:

%.class:  %.java
          javac $<

will do that. So the makefile ouht to look something like:

%.class:  %.java
          javac $<

SOURCE=   GenLog.java\
          GenMessageItem.java\
          GenMessageCollection.java\
          GenErrorLogger.java\
          GenComponentLogger.java

CLASSES=  GenLog.class\
          GenMessageItem.class\
          GenMessageCollection.class\
          GenErrorLogger.class\
          GenComponentLogger.class

all:      $(CLASSES)

clean:
          rm $(CLASSES)

should do what you want.
0
 

Accepted Solution

by:
forraidp earned 20 total points
ID: 2873666
Your problem is in your $(CLASS) target.  In the line

 javac $(SOURCE)

$(SOURCE) will substitute all sources and thus compile all source files.  You can eliminate the SOURCE macro, set up a suffix rule, and add a generic target:

# Clear existing suffixes
..SUFFIXES:

# Add your suffixes
..SUFFIXES: .class .java

#  Add the suffix rule
..java.class:
    javac $<

all: $(CLASSES)
0
 
LVL 1

Author Comment

by:polimetla
ID: 2874401
Answer accepted
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses
Course of the Month9 days, 11 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question