-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
39 lines (28 loc) · 978 Bytes
/
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
# Makefile for compiling and running the Java program 'rpal20'
# Define the Java compiler and flags
JAVAC = javac
JFLAGS = -d .
# Define the source directory
SRCDIR = src
# Define the classpath
CLASSPATH = -cp .
# Define the main class
MAIN_CLASS = rpal20
# Define the default target (what will be built when you run 'make' without any arguments)
all: build
# Target for compiling Java source files
build: $(SOURCES)
$(JAVAC) $(JFLAGS) $(SOURCES)
# Target for moving class files to the root directory
move: build
@find . -name "*.class" -print0 | xargs -0 mv -t .
# Target for running the Java program
run:
java $(CLASSPATH) $(MAIN_CLASS)
# Target for cleaning (removing generated class files)
clean:
rm -f *.class
# Phony targets to avoid conflicts with files/folders named "clean", "run", and "move"
.PHONY: all build run clean move
# Collect all Java source files recursively using wildcard function
SOURCES := $(wildcard $(SRCDIR)/**/*.java $(SRCDIR)/*.java)