Makefiles cleanup.
[TP_POO.git] / HelloWorld / Makefile
CommitLineData
fc3673c1
JB
1# define compiler and compiler flag variables
2# define a variable for compiler flags (JFLAGS)
3# define a variable for the compiler (JC)
4# define a variable for the Java Virtual Machine (JVM)
5# define a variable for a parameter. When you run make, you could use:
6# make run FILE="Algo.csv" para sobre escribir el valor de FILE.
7
8JFLAGS = -g
9JC = javac
10JVM = java
11FILE =
12
13#
14# Clear any default targets for building .class files from .java files; we
15# will provide our own target entry to do this in this makefile.
16# make has a set of default targets for different suffixes (like .c.o)
17# Currently, clearing the default for .java.class is not necessary since
18# make does not have a definition for this target, but later versions of
19# make may, so it doesn't hurt to make sure that we clear any default
20# definitions for these
21#
22
23.SUFFIXES: .java .class
24
25
26#
27# Here is our target entry for creating .class files from .java files
28# This is a target entry that uses the suffix rule syntax:
29# DSTS:
30# rule
31# DSTS (Dependency Suffix Target Suffix)
32# 'TS' is the suffix of the target file, 'DS' is the suffix of the dependency
33# file, and 'rule' is the rule for building a target
34# '$*' is a built-in macro that gets the basename of the current target
35# Remember that there must be a < tab > before the command line ('rule')
36#
37
38.java.class:
39 $(JC) $(JFLAGS) $*.java
40
41
42#
43# CLASSES is a macro consisting of N words (one for each java source file)
44# When a single line is too long, use \<return> to split lines that then will be
45# considered as a single line. For example:
46# NAME = Camilo \
47 Juan
48# is understood as
49# NAME = Camilo Juan
50
51CLASSES = \
52 HelloWorld.java
53
54#
55# MAIN is a variable with the name of the file containing the main method
56#
57
58MAIN = HelloWorld
59
60#
61# the default make target entry
62# for this example it is the target classes
63
64default: classes
65
66
67# Next line is a target dependency line
68# This target entry uses Suffix Replacement within a macro:
69# $(macroname:string1=string2)
70# In the words in the macro named 'macroname' replace 'string1' with 'string2'
71# Below we are replacing the suffix .java of all words in the macro CLASSES
72# with the .class suffix
73#
74
75classes: $(CLASSES:.java=.class)
76
77
78# Next two lines contain a target for running the program
79# Remember the tab in the second line.
80# $(JMV) y $(MAIN) are replaced by their values
81
82run: $(MAIN).class
83 $(JVM) $(MAIN)
84
85# this line is to remove all unneeded files from
86# the directory when we are finished executing(saves space)
87# and "cleans up" the directory of unneeded .class files
88# RM is a predefined macro in make (RM = rm -f)
89#
90
91clean:
92 $(RM) *.class