-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
60 lines (43 loc) · 2.52 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
# Copyright 2014 Abid Hasan Mujtaba
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Author: Abid H. Mujtaba
# Date: 2013-01-06
#
# This Makefile automates the building of the project using gradle. It also has functionality for sending the code to the EV3 and running it on it, using the Wifi connection (and SSH).
# This is the name of the Project as well as the main class (the class that contains the main() function where execution begins.
NAME=BumperCar
# We define the various files involved. We use $(NAME) wherever needed so that one need only change that one variable to change everything else.
SRC=$(wildcard src/*.java) $(wildcard src/*/*.java) # All the Java source files in the project specified using globbing patterns
JAR=build/libs/$(NAME).jar # .jar file generated by compiling the project
# Destination of compiled files on the EV3
DEST=/home/lejos/programs
# We define the PHONY Targets i.e. targets that do NOT correspond to actual files and so are run by being called explicitly along with make or as prerequisites for other targets.
.PHONY: default, build, run
# Since this is the first rule in the Makefile this will be run if one issues only "make" at the prompt.
default: build
# We define the output file .jar. "make" will study its timestamp to determine whether it needs to be recompiled.
build: $(JAR)
# We declare the prequisites of the .jar file. Any time the prerequisites are newer than the target the recipe is run.
$(JAR): $(SRC) build.gradle
# Straight-forward recipe for recompiling the source code to get the .jar file
gradle build
touch $(JAR)
# We touch the jar file because if the source code hasn't changed "gradle build" will NOT recreate the jar file
# EMPTY target for sending the .jar file to the EV3. This is the file that can be launched directly from the EV3.
sync: $(JAR)
scp $(JAR) ev3:$(DEST)
touch sync
# PHONY target to actually run the .jar file on the EV3 remotely. It will build and/or sync the .jar file to the EV3 before running if needed.
run: sync
ssh ev3 "cd $(DEST) && jrun -jar $(NAME).jar"