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

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

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

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

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

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

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

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

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

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

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

451
postconf: postconf_hosts
452 453
	@echo "Post configuration done"

454 455
uninstall:	configure handler_uninstall portal_uninstall manager_uninstall

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

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

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

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

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

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

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

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

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

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

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

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

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

519
documentation:
520
	@cd doc/ && ../scripts/doc.pl
521

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

534 535 536
distclean:	clean

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

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

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

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

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

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

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

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

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

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

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

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