-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
164 lines (125 loc) · 3.54 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
PREFIX ?= /usr/local
bindir = $(PREFIX)/bin
docdir = $(PREFIX)/share/doc/oschema
XSDDIR = $(bindir)/oschema_xsd
SRC = src
DOC = doc
DIST = dist
LIB = lib
STYLE = css
TEST = test_data
OSCHEMA_VERSION ?= 1.3.1
#needs tool check
#http://stackoverflow.com/questions/5618615/check-if-a-program-exists-from-a-makefile
default: doc
all: doc
doc: $(SRC)/oschema.xsd
@echo ""
@echo "creating schmea documentation for oschema.xsd"
@echo "---------------------------------------------"
@echo ""
@echo "tools needed: java, xmlstarlet"
@echo ""
@echo "the github repository contains a generated"
@echo "documentaion that corresponds the the oschema.xsd file."
@echo ""
@echo "this step is not necessary to use the install target."
@echo ""
java -version
cd $(DOC) \
&& echo ""; echo "creating svg..." \
&& java -jar ../$(LIB)/xsdvi.jar ../$(SRC)/oschema.xsd >/dev/null 2>&1 \
&& echo "creating html..." \
&& xmlstarlet tr ../$(LIB)/xs3p.xsl ../$(SRC)/oschema.xsd > oschema.html \
&& rm xsdvi.log \
&& cd ..
@echo ""
@echo "output: $(DOC)/oschema.svg"
@echo "output: $(DOC)/oschema.html"
@echo ""
@echo "done."
@echo ""
dist:
@echo ""
@echo "creating tarball for distribution"
@echo "---------------------------------"
@echo ""
mkdir -p $(DIST)/oschema-$(OSCHEMA_VERSION)
cp $(SRC)/oschema.xsd $(DIST)/oschema-$(OSCHEMA_VERSION)
cp $(SRC)/oschema_validate.sh $(DIST)/oschema-$(OSCHEMA_VERSION)
cp $(DOC)/oschema.svg $(DIST)/oschema-$(OSCHEMA_VERSION)
cp $(DOC)/oschema.html $(DIST)/oschema-$(OSCHEMA_VERSION)
cp $(TEST)/minimal.xml $(DIST)/oschema-$(OSCHEMA_VERSION)
cd $(DIST) && \
tar cfvz oschema-$(OSCHEMA_VERSION).tgz oschema-$(OSCHEMA_VERSION) && \
cd ..
@echo ""
@echo "output: $(DIST)/oschema-$(OSCHEMA_VERSION).tgz"
@echo ""
@echo "done."
test:
@echo ""
@echo "testing several invalid and valid instances against scheama"
@echo "-----------------------------------------------------------"
@echo ""
$(TEST)/run_test.sh $(SRC)/oschema.xsd $(SRC)/oschema_validate.sh $(TEST)
@echo ""
@echo "done."
@echo ""
install:
@echo ""
@echo "installing oschema_validate"
@echo "---------------------------"
@echo ""
@echo "DESTDIR: $(DESTDIR)"
@echo "bindir: $(bindir)"
@echo ""
@echo "docdir: $(docdir)"
@echo "'make install' probably needs to be run with root privileges, i.e."
@echo ""
@echo "sudo make install"
@echo ""
install -d $(DESTDIR)$(bindir)
install -m755 $(SRC)/oschema_validate.sh $(DESTDIR)$(bindir)/oschema_validate
install -d $(DESTDIR)$(XSDDIR)
install -m644 $(SRC)/oschema.xsd $(DESTDIR)$(XSDDIR)/
install -d $(DESTDIR)$(docdir)
install -m644 $(DOC)/oschema.svg $(DESTDIR)$(docdir)
install -m644 $(DOC)/oschema.html $(DESTDIR)$(docdir)
@echo ""
@echo "use: oschema_validate my_oschema_instance.xml"
@echo ""
@echo "done."
@echo ""
uninstall:
@echo ""
@echo "uninstalling oschema_validate"
@echo "-----------------------------"
@echo ""
@echo "DESTDIR: $(DESTDIR)"
@echo "bindir: $(bindir)"
@echo ""
@echo "'make uninstall' needs to be run with root privileges, i.e."
@echo ""
@echo "sudo make uninstall"
@echo ""
rm -f $(DESTDIR)$(bindir)/oschema_validate
rm -f $(DESTDIR)$(XSDDIR)/oschema.xsd
-rmdir $(DESTDIR)$(XSDDIR)
-rmdir $(DESTDIR)$(bindir)
rm -f $(DESTDIR)$(docdir)/oschema.svg
rm -f $(DESTDIR)$(docdir)/oschema.html
-rmdir $(DESTDIR)$(docdir)
@echo ""
@echo "done."
@echo ""
clean:
@echo ""
@echo "cleaning up $(DIST) directory"
@echo "-----------------------------"
@echo ""
rm -rf $(DIST)
@echo ""
@echo "done."
@echo ""
.PHONY: all doc clean install uninstall dist test