сделать файл для Java / Linux - PullRequest
0 голосов
/ 30 марта 2012

У меня есть следующий make-файл после запуска, как только я внесу некоторые изменения в make-файл, и теперь, когда я запускаю его, я получаю «make: Ничего не нужно делать для` default ”. Как я могу заставить его восстановить? Я выполняю «make», а также «make clean», и все равно получаю сообщение об ошибке, когда набираю «make».

Кроме того, как мне получить файл log4.properties, который находится в каталоге src, для копирования в целевой каталог (в файле make и в командной строке: 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:

Ответы [ 3 ]

2 голосов
/ 30 марта 2012

Проблема в том, что это:

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

не делает то, что вы думаете, что делает.Возможно, вы имели в виду что-то вроде этого?

%.class: %.java
    $(JC) $(JFLAGS) $^
0 голосов
/ 30 марта 2012

Убедитесь, что нет файла или каталога, называемого классами. Тогда Make мог предположить, что больше ничего не делает.

0 голосов
/ 30 марта 2012

Я не внимательно прочитал ваш Makefile и не считаю себя экспертом по make но

  1. похоже, что нет никакой зависимости от самого Makefile
  2. все, что вы изменили, это Makefile

заставляет меня думать, что правильное поведение - это именно то, что вы описали. Возможно, вы можете добавить зависимость в Makefile.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...