Makefile 25.5 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'`
Yadd's avatar
Yadd 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
Yadd's avatar
Yadd committed
12
COMPRESSSUFFIX=tar.gz
13 14 15 16 17
# Perl options
#PERLOPTIONS="INSTALLDIRS=vendor"
PERLOPTIONS=

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

Yadd's avatar
Yadd committed
27
EXAMPLEROOT=`pwd`/example
28 29

# Document roots for Apache VirtualHosts
Yadd's avatar
Yadd committed
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)
Yadd's avatar
Yadd committed
37 38
MANAGERSKINSDIR=$(MANAGERDIR)/skins
RMANAGERSKINSDIR=$(DESTDIR)/$(MANAGERSKINSDIR)
39
SESSIONSEXPLORERDIR=$(MANAGERDIR)
Yadd's avatar
Yadd committed
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
Yadd's avatar
Yadd committed
51 52
HANDLERDIR=$(LMPREFIX)/handler
RHANDLERDIR=$(DESTDIR)/$(HANDLERDIR)
53 54

# Configuration dir
Yadd's avatar
Yadd committed
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
Yadd's avatar
Yadd committed
63 64
FILECONFIGDIR=$(DATADIR)/conf
RFILECONFIGDIR=$(DESTDIR)/$(FILECONFIGDIR)
65 66

# Apache::Session::File storage dir
Yadd's avatar
Yadd committed
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
Yadd's avatar
Yadd committed
90
VERSION=`head -n1 changelog |sed -e 's/lemonldap-ng (//' -e 's/).*$$//'`
Yadd's avatar
Yadd 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

Yadd's avatar
Yadd committed
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

Yadd's avatar
Yadd committed
102 103
DIFFPREFIX=

104
all:	configure common handler manager portal
Yadd's avatar
Yadd committed
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
#
Yadd's avatar
Yadd committed
137

138 139 140
configure:	common_conf handler_conf portal_conf manager_conf

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

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

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

manager_conf:
Yadd's avatar
Yadd 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

Yadd's avatar
Yadd 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

Yadd's avatar
Yadd committed
189
extra_test:	all
Yadd's avatar
Yadd 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
#
Yadd's avatar
Yadd committed
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

Yadd's avatar
Yadd committed
205
install_handler_libs:	handler
206
	@$(MAKE) -C ${SRCHANDLERDIR} install
207

Yadd's avatar
Yadd committed
208
install_portal_libs:		portal
209
	@$(MAKE) -C ${SRCPORTALDIR} install
210

Yadd's avatar
Yadd committed
211
install_manager_libs:	manager
212
	@$(MAKE) -C ${SRCMANAGERDIR} install
213

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

Yadd's avatar
Yadd committed
217
install_bin:	install_conf_dir
218 219
	# Binary install
	@install -v -d $(RBINDIR)
Yadd's avatar
Yadd committed
220
	@cp --preserve=mode --remove-destination \
221
		${SRCHANDLERDIR}/example/scripts/purgeLocalCache \
Yadd's avatar
Yadd committed
222
		${SRCPORTALDIR}/example/scripts/purgeCentralCache \
223
		${SRCPORTALDIR}/example/scripts/buildPortalWSDL \
Yadd's avatar
Yadd committed
224
		${SRCCOMMONDIR}/scripts/convertConfig \
Yadd's avatar
Bugs :  
Yadd committed
225
		${SRCCOMMONDIR}/scripts/lmMigrateConfFiles2ini \
Yadd's avatar
Yadd committed
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
Yadd's avatar
Yadd 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
Yadd's avatar
Yadd 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
Yadd's avatar
Yadd committed
295
	@install -v -d ${RMANAGERDIR} ${RMANAGERSKINSDIR} \
296
		${RSESSIONSEXPLORERDIR} \
Yadd's avatar
Yadd 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}
Yadd's avatar
Yadd 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
Yadd's avatar
Yadd 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)
Yadd's avatar
Yadd 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 $(PORTALDIR)/captcha_output/
	@mkdir -p $(DATADIR)/captcha/data
	@chmod -R 777 $(DATADIR)/captcha $(PORTALDIR)/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 \
Yadd's avatar
Yadd committed
328 329
		[ -h $(RPORTALDIR)/skins/$$skin ] && rm -f $(RPORTALDIR)/skins/$$skin; \
		install -v -d $(RPORTALSKINSDIR)/$$skin; \
330
	done
Yadd's avatar
Yadd committed
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)
Yadd's avatar
Yadd committed
336
	@if [ "$(PORTALDIR)/skins/" != "$(PORTALSKINSDIR)/" ]; then \
337
		for skin in $$(ls lemonldap-ng-portal/example/skins/); do \
Yadd's avatar
Yadd committed
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
Clément OUDOT's avatar
 
Clément OUDOT committed
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 362
	@cp --remove-destination lemonldap-ng-handler/example/scripts/purgeLocalCache.cron.d $(RCRONDIR)/lemonldap-ng-handler
	@if [ ! "$(APACHEUSER)" ]; then \
363
		$(PERL) -i -pe 's#__APACHEUSER__#nobody#g;' $(RCRONDIR)/lemonldap-ng-handler; \
364 365 366 367
	else \
		$(PERL) -i -pe 's#__APACHEUSER__#$(APACHEUSER)#g;' $(RCRONDIR)/lemonldap-ng-handler; \
	fi
	@$(PERL) -i -pe 's#__BINDIR__#$(BINDIR)#g;' $(RCRONDIR)/lemonldap-ng-handler
368
	@rm -rf $$(find $(RHANDLERDIR) -type d -name .svn)
369 370

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

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

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

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

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

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

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

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

453 454
uninstall:	configure handler_uninstall portal_uninstall manager_uninstall

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

533 534 535
distclean:	clean

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

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

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

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

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

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

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

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

diff: debian-diff
Yadd's avatar
Yadd committed
575

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

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

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