Makefile 25.4 KB
Newer Older
1 2
#!/usr/bin/make

3 4 5
# Prefix for packaging
DESTDIR=

6
PERL=$$(which perl)
7
PERLVERSION=`perl -e '$$version = $$^V; $$version =~ s/v//; print $$version'`
Xavier Guimard's avatar
Xavier Guimard committed
8 9 10
SU=su -c
COMPRESS=tar czf
UNCOMPRESS=tar xzf
Clément OUDOT's avatar
Clément OUDOT committed
11
LISTCOMPRESSED=tar tzf
Xavier Guimard's avatar
Xavier Guimard committed
12
COMPRESSSUFFIX=tar.gz
13 14 15 16 17
# Perl options
#PERLOPTIONS="INSTALLDIRS=vendor"
PERLOPTIONS=

# Default directories install
18 19 20
PREFIX=/usr/local
LMPREFIX=$(PREFIX)/lemonldap-ng
RLMPREFIX=$(DESTDIR)/$(LMPREFIX)
21
# BIN dirs
22 23 24 25
BINDIR=$(LMPREFIX)/bin
RBINDIR=$(DESTDIR)/$(BINDIR)
DATADIR=$(LMPREFIX)/data
RDATADIR=$(DESTDIR)/$(DATADIR)
26

27
EXAMPLEROOT=`pwd`/example
28 29

# Document roots for Apache VirtualHosts
30 31 32 33 34 35 36
DOCUMENTROOT=$(LMPREFIX)/htdocs
PORTALDIR=$(DOCUMENTROOT)/portal
RPORTALDIR=$(DESTDIR)/$(PORTALDIR)
PORTALSKINSDIR=$(PORTALDIR)/skins
RPORTALSKINSDIR=$(DESTDIR)/$(PORTALSKINSDIR)
MANAGERDIR=$(DOCUMENTROOT)/manager
RMANAGERDIR=$(DESTDIR)/$(MANAGERDIR)
Xavier Guimard's avatar
Xavier Guimard committed
37 38
MANAGERSKINSDIR=$(MANAGERDIR)/skins
RMANAGERSKINSDIR=$(DESTDIR)/$(MANAGERSKINSDIR)
39
SESSIONSEXPLORERDIR=$(MANAGERDIR)
40 41 42 43 44 45 46 47 48
RSESSIONSEXPLORERDIR=$(DESTDIR)/$(SESSIONSEXPLORERDIR)
DOCDIR=$(DOCUMENTROOT)/doc
RDOCDIR=$(DESTDIR)/$(DOCDIR)
TESTDIR=$(DOCUMENTROOT)/test
RTESTDIR=$(DESTDIR)/$(TESTDIR)
EXAMPLESDIR=$(LMPREFIX)/examples
REXAMPLESDIR=$(DESTDIR)/$(EXAMPLESDIR)
TOOLSDIR=$(LMPREFIX)/tools
RTOOLSDIR=$(DESTDIR)/$(TOOLSDIR)
49 50

# Handler dir
51 52
HANDLERDIR=$(LMPREFIX)/handler
RHANDLERDIR=$(DESTDIR)/$(HANDLERDIR)
53 54

# Configuration dir
55 56 57 58
CONFDIR=$(LMPREFIX)/etc
RCONFDIR=$(DESTDIR)/$(CONFDIR)
CRONDIR=$(LMPREFIX)/etc/cron.d
RCRONDIR=$(DESTDIR)/$(CRONDIR)
59 60
CONFFILENAME=lemonldap-ng.ini
STORAGECONFFILE=$(CONFDIR)/$(CONFFILENAME)
61 62

# Lemonldap-ng configuration storage dir
63 64
FILECONFIGDIR=$(DATADIR)/conf
RFILECONFIGDIR=$(DESTDIR)/$(FILECONFIGDIR)
65 66

# Apache::Session::File storage dir
67 68 69 70
APACHESESSIONFILEDIR=$(DATADIR)/sessions
RAPACHESESSIONFILEDIR=$(DESTDIR)/$(APACHESESSIONFILEDIR)
APACHESESSIONFILELOCKDIR=$(APACHESESSIONFILEDIR)/lock
RAPACHESESSIONFILELOCKDIR=$(DESTDIR)/$(APACHESESSIONFILELOCKDIR)
71

72 73 74
# Lemonldap-ng notifications storage dir
RFILENOTIFDIR=$(DESTDIR)/$(DATADIR)/notifications

75
# Apache user/group
76 77 78
APACHEUSER=
APACHEGROUP=

79 80 81
# Apache version
APACHEVERSION=2

82
# DNS Domain for cookie and virtual hosts
83 84
DNSDOMAIN=example.com

85 86 87
# Virtual Host Listen IP and Port (*, *:80, ...)
VHOSTLISTEN=*:80

88
# Other
89
VERSION=`head -n1 changelog |sed -e 's/lemonldap-ng (//' -e 's/).*$$//'`
Xavier Guimard's avatar
Xavier Guimard committed
90 91
PORTALSKINS=`ls lemonldap-ng-portal/example/skins/`
MANAGERSKINS=`ls lemonldap-ng-manager/example/skins/`
92
DIFF=diff -aurN -x '*.bak' -x .svn -x '*.swp' --ignore-matching-lines='.*jquery.*' --ignore-matching-lines='.*lemonldap-ng\.ini.*'
93

94 95 96 97
SRCCOMMONDIR=lemonldap-ng-common
SRCHANDLERDIR=lemonldap-ng-handler
SRCPORTALDIR=lemonldap-ng-portal
SRCMANAGERDIR=lemonldap-ng-manager
98
EXAMPLELANG=en # For static Manager example only
Clément OUDOT's avatar
Clément OUDOT committed
99
ERASECONFIG=1 # Set to 0 if you do not want to replace your configuration
100

Xavier Guimard's avatar
Xavier Guimard committed
101 102
DIFFPREFIX=

