-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
95 lines (78 loc) · 2.43 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
VIEWS = \
layout/default \
admin/assign_edit \
admin/assign_main \
admin/assignment_edit \
admin/assignment_list \
admin/course_edit \
admin/course_list \
admin/download_main \
admin/download_whole_course \
admin/enroll_edit \
admin/enroll_main \
admin/grade_assignment \
admin/grade_course_main \
admin/grade_main \
admin/grade_whole_course \
admin/grade_whole_course_print \
admin/main \
admin/user_edit \
admin/user_list \
admin/user_reset_password \
assignment/index \
course/index \
login \
main \
password \
sitedown
LANGAUGES = \
cs_CZ
INSTALL_DIR = install_dir
PHP_CLI = php
SQLITE = sqlite3
VIEWS_OUT_FILES = $(addprefix views/, $(addsuffix .html.php,$(VIEWS)))
PO_FILES = $(addprefix locale/,$(addsuffix /LC_MESSAGES/nevilis.po,$(LANGAUGES)))
MO_FILES = $(addprefix locale/,$(addsuffix /LC_MESSAGES/nevilis.mo,$(LANGAUGES)))
all: $(VIEWS_OUT_FILES) $(MO_FILES)
%.html.php: %.tpl.html.php
$(PHP_CLI) ./tools/make_views.php <$< >$@
nevilis.pot: | $(VIEWS_OUT_FILES)
find -name '*.php' -and -not -name '*.tpl.*' \
| xargs xgettext \
-dnevilis \
--package-name="Nevilis PHP" \
--package-version=0.1 \
--sort-output \
-o - \
| sed 's@\(Content-Type:.*charset=\)CHARSET\(.*\)@\1UTF-8\2@' \
> $@
update-po-files: $(PO_FILES)
%.mo: %.po
msgfmt $< -o $@
locale/%/LC_MESSAGES/nevilis.po: nevilis.pot
msgmerge $@ nevilis.pot --sort-output --output-file=$*.new.po
if [ -z "`diff -ud $@ $*.new.po | tail -n +3 | grep '^[-+]' | grep -v 'POT-Creation-Date'`" ]; then \
rm $*.new.po; \
else \
mv $*.new.po $@; \
fi
prep-install:
! [ -d "$(INSTALL_DIR)" ]
mkdir -p $(INSTALL_DIR)
cp index.php $(INSTALL_DIR)/index.php
for i in $(MO_FILES); do install -D $$i $(INSTALL_DIR)/$$i; done
cp -R css lib controllers $(INSTALL_DIR)/
find views/ -name '*.html.php' -not -name '*.tpl.html.php' \
-exec install -D {} $(INSTALL_DIR)/{} \;
install -d $(INSTALL_DIR)/db
$(SQLITE) $(INSTALL_DIR)/db/main.db <db/schema.sql
echo "<?php printf(\"INSERT INTO user VALUES('admin','%s','Super User','admin');\\n\", password_hash('nevilis1234', PASSWORD_DEFAULT));" \
| $(PHP_CLI) | $(SQLITE) $(INSTALL_DIR)/db/main.db
chmod a+w $(INSTALL_DIR)/db/main.db
install -d -m 0777 $(INSTALL_DIR)/userfiles
sed \
-e "s@\(option('file_dir',\).*@\1 'userfiles/');@" \
-e "s@\(option('database',\).*@\1 'sqlite:db/main.db');@" \
config.php.dist > $(INSTALL_DIR)/config.php
clean:
rm -f $(VIEWS_OUT_FILES) $(MO_FILES) nevilis.pot