pechkin: (Default)
pechkin ([personal profile] pechkin) wrote2004-03-03 12:05 pm

(no subject)

Вот итог изучения makefileов: makefile для компиляции жаба-проекта:
#JSDK options:
#Where's the compiler

JAVADIR=/usr/local/j2sdk1.4.1_02
#How to call the compiler
CMP=$(JAVADIR)/bin/javac

#Project options
#Where's the project

PROJDIR=.
#What to include
INC=/mnt/prj/java/ftp-1.2.3/ftp.jar
#Where to put the result
DST=-d $(PROJDIR)/classes
#What is the resulting classpath
CPT=-classpath .:/home/pechkin/prj/classes:$(INC):$(JAVADIR)/lib/tools.jar
#How to compile
OPT=-deprecation #-verbose

#make variables

SHELL=/bin/bash

.PHONY: sources compileall
include sources.lst

compileall: sources.lst
$(CMP) $(SRC) $(CPT) $(OPT) $(DST)
#Чего-нибудь навроде тирьям-тирьям-тирьям:
# for srcfile in `cat sources.lst` do;
# cat $$srcfile | awk ‘BEGIN {$$srcfile”.class: \\” /^import (.*);$/ {print $1”\\”}’ END {print “\t$(CMP) $^ $(CPT) $(OPT) $(DST)”}’ >$$srcfile.makefile #, короче, достать импорты и проверить, что такие файлы есть внутри проекта
# done;
cp sources.lst _sources.lst
rm sources.lst

#Каким-то образом надо заинклюдить все файлы, имена которых $(SRC:.java=.makefile), причем рекурсивно под $(PROJDIR)
#И их замейкать.

sources.lst:
ls -R1 $(PROJDIR) | awk 'BEGIN {print "SRC=\\"} /^\./ {dirname=substr($$0, 0, length($$0)-1)} /\.java/ {print dirname"/"$$0"\\"}' - > sources.lst

#What's so bad: 1. the compilation is unconditional. So far there's some 30 files in the project. What with 3000?
#Solution: generate the list of imports for each file in $(SRC) and set the project (non-system) import classes as prerequisites.
#This suggests that a makefile should be generated and included for each project .java file.
#Which must affect the compilation speed very bad.


Какие-нибудь предложения, идеи?

[identity profile] olegs.livejournal.com 2004-03-03 02:18 am (UTC)(link)
Для сборки лучше использовать ant, а не make.

[identity profile] beldmit.livejournal.com 2004-04-03 08:20 am (UTC)(link)
А что такое ant?

[identity profile] olegs.livejournal.com 2004-04-03 08:25 am (UTC)(link)
http://ant.apache.org/

предназначен, как и make, для сборки больших программ, но больше подходящий для Java и родственных ей технологий.

[identity profile] gianthare.livejournal.com 2004-03-03 02:20 am (UTC)(link)
Ка-то всё странно, если это, конечно, не намеренно. Казалось бы, compileall зависит от списка класс файлов, а не Джава файлов (а еще лучше от джара, который зависит от класс-файлов). А каждый класс-файл зависит от своего ява-файла. Не так?

[identity profile] trurle.livejournal.com 2004-03-03 02:25 am (UTC)(link)
Ant

.

[identity profile] kkk-ddd.livejournal.com 2004-03-03 02:29 am (UTC)(link)
autoconf, automake, etc...

[identity profile] yms.livejournal.com 2004-03-03 05:14 am (UTC)(link)
Хотел посоветовать ant, а меня уже дважды опередили...