-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
33 lines (25 loc) · 980 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
#!/usr/bin/make -f
binaries = fortune-mod
fortune-mod = /usr/bin/strfile
file-exists = $(if $(wildcard $(firstword $($1))),,$(error Please install $1: aptitude install $1))
quotes-file = kahevato
all: prep clean fortune
prep: $(binaries)
$(binaries):
$(call file-exists,$@)
fortune:
while read line; do echo $$line >> kahevato; echo '%' >> $(quotes-file); done < $(quotes-file).txt
strfile $(quotes-file) $(quotes-file).dat
php: clean $(quotes-file)
echo '<?php' >> $(quotes-file).php
echo '$$kahevato = Array(' >> $(quotes-file).php
while read line; do echo '"'$$line'", ' >> $(quotes-file).php; done < $(quotes-file).txt
echo ');' >> $(quotes-file).php
json: clean
echo '[' >> temp.json
while read line; do echo '"'$$line'", ' >> temp.json; done < $(quotes-file).txt
sed '$$ s/,\s$$//' temp.json > $(quotes-file).json
echo ']' >> $(quotes-file).json
rm -rf temp.json
clean:
-rm -rf $(quotes-file).php $(quotes-file).json $(quotes-file).dat $(quotes-file)