|
| 1 | +################################################################################ |
| 2 | +# |
| 3 | +# Makefile for the basic Computer Graphics source code |
| 4 | +# |
| 5 | +# The following lines are the only files that you as a student should edit. |
| 6 | +# |
| 7 | +################################################################################ |
| 8 | + |
| 9 | +# specify the directory where the source code can be found. |
| 10 | +SOURCEDIR = src |
| 11 | + |
| 12 | +# specify the name of the executable jar file. |
| 13 | +EXECUTABLENAME = cgproject.jar |
| 14 | + |
| 15 | +# specify the name of the class containing main method. |
| 16 | +ENTRYPOINT = main.Renderer |
| 17 | + |
| 18 | +# specify the packages where the code can be found |
| 19 | +PACKAGES = camera gui main math sampling shape |
| 20 | + |
| 21 | +################################################################################ |
| 22 | +# Only the code above this line has to be edited if more classes are added # |
| 23 | +################################################################################ |
| 24 | + |
| 25 | +JAVAC = javac |
| 26 | +JFLAGS = -g -d $(SOURCEDIR) -classpath $(SOURCEDIR) |
| 27 | +JAR = jar |
| 28 | + |
| 29 | +######################## |
| 30 | +# default build target # |
| 31 | +######################## |
| 32 | + |
| 33 | +default: all |
| 34 | + |
| 35 | +###################### |
| 36 | +# target to make all # |
| 37 | +###################### |
| 38 | + |
| 39 | +all: clean classes jar |
| 40 | + |
| 41 | +########################################################################### |
| 42 | +# target which compiles all the .java files specified in the SOURCES list # |
| 43 | +########################################################################### |
| 44 | + |
| 45 | +classes: SOURCES := $(foreach dir,$(PACKAGES),$(wildcard $(SOURCEDIR)/$(dir)/*.java)) |
| 46 | +classes: |
| 47 | + @echo -e "\nsearching .java files from the following packages:" |
| 48 | + @echo -e "$(foreach package,$(PACKAGES),\n\t$(package))" |
| 49 | + @echo -e "\ncompiling the following .java classes:" |
| 50 | + @echo -e "$(foreach java,$(SOURCES),\n\t$(java))" |
| 51 | + @$(JAVAC) $(JFLAGS) $(SOURCES) |
| 52 | + @echo -e "\nfinished compilation" |
| 53 | + |
| 54 | +############################################################################# |
| 55 | +# Creates an executable JAR file from the classes in the SOURCEDIR with the # |
| 56 | +# ENTRYPOINT class as the class containing the main method # |
| 57 | +############################################################################# |
| 58 | + |
| 59 | +jar: |
| 60 | + @echo -e "\nbuilding $(EXECUTABLENAME)" |
| 61 | + @$(JAR) -cfe $(EXECUTABLENAME) $(ENTRYPOINT) -C $(SOURCEDIR)/ . |
| 62 | + @echo -e "finished building $(EXECUTABLENAME)" |
| 63 | + |
| 64 | +########################################## |
| 65 | +# removes all the generated .class files # |
| 66 | +########################################## |
| 67 | + |
| 68 | +cleanclasses: CLASSFILES := $(foreach filename,$(foreach dir,$(PACKAGES),$(wildcard $(SOURCEDIR)/$(dir)/*.class)),$(filename)) |
| 69 | +cleanclasses: |
| 70 | + @echo -e "\nremoving the following .class files:" |
| 71 | + @echo -e $(foreach filename,${CLASSFILES},'\n\t$(filename)') |
| 72 | + @$(foreach filename,${CLASSFILES},rm -f '$(filename)') |
| 73 | + |
| 74 | +################################################ |
| 75 | +# Removes the BINARYDIR and the executable JAR # |
| 76 | +################################################ |
| 77 | +clean: cleanclasses |
| 78 | + @rm -f $(EXECUTABLENAME) |
| 79 | + |
0 commit comments