Makefile 26.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
# LL::NG configuration storage dir
63 64
FILECONFIGDIR=$(DATADIR)/conf
RFILECONFIGDIR=$(DESTDIR)/$(FILECONFIGDIR)
65

66
# LL::NG sessions storage dir
67 68 69
APACHESESSIONFILEDIR=$(DATADIR)/sessions
RAPACHESESSIONFILEDIR=$(DESTDIR)/$(APACHESESSIONFILEDIR)
APACHESESSIONFILELOCKDIR=$(APACHESESSIONFILEDIR)/lock
70
RAPACHESESSIONFILELOCKDIR=$(DESTDIR)/$(APACHEPSESSIONFILELOCKDIR)
71

72 73 74 75 76 77 78
# LL::NG persistent sessions storage dir
APACHEPSESSIONFILEDIR=$(DATADIR)/psessions
RAPACHEPSESSIONFILEDIR=$(DESTDIR)/$(APACHEPSESSIONFILEDIR)
APACHEPSESSIONFILELOCKDIR=$(APACHEPSESSIONFILEDIR)/lock
RAPACHEPSESSIONFILELOCKDIR=$(DESTDIR)/$(APACHEPSESSIONFILELOCKDIR)

# LL::NG notifications storage dir
79 80
APACHEFILENOTIFDIR=$(DATADIR)/notifications
RFILENOTIFDIR=$(DESTDIR)/$(APACHEFILENOTIFDIR)
81

82
# Apache user/group
83 84 85
APACHEUSER=
APACHEGROUP=

86 87 88
# Apache version
APACHEVERSION=2

89
# DNS Domain for cookie and virtual hosts
90 91
DNSDOMAIN=example.com

92 93 94
# Virtual Host Listen IP and Port (*, *:80, ...)
VHOSTLISTEN=*:80

95
# Other
96
VERSION=`head -n1 changelog |sed -e 's/lemonldap-ng (//' -e 's/).*$$//'`
Xavier Guimard's avatar
Xavier Guimard committed
97 98
PORTALSKINS=`ls lemonldap-ng-portal/example/skins/`
MANAGERSKINS=`ls lemonldap-ng-manager/example/skins/`
99
DIFF=diff -aurN -x '*.bak' -x .svn -x '*.swp' --ignore-matching-lines='.*jquery.*' --ignore-matching-lines='.*lemonldap-ng\.ini.*'
100

101 102 103 104
SRCCOMMONDIR=lemonldap-ng-common
SRCHANDLERDIR=lemonldap-ng-handler
SRCPORTALDIR=lemonldap-ng-portal
SRCMANAGERDIR=lemonldap-ng-manager
105
EXAMPLELANG=en # For static Manager example only
Clément OUDOT's avatar
Clément OUDOT committed
106
ERASECONFIG=1 # Set to 0 if you do not want to replace your configuration
107

Xavier Guimard's avatar
Xavier Guimard committed
108 109
DIFFPREFIX=

110
all:	configure common handler manager portal
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
	@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
139

140 141 142
#
# Perl libraries configuration
#
143

144 145 146
configure:	common_conf handler_conf portal_conf manager_conf

common_conf:
Xavier Guimard's avatar
Xavier Guimard committed
147
	@cd ${SRCCOMMONDIR}; LMNGCONFFILE=$(STORAGECONFFILE) $(PERL) Makefile.PL $(PERLOPTIONS)
148 149 150
	@touch common_conf

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

portal_conf:
Xavier Guimard's avatar
Xavier Guimard committed
155
	@cd ${SRCPORTALDIR}; $(PERL) Makefile.PL $(PERLOPTIONS)
156 157 158
	@touch portal_conf

manager_conf:
Xavier Guimard's avatar
Xavier Guimard committed
159
	@cd ${SRCMANAGERDIR}; $(PERL) Makefile.PL $(PERLOPTIONS)
160
	@touch manager_conf
161

162 163 164
#
# Perl libraries make
#
165 166 167
common:		common_conf
	@$(MAKE) -C ${SRCCOMMONDIR}
	@touch common
168 169

handler:	handler_conf
170
	@$(MAKE) -C ${SRCHANDLERDIR}
171
	@touch handler
172 173

portal:		portal_conf
174
	@$(MAKE) -C ${SRCPORTALDIR}
175
	@touch portal
176 177

manager:	manager_conf
178
	@$(MAKE) -C ${SRCMANAGERDIR}
