merged .hgtags, Makefile: 'fakeroot id -u' is 0, better using $USER env variable
[iserv-mod-room-reservation.git] / Makefile
old mode 100755 (executable)
new mode 100644 (file)
index 2a4fc00..9440ef6
--- a/Makefile
+++ b/Makefile
@@ -24,6 +24,7 @@
 # THE SOFTWARE.\r
 #\r
 \r
+DESTDIR?=\r
 SOURCEFILES=src/*.php includes/*.inc\r
 MODULE_DOC_FILES=doc/source/html/* doc/source/latex/*\r
 LN=ln -f\r
@@ -33,35 +34,55 @@ MKDIR=mkdir -p
 # hardlink the files to their destinations\r
 # TODO move documentation where Jörg wants it ;)\r
 links:\r
-       $(MKDIR) /usr/share/doc/iserv/mod/room-reservation/source/\r
-       $(LN) doc/{LICENSE*,TODO,changelog*} /usr/share/doc/iserv/mod/room-reservation/\r
-       $(LN) doc/source/html/* /usr/share/doc/iserv/mod/room-reservation/source/\r
+       # documentation\r
+       $(MKDIR) $(DESTDIR)/usr/share/doc/iserv/mod/room-reservation/source/\r
+       $(LN) doc/{TODO,changelog.html} $(DESTDIR)/usr/share/doc/iserv/mod/room-reservation/\r
+       $(LN) doc/source/html/* $(DESTDIR)/usr/share/doc/iserv/mod/room-reservation/source/\r
        \r
-       $(LN) img/16/*.png /usr/share/iserv/www/img/default/16/\r
-       $(LN) img/24/*.png /usr/share/iserv/www/img/default/24/\r
-       $(LN) img/32/*.png /usr/share/iserv/www/img/default/32/\r
+       # images\r
+       if [ ! -d $(DESTDIR)/usr/share/iserv/www/img/default/16/ ]; then $(MKDIR) $(DESTDIR)/usr/share/iserv/www/img/default/16/; fi\r
+       $(LN) img/16/*.png $(DESTDIR)/usr/share/iserv/www/img/default/16/\r
+       if [ ! -d $(DESTDIR)/usr/share/iserv/www/img/default/24/ ]; then $(MKDIR) $(DESTDIR)/usr/share/iserv/www/img/default/24/; fi\r
+       $(LN) img/24/*.png $(DESTDIR)/usr/share/iserv/www/img/default/24/\r
+       if [ ! -d $(DESTDIR)/usr/share/iserv/www/img/default/32/ ]; then $(MKDIR) $(DESTDIR)/usr/share/iserv/www/img/default/32/; fi\r
+       $(LN) img/32/*.png $(DESTDIR)/usr/share/iserv/www/img/default/32/\r
        \r
-       $(MKDIR) /usr/share/iserv/www/inc/mod_room-reservation\r
-       $(LN) includes/*.inc /usr/share/iserv/www/inc/mod_room-reservation/\r
-       chmod 664 /usr/share/iserv/www/inc/mod_room-reservation/config.inc\r
-       chown www-data /usr/share/iserv/www/inc/mod_room-reservation/config.inc\r
+       # includes\r
+       $(MKDIR) $(DESTDIR)/usr/share/iserv/www/inc/mod_room-reservation\r
+       $(LN) includes/*.inc $(DESTDIR)/usr/share/iserv/www/inc/mod_room-reservation/\r
+       if [ ! -e $(DESTDIR)/usr/share/iserv/www/inc/mod_room-reservation/config.inc ] ; then touch $(DESTDIR)/usr/share/iserv/www/inc/mod_room-reservation/config.inc; fi\r
+ifeq ($(shell id -u),0)\r
+       chmod g+w $(DESTDIR)/usr/share/iserv/www/inc/mod_room-reservation/config.inc\r
+       chown www-data $(DESTDIR)/usr/share/iserv/www/inc/mod_room-reservation/config.inc\r
+endif\r
        \r
-       $(LN) lang/*.po /usr/share/iserv/locale/de/\r
+       # i18n\r
+       if [ ! -d $(DESTDIR)/usr/share/iserv/locale/de/ ]; then $(MKDIR) $(DESTDIR)/usr/share/iserv/locale/de/; fi\r
+       $(LN) lang/*.po $(DESTDIR)/usr/share/iserv/locale/de/\r
        \r
-       $(LN) nav/*.mod /usr/share/iserv/www/nav/\r
-       $(LN) nav/admin/*.mod /usr/share/iserv/www/nav/admin\r
-\r
-       $(LN) priv/* /usr/share/iserv/priv/\r
+       # navigation\r
+       if [ ! -d $(DESTDIR)/usr/share/iserv/www/nav/admin ]; then $(MKDIR) $(DESTDIR)/usr/share/iserv/www/nav/admin; fi\r
+       $(LN) nav/*.mod $(DESTDIR)/usr/share/iserv/www/nav/\r
+       $(LN) nav/admin/*.mod $(DESTDIR)/usr/share/iserv/www/nav/admin/\r
        \r
-       $(LN) sql/*.sql /usr/share/iserv/db/\r
+       # privileges\r
+       if [ ! -d $(DESTDIR)/usr/share/iserv/priv/ ]; then $(MKDIR) $(DESTDIR)/usr/share/iserv/priv/; fi\r
+       $(LN) priv/* $(DESTDIR)/usr/share/iserv/priv/\r
        \r
-       $(MKDIR) /usr/share/iserv/www/mod_room-reservation/admin\r
-       $(LN) src/index.php /usr/share/iserv/www/mod_room-reservation/\r
-       $(LN) src/admin/config.php /usr/share/iserv/www/mod_room-reservation/admin/\r
-\r
-       $(MKDIR) /usr/share/iserv/modules/room-reservation\r
-       $(LN) update-iserv1-iserv2.pl /usr/share/iserv/modules/room-reservation\r
-       chmod 755 /usr/share/iserv/modules/room-reservation/update-iserv1-iserv2.pl\r
+       # SQL tables\r
+       if [ ! -d $(DESTDIR)/usr/share/iserv/db/log_module ]; then $(MKDIR) $(DESTDIR)/usr/share/iserv/db/log_module; fi\r
+       $(LN) sql/*.sql $(DESTDIR)/usr/share/iserv/db/\r
+       $(LN) sql/log_module/* $(DESTDIR)/usr/share/iserv/db/log_module\r
+       \r
+       # web pages\r
+       $(MKDIR) $(DESTDIR)/usr/share/iserv/www/mod_room-reservation/admin\r
+       $(LN) src/index.php $(DESTDIR)/usr/share/iserv/www/mod_room-reservation/\r
+       $(LN) src/admin/config.php $(DESTDIR)/usr/share/iserv/www/mod_room-reservation/admin/\r
+       \r
+       # additional files\r
+       $(MKDIR) $(DESTDIR)/usr/share/iserv/modules/room-reservation\r
+       $(LN) maint/update-iserv1-iserv2.pl $(DESTDIR)/usr/share/iserv/modules/room-reservation\r
+       chmod +x $(DESTDIR)/usr/share/iserv/modules/room-reservation/update-iserv1-iserv2.pl\r
 \r
 # build doxygen documentation from source\r
 sourcedoc:\r
@@ -69,27 +90,39 @@ sourcedoc:
 \r
 # install everything\r
 install: sourcedoc links\r
+ifeq ($(shell echo $USER),root)\r
        chkdb -r\r
        chkpriv\r
        chklocale\r
+endif\r
 \r
 # uninstalling\r
 uninstall:\r
-       $(RM) /usr/share/doc/iserv/mod/mod_room-reservation\r
-       $(RM) /usr/share/iserv/locale/de/mod_room-reservation.po\r
-       $(RM) /usr/share/iserv/db/mod_room-reservation.sql\r
-       $(RM) /usr/share/iserv/www/nav/79mod_room-reservation.mod\r
-       $(RM) /usr/share/iserv/priv/mod_room-reservation\r
-       $(RM) /usr/share/iserv/www/nav/admin/99mod_room-reservation.mod\r
-       $(RM) /usr/share/iserv/www/img/default/{16,24,32}/mod_room-reservation_{timeslice,index,config}.png\r
-       $(RM) /usr/share/iserv/www/inc/mod_room-reservation\r
-       $(RM) /usr/share/iserv/www/mod_room-reservation\r
-       $(RM) /usr/share/iserv/modules/room-reservation\r
+       $(RM) $(DESTDIR)/usr/share/doc/iserv/mod/mod_room-reservation\r
+       $(RM) $(DESTDIR)/usr/share/iserv/locale/de/mod_room-reservation.po\r
+       $(RM) $(DESTDIR)/usr/share/iserv/db/mod_room-reservation.sql\r
+       $(RM) $(DESTDIR)/usr/share/iserv/db/log_module/mod_room-reservation\r
+       $(RM) $(DESTDIR)/usr/share/iserv/www/nav/79mod_room-reservation.mod\r
+       $(RM) $(DESTDIR)/usr/share/iserv/priv/mod_room-reservation\r
+       $(RM) $(DESTDIR)/usr/share/iserv/www/nav/admin/99mod_room-reservation.mod\r
+       $(RM) $(DESTDIR)/usr/share/iserv/www/img/default/{16,24,32}/mod_room-reservation_{timeslice,index,config}.png\r
+       $(RM) $(DESTDIR)/usr/share/iserv/www/inc/mod_room-reservation\r
+       $(RM) $(DESTDIR)/usr/share/iserv/www/mod_room-reservation\r
+       $(RM) $(DESTDIR)/usr/share/iserv/modules/room-reservation\r
        \r
+       psql -c "DELETE FROM log_module WHERE module='Room Reservation Schedule';"\r
        chklocale\r
        \r
-       @echo ----------------------------------------------------------------------\r
+       @echo\r
        @echo If you do not need the SQL tables anymore, remove them by running\r
        @echo '  psql -c "DROP TABLE mod_roomreservation_bookings;"'\r
        @echo After that, all bookings are unrecoverably deleted!\r
-       @echo ----------------------------------------------------------------------\r
+       @echo\r
+\r
+# clean up\r
+clean: distclean\r
+\r
+distclean:\r
+       $(RM) doc/source\r
+\r
+.PHONY: clean\r
This page took 0.021266 seconds and 4 git commands to generate.