-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathMakefile
74 lines (57 loc) · 1.92 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
VERSION=$(shell git describe --always --tags)
export VERSION
SRC_DIR=src/com/shmuelzon/HomeAssistantFloorPlan
SRCS=$(wildcard $(SRC_DIR)/*)
OBJS=$(subst src/,build/,$(SRCS:.java=.class))
SWEET_HOME_VERSION=7.5
SWEET_HOME_JAR=dl/SweetHome3D-$(SWEET_HOME_VERSION).jar
J3D_CORE_JAR=dl/j3dcore.jar
J3D_VECMATH_JAR=dl/vecmath.jar
JAVA_DEPENDENCIES=$(SWEET_HOME_JAR) $(J3D_CORE_JAR) $(J3D_VECMATH_JAR)
PLUGIN=HomeAssistantFloorPlanPlugin-$(VERSION).sh3p
DOCKER_CMD :=
ifeq ($(wildcard /.dockerenv),)
ifneq ($(shell which docker),)
DOCKER_CMD := docker run $(if $(TERM),-it )--rm --user $(shell id -u):$(shell id -g) --volume $(PWD):$(PWD) --workdir $(PWD) eclipse-temurin:8-noble
endif
endif
ifneq ($(V),)
Q :=
define exec
$3
endef
else
Q := @
define exec
@echo "$1\\t$2"
@output=`$3 2>&1` || (echo "$$output"; false)
endef
endif
define download
$(Q)mkdir -p dl/
$(call exec,DL,$2,wget -4 --quiet --show-progress -O $1 $2)
endef
$(SWEET_HOME_JAR):
$(call download,$@,https://sourceforge.net/projects/sweethome3d/files/SweetHome3D/SweetHome3D-$(SWEET_HOME_VERSION)/SweetHome3D-$(SWEET_HOME_VERSION).jar)
$(J3D_CORE_JAR):
$(call download,$@,https://jogamp.org/deployment/java3d/1.6.0-final/j3dcore.jar)
$(J3D_VECMATH_JAR):
$(call download,$@,https://jogamp.org/deployment/java3d/1.6.0-final/vecmath.jar)
build/%.class: src/%.java $(JAVA_DEPENDENCIES)
$(call exec,JAVA,$@,$(DOCKER_CMD) javac -classpath "dl/*:src" -target 1.8 -source 1.8 -Xlint:-options -d build $<)
build/%.properties: src/%.properties
$(Q)mkdir -p $(dir $@)
$(call exec,GEN,$@,envsubst < $< > $@)
$(PLUGIN): $(OBJS)
$(call exec,JAR,$@,$(DOCKER_CMD) jar -cf $@ -C build .)
build: $(PLUGIN)
clean:
$(Q)rm -rf build *.sh3p
distclean: clean
$(Q)rm -rf dl
install: $(PLUGIN)
$(call exec,INSTALL,$(PLUGIN),install -D $(PLUGIN) -t ~/.eteks/sweethome3d/plugins/)
test: install
$(Q)java -jar $(SWEET_HOME_JAR)
.DEFAULT_GOAL:=build
.PHONY:=build clean distclean install test