-
Notifications
You must be signed in to change notification settings - Fork 31
/
Makefile
139 lines (116 loc) · 4.49 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
include Makefile.config
include Makefile.options
### Building
.PHONY: default all doc
default all: build
.PHONY: build
build:
${MAKE} -C src
doc:
$(MAKE) -C doc
### Testing : local execution and toplevel ###
.PHONY: run.local run.opt.local top
run.local: build install.files
CAML_LD_LIBRARY_PATH=${BLD}/server:$(CAML_LD_LIBRARY_PATH) ${BLD}/ocsigenserver.bc -c local/etc/ocsigenserver.conf
run.opt.local: build install.files
CAML_LD_LIBRARY_PATH=${BLD}/server:$(CAML_LD_LIBRARY_PATH) ${BLD}/ocsigenserver.exe -c local/etc/ocsigenserver.conf
top:
cd src/server && ${MAKE} top
### Cleaning ###
clean: clean.local
${MAKE} -C src clean
clean.local:
-rm -f ocsigenserver-*.tar.gz
distclean: clean.local
${MAKE} -C src distclean
-make -C doc clean
-rm Makefile.config
-rm -f *~ \#* .\#*
### Installation ####
.PHONY: purge.files install.files
# BB If install is not run by root but OCSIGENUSER, OCSIGENGROUP is somebody
# BB different, make files universally accessible, we cannot chown.
INSTALL_CAN_PUT_PERMISSIONS=yes
INSTALL_USER_GROUP=-o $(OCSIGENUSER) -g "$(OCSIGENGROUP)"
INSTALL_MOD_660=660
INSTALL_MOD_644=644
INSTALL_MOD_755=755
INSTALL_MOD_770=770
INSTALL_MOD_750=750
USERNAME=$(shell whoami)
ifneq ($(shell id -u), 0)
ifneq ($(OCSIGENUSER), $(USERNAME))
INSTALL_CAN_PUT_PERMISSIONS=no
endif
ifneq ($(shell groups ${USERNAME}|grep -q ${OCSIGENGROUP}; echo $$?), 0)
INSTALL_CAN_PUT_PERMISSIONS=no
endif
endif
ifeq ($(INSTALL_CAN_PUT_PERMISSIONS), no)
INSTALL_USER_GROUP=
INSTALL_MOD_660=666
INSTALL_MOD_644=666
INSTALL_MOD_755=777
INSTALL_MOD_770=777
INSTALL_MOD_750=777
endif
install.files:
@echo
@echo "## Run \"make doc\" and \"make install.doc\" to build and install the ocamldoc."
@echo INSTALL_CAN_PUT_PERMISSIONS: ${INSTALL_CAN_PUT_PERMISSIONS}
## Configuration files
$(INSTALL) -m ${INSTALL_MOD_755} -d $(TEMPROOT)$(CONFIGDIR)/conf.d
${INSTALL} -m ${INSTALL_MOD_644} ocsigenserver.conf.sample $(TEMPROOT)$(CONFIGDIR)/
[ -f $(TEMPROOT)$(CONFIGDIR)/ocsigenserver.conf ] || \
{ $(INSTALL) -m ${INSTALL_MOD_644} ocsigenserver.conf.sample \
$(TEMPROOT)$(CONFIGDIR)/ocsigenserver.conf; }
-mv $(TEMPROOT)$(CONFIGDIR)/mime.types $(TEMPROOT)$(CONFIGDIR)/mime.types.old
## Log directory
$(INSTALL) -m ${INSTALL_MOD_644} src/files/mime.types $(TEMPROOT)$(CONFIGDIR)
$(INSTALL) -d -m ${INSTALL_MOD_755} ${INSTALL_USER_GROUP} $(TEMPROOT)$(LOGDIR)
## Static files
$(INSTALL) -d -m ${INSTALL_MOD_755} ${INSTALL_USER_GROUP} $(TEMPROOT)$(STATICPAGESDIR)
$(INSTALL) -d -m ${INSTALL_MOD_750} ${INSTALL_USER_GROUP} $(TEMPROOT)$(DATADIR)
$(INSTALL) -m ${INSTALL_MOD_644} ${INSTALL_USER_GROUP} \
local/var/www/*.html $(TEMPROOT)$(STATICPAGESDIR)
$(INSTALL) -d -m ${INSTALL_MOD_755} ${INSTALL_USER_GROUP} \
$(TEMPROOT)$(STATICPAGESDIR)/ocsigenstuff
$(INSTALL) -m ${INSTALL_MOD_644} ${INSTALL_USER_GROUP} \
local/var/www/ocsigenstuff/*.png local/var/www/ocsigenstuff/*.css \
$(TEMPROOT)$(STATICPAGESDIR)/ocsigenstuff
$(INSTALL) -d -m ${INSTALL_MOD_755} $(TEMPROOT)$(MANDIR)
$(INSTALL) -m ${INSTALL_MOD_644} src/files/ocsigenserver.1 $(TEMPROOT)$(MANDIR)
uninstall:
-make -C doc uninstall
-rm -f $(TEMPROOT)$(CONFIGDIR)/ocsigenserver.conf.sample
-rm -f $(TEMPROOT)$(MANDIR)/ocsigenserver.1
-rm -f $(TEMPROOT)$(COMMANDPIPE)
-rmdir --ignore-fail-on-non-empty $(TEMPROOT)$(CONFIGDIR)/conf.d
-rmdir --ignore-fail-on-non-empty $(TEMPROOT)$(CONFIGDIR)
-rmdir --ignore-fail-on-non-empty $(TEMPROOT)$(LOGDIR)
-rmdir --ignore-fail-on-non-empty $(TEMPROOT)$(DATADIR)
-rmdir --ignore-fail-on-non-empty $(TEMPROOT)$(MANDIR)
purge: purge.files
purge.files:
-rm -f $(TEMPROOT)$(CONFIGDIR)/mime.types $(TEMPROOT)$(CONFIGDIR)/mime.types.old
-rm -f $(TEMPROOT)$(CONFIGDIR)/ocsigenserver.conf
-rm -f $(patsubst local/var/www/ocsigenstuff/%, \
$(TEMPROOT)$(STATICPAGESDIR)/ocsigenstuff/%, \
$(wildcard local/var/www/ocsigenstuff/*))
-rmdir --ignore-fail-on-non-empty $(TEMPROOT)$(STATICPAGESDIR)/ocsigenstuff
-rm -f $(patsubst local/var/www/%, \
$(TEMPROOT)$(STATICPAGESDIR)/%, \
$(wildcard local/var/www/*.html))
-rmdir --ignore-fail-on-non-empty $(TEMPROOT)$(STATICPAGESDIR)
install.doc:
${MAKE} -C doc install
### Install logrotate configuration files ###
.PHONY: logrotate
logrotate:
$(INSTALL) -m 755 -d $(TEMPROOT)/etc/logrotate.d
cat src/files/logrotate.in \
| sed s%LOGDIR%$(LOGDIR)%g \
| sed s%USER%$(OCSIGENUSER)%g \
| sed s%GROUP%"$(OCSIGENGROUP)"%g \
| sed s%_COMMANDPIPE_%$(COMMANDPIPE)%g \
> $(TEMPROOT)/etc/logrotate.d/ocsigenserver