为Java/Linux创建文件 [英] make file for Java/Linux

查看:491
本文介绍了为Java/Linux创建文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在对makefile进行一些更改后,我在运行它后具有以下makefile,而现在当我运行它时,我得到一个"make:'default'不需要做的任何事情."我该如何强制它进行重建?我执行"make",也执行"make clean",当我键入"make"时仍然收到错误消息.

I have the following makefile after running it once I make some changes to the makefile and now when I run it I get a "make: Nothing to be done for `default'." How can I force it to rebuild? I execute "make" and also "make clean" and I still get the error message when I type "make".

此外,我如何获取src目录中的log4.properties文件以将其复制到目标目录(在make文件中和在命令行上:javac -classpath src:lib/log4j-1.2. 16.jar src/*.java -d bin)吗?

Also, how do I get the log4.properties file which is in the src directory to be copied over to the target directory (in the make file and on the command line: javac -classpath src:lib/log4j-1.2.16.jar src/*.java -d bin)?


#
# define compiler and compiler flag variables
#

JFLAGS = -g -cp .:src:lib/log4j-1.2.16.jar
JC = javac


#
# Clear any default targets for building .class files from .java files; we 
# will provide our own target entry to do this in this makefile.
# make has a set of default targets for different suffixes (like .c.o) 
# Currently, clearing the default for .java.class is not necessary since 
# make does not have a definition for this target, but later versions of 
# make may, so it doesn't hurt to make sure that we clear any default 
# definitions for these
#

.SUFFIXES: .java .class


#
# Here is our target entry for creating .class files from .java files 
# This is a target entry that uses the suffix rule syntax:
#   DSTS:
#       rule
#  'TS' is the suffix of the target file, 'DS' is the suffix of the dependency 
#  file, and 'rule'  is the rule for building a target  
# '$*' is a built-in macro that gets the basename of the current target 
# Remember that there must be a  before the command line ('rule') 
#

.java.class:
    $(JC) $(JFLAGS) $*.java


#
# CLASSES is a macro consisting of 4 words (one for each java source file)
#

CLASSES = \
    src/MatrixDriver.java \
    src/ConcreteMatrix.java \
    src/Matrix.java \
    src/Submatrix.java 


#
# the default make target entry
#

default: classes


#
# This target entry uses Suffix Replacement within a macro: 
# $(name:string1=string2)
#   In the words in the macro named 'name' replace 'string1' with 'string2'
# Below we are replacing the suffix .java of all words in the macro CLASSES 
# with the .class suffix
#

classes: $(CLASSES:.java=.class)


#
# RM is a predefined macro in make (RM = rm -f)
#

clean: FORCE
    $(RM) *.class

FORCE:

推荐答案

问题是这样的:

.java.class:
    $(JC) $(JFLAGS) $*.java

不执行您认为的操作.也许你的意思是这样的?

doesn't do what you think it does. Perhaps you meant something like this?

%.class: %.java
    $(JC) $(JFLAGS) $^

这篇关于为Java/Linux创建文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