blob: db10a58bc19b7bb9789f7e85a1d4f1fe2ecabbd2 (
plain)
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
75
76
|
## Parameters ##################################################################
SRC_DIR ?= ${CURDIR}/src/
BIN_DIR ?= ${CURDIR}/bin/
LIB_DIR ?= ${CURDIR}/lib/
TARGET ?= ghdl2hastabel.jar
RUN_SCRIPT ?= ghdl2hastabel.sh
INSTALL_DIR ?= $(LIB_DIR)
#### Where to get the missing Jar files.
JAR_SOURCE ?= "https://noot-noot.org/tabellion/jar/"
#### Binaries
###### JAR binary
JAR ?= jar
###### JRE binary
JAVA ?= java
###### JDK binary
JAVAC ?= javac
##### Downloader
DOWNLOADER ?= wget
## Parameters Sanity Check #####################################################
ifeq ($(strip $(JAVA)),)
$(error No Java executable defined as parameter.)
endif
ifeq ($(strip $(JAVAC)),)
$(error No Java compiler defined as parameter.)
endif
## Java Config #################################################################
CLASSPATH = "$(SRC_DIR):$(BIN_DIR)"
## Makefile Magic ##############################################################
JAVA_SOURCES = \
$(wildcard $(SRC_DIR)/ghdl2hastabel/*.java) \
$(wildcard $(SRC_DIR)/ghdl2hastabel/*/*.java)
CLASSES = $(patsubst $(SRC_DIR)/%,$(BIN_DIR)/%, $(JAVA_SOURCES:.java=.class))
## Makefile Rules ##############################################################
$(TARGET): $(RUN_SCRIPT) $(JAVA_SOURCES) $(CLASSES)
$(MAKE) $(LIB_DIR)
rm -f $(TARGET) $(INSTALL_DIR)/$@
$(JAR) cf $@ -C $(BIN_DIR) .
cp $@ $(INSTALL_DIR)/$@
clean:
rm -rf $(BIN_DIR)/*
rm -f $(TARGET)
$(CLASSES): $(BIN_DIR)/%.class: $(SRC_DIR)/%.java $(BIN_DIR)
$(JAVAC) -cp $(CLASSPATH) -d $(BIN_DIR) $<
%.jar:
$(MAKE) $(LIB_DIR)
echo "Attempting to download missing jar '$@'..."
cd $(LIB_DIR); $(DOWNLOADER) "$(JAR_SOURCE)/$(notdir $@)"
$(RUN_SCRIPT): Makefile
echo "#!/bin/sh" > $@
echo "$(JAVA) -cp \"$(CLASSPATH)\" ghdl2hastabel.Main \$$*" >> $@
chmod +x $@
$(LIB_DIR):
mkdir -p $@
$(BIN_DIR):
mkdir -p $@
##### For my private use...
publish: $(TARGET)
scp $< dreamhost:~/noot-noot/tabellion/jar/
|