This repository has been archived by the owner on Nov 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
74 lines (57 loc) · 2.61 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
################################################################################
# Makefile
################################################################################
# The directory where the source code can be found.
SOURCEDIR = src
# The name of the executable jar file.
EXECUTABLENAME = java-smallpt.jar
# The name of the class containing the main method.
ENTRYPOINT = core.SmallPT
# The packages where the code can be found.
PACKAGES = core
################################################################################
# Only the code above this line has to be edited if more classes are added #
################################################################################
JAVAC = javac
JFLAGS = -g -d $(SOURCEDIR) -classpath $(SOURCEDIR)
JAR = jar
########################
# default build target #
########################
default: all
######################
# target to make all #
######################
all: clean classes jar
###########################################################################
# target which compiles all the .java files specified in the SOURCES list #
###########################################################################
classes: SOURCES := $(foreach dir,$(PACKAGES),$(wildcard $(SOURCEDIR)/$(dir)/*.java))
classes:
$(info searching .java files from the following packages:)
$(foreach package,$(PACKAGES),$(info $ $ - $(package)))
$(info compiling the following .java classes:)
$(foreach java,$(SOURCES),$(info $ $ - $(java)))
@$(JAVAC) $(JFLAGS) $(SOURCES)
$(info finished compilation)
#############################################################################
# Creates an executable JAR file from the classes in the SOURCEDIR with the #
# ENTRYPOINT class as the class containing the main method #
#############################################################################
jar:
$(info building $(EXECUTABLENAME))
@$(JAR) -cfe $(EXECUTABLENAME) $(ENTRYPOINT) -C $(SOURCEDIR)/ .
$(info finished building $(EXECUTABLENAME))
##########################################
# removes all the generated .class files #
##########################################
cleanclasses: CLASSFILES := $(foreach filename,$(foreach dir,$(PACKAGES),$(wildcard $(SOURCEDIR)/$(dir)/*.class)),$(filename))
cleanclasses:
$(info removing the following .class files:)
$(foreach filename, ${CLASSFILES}, $(info $ $ - $(filename)))
@$(foreach filename,${CLASSFILES},rm -f '$(filename)')
################################################
# Removes the BINARYDIR and the executable JAR #
################################################
clean: cleanclasses
@rm -f $(EXECUTABLENAME)