103
all:	configure common handler manager portal
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
	@echo
	@echo "Building succeed. Now run :"
	@echo " - make test to verify your installation"
	@echo " - make install to install all"
	@echo
	@echo 'Other targets :'
	@echo " * Partial build :"
	@echo "   - portal, manager, handler"
	@echo " * Doxygen documentation"
	@echo "   - doxygen (to build Doxygen documentation in doc/devel/)"
	@echo
	@echo 'Other targets launched by "make install" :'
	@echo " * Perl libraries install :"
	@echo "   - install_libs          (all Perl libraries)"
	@echo "   - install_portal_libs"
	@echo "   - install_manager_libs"
	@echo "   - install_handler_libs"
	@echo " * Binaries install :"
	@echo "   - install_bin           ($(BINDIR))"
	@echo " * Web sites install :"
	@echo "   - install_site          (all sites including install_doc_site)"
	@echo "   - install_portal_site   ($(PORTALDIR))"
	@echo "   - install_manager_site  ($(MANAGERDIR))"
	@echo "   - install_handler_site  ($(HANDLERDIR))"
	@echo " * Documentation install :"
	@echo "   - install_doc_site      ($(DOCDIR))"
	@echo "   - install_examples_site ($(EXAMPLESDIR))"
	@echo
132

133 134 135
#
# Perl libraries configuration
#
136

137 138 139
configure:	common_conf handler_conf portal_conf manager_conf

common_conf:
Xavier Guimard's avatar
Xavier Guimard committed
140
	@cd ${SRCCOMMONDIR}; LMNGCONFFILE=$(STORAGECONFFILE) $(PERL) Makefile.PL $(PERLOPTIONS)
141 142 143
	@touch common_conf

handler_conf:
Xavier Guimard's avatar
Xavier Guimard committed
144
	@cd ${SRCHANDLERDIR}; $(PERL) Makefile.PL $(PERLOPTIONS)
145 146 147
	@touch handler_conf

portal_conf:
Xavier Guimard's avatar
Xavier Guimard committed
148
	@cd ${SRCPORTALDIR}; $(PERL) Makefile.PL $(PERLOPTIONS)
149 150 151
	@touch portal_conf

manager_conf:
Xavier Guimard's avatar
Xavier Guimard committed
152
	@cd ${SRCMANAGERDIR}; $(PERL) Makefile.PL $(PERLOPTIONS)
153
	@touch manager_conf
154

155 156 157
#
# Perl libraries make
#
158 159 160
common:		common_conf
	@$(MAKE) -C ${SRCCOMMONDIR}
	@touch common
161 162

handler:	handler_conf
163
	@$(MAKE) -C ${SRCHANDLERDIR}
164
	@touch handler
165 166

portal:		portal_conf
167
	@$(MAKE) -C ${SRCPORTALDIR}
168
	@touch portal
169 170

manager:	manager_conf
171
	@$(MAKE) -C ${SRCMANAGERDIR}
172
	@touch manager
173

Xavier Guimard's avatar
Xavier Guimard committed
174
test:		all common_test handler_test portal_test manager_test extra_test
175 176 177 178 179

common_test:	common
	@$(MAKE) -C ${SRCCOMMONDIR} test

handler_test:	handler common_test
180
	@$(MAKE) -C ${SRCHANDLERDIR} test FULLPERL="$(PERL) -I../${SRCCOMMONDIR}/blib/lib/"
181

182
portal_test:	portal handler_test common_test
183
	@$(MAKE) -C ${SRCPORTALDIR} test FULLPERL="$(PERL) -I../${SRCCOMMONDIR}/blib/lib/ -I../${SRCHANDLERDIR}/blib/lib/"
184

185
manager_test:	manager handler_test common_test
186
	@$(MAKE) -C ${SRCMANAGERDIR} test FULLPERL="$(PERL) -I../${SRCCOMMONDIR}/blib/lib/ -I../${SRCHANDLERDIR}/blib/lib/"
187

Xavier Guimard's avatar
Xavier Guimard committed
188
extra_test:	all
Xavier Guimard's avatar
Xavier Guimard committed
189 190
	PERL_DL_NONLAZY=1 $(PERL) "-MExtUtils::Command::MM" "-e" "test_harness(0, 'lemonldap-ng-common/blib/lib', 'lemonldap-ng-handler/blib/lib', 'lemonldap-ng-manager/blib/lib', 'lemonldap-ng-portal/blib/lib')" extra-tests/*.t

191 192 193 194
#
# INSTALL
#
install:	install_libs install_bin install_site
195

196 197 198
#
# Perl libraires install
#
199
install_libs:	common_install_libs install_handler_libs install_portal_libs install_manager_libs
200 201

common_install_libs:		common
202
	@$(MAKE) -C ${SRCCOMMONDIR} install
203

204
install_handler_libs:	handler
205
	@$(MAKE) -C ${SRCHANDLERDIR} install
206

207
install_portal_libs:		portal
208
	@$(MAKE) -C ${SRCPORTALDIR} install
209

210
install_manager_libs:	manager
211
	@$(MAKE) -C ${SRCMANAGERDIR} install
212

213
example:
Xavier Guimard's avatar
Xavier Guimard committed
214
	$(MAKE) install_site install_bin LMPREFIX=$(EXAMPLEROOT)
215

Xavier Guimard's avatar
Xavier Guimard committed
216
install_bin:	install_conf_dir
217 218
	# Binary install
	@install -v -d $(RBINDIR)
219
	@cp --preserve=mode --remove-destination \
220
		${SRCHANDLERDIR}/example/scripts/purgeLocalCache \
221
		${SRCPORTALDIR}/example/scripts/purgeCentralCache \
222
		${SRCPORTALDIR}/example/scripts/buildPortalWSDL \
Xavier Guimard's avatar
Xavier Guimard committed
223
		${SRCCOMMONDIR}/scripts/convertConfig \
Xavier Guimard's avatar
Xavier Guimard committed
224
		${SRCCOMMONDIR}/scripts/lmMigrateConfFiles2ini \
225 226
		${SRCMANAGERDIR}/example/scripts/lmConfigEditor \
			$(RBINDIR)
227 228 229 230 231 232 233 234 235 236
	@if [ ! "$(APACHEUSER)" ]; then \
		$(PERL) -i -pe 's#__APACHEUSER__#nobody#g;' $(RBINDIR)/lmConfigEditor; \
	else \
		$(PERL) -i -pe 's#__APACHEUSER__#$(APACHEUSER)#g;' $(RBINDIR)/lmConfigEditor; \
	fi
	@if [ ! "$(APACHEGROUP)" ]; then \
		$(PERL) -i -pe 's#__APACHEGROUP__#nobody#g;' $(RBINDIR)/lmConfigEditor; \
	else \
		$(PERL) -i -pe 's#__APACHEGROUP__#$(APACHEGROUP)#g;' $(RBINDIR)/lmConfigEditor; \
	fi
237
	@chmod +x $(RBINDIR)/*
238 239 240 241

#
# SITE INSTALL
#
242
install_site:	install_manager_site install_portal_site install_handler_site install_test_site install_examples_site install_doc_site
243
	# Site install
244
	@install -v -d $(RCONFDIR)
Clément OUDOT's avatar
Clément OUDOT committed
245 246
	# Check if erase is wanted
	@if [ "$(ERASECONFIG)" -eq "1" ]; then \
247 248 249
		cp --remove-destination _example/etc/portal-apache$(APACHEVERSION).conf $(RCONFDIR); \
		cp --remove-destination _example/etc/handler-apache$(APACHEVERSION).conf $(RCONFDIR); \
		cp --remove-destination _example/etc/manager-apache$(APACHEVERSION).conf $(RCONFDIR); \
250 251
		cp --remove-destination _example/etc/for_etc_hosts $(RCONFDIR); \
	fi
Xavier Guimard's avatar
Xavier Guimard committed
252
	@$(PERL) -i -pe 's#__HANDLER__#${HANDLERDIR}/MyHandler.pm#; \
Clément OUDOT's avatar
Clément OUDOT committed
253 254 255 256
			s/__DNSDOMAIN__/$(DNSDOMAIN)/g; \
			s#__PORTALDIR__#$(PORTALDIR)/#g; \
			s#__MANAGERDIR__#$(MANAGERDIR)/#g; \
			s#__TESTDIR__#$(TESTDIR)/#g; \
257 258
			s#__VHOSTLISTEN__#$(VHOSTLISTEN)#g; \
			s#__DOCDIR__#$(DOCDIR)/#g;' $(RCONFDIR)/*apache*.conf
Xavier Guimard's avatar
Xavier Guimard committed
259
	@$(PERL) -i -pe 's/__DNSDOMAIN__/$(DNSDOMAIN)/g' $(RCONFDIR)/for_etc_hosts
260
	# Fix a lost of rights on the main directory
261
	@chmod 755 $(RBINDIR) $(RDOCUMENTROOT) $(REXAMPLESDIR) $(RHANDLERDIR) $(RPORTALSKINSDIR) $(RMANAGERSKINSDIR) $(RTOOLSDIR) $(RCONFDIR) $(RDATADIR)
262
	@echo
263
	@echo "LemonLDAP::NG v${VERSION} is installed with these parameters:"
264 265 266 267 268
	@echo "  - System configuration: ${CONFDIR}"
	@echo "  - DNS domain (for cookies and virtual hosts): ${DNSDOMAIN}"
	@echo
	@echo "To finish configuration:"
	@echo
269 270 271 272
	@echo "1 - Add this in your Apache $(APACHEVERSION) configuration file:"
	@echo "      include ${CONFDIR}/portal-apache$(APACHEVERSION).conf"
	@echo "      include ${CONFDIR}/handler-apache$(APACHEVERSION).conf"
	@echo "      include ${CONFDIR}/manager-apache$(APACHEVERSION).conf"
273
	@echo
274 275
	@echo "2 - Restart Apache:"
	@echo "      apache$(APACHEVERSION)ctl restart"
276
	@echo
277
	@echo "3 - Run 'make postconf' as root to update /etc/hosts if your DNS service does not known auth.$(DNSDOMAIN) and manager.$(DNSDOMAIN)"
278
	@echo
279 280 281 282 283 284
	@echo "4 - Try to connect to http://test1.${DNSDOMAIN}/ or http://test2.${DNSDOMAIN}/ with demonstration accounts:"
	@echo "    - rtyler/rtyler"
	@echo "    - msmith/msmith"
	@echo "    - dwho/dwho"
	@echo
	@echo "5 - Connect to Manager at http://manager.${DNSDOMAIN}/ to edit configuration"
285
	@echo
286
	@if [ ! "$(APACHEUSER)" ]; then \
287 288 289 290
		echo;echo "    Warning, since APACHEUSER was not set, $(APACHESESSIONFILEDIR) and $(CONFDIR) have permissive permissions."; \
		echo "    Fix them by yourself to restrict their view to apache process only"; \
	fi
	@echo
291 292 293

install_manager_site:	install_conf_dir
	# Manager install
Xavier Guimard's avatar
Xavier Guimard committed
294
	@install -v -d ${RMANAGERDIR} ${RMANAGERSKINSDIR} \
295
		${RSESSIONSEXPLORERDIR} \
Xavier Guimard's avatar
Xavier Guimard committed
296 297 298 299 300 301
		$(RCONFDIR) ${RMANAGERDIR}/skins/
	@for skin in $$(ls lemonldap-ng-manager/example/skins/); do \
		[ -h $(RMANAGERDIR)/skins/$$skin ] && rm -f $(RMANAGERDIR)/skins/$$skin; \
		install -v -d $(RMANAGERSKINSDIR)/$$skin; \
	done
	@cp -pR --remove-destination ${SRCMANAGERDIR}/example/index.pl ${RMANAGERDIR}
Clément OUDOT's avatar
Clément OUDOT committed
302
	@cp -pR --remove-destination ${SRCMANAGERDIR}/example/notfound.html ${RMANAGERDIR}
Xavier Guimard's avatar
Xavier Guimard committed
303 304 305 306 307 308
	@cp -pR --remove-destination ${SRCMANAGERDIR}/example/skins/* $(RMANAGERSKINSDIR)
	@if [ "$(MANAGERDIR)/skins/" != "$(MANAGERSKINSDIR)/" ]; then \
		for skin in $$(ls lemonldap-ng-manager/example/skins/); do \
			rm -rf $(RMANAGERDIR)/skins/$$skin/; \
			ln -s $(MANAGERSKINSDIR)/$$skin $(RMANAGERDIR)/skins/$$skin; \
		done; \
309
	fi
Xavier Guimard's avatar
Xavier Guimard committed
310
	@$(PERL) -i -pe 's/__DNSDOMAIN__/$(DNSDOMAIN)/g' $(RCONFDIR)/$(CONFFILENAME)
311
	# Sessions explorer and notifications explorer install
312
	@cp -pR --remove-destination ${SRCMANAGERDIR}/example/sessions.pl $(RSESSIONSEXPLORERDIR)
313
	@cp -pR --remove-destination ${SRCMANAGERDIR}/example/notifications.pl $(RSESSIONSEXPLORERDIR)
Xavier Guimard's avatar
Xavier Guimard committed
314
	@rm -rf $$(find ${RMANAGERDIR} ${RMANAGERSKINSDIR} \
315
		${RSESSIONSEXPLORERDIR} \
316
		$(RCONFDIR) -type d -name .svn)
317 318 319

install_portal_site:	install_conf_dir
	# Portal install
320 321 322
	@mkdir -p $(PORTALDIR)/captcha_output/
	@mkdir -p $(DATADIR)/captcha/data
	@chmod -R 777 $(DATADIR)/captcha $(PORTALDIR)/captcha_output/
323
	@install -v -d $(RPORTALDIR) $(RPORTALSKINSDIR) \
324
		$(RPORTALDIR)/skins/ \
325 326
		$(RCRONDIR) $(RCONFDIR)
	@for skin in $$(ls lemonldap-ng-portal/example/skins/); do \
327 328
		[ -h $(RPORTALDIR)/skins/$$skin ] && rm -f $(RPORTALDIR)/skins/$$skin; \
		install -v -d $(RPORTALSKINSDIR)/$$skin; \
329
	done
330
	@cp -pR --remove-destination ${SRCPORTALDIR}/example/index_skin.pl ${RPORTALDIR}/index.pl
331
	@cp -pR --remove-destination ${SRCPORTALDIR}/example/mail.pl ${RPORTALDIR}
Clément OUDOT's avatar
SAML:  
Clément OUDOT committed
332
	@cp -pR --remove-destination ${SRCPORTALDIR}/example/metadata.pl ${RPORTALDIR}
333
	@cp -pR --remove-destination ${SRCPORTALDIR}/example/cdc.pl ${RPORTALDIR}
334
	@tar -cf - -C ${SRCPORTALDIR}/example/skins/ $$(ls ${SRCPORTALDIR}/example/skins/) |tar -xf - -C $(RPORTALSKINSDIR)
335
	@if [ "$(PORTALDIR)/skins/" != "$(PORTALSKINSDIR)/" ]; then \
336
		for skin in $$(ls lemonldap-ng-portal/example/skins/); do \
337 338
			rm -rf $(RPORTALDIR)/skins/$$skin/; \
			ln -s $(PORTALSKINSDIR)/$$skin $(RPORTALDIR)/skins/$$skin; \
339 340 341
		done; \
	fi
	# Cron files
342
	@cp --remove-destination lemonldap-ng-portal/example/scripts/purgeCentralCache.cron.d $(RCRONDIR)/lemonldap-ng-portal
343
	@if [ ! "$(APACHEUSER)" ]; then \
344
		$(PERL) -i -pe 's#__APACHEUSER__#nobody#g;' $(RCRONDIR)/lemonldap-ng-portal; \
345
	else \
346
		$(PERL) -i -pe 's#__APACHEUSER__#$(APACHEUSER)#g;' $(RCRONDIR)/lemonldap-ng-portal; \
347
	fi
348
	@$(PERL) -i -pe 's#__BINDIR__#$(BINDIR)#g;' $(RCRONDIR)/lemonldap-ng-portal
349
	# Clean SVN files
350
	@rm -rf $$(find ${RPORTALDIR} $(RPORTALSKINSDIR) $(RCRONDIR) $(RCONFDIR) -type d -name .svn)
351 352

install_handler_site:	install_conf_dir
353
	# Handler install
354 355
	@install -v -d ${RHANDLERDIR}
	@cp --remove-destination ${SRCHANDLERDIR}/example/MyHandler.pm ${RHANDLERDIR}
356
	@cp --remove-destination ${SRCHANDLERDIR}/example/MyHandlerZimbra.pm ${RHANDLERDIR}
Clément OUDOT's avatar
Clément OUDOT committed
357
	@cp --remove-destination ${SRCHANDLERDIR}/example/MyHandlerSympa.pm ${RHANDLERDIR}
358
	@cp --remove-destination ${SRCHANDLERDIR}/example/MyHandlerSecureToken.pm ${RHANDLERDIR}
359
	@cp --remove-destination ${SRCHANDLERDIR}/example/MyUpdateCookieHandler.pm ${RHANDLERDIR}
360 361
	@cp --remove-destination lemonldap-ng-handler/example/scripts/purgeLocalCache.cron.d $(RCRONDIR)/lemonldap-ng-handler
	@if [ ! "$(APACHEUSER)" ]; then \
362
		$(PERL) -i -pe 's#__APACHEUSER__#nobody#g;' $(RCRONDIR)/lemonldap-ng-handler; \
363 364 365 366
	else \
		$(PERL) -i -pe 's#__APACHEUSER__#$(APACHEUSER)#g;' $(RCRONDIR)/lemonldap-ng-handler; \
	fi
	@$(PERL) -i -pe 's#__BINDIR__#$(BINDIR)#g;' $(RCRONDIR)/lemonldap-ng-handler
367
	@rm -rf $$(find $(RHANDLERDIR) -type d -name .svn)
368 369

install_test_site:
370
	# Test site install
371 372
	@install -v -d $(RTESTDIR)
	@cp -pR --remove-destination _example/test/* $(RTESTDIR)
373
	@rm -rf $$(find $(RTESTDIR) -type d -name .svn)
Xavier Guimard's avatar
Xavier Guimard committed
374
	@$(PERL) -i -pe 's/__DNSDOMAIN__/$(DNSDOMAIN)/g' $(RTESTDIR)/index.pl
375
	@rm -rf $$(find $(RTESTDIR) -type d -name .svn)
376 377

install_examples_site:
378
	# Examples install
379
	@install -v -d $(REXAMPLESDIR)
380
	@for i in manager portal handler; do \
381 382
		cp -dpR --remove-destination lemonldap-ng-$$i/example $(REXAMPLESDIR)/$$i; \
	done
383
	@rm -rf $(REXAMPLESDIR)/portal/skins \
Xavier Guimard's avatar
Xavier Guimard committed
384
		$(REXAMPLESDIR)/manager/skins \
385
	@rm -rf $$(find $(REXAMPLESDIR) -type d -name .svn)
386
	@$(PERL) -i -pe 's#__SESSIONDIR__#$(APACHESESSIONFILEDIR)/#g;' $(REXAMPLESDIR)/portal/*.pl
387

388
install_doc_site:
389 390
	# Offline documentation install
	@rm -rf $(RDOCDIR)
391
	@install -v -d $(RDOCDIR)
Xavier Guimard's avatar
Xavier Guimard committed
392
	@cp -dR --remove-destination doc/* $(RDOCDIR)
393

394
install_conf_dir:	install_sessions_dir install_notif_dir
395
	# Configuration files install
396
	@install -v -d $(RCONFDIR) $(RFILECONFIGDIR) $(RTOOLSDIR)
Clément OUDOT's avatar
Clément OUDOT committed
397
	@if [ "$(ERASECONFIG)" -eq "1" ]; then \
398
		cp --remove-destination $(SRCCOMMONDIR)/$(CONFFILENAME) $(RCONFDIR); \
Xavier Guimard's avatar
Xavier Guimard committed
399
		$(PERL) -i -pe 's#^dirName\s*=\s*.*#dirName = $(FILECONFIGDIR)#g' $(RCONFDIR)/$(CONFFILENAME); \
Clément OUDOT's avatar
Clément OUDOT committed
400
	fi
401
	@cp _example/conf/lmConf-1 $(RFILECONFIGDIR)
Xavier Guimard's avatar
Xavier Guimard committed
402 403
	@$(PERL) -000 -i -pe "s#^(globalStorageOptions\\n\\s+)'[^\\n]*?'\$$#\$${1}\'\\\$$data1 = {&39;Directory&39; => &39;$(APACHESESSIONFILEDIR)&39;,&39;LockDirectory&39; => &39;$(APACHESESSIONFILELOCKDIR)&39;};'#m" $(RFILECONFIGDIR)/lmConf-1
	@$(PERL) -i -pe 's/__DNSDOMAIN__/$(DNSDOMAIN)/g;\
404
		s#__SESSIONDIR__#$(APACHESESSIONFILEDIR)#g;' $(RFILECONFIGDIR)/lmConf-1
405 406 407 408 409 410 411 412 413
	@if [ "$(APACHEUSER)" != "" ]; then \
		chown $(APACHEUSER) $(RFILECONFIGDIR) || exit 1; \
		if [ "$(APACHEGROUP)" != "" ]; then \
			chgrp $(APACHEGROUP) $(RFILECONFIGDIR) || exit 1; \
		fi; \
		chmod 770 $(RFILECONFIGDIR); \
	else \
		chmod 777 $(RFILECONFIGDIR); \
	fi
414
	@cp lemonldap-ng-common/tools/lmConfig.* lemonldap-ng-common/tools/apache-session-mysql.sql $(RTOOLSDIR)
415
	@cp lemonldap-ng-common/tools/sso.schema $(RTOOLSDIR)
416
	@rm -rf $$(find $(RCONFDIR) $(RFILECONFIGDIR) $(RTOOLSDIR) -type d -name .svn)
417 418 419 420 421

install_sessions_dir:
	@install -m 777 -v -d $(RAPACHESESSIONFILEDIR) $(RAPACHESESSIONFILELOCKDIR)
	# Fix Apache::Session directories permissions
	@if [ "$(APACHEUSER)" != "" ]; then \
422
		chown $(APACHEUSER) $(RAPACHESESSIONFILEDIR) $(RAPACHESESSIONFILELOCKDIR) || exit 1; \
423
		if [ "$(APACHEGROUP)" != "" ]; then \
424
			chgrp $(APACHEGROUP) $(RAPACHESESSIONFILEDIR) $(RAPACHESESSIONFILELOCKDIR) || exit 1; \
425 426 427 428 429 430
		fi; \
		chmod 770 $(RAPACHESESSIONFILEDIR) $(RAPACHESESSIONFILELOCKDIR); \
	else \
		chmod 777 $(RAPACHESESSIONFILEDIR) $(RAPACHESESSIONFILELOCKDIR); \
	fi

431 432 433 434 435 436 437 438 439 440 441 442 443
install_notif_dir:
	@install -m 777 -v -d $(RFILENOTIFDIR)
	# Fix notifications directory permissions
	@if [ "$(APACHEUSER)" != "" ]; then \
		chown $(APACHEUSER) $(RFILENOTIFDIR) || exit 1; \
		if [ "$(APACHEGROUP)" != "" ]; then \
			chgrp $(APACHEGROUP) $(RFILENOTIFDIR) || exit 1; \
		fi; \
		chmod 770 $(RFILENOTIFDIR); \
	else \
		chmod 777 $(RFILENOTIFDIR); \
	fi

444
postconf_hosts:
Clément OUDOT's avatar
Clément OUDOT committed
445
	@cat ${CONFDIR}/for_etc_hosts >> /etc/hosts
446 447
	@echo "/etc/hosts was updated"

448
postconf: postconf_hosts
449 450
	@echo "Post configuration done"

451 452
uninstall:	configure handler_uninstall portal_uninstall manager_uninstall

453 454 455 456
common_uninstall:	common
	@$(MAKE) -C ${SRCCOMMONDIR} uninstall
	@rm -vf common_uninstall

457
handler_uninstall:	handler
458
	@$(MAKE) -C ${SRCHANDLERDIR} uninstall
459
	@rm -vf handler_uninstall
460 461

portal_uninstall:		portal
462
	@$(MAKE) -C ${SRCPORTALDIR} uninstall
463
	@rm -vf portal_uninstall
464 465

manager_uninstall:	manager
466
	@$(MAKE) -C ${SRCMANAGERDIR} uninstall
467
	@rm -vf manager_uninstall
468

469
dist:	clean
470 471 472 473
	@mkdir -p lemonldap-ng-$(VERSION)
	@cp -pRH $$(find * -maxdepth 0|grep -v lemonldap-ng-$(VERSION)) lemonldap-ng-$(VERSION)
	@rm -rf $$(find lemonldap-ng-$(VERSION) -name .svn -print)
	@find $$dir -name '*.bak' -delete
474
	@rm -rf lemonldap-ng-$(VERSION)/lemonldap-ng-$(VERSION)
Xavier Guimard's avatar
Xavier Guimard committed
475
	@$(COMPRESS) lemonldap-ng-$(VERSION).$(COMPRESSSUFFIX) lemonldap-ng-$(VERSION)
476
	@rm -rf lemonldap-ng-$(VERSION)
477

478
debian-dist:	dist
Xavier Guimard's avatar
Xavier Guimard committed
479 480 481 482
	@mv lemonldap-ng-$(VERSION).$(COMPRESSSUFFIX) lemonldap-ng_$(VERSION).orig.$(COMPRESSSUFFIX)

zip-dist:
	$(MAKE) dist "COMPRESS=zip -r" COMPRESSSUFFIX=zip
483

484 485 486 487 488 489 490 491
manifest:   configure
	@for i in ${SRCCOMMONDIR} ${SRCHANDLERDIR} ${SRCPORTALDIR} ${SRCMANAGERDIR}; do \
		cd $$i; \
		make manifest; \
		rm -vf MANIFEST.*; \
		cd -; \
	done

492
cpan:	clean configure common_cpan handler_cpan portal_cpan manager_cpan
Clément OUDOT's avatar
Clément OUDOT committed
493
	for i in Common Portal Handler Manager; do \
Xavier Guimard's avatar
Xavier Guimard committed
494
		$(UNCOMPRESS) Lemonldap-NG-$$i-*.$(COMPRESSSUFFIX) \
Clément OUDOT's avatar
Clément OUDOT committed
495
			$$($(LISTCOMPRESSED) Lemonldap-NG-$$i-*.$(COMPRESSSUFFIX) |grep META.yml); \
Xavier Guimard's avatar
Xavier Guimard committed
496
		mv Lemonldap-NG-$$i-*/META.yml lemonldap-ng-$$($(PERL) -e "print lc('$$i')")/; \
497
		rm -rf Lemonldap-NG-$$i*/; \
Xavier Guimard's avatar
Xavier Guimard committed
498
		done
499 500 501 502

common_cpan:	common_conf
	@$(MAKE) -C ${SRCCOMMONDIR} dist
	@mv ${SRCCOMMONDIR}/Lemonldap*.gz .
503 504

handler_cpan:	handler_conf
505 506
	@$(MAKE) -C ${SRCHANDLERDIR} dist
	@mv ${SRCHANDLERDIR}/Lemonldap*.gz .
507 508

portal_cpan:		portal_conf
509 510
	@$(MAKE) -C ${SRCPORTALDIR} dist
	@mv ${SRCPORTALDIR}/Lemonldap*.gz .
511 512

manager_cpan:	manager_conf
513 514
	@$(MAKE) -C ${SRCMANAGERDIR} dist
	@mv ${SRCMANAGERDIR}/Lemonldap*.gz .
515

516
documentation:
517
	@cd doc/ && ../scripts/doc.pl
518

519
doxygen:	clean
Xavier Guimard's avatar
Xavier Guimard committed
520
	$(PERL) -i -pe 's/^(PROJECT_NUMBER\s*=\s*)\d.*$$/$${1}'$(VERSION)'/' Doxyfile
521 522 523 524 525 526
	COLLABORATIVE_GRAPH=1 doxygen Doxyfile
	mkdir doc/devel/tmp
	mv doc/devel/html/inherit* doc/devel/tmp/
	COLLABORATIVE_GRAPH=0 doxygen Doxyfile
	mv -f doc/devel/tmp/* doc/devel/html/
	rm -rf doc/devel/tmp
Xavier Guimard's avatar
Xavier Guimard committed
527
	$(PERL) -i -pe 's/Graphical Class Hierarchy/Class Collaboration Graph/' doc/devel/html/inherits.html doc/devel/html/tree.html
528 529
	# Some files are not generated
	for i in doc/devel/html/*dot; do dot -T png -o $${i/.dot/.png} $$i; rm -f $$i; done
530

531 532 533
distclean:	clean

clean:		common_clean handler_clean portal_clean manager_clean
Xavier Guimard's avatar
Xavier Guimard committed
534
	@rm -f $$(find */ -name '*bak' -delete)
535
	@rm -rf $(EXAMPLEROOT) example/ doc/devel
Xavier Guimard's avatar
Xavier Guimard committed
536
	@rm -vf *gz *zip
Xavier Guimard's avatar
Xavier Guimard committed
537
	@rm -rf lemonldap-ng-$(VERSION)
Xavier Guimard's avatar
Xavier Guimard committed
538
	@echo "Cleaned"
539 540

common_clean:
Xavier Guimard's avatar
Xavier Guimard committed
541
	@if test -e ${SRCCOMMONDIR}/Makefile;then $(MAKE) -C ${SRCCOMMONDIR} distclean;fi
542 543 544
	@rm -vf common*

handler_clean:
Xavier Guimard's avatar
Xavier Guimard committed
545
	@if test -e ${SRCHANDLERDIR}/Makefile;then $(MAKE) -C ${SRCHANDLERDIR} distclean;fi
546 547 548
	@rm -vf handler*

portal_clean:
Xavier Guimard's avatar
Xavier Guimard committed
549
	@if test -e ${SRCPORTALDIR}/Makefile;then $(MAKE) -C ${SRCPORTALDIR} distclean;fi
550 551 552
	@rm -vf portal*

manager_clean:
Xavier Guimard's avatar
Xavier Guimard committed
553
	@if test -e ${SRCMANAGERDIR}/Makefile;then $(MAKE) -C ${SRCMANAGERDIR} distclean;fi
554 555
	@rm -vf manager*

556
debian-packages: debian-dist
Xavier Guimard's avatar
Xavier Guimard committed
557
	mv lemonldap-ng_$(VERSION).orig.$(COMPRESSSUFFIX) /tmp/
558 559
	version=$(VERSION) && \
	cd /tmp/ && \
Xavier Guimard's avatar
Xavier Guimard committed
560
	rm -rf lemonldap-ng-$$version && \
Xavier Guimard's avatar
Xavier Guimard committed
561
	$(UNCOMPRESS) lemonldap-ng_$$version.orig.$(COMPRESSSUFFIX) && \
562
	cd lemonldap-ng-$$version && \
563
	export LOCALBUILD=1; debuild -us -uc -b --lintian-opts -i --lintian-opts -v
Xavier Guimard's avatar
Xavier Guimard committed
564 565 566

debian-install: debian-packages
	cd /tmp/lemonldap-ng-$(VERSION) && \
Xavier Guimard's avatar
Xavier Guimard committed
567 568 569 570 571 572
	$(SU) debi

ubuntu-install:
	$(MAKE) debian-install SU=sudo

diff: debian-diff
Xavier Guimard's avatar
Xavier Guimard committed
573

Xavier Guimard's avatar
Xavier Guimard committed
574
debian-diff:
Xavier Guimard's avatar
Xavier Guimard committed
575
	@# Portal
Xavier Guimard's avatar
Xavier Guimard committed
576 577 578
	@$(DIFF) lemonldap-ng-portal/lib/Lemonldap/NG/Portal $(DIFFPREFIX)/usr/share/perl5/Lemonldap/NG/Portal ||true
	@$(DIFF) lemonldap-ng-portal/example/scripts/purgeCentralCache $(DIFFPREFIX)/usr/share/lemonldap-ng/bin/purgeCentralCache ||true
	@$(DIFF) lemonldap-ng-portal/example/scripts/buildPortalWSDL $(DIFFPREFIX)/usr/share/lemonldap-ng/bin/buildPortalWSDL ||true
Xavier Guimard's avatar
Xavier Guimard committed
579
	@for i in $(PORTALSKINS); do \
Xavier Guimard's avatar
Xavier Guimard committed
580
		$(DIFF) -x 'jquery*' lemonldap-ng-portal/example/skins/$$i $(DIFFPREFIX)/usr/share/lemonldap-ng/portal-skins/$$i; \
Xavier Guimard's avatar
Xavier Guimard committed
581
	done ||true
Xavier Guimard's avatar
Xavier Guimard committed
582 583 584 585
	@$(DIFF) lemonldap-ng-portal/example/index_skin.pl $(DIFFPREFIX)/var/lib/lemonldap-ng/portal/index.pl ||true
	@$(DIFF) lemonldap-ng-portal/example/mail.pl $(DIFFPREFIX)/var/lib/lemonldap-ng/portal/mail.pl ||true
	@$(DIFF) lemonldap-ng-portal/example/metadata.pl $(DIFFPREFIX)/var/lib/lemonldap-ng/portal/metadata.pl ||true
	@$(DIFF) lemonldap-ng-portal/example/cdc.pl $(DIFFPREFIX)/var/lib/lemonldap-ng/portal/cdc.pl ||true
Xavier Guimard's avatar
Xavier Guimard committed
586
	@# Handler
Xavier Guimard's avatar
Xavier Guimard committed
587
	@$(DIFF) lemonldap-ng-handler/lib/Lemonldap/NG/Handler $(DIFFPREFIX)/usr/share/perl5/Lemonldap/NG/Handler ||true
588
	@$(DIFF) lemonldap-ng-handler/example/scripts/purgeLocalCache $(DIFFPREFIX)/usr/share/lemonldap-ng/bin/purgeLocalCache ||true
Xavier Guimard's avatar
Xavier Guimard committed
589
	@# Common
Xavier Guimard's avatar
Xavier Guimard committed
590 591 592 593
	@$(DIFF) lemonldap-ng-common/lib/Lemonldap/NG/Common $(DIFFPREFIX)/usr/share/perl5/Lemonldap/NG/Common ||true
	@$(DIFF) lemonldap-ng-common/lib/Lemonldap/NG/Common.pm $(DIFFPREFIX)/usr/share/perl5/Lemonldap/NG/Common.pm ||true
	@$(DIFF) lemonldap-ng-common/scripts/lmMigrateConfFiles2ini $(DIFFPREFIX)/usr/share/lemonldap-ng/bin/lmMigrateConfFiles2ini ||true
	@$(DIFF) lemonldap-ng-common/scripts/convertConfig $(DIFFPREFIX)/usr/share/lemonldap-ng/bin/convertConfig ||true
Xavier Guimard's avatar
Xavier Guimard committed
594
	@# Manager
Xavier Guimard's avatar
Xavier Guimard committed
595 596 597 598
	@$(DIFF) lemonldap-ng-manager/lib/Lemonldap/NG/Manager $(DIFFPREFIX)/usr/share/perl5/Lemonldap/NG/Manager ||true
	@$(DIFF) lemonldap-ng-manager/lib/Lemonldap/NG/Manager.pm $(DIFFPREFIX)/usr/share/perl5/Lemonldap/NG/Manager.pm ||true
	@$(DIFF) lemonldap-ng-manager/example/index.pl $(DIFFPREFIX)/var/lib/lemonldap-ng/manager/index.pl ||true
	@$(DIFF) lemonldap-ng-manager/example/sessions.pl $(DIFFPREFIX)/var/lib/lemonldap-ng/manager/sessions.pl ||true
599
	@$(DIFF) lemonldap-ng-manager/example/notifications.pl $(DIFFPREFIX)/var/lib/lemonldap-ng/manager/notifications.pl ||true
600
	@$(DIFF) --ignore-matching-lines='.*POSIX.*' lemonldap-ng-manager/example/scripts/lmConfigEditor $(DIFFPREFIX)/usr/share/lemonldap-ng/bin/lmConfigEditor ||true
Xavier Guimard's avatar
Xavier Guimard committed
601
	@for i in $(MANAGERSKINS); do \
Xavier Guimard's avatar
Xavier Guimard committed
602
		$(DIFF) -x 'jquery*' lemonldap-ng-manager/example/skins/$$i $(DIFFPREFIX)/usr/share/lemonldap-ng/manager-skins/$$i; \
Xavier Guimard's avatar
Xavier Guimard committed
603 604
	done ||true

605 606
default-diff:
	@# Portal
607
	@$(DIFF) lemonldap-ng-portal/lib/Lemonldap/NG/Portal /usr/local/share/perl/$(PERLVERSION)/Lemonldap/NG/Portal ||true
608 609 610
	@$(DIFF) lemonldap-ng-portal/example/scripts/purgeCentralCache $(LMPREFIX)/bin/purgeCentralCache ||true
	@$(DIFF) lemonldap-ng-portal/example/scripts/buildPortalWSDL $(LMPREFIX)/bin/buildPortalWSDL ||true
	@$(DIFF) lemonldap-ng-portal/example/skins $(LMPREFIX)/htdocs/portal/skins ||true
Clément OUDOT's avatar
Clément OUDOT committed
611 612
	@$(DIFF) lemonldap-ng-portal/example/index_skin.pl $(LMPREFIX)/htdocs/portal/index.pl ||true
	@$(DIFF) lemonldap-ng-portal/example/mail.pl $(LMPREFIX)/htdocs/portal/mail.pl ||true
Clément OUDOT's avatar
SAML:  
Clément OUDOT committed
613
	@$(DIFF) lemonldap-ng-portal/example/metadata.pl $(LMPREFIX)/htdocs/portal/metadata.pl ||true
614
	@$(DIFF) lemonldap-ng-portal/example/cdc.pl $(LMPREFIX)/htdocs/portal/cdc.pl ||true
615
	@# Handler
616
	@$(DIFF) lemonldap-ng-handler/lib/Lemonldap/NG/Handler /usr/local/share/perl/$(PERLVERSION)/Lemonldap/NG/Handler ||true
617
	@$(DIFF) lemonldap-ng-handler/example/MyHandler.pm $(LMPREFIX)/handler/MyHandler.pm ||true
618
	@$(DIFF) lemonldap-ng-handler/example/MyHandlerZimbra.pm $(LMPREFIX)/handler/MyHandlerZimbra.pm ||true
Clément OUDOT's avatar
Clément OUDOT committed
619
	@$(DIFF) lemonldap-ng-handler/example/MyHandlerSympa.pm $(LMPREFIX)/handler/MyHandlerSympa.pm ||true
620 621
	@$(DIFF) lemonldap-ng-handler/example/MyHandlerSecureToken.pm $(LMPREFIX)/handler/MyHandlerSecureToken.pm ||true
	@$(DIFF) lemonldap-ng-handler/example/MyUpdateCookieHandler.pm $(LMPREFIX)/handler/MyUpdateCookieHandler.pm ||true
622
	@$(DIFF) lemonldap-ng-handler/example/scripts/purgeLocalCache $(LMPREFIX)/bin/purgeLocalCache ||true
623
	@# Common
624 625
	@$(DIFF) lemonldap-ng-common/lib/Lemonldap/NG/Common /usr/local/share/perl/$(PERLVERSION)/Lemonldap/NG/Common ||true
	@$(DIFF) lemonldap-ng-common/lib/Lemonldap/NG/Common.pm /usr/local/share/perl/$(PERLVERSION)/Lemonldap/NG/Common.pm ||true
626 627 628
	@$(DIFF) lemonldap-ng-common/scripts/lmMigrateConfFiles2ini $(LMPREFIX)/bin/lmMigrateConfFiles2ini ||true
	@$(DIFF) lemonldap-ng-common/scripts/convertConfig $(LMPREFIX)/bin/convertConfig ||true
	@# Manager
629 630
	@$(DIFF) lemonldap-ng-manager/lib/Lemonldap/NG/Manager /usr/local/share/perl/$(PERLVERSION)/Lemonldap/NG/Manager ||true
	@$(DIFF) lemonldap-ng-manager/lib/Lemonldap/NG/Manager.pm /usr/local/share/perl/$(PERLVERSION)/Lemonldap/NG/Manager.pm ||true
631
	@$(DIFF) lemonldap-ng-manager/example/skins $(LMPREFIX)/htdocs/manager/skins ||true
632
	@$(DIFF) lemonldap-ng-manager/example/index.pl $(LMPREFIX)/htdocs/manager/index.pl ||true
633
	@$(DIFF) lemonldap-ng-manager/example/sessions.pl $(LMPREFIX)/htdocs/manager/sessions.pl ||true
634
	@$(DIFF) lemonldap-ng-manager/example/notifications.pl $(LMPREFIX)/htdocs/manager/notifications.pl ||true
635
	@$(DIFF) --ignore-matching-lines='.*POSIX.*' lemonldap-ng-manager/example/scripts/lmConfigEditor $(LMPREFIX)/bin/lmConfigEditor ||true
636

637
tidy: clean
Xavier Guimard's avatar
Xavier Guimard committed
638
	find lemon*/ -type f \( -name '*.pm' -or -name '*.pl' -or -name '*.t' \) -print -exec perltidy -b {} \;
639 640
	find lemon*/ -name '*.bak' -delete