############################################################-*-Makefile-*-#### # Makefile pour le projet de compilation (nécessite GNUMake). ############################################################################## # # Par défaut, ne recompile que les fichiers qui ont été modifiés après # la dernière compilation réussie. # Pour forcer la compilation de tous les fichiers, utiliser "make force". # # $Id: Makefile 2286 2005-11-20 21:29:14 +0100 (Sun, 20 Nov 2005) michelou $ # ############################################################################## ############################################################################## # Variables # Groupe GROUP_NUMBER = # remplacez ceci par votre numéro de groupe # GROUP = $(GROUP_NUMBER:%=compil%) COMPILER_MAIN = zweic.GeneratorTest EXAMPLES_DIR = $(ROOT)/examples TESTS_DIR = $(ROOT)/tests/5 TO_ADDRESS = compilation@lampsun1.epfl.ch # Global ROOT = . TARGETS += $(JC_TARGET) SOURCES += $(JC_SOURCES) OBJECTS += $(JC_OUTPUTDIR) # Compilation Java JC_COMMAND = javac JC_FLAGS = -g -deprecation -source 1.4 JC_OUTPUTDIR = $(ROOT)/classes JC_CLASSPATH = $(JC_OUTPUTDIR) JC_TARGET = .latest-jc JC_FILES += Position JC_FILES += Report JC_FILES += Tokens JC_FILES += Scanner JC_FILES += ScannerTest JC_FILES += Name JC_FILES += Tree JC_FILES += Parser JC_FILES += ParserTest JC_FILES += Formal JC_FILES += Visitor JC_FILES += Printer JC_FILES += PrinterTest JC_FILES += Symbol JC_FILES += Type JC_FILES += DefaultVisitor JC_FILES += Analyzer JC_FILES += AnalyzerTest JC_FILES += RISC JC_FILES += Code JC_FILES += Generator JC_FILES += GeneratorTest JC_SOURCES += $(JC_FILES:%=sources/zweic/%.java) # Execution Java JAVA_COMMAND = java # Comptage WC_COMMAND = wc WC_FILES = $(SOURCES) # Recherche GREP_COMMAND = grep GREP_FILES = $(SOURCES) GREP_ARGS ?= $(ARGS) # Utilitaires divers CHGRP = chgrp CHMOD = chmod ECHO = echo FIND = find MKDIR = mkdir MPACK = /home/iclamp/soft/bin/mpack PRINTF = printf RM = rm -f SED = sed TOUCH = touch WC = wc ZIP = zip ############################################################################## # Fonctions # Affiche puis exécute une commande run = $(ECHO) $(1); $(1) || exit $$? ############################################################################## # Commandes all : $(TARGETS) force : $(RM) $(TARGETS) $(MAKE) all clean : $(RM) $(TARGETS) $(RM) -r $(OBJECTS) distclean : clean $(RM) $(GROUP).zip $(strip $(FIND) . \ \( -name "*~" \ -o -name "*.class" \ -o -name "core" \ \) \ -exec $(RM) "{}" ";") wc : @$(WC_COMMAND) $(WC_FILES) grep : @if [ -z $(GREP_ARGS) ]; then \ $(ECHO) "usage: $(MAKE) grep ARGS="; \ else \ $(GREP_COMMAND) $(GREP_ARGS) $(GREP_FILES); \ fi stat : @sorted=`echo $(JC_SOURCES) | xargs -n 1 | sort`; \ total=0; total1=0; \ tmpfile="/tmp/$(USER)_stat.tmp"; \ for file in $$sorted; do \ size=0; size1=0; \ if [ -f "$$file" ]; then \ size=`stat -L -c%s $$file`; \ total=`echo "$$total + $$size" | bc`; \ $(SED) -es"#^[ \t]*\(.*\)#\1#" $$file > $$tmpfile; \ size1=`stat -L -c%s $$tmpfile`; \ total1=`echo "$$total1 + $$size1" | bc`; \ fi; \ $(PRINTF) "%6d %6d %s\n" $$size $$size1 $$file; \ done; \ $(PRINTF) "%6d %6d\n" $$total $$total1; \ $(RM) $$tmpfile fix-permissions : test-group $(CHGRP) -R $(GROUP) . $(CHMOD) -R g=u . $(CHMOD) -R o-rwx . submit : test-group $(ZIP) $(GROUP).zip $(SOURCES) $(MPACK) -s "$(GROUP)" $(GROUP).zip "$(TO_ADDRESS)" $(RM) $(GROUP).zip test-group : @if [ -z "$(GROUP_NUMBER)" ]; then \ $(ECHO) "erreur : votre numero de groupe manque"; \ $(ECHO) "solution: definissez-le dans votre fichier Makefile"; \ exit 1; \ fi @exist=`groups | grep -c $(GROUP)`; \ if [ "$$exist" -lt 1 ]; then \ $(ECHO) "erreur : le groupe Unix \"$(GROUP)\" n'existe pas"; \ $(ECHO) "solution: verifiez votre numero de groupe"; \ exit 1; \ fi tests : all @for file in `ls -1 $(TESTS_DIR)/*.zwei`; do \ $(ECHO); \ $(ECHO) "fichier $$file"; \ $(JAVA_COMMAND) -cp $(JC_OUTPUTDIR) $(COMPILER_MAIN) $$file; \ done examples : all @for file in `ls -1 $(EXAMPLES_DIR)/*.zwei`; do \ $(ECHO); \ $(ECHO) "fichier $$file"; \ $(JAVA_COMMAND) -cp $(JC_OUTPUTDIR) $(COMPILER_MAIN) $$file; \ done .PHONY : all .PHONY : force .PHONY : clean .PHONY : distclean .PHONY : wc .PHONY : grep .PHONY : stat .PHONY : fix-premissions .PHONY : submit .PHONY : test-group .PHONY : tests .PHONY : examples ############################################################################## # Règles $(JC_TARGET) : $(JC_SOURCES) @if [ ! -d $(JC_OUTPUTDIR) ]; then \ $(call run,$(MKDIR) -p $(JC_OUTPUTDIR)); \ fi $(strip $(JC_COMMAND) $(JC_FLAGS) $(JC_OUTPUTDIR:%=-d %) \ $(JC_CLASSPATH:%=-classpath %) $?) $(TOUCH) $@ ##############################################################################