179
	@touch manager
180

Xavier Guimard's avatar
Xavier Guimard committed
181
test:		all common_test handler_test portal_test manager_test extra_test
182 183 184 185 186

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

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

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

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

Xavier Guimard's avatar
Xavier Guimard committed
195
extra_test:	all
Xavier Guimard's avatar
Xavier Guimard committed
196 197
	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

198 199 200 201
#
# INSTALL
#
install:	install_libs install_bin install_site
202

203 204 205
#
# Perl libraires install
#
206
install_libs:	common_install_libs install_handler_libs install_portal_libs install_manager_libs
207 208

common_install_libs:		common
209
	@$(MAKE) -C ${SRCCOMMONDIR} install
210

211
install_handler_libs:	handler
212
	@$(MAKE) -C ${SRCHANDLERDIR} install
213

214
install_portal_libs:		portal
215
	@$(MAKE) -C ${SRCPORTALDIR} install
216

217
install_manager_libs:	manager
218
	@$(MAKE) -C ${SRCMANAGERDIR} install
219

220
example:
Xavier Guimard's avatar
Xavier Guimard committed
221
	$(MAKE) install_site install_bin LMPREFIX=$(EXAMPLEROOT)
222

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

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

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

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

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

install_test_site:
380
	# Test site install
381 382
	@install -v -d $(RTESTDIR)
	@cp -pR --remove-destination _example/test/* $(RTESTDIR)
383
	@rm -rf $$(find $(RTESTDIR) -type d -name .svn)
Xavier Guimard's avatar
Xavier Guimard committed
384
	@$(PERL) -i -pe 's/__DNSDOMAIN__/$(DNSDOMAIN)/g' $(RTESTDIR)/index.pl
385
	@rm -rf $$(find $(RTESTDIR) -type d -name .svn)
386 387

install_examples_site:
388
	# Examples install
389
	@install -v -d $(REXAMPLESDIR)
390
	@for i in manager portal handler; do \
391 392
		cp -dpR --remove-destination lemonldap-ng-$$i/example $(REXAMPLESDIR)/$$i; \
	done
393
	@rm -rf $(REXAMPLESDIR)/portal/skins \
Xavier Guimard's avatar
Xavier Guimard committed
394
		$(REXAMPLESDIR)/manager/skins \
395
	@rm -rf $$(find $(REXAMPLESDIR) -type d -name .svn)
396
	@$(PERL) -i -pe 's#__SESSIONDIR__#$(APACHESESSIONFILEDIR)/#g;' $(REXAMPLESDIR)/portal/*.pl
397
	@$(PERL) -i -pe 's#__PSESSIONDIR__#$(APACHEPSESSIONFILEDIR)/#g;' $(REXAMPLESDIR)/portal/*.pl
398

399
install_doc_site:
400 401
	# Offline documentation install
	@rm -rf $(RDOCDIR)
402
	@install -v -d $(RDOCDIR)
Xavier Guimard's avatar
Xavier Guimard committed
403
	@cp -dR --remove-destination doc/* $(RDOCDIR)
404

405
install_conf_dir:	install_sessions_dir install_notif_dir
406
	# Configuration files install
407
	@install -v -d $(RCONFDIR) $(RFILECONFIGDIR) $(RTOOLSDIR)
Clément OUDOT's avatar
Clément OUDOT committed
408
	@if [ "$(ERASECONFIG)" -eq "1" ]; then \
409
		cp --remove-destination $(SRCCOMMONDIR)/$(CONFFILENAME) $(RCONFDIR); \
Xavier Guimard's avatar
Xavier Guimard committed
410
		$(PERL) -i -pe 's#^dirName\s*=\s*.*#dirName = $(FILECONFIGDIR)#g' $(RCONFDIR)/$(CONFFILENAME); \
Clément OUDOT's avatar
Clément OUDOT committed
411
	fi
412
	@cp _example/conf/lmConf-1 $(RFILECONFIGDIR)
Xavier Guimard's avatar
Xavier Guimard committed
413
	@$(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
414
	@$(PERL) -000 -i -pe "s#^(persistentStorageOptions\\n\\s+)'[^\\n]*?'\$$#\$${1}\'\\\$$data1 = {&39;Directory&39; => &39;$(APACHEPSESSIONFILEDIR)&39;,&39;LockDirectory&39; => &39;$(APACHEPSESSIONFILELOCKDIR)&39;};'#m" $(RFILECONFIGDIR)/lmConf-1
Xavier Guimard's avatar
Xavier Guimard committed
415
	@$(PERL) -i -pe 's/__DNSDOMAIN__/$(DNSDOMAIN)/g;\
416 417
		s#__SESSIONDIR__#$(APACHESESSIONFILEDIR)#g;\
		s#__NOTIFICATIONDIR__#$(APACHEFILENOTIFDIR)#g;' $(RFILECONFIGDIR)/lmConf-1
418 419 420 421 422 423 424 425 426
	@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
427
	@cp lemonldap-ng-common/tools/lmConfig.* lemonldap-ng-common/tools/apache-session-mysql.sql $(RTOOLSDIR)
428
	@cp lemonldap-ng-common/tools/sso.schema $(RTOOLSDIR)
429
	@rm -rf $$(find $(RCONFDIR) $(RFILECONFIGDIR) $(RTOOLSDIR) -type d -name .svn)
430 431

install_sessions_dir:
432
	@install -m 777 -v -d $(RAPACHESESSIONFILEDIR) $(RAPACHESESSIONFILELOCKDIR) $(RAPACHEPSESSIONFILEDIR) $(RAPACHEPSESSIONFILELOCKDIR)
433 434
	# Fix Apache::Session directories permissions
	@if [ "$(APACHEUSER)" != "" ]; then \
435
		chown $(APACHEUSER) $(RAPACHESESSIONFILEDIR) $(RAPACHESESSIONFILELOCKDIR) $(RAPACHEPSESSIONFILEDIR) $(RAPACHEPSESSIONFILELOCKDIR)|| exit 1; \
436
		if [ "$(APACHEGROUP)" != "" ]; then \
437
			chgrp $(APACHEGROUP) $(RAPACHESESSIONFILEDIR) $(RAPACHESESSIONFILELOCKDIR) $(RAPACHEPSESSIONFILEDIR) $(RAPACHEPSESSIONFILELOCKDIR) || exit 1; \
438
		fi; \
439
		chmod 770 $(RAPACHESESSIONFILEDIR) $(RAPACHESESSIONFILELOCKDIR) $(RAPACHEPSESSIONFILEDIR) $(RAPACHEPSESSIONFILELOCKDIR); \
440
	else \
441
		chmod 777 $(RAPACHESESSIONFILEDIR) $(RAPACHESESSIONFILELOCKDIR) $(RAPACHEPSESSIONFILEDIR) $(RAPACHEPSESSIONFILELOCKDIR); \
442 443
	fi

444 445 446 447 448 449 450 451 452 453 454 455 456
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

457
postconf_hosts:
Clément OUDOT's avatar
Clément OUDOT committed
458
	@cat ${CONFDIR}/for_etc_hosts >> /etc/hosts
459 460
	@echo "/etc/hosts was updated"

461
postconf: postconf_hosts
462 463
	@echo "Post configuration done"

464 465
uninstall:	configure handler_uninstall portal_uninstall manager_uninstall

466 467 468 469
common_uninstall:	common
	@$(MAKE) -C ${SRCCOMMONDIR} uninstall
	@rm -vf common_uninstall

470
handler_uninstall:	handler
471
	@$(MAKE) -C ${SRCHANDLERDIR} uninstall
472
	@rm -vf handler_uninstall
473 474

portal_uninstall:		portal
475
	@$(MAKE) -C ${SRCPORTALDIR} uninstall
476
	@rm -vf portal_uninstall
477 478

manager_uninstall:	manager
479
	@$(MAKE) -C ${SRCMANAGERDIR} uninstall
480
	@rm -vf manager_uninstall
481

482
dist:	clean
483 484 485 486
	@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
487
	@rm -rf lemonldap-ng-$(VERSION)/lemonldap-ng-$(VERSION)
Xavier Guimard's avatar
Xavier Guimard committed
488
	@$(COMPRESS) lemonldap-ng-$(VERSION).$(COMPRESSSUFFIX) lemonldap-ng-$(VERSION)
489
	@rm -rf lemonldap-ng-$(VERSION)
490

491
debian-dist:	dist
Xavier Guimard's avatar
Xavier Guimard committed
492 493 494 495
	@mv lemonldap-ng-$(VERSION).$(COMPRESSSUFFIX) lemonldap-ng_$(VERSION).orig.$(COMPRESSSUFFIX)

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

497 498 499 500 501 502 503 504
manifest:   configure
	@for i in ${SRCCOMMONDIR} ${SRCHANDLERDIR} ${SRCPORTALDIR} ${SRCMANAGERDIR}; do \
		cd $$i; \
		make manifest; \
		rm -vf MANIFEST.*; \
		cd -; \
	done

505
cpan:	clean configure common_cpan handler_cpan portal_cpan manager_cpan
Clément OUDOT's avatar
Clément OUDOT committed
506
	for i in Common Portal Handler Manager; do \
Xavier Guimard's avatar
Xavier Guimard committed
507
		$(UNCOMPRESS) Lemonldap-NG-$$i-*.$(COMPRESSSUFFIX) \
Clément OUDOT's avatar
Clément OUDOT committed
508
			$$($(LISTCOMPRESSED) Lemonldap-NG-$$i-*.$(COMPRESSSUFFIX) |grep META.yml); \
Xavier Guimard's avatar
Xavier Guimard committed
509
		mv Lemonldap-NG-$$i-*/META.yml lemonldap-ng-$$($(PERL) -e "print lc('$$i')")/; \
510
		rm -rf Lemonldap-NG-$$i*/; \
Xavier Guimard's avatar
Xavier Guimard committed
511
		done
512 513 514 515

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

handler_cpan:	handler_conf
518 519
	@$(MAKE) -C ${SRCHANDLERDIR} dist
	@mv ${SRCHANDLERDIR}/Lemonldap*.gz .
520 521

portal_cpan:		portal_conf
522 523
	@$(MAKE) -C ${SRCPORTALDIR} dist
	@mv ${SRCPORTALDIR}/Lemonldap*.gz .
524 525

manager_cpan:	manager_conf
526 527
	@$(MAKE) -C ${SRCMANAGERDIR} dist
	@mv ${SRCMANAGERDIR}/Lemonldap*.gz .
528

529
documentation:
530
	@cd doc/ && ../scripts/doc.pl
531

532
doxygen:	clean
Xavier Guimard's avatar
Xavier Guimard committed
533
	$(PERL) -i -pe 's/^(PROJECT_NUMBER\s*=\s*)\d.*$$/$${1}'$(VERSION)'/' Doxyfile
534 535 536 537 538 539
	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
540
	$(PERL) -i -pe 's/Graphical Class Hierarchy/Class Collaboration Graph/' doc/devel/html/inherits.html doc/devel/html/tree.html
541 542
	# 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
543

544 545 546
distclean:	clean

clean:		common_clean handler_clean portal_clean manager_clean
Xavier Guimard's avatar
Xavier Guimard committed
547
	@rm -f $$(find */ -name '*bak' -delete)
548
	@rm -rf $(EXAMPLEROOT) example/ doc/devel
Xavier Guimard's avatar
Xavier Guimard committed
549
	@rm -vf *gz *zip
Xavier Guimard's avatar
Xavier Guimard committed
550
	@rm -rf lemonldap-ng-$(VERSION)
Xavier Guimard's avatar
Xavier Guimard committed
551
	@echo "Cleaned"
552 553

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

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

portal_clean:
Xavier Guimard's avatar
Xavier Guimard committed
562
	@if test -e ${SRCPORTALDIR}/Makefile;then $(MAKE) -C ${SRCPORTALDIR} distclean;fi
563 564 565
	@rm -vf portal*

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

569
debian-packages: debian-dist
Xavier Guimard's avatar
Xavier Guimard committed
570
	mv lemonldap-ng_$(VERSION).orig.$(COMPRESSSUFFIX) /tmp/
571 572
	version=$(VERSION) && \
	cd /tmp/ && \
Xavier Guimard's avatar
Xavier Guimard committed
573
	rm -rf lemonldap-ng-$$version && \
Xavier Guimard's avatar
Xavier Guimard committed
574
	$(UNCOMPRESS) lemonldap-ng_$$version.orig.$(COMPRESSSUFFIX) && \
575
	cd lemonldap-ng-$$version && \
576
	export LOCALBUILD=1; debuild -us -uc -b --lintian-opts -i --lintian-opts -v
Xavier Guimard's avatar
Xavier Guimard committed
577 578 579

debian-install: debian-packages
	cd /tmp/lemonldap-ng-$(VERSION) && \
Xavier Guimard's avatar
Xavier Guimard committed
580 581 582 583 584 585
	$(SU) debi

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

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

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

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

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