Commit | Line | Data |
---|---|---|
4871c009 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 | ||
6 | JFLAGS = -g | |
7 | JC = javac | |
8 | JVM = java | |
9 | ||
10 | # | |
11 | # Clear any default targets for building .class files from .java files; we | |
12 | # will provide our own target entry to do this in this makefile. | |
13 | # make has a set of default targets for different suffixes (like .c.o) | |
14 | # Currently, clearing the default for .java.class is not necessary since | |
15 | # make does not have a definition for this target, but later versions of | |
16 | # make may, so it doesn't hurt to make sure that we clear any default | |
17 | # definitions for these | |
18 | # | |
19 | ||
20 | .SUFFIXES: .java .class | |
21 | ||
22 | ||
23 | # | |
24 | # Here is our target entry for creating .class files from .java files | |
25 | # This is a target entry that uses the suffix rule syntax: | |
26 | # DSTS: | |
27 | # rule | |
28 | # DSTS (Dependency Suffix Target Suffix) | |
29 | # 'TS' is the suffix of the target file, 'DS' is the suffix of the dependency | |
30 | # file, and 'rule' is the rule for building a target | |
31 | # '$*' is a built-in macro that gets the basename of the current target | |
32 | # Remember that there must be a < tab > before the command line ('rule') | |
33 | # | |
34 | ||
35 | .java.class: | |
36 | $(JC) $(JFLAGS) $*.java | |
37 | ||
38 | ||
39 | # | |
40 | # CLASSES is a macro consisting of N words (one for each java source file) | |
41 | # When a single line is too long, use \<return> to split lines that then will be | |
42 | # considered as a single line. For example: | |
43 | # NAME = Camilo \ | |
44 | Juan | |
45 | # is understood as | |
46 | # NAME = Camilo Juan | |
47 | ||
48 | CLASSES = \ | |
78c725c5 | 49 | ClassPreamble.java \ |
97929775 | 50 | Compactable.java \ |
9cc8a5bc JB |
51 | Affichable.java \ |
52 | Structure.java \ | |
2a977a24 | 53 | Point.java \ |
bd443eec | 54 | Forme.java \ |
a988a46e | 55 | Image.java \ |
4871c009 JB |
56 | Segment.java \ |
57 | Cercle.java \ | |
2a977a24 | 58 | Entiers.java \ |
4d9f4a58 | 59 | Node.java \ |
2a977a24 | 60 | Liste.java \ |
14d4fd0d | 61 | Piletransformations.java \ |
4871c009 JB |
62 | Main.java |
63 | ||
64 | # | |
65 | # MAIN is a variable with the name of the file containing the main method | |
66 | # | |
67 | ||
68 | MAIN = Main | |
69 | ||
70 | # | |
71 | # the default make target entry | |
72 | # for this example it is the target classes | |
73 | ||
74 | default: classes | |
75 | ||
76 | ||
77 | # Next line is a target dependency line | |
78 | # This target entry uses Suffix Replacement within a macro: | |
79 | # $(macroname:string1=string2) | |
80 | # In the words in the macro named 'macroname' replace 'string1' with 'string2' | |
81 | # Below we are replacing the suffix .java of all words in the macro CLASSES | |
82 | # with the .class suffix | |
83 | # | |
84 | ||
85 | classes: $(CLASSES:.java=.class) | |
86 | ||
87 | ||
88 | # Next two lines contain a target for running the program | |
89 | # Remember the tab in the second line. | |
90 | # $(JMV) y $(MAIN) are replaced by their values | |
91 | ||
92 | run: $(MAIN).class | |
93 | $(JVM) $(MAIN) | |
94 | ||
95 | # this line is to remove all unneeded files from | |
96 | # the directory when we are finished executing(saves space) | |
97 | # and "cleans up" the directory of unneeded .class files | |
98 | # RM is a predefined macro in make (RM = rm -f) | |
99 | # | |
100 | ||
101 | clean: | |
102 | $(RM) *.class |