Makefile 25.9 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
# Lemonldap-ng notifications storage dir
73 74
APACHEFILENOTIFDIR=$(DATADIR)/notifications
RFILENOTIFDIR=$(DESTDIR)/$(APACHEFILENOTIFDIR)
75

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

80 81 82
# Apache version
APACHEVERSION=2

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

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

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

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

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

104
all:	configure common handler manager portal
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
	@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
133

134 135 136
#
# Perl libraries configuration
#
137

138 139 140
configure:	common_conf handler_conf portal_conf manager_conf

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

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

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

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

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

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

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

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

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

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

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

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

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

Xavier Guimard's avatar
Xavier Guimard committed
189
extra_test:	all
Xavier Guimard's avatar
Xavier Guimard committed
190 191
	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

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

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

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

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

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

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

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

Xavier Guimard's avatar
Xavier Guimard committed
217
install_bin:	install_conf_dir
218 219
	# Binary install
	@install -v -d $(RBINDIR)
220
	@cp --preserve=mode --remove-destination \
221
		${SRCHANDLERDIR}/example/scripts/purgeLocalCache \
222
		${SRCPORTALDIR}/example/scripts/purgeCentralCache \
223
		${SRCPORTALDIR}/example/scripts/buildPortalWSDL \
Xavier Guimard's avatar
Xavier Guimard committed
224
		${SRCCOMMONDIR}/scripts/convertConfig \
Xavier Guimard's avatar
Xavier Guimard committed
225
		${SRCCOMMONDIR}/scripts/lmMigrateConfFiles2ini \
226 227
		${SRCMANAGERDIR}/example/scripts/lmConfigEditor \
			$(RBINDIR)
228 229 230 231 232 233 234 235 236 237
	@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
238
	@chmod +x $(RBINDIR)/*
239 240 241 242

#
# SITE INSTALL
#
243
install_site:	install_manager_site install_portal_site install_handler_site install_test_site install_examples_site install_doc_site
244
	# Site install
245
	@install -v -d $(RCONFDIR)
Clément OUDOT's avatar
Clément OUDOT committed
246 247
	# Check if erase is wanted
	@if [ "$(ERASECONFIG)" -eq "1" ]; then \
248 249 250
		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); \
251
		cp --remove-destination _example/etc/test-apache$(APACHEVERSION).conf $(RCONFDIR); \
252 253
		cp --remove-destination _example/etc/for_etc_hosts $(RCONFDIR); \
	fi
Xavier Guimard's avatar
Xavier Guimard committed
254
	@$(PERL) -i -pe 's#__HANDLER__#${HANDLERDIR}/MyHandler.pm#; \
Clément OUDOT's avatar
Clément OUDOT committed
255 256 257 258
			s/__DNSDOMAIN__/$(DNSDOMAIN)/g; \
			s#__PORTALDIR__#$(PORTALDIR)/#g; \
			s#__MANAGERDIR__#$(MANAGERDIR)/#g; \
			s#__TESTDIR__#$(TESTDIR)/#g; \
259 260
			s#__VHOSTLISTEN__#$(VHOSTLISTEN)#g; \
			s#__DOCDIR__#$(DOCDIR)/#g;' $(RCONFDIR)/*apache*.conf
Xavier Guimard's avatar
Xavier Guimard committed
261
	@$(PERL) -i -pe 's/__DNSDOMAIN__/$(DNSDOMAIN)/g' $(RCONFDIR)/for_etc_hosts
262
	# Fix a lost of rights on the main directory
Clément OUDOT's avatar
Clément OUDOT committed
263
	@chmod 755 $(RBINDIR) $(RDOCUMENTROOT) $(REXAMPLESDIR) $(RHANDLERDIR) $(RPORTALSKINSDIR) $(RMANAGERSKINSDIR) $(RTOOLSDIR) $(RCONFDIR) $(RDATADIR)
264
	@echo
265
	@echo "LemonLDAP::NG v${VERSION} is installed with these parameters:"
266 267 268 269 270
	@echo "  - System configuration: ${CONFDIR}"
	@echo "  - DNS domain (for cookies and virtual hosts): ${DNSDOMAIN}"
	@echo
	@echo "To finish configuration:"
	@echo
271 272 273 274
	@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"
275
	@echo "      include ${CONFDIR}/test-apache$(APACHEVERSION).conf"
276
	@echo
277 278
	@echo "2 - Restart Apache:"
	@echo "      apache$(APACHEVERSION)ctl restart"
279
	@echo
280
	@echo "3 - Run 'make postconf' as root to update /etc/hosts if your DNS service does not known auth.$(DNSDOMAIN) and manager.$(DNSDOMAIN)"
281
	@echo
282 283 284 285 286 287
	@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"
288
	@echo
289
	@if [ ! "$(APACHEUSER)" ]; then \
290 291 292 293
		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
294 295 296

install_manager_site:	install_conf_dir
	# Manager install
Xavier Guimard's avatar
Xavier Guimard committed
297
	@install -v -d ${RMANAGERDIR} ${RMANAGERSKINSDIR} \
298
		${RSESSIONSEXPLORERDIR} \
Xavier Guimard's avatar
Xavier Guimard committed
299 300 301 302 303 304
		$(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
305
	@cp -pR --remove-destination ${SRCMANAGERDIR}/example/notfound.html ${RMANAGERDIR}
Xavier Guimard's avatar
Xavier Guimard committed
306 307 308 309 310 311
	@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; \
312
	fi
Xavier Guimard's avatar
Xavier Guimard committed
313
	@$(PERL) -i -pe 's/__DNSDOMAIN__/$(DNSDOMAIN)/g' $(RCONFDIR)/$(CONFFILENAME)
314
	# Sessions explorer and notifications explorer install
315
	@cp -pR --remove-destination ${SRCMANAGERDIR}/example/sessions.pl $(RSESSIONSEXPLORERDIR)
316
	@cp -pR --remove-destination ${SRCMANAGERDIR}/example/notifications.pl $(RSESSIONSEXPLORERDIR)
Xavier Guimard's avatar
Xavier Guimard committed
317
	@rm -rf $$(find ${RMANAGERDIR} ${RMANAGERSKINSDIR} \
318
		${RSESSIONSEXPLORERDIR} \
319
		$(RCONFDIR) -type d -name .svn)
320 321 322

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

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

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

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

392
install_doc_site:
393 394
	# Offline documentation install
	@rm -rf $(RDOCDIR)
395
	@install -v -d $(RDOCDIR)
Xavier Guimard's avatar
Xavier Guimard committed
396
	@cp -dR --remove-destination doc/* $(RDOCDIR)
397

398
install_conf_dir:	install_sessions_dir install_notif_dir
399
	# Configuration files install
400
	@install -v -d $(RCONFDIR) $(RFILECONFIGDIR) $(RTOOLSDIR)
Clément OUDOT's avatar
Clément OUDOT committed
401
	@if [ "$(ERASECONFIG)" -eq "1" ]; then \
402
		cp --remove-destination $(SRCCOMMONDIR)/$(CONFFILENAME) $(RCONFDIR); \
Xavier Guimard's avatar
Xavier Guimard committed
403
		$(PERL) -i -pe 's#^dirName\s*=\s*.*#dirName = $(FILECONFIGDIR)#g' $(RCONFDIR)/$(CONFFILENAME); \
Clément OUDOT's avatar
Clément OUDOT committed
404
	fi
405
	@cp _example/conf/lmConf-1 $(RFILECONFIGDIR)
Xavier Guimard's avatar
Xavier Guimard committed
406 407
	@$(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;\
408 409
		s#__SESSIONDIR__#$(APACHESESSIONFILEDIR)#g;\
		s#__NOTIFICATIONDIR__#$(APACHEFILENOTIFDIR)#g;' $(RFILECONFIGDIR)/lmConf-1
410 411 412 413 414 415 416 417 418
	@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
419
	@cp lemonldap-ng-common/tools/lmConfig.* lemonldap-ng-common/tools/apache-session-mysql.sql $(RTOOLSDIR)
420
	@cp lemonldap-ng-common/tools/sso.schema $(RTOOLSDIR)
421
	@rm -rf $$(find $(RCONFDIR) $(RFILECONFIGDIR) $(RTOOLSDIR) -type d -name .svn)
422 423 424 425 426

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

436 437 438 439 440 441 442 443 444 445 446 447 448
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

449
postconf_hosts:
Clément OUDOT's avatar
Clément OUDOT committed
450
	@cat ${CONFDIR}/for_etc_hosts >> /etc/hosts
451 452
	@echo "/etc/hosts was updated"

453
postconf: postconf_hosts
454 455
	@echo "Post configuration done"

456 457
uninstall:	configure handler_uninstall portal_uninstall manager_uninstall

458 459 460 461
common_uninstall:	common
	@$(MAKE) -C ${SRCCOMMONDIR} uninstall
	@rm -vf common_uninstall

462
handler_uninstall:	handler
463
	@$(MAKE) -C ${SRCHANDLERDIR} uninstall
464
	@rm -vf handler_uninstall
465 466

portal_uninstall:		portal
467
	@$(MAKE) -C ${SRCPORTALDIR} uninstall
468
	@rm -vf portal_uninstall
469 470

manager_uninstall:	manager
471
	@$(MAKE) -C ${SRCMANAGERDIR} uninstall
472
	@rm -vf manager_uninstall
473

474
dist:	clean
475 476 477 478
	@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
479
	@rm -rf lemonldap-ng-$(VERSION)/lemonldap-ng-$(VERSION)
Xavier Guimard's avatar
Xavier Guimard committed
480
	@$(COMPRESS) lemonldap-ng-$(VERSION).$(COMPRESSSUFFIX) lemonldap-ng-$(VERSION)
481
	@rm -rf lemonldap-ng-$(VERSION)
482

483
debian-dist:	dist
Xavier Guimard's avatar
Xavier Guimard committed
484 485 486 487
	@mv lemonldap-ng-$(VERSION).$(COMPRESSSUFFIX) lemonldap-ng_$(VERSION).orig.$(COMPRESSSUFFIX)

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

489 490 491 492 493 494 495 496
manifest:   configure
	@for i in ${SRCCOMMONDIR} ${SRCHANDLERDIR} ${SRCPORTALDIR} ${SRCMANAGERDIR}; do \
		cd $$i; \
		make manifest; \
		rm -vf MANIFEST.*; \
		cd -; \
	done

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

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

handler_cpan:	handler_conf
510 511
	@$(MAKE) -C ${SRCHANDLERDIR} dist
	@mv ${SRCHANDLERDIR}/Lemonldap*.gz .
512 513

portal_cpan:		portal_conf
514 515
	@$(MAKE) -C ${SRCPORTALDIR} dist
	@mv ${SRCPORTALDIR}/Lemonldap*.gz .
516 517

manager_cpan:	manager_conf
518 519
	@$(MAKE) -C ${SRCMANAGERDIR} dist
	@mv ${SRCMANAGERDIR}/Lemonldap*.gz .
520

521
documentation:
522
	@cd doc/ && ../scripts/doc.pl
523

524
doxygen:	clean
Xavier Guimard's avatar
Xavier Guimard committed
525
	$(PERL) -i -pe 's/^(PROJECT_NUMBER\s*=\s*)\d.*$$/$${1}'$(VERSION)'/' Doxyfile
526 527 528 529 530 531
	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
532
	$(PERL) -i -pe 's/Graphical Class Hierarchy/Class Collaboration Graph/' doc/devel/html/inherits.html doc/devel/html/tree.html
533 534
	# 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
535

536 537 538
distclean:	clean

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

common_clean:
Xavier Guimard's avatar
Xavier Guimard committed
546
	@if test -e ${SRCCOMMONDIR}/Makefile;then $(MAKE) -C ${SRCCOMMONDIR} distclean;fi
547 548 549
	@rm -vf common*

handler_clean:
Xavier Guimard's avatar
Xavier Guimard committed
550
	@if test -e ${SRCHANDLERDIR}/Makefile;then $(MAKE) -C ${SRCHANDLERDIR} distclean;fi
551 552 553
	@rm -vf handler*

portal_clean:
Xavier Guimard's avatar
Xavier Guimard committed
554
	@if test -e ${SRCPORTALDIR}/Makefile;then $(MAKE) -C ${SRCPORTALDIR} distclean;fi
555 556 557
	@rm -vf portal*

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

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

debian-install: debian-packages
	cd /tmp/lemonldap-ng-$(VERSION) && \
Xavier Guimard's avatar
Xavier Guimard committed
572 573 574 575 576 577
	$(SU) debi

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

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

Xavier Guimard's avatar
Xavier Guimard committed
579
debian-diff:
Xavier Guimard's avatar
Xavier Guimard committed
580
	@# Portal
Xavier Guimard's avatar
Xavier Guimard committed
581 582 583
	@$(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
584
	@for i in $(PORTALSKINS); do \
Xavier Guimard's avatar
Xavier Guimard committed
585
		$(DIFF) -x 'jquery*' lemonldap-ng-portal/example/skins/$$i $(DIFFPREFIX)/usr/share/lemonldap-ng/portal-skins/$$i; \
Xavier Guimard's avatar
Xavier Guimard committed
586
	done ||true
Xavier Guimard's avatar
Xavier Guimard committed
587 588 589 590
	@$(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
591
	@# Handler
Xavier Guimard's avatar
Xavier Guimard committed
592
	@$(DIFF) lemonldap-ng-handler/lib/Lemonldap/NG/Handler $(DIFFPREFIX)/usr/share/perl5/Lemonldap/NG/Handler ||true
593
	@$(DIFF) lemonldap-ng-handler/example/scripts/purgeLocalCache $(DIFFPREFIX)/usr/share/lemonldap-ng/bin/purgeLocalCache ||true
Xavier Guimard's avatar
Xavier Guimard committed
594
	@# Common
Xavier Guimard's avatar
Xavier Guimard committed
595 596 597 598
	@$(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
599
	@# Manager
Xavier Guimard's avatar
Xavier Guimard committed
600 601 602 603
	@$(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
604
	@$(DIFF) lemonldap-ng-manager/example/notifications.pl $(DIFFPREFIX)/var/lib/lemonldap-ng/manager/notifications.pl ||true
605
	@$(DIFF) --ignore-matching-lines='set.*get.*\[2\]' lemonldap-ng-manager/example/scripts/lmConfigEditor $(DIFFPREFIX)/usr/share/lemonldap-ng/bin/lmConfigEditor ||true
Xavier Guimard's avatar
Xavier Guimard committed
606
	@for i in $(MANAGERSKINS); do \
Xavier Guimard's avatar
Xavier Guimard committed
607
		$(DIFF) -x 'jquery*' lemonldap-ng-manager/example/skins/$$i $(DIFFPREFIX)/usr/share/lemonldap-ng/manager-skins/$$i; \
Xavier Guimard's avatar
Xavier Guimard committed
608 609
	done ||true

610 611
default-diff:
	@# Portal
612
	@$(DIFF) lemonldap-ng-portal/lib/Lemonldap/NG/Portal /usr/local/share/perl/$(PERLVERSION)/Lemonldap/NG/Portal ||true
613 614 615
	@$(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
616 617
	@$(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
618
	@$(DIFF) lemonldap-ng-portal/example/metadata.pl $(LMPREFIX)/htdocs/portal/metadata.pl ||true
619
	@$(DIFF) lemonldap-ng-portal/example/cdc.pl $(LMPREFIX)/htdocs/portal/cdc.pl ||true
620
	@# Handler
621
	@$(DIFF) lemonldap-ng-handler/lib/Lemonldap/NG/Handler /usr/local/share/perl/$(PERLVERSION)/Lemonldap/NG/Handler ||true
622
	@$(DIFF) lemonldap-ng-handler/example/MyHandler.pm $(LMPREFIX)/handler/MyHandler.pm ||true
623
	@$(DIFF) lemonldap-ng-handler/example/MyHandlerZimbra.pm $(LMPREFIX)/handler/MyHandlerZimbra.pm ||true
Clément OUDOT's avatar
Clément OUDOT committed
624
	@$(DIFF) lemonldap-ng-handler/example/MyHandlerSympa.pm $(LMPREFIX)/handler/MyHandlerSympa.pm ||true
625 626
	@$(DIFF) lemonldap-ng-handler/example/MyHandlerSecureToken.pm $(LMPREFIX)/handler/MyHandlerSecureToken.pm ||true
	@$(DIFF) lemonldap-ng-handler/example/MyUpdateCookieHandler.pm $(LMPREFIX)/handler/MyUpdateCookieHandler.pm ||true
627
	@$(DIFF) lemonldap-ng-handler/example/MyHandlerAuthBasic.pm $(LMPREFIX)/handler/MyHandlerAuthBasic.pm ||true
628
	@$(DIFF) lemonldap-ng-handler/example/scripts/purgeLocalCache $(LMPREFIX)/bin/purgeLocalCache ||true
629
	@# Common
630 631
	@$(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
632 633 634
	@$(DIFF) lemonldap-ng-common/scripts/lmMigrateConfFiles2ini $(LMPREFIX)/bin/lmMigrateConfFiles2ini ||true
	@$(DIFF) lemonldap-ng-common/scripts/convertConfig $(LMPREFIX)/bin/convertConfig ||true
	@# Manager
635 636
	@$(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
637
	@$(DIFF) lemonldap-ng-manager/example/skins $(LMPREFIX)/htdocs/manager/skins ||true
638
	@$(DIFF) lemonldap-ng-manager/example/index.pl $(LMPREFIX)/htdocs/manager/index.pl ||true
639
	@$(DIFF) lemonldap-ng-manager/example/sessions.pl $(LMPREFIX)/htdocs/manager/sessions.pl ||true
640
	@$(DIFF) lemonldap-ng-manager/example/notifications.pl $(LMPREFIX)/htdocs/manager/notifications.pl ||true
641
	@$(DIFF) --ignore-matching-lines='set.*get.*\[2\]' lemonldap-ng-manager/example/scripts/lmConfigEditor $(LMPREFIX)/bin/lmConfigEditor ||true
642

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