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

3 4 5
# Prefix for packaging
DESTDIR=

6
PERL=$$(which perl)
Yadd's avatar
Yadd committed
7 8 9 10
SU=su -c
COMPRESS=tar czf
UNCOMPRESS=tar xzf
COMPRESSSUFFIX=tar.gz
11 12 13 14 15
# Perl options
#PERLOPTIONS="INSTALLDIRS=vendor"
PERLOPTIONS=

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

Yadd's avatar
Yadd committed
25
EXAMPLEROOT=`pwd`/example
26 27

# Document roots for Apache VirtualHosts
Yadd's avatar
Yadd committed
28 29 30 31 32 33 34
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
35 36
MANAGERSKINSDIR=$(MANAGERDIR)/skins
RMANAGERSKINSDIR=$(DESTDIR)/$(MANAGERSKINSDIR)
37
SESSIONSEXPLORERDIR=$(MANAGERDIR)
Yadd's avatar
Yadd committed
38 39 40 41 42 43 44 45 46 47 48
RSESSIONSEXPLORERDIR=$(DESTDIR)/$(SESSIONSEXPLORERDIR)
SESSIONSEXPLORERDATADIR=$(SESSIONSEXPLORERDIR)/images
RSESSIONSEXPLORERDATADIR=$(DESTDIR)/$(SESSIONSEXPLORERDATADIR)
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

# Apache user/group
73 74 75
APACHEUSER=
APACHEGROUP=

76 77 78
# Apache version
APACHEVERSION=2

79
# DNS Domain for cookie and virtual hosts
80 81
DNSDOMAIN=example.com

82
# LDAP parameters
83 84
LDAPHOST=localhost
LDAPPORT=389
Clément OUDOT's avatar
Clément OUDOT committed
85
LDAPSUFFIX=dc=example,dc=com
86

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

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

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

103 104 105 106 107
# Liberty Alliance support
WITHLA=0 # Set to 1 if you want to install Liberty Alliance portal (deprecated by SAML2 support)
LASPPORTALDIR=$(DOCUMENTROOT)/liberty-alliance-sp-portal
RLASPPORTALDIR=$(DESTDIR)/$(LASPPORTALDIR)

108
all:	configure common handler manager portal
Yadd's avatar
Yadd committed
109 110 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
	@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
137

138 139 140
#
# Perl libraries configuration
#
Yadd's avatar
Yadd committed
141

142 143 144
configure:	common_conf handler_conf portal_conf manager_conf

common_conf:
Yadd's avatar
Yadd committed
145
	@cd ${SRCCOMMONDIR}; LMNGCONFFILE=$(STORAGECONFFILE) $(PERL) Makefile.PL $(PERLOPTIONS)
146 147 148
	@touch common_conf

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

portal_conf:
Yadd's avatar
Yadd committed
153
	@cd ${SRCPORTALDIR}; $(PERL) Makefile.PL $(PERLOPTIONS)
154 155 156
	@touch portal_conf

manager_conf:
Yadd's avatar
Yadd committed
157
	@cd ${SRCMANAGERDIR}; $(PERL) Makefile.PL $(PERLOPTIONS)
158
	@touch manager_conf
159

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

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

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

manager:	manager_conf
176
	@$(MAKE) -C ${SRCMANAGERDIR}
177
	@touch manager
178

179 180 181 182 183 184
test:		common handler portal manager common_test handler_test portal_test manager_test

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

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

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

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

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

198 199 200
#
# Perl libraires install
#
Yadd's avatar
Yadd committed
201
install_libs:	common_install_libs install_handler_libs install_portal_libs install_manager_libs
202 203

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

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

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

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

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

Yadd's avatar
Yadd committed
218
install_bin:	install_conf_dir
219 220
	# Binary install
	@install -v -d $(RBINDIR)
Yadd's avatar
Yadd committed
221 222
	@cp --preserve=mode --remove-destination \
		${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
	chmod +x $(RBINDIR)/*
229 230 231 232

#
# SITE INSTALL
#
233
install_site:	install_manager_site install_portal_site install_handler_site install_test_site install_examples_site install_doc_site
234
	# Site install
235
	@install -v -d $(RCONFDIR)
Clément OUDOT's avatar
Clément OUDOT committed
236 237
	# Check if erase is wanted
	@if [ "$(ERASECONFIG)" -eq "1" ]; then \
238 239 240
		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); \
241 242
		cp --remove-destination _example/etc/for_etc_hosts $(RCONFDIR); \
	fi
Yadd's avatar
Yadd committed
243
	@$(PERL) -i -pe 's#__HANDLER__#${HANDLERDIR}/MyHandler.pm#; \
Clément OUDOT's avatar
Clément OUDOT committed
244 245 246 247
			s/__DNSDOMAIN__/$(DNSDOMAIN)/g; \
			s#__PORTALDIR__#$(PORTALDIR)/#g; \
			s#__MANAGERDIR__#$(MANAGERDIR)/#g; \
			s#__TESTDIR__#$(TESTDIR)/#g; \
248 249
			s#__VHOSTLISTEN__#$(VHOSTLISTEN)#g; \
			s#__DOCDIR__#$(DOCDIR)/#g;' $(RCONFDIR)/*apache*.conf
Yadd's avatar
Yadd committed
250
	@$(PERL) -i -pe 's/__DNSDOMAIN__/$(DNSDOMAIN)/g' $(RCONFDIR)/for_etc_hosts
251
	@echo
252
	@echo "LemonLDAP::NG v${VERSION} is installed with these parameters:"
253 254 255 256 257 258 259 260 261
	@echo "  - System configuration: ${CONFDIR}"
	@echo "  - DNS domain (for cookies and virtual hosts): ${DNSDOMAIN}"
	@echo "  - LDAP parameters:"
	@echo "    - Host: ${LDAPHOST}"
	@echo "    - Port: ${LDAPPORT}"
	@echo "    - Suffix: ${LDAPSUFFIX}"
	@echo
	@echo "To finish configuration:"
	@echo
262 263 264 265
	@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"
266
	@echo
267 268
	@echo "2 - Restart Apache:"
	@echo "      apache$(APACHEVERSION)ctl restart"
269
	@echo
270
	@echo "3 - Run 'make postconf' as root to update /etc/hosts if your DNS service does not known auth.$(DNSDOMAIN) and manager.$(DNSDOMAIN)"
271
	@echo
272 273
	@echo "4 - Use the manager from localhost at http://manager.${DNSDOMAIN}/ (after Apache restart) to modify LemonLDAP::NG configuration."
	@echo "      Warning: If you access http://manager.${DNSDOMAIN}/ from other host, modify first Apache Manager configuration to allow access from non local address."
274 275
	@echo
	@echo "5 - Try to connect to http://test1.${DNSDOMAIN}/ or http://test2.${DNSDOMAIN}/"
276
	@if [ ! "$(APACHEUSER)" ]; then \
277 278 279 280
		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
281 282 283

install_manager_site:	install_conf_dir
	# Manager install
Yadd's avatar
Yadd committed
284
	@install -v -d ${RMANAGERDIR} ${RMANAGERSKINSDIR} \
285
		${RSESSIONSEXPLORERDIR} $(RSESSIONSEXPLORERDATADIR) \
Yadd's avatar
Yadd committed
286 287 288 289 290 291 292 293 294 295 296 297 298
		$(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
	@find ${RSESSIONSEXPLORERDIR} -type l -name images -delete
	@cp -pR --remove-destination ${SRCMANAGERDIR}/example/index.pl ${RMANAGERDIR}
	@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; \
299
	fi
Yadd's avatar
Yadd committed
300
	@$(PERL) -i -pe 's/__DNSDOMAIN__/$(DNSDOMAIN)/g' $(RCONFDIR)/$(CONFFILENAME)
301
	# Sessions explorer install
302 303
	@cp -pR --remove-destination ${SRCMANAGERDIR}/example/sessions.pl $(RSESSIONSEXPLORERDIR)
	@cp -pR --remove-destination ${SRCMANAGERDIR}/example/images $(RSESSIONSEXPLORERDIR)
Yadd's avatar
Yadd committed
304 305
	@if [ "${SESSIONSEXPLORERDIR}/images/" != "${SESSIONSEXPLORERDATADIR}/" ]; then \
		mv -f ${RSESSIONSEXPLORERDIR}/images/* ${RSESSIONSEXPLORERDATADIR}; \
Yadd's avatar
Yadd committed
306 307
		rm -rf ${RMANAGERDIR}/images; \
		ln -s $$(echo ${SESSIONSEXPLORERDATADIR} | sed -e 's/\/$$//') ${RMANAGERDIR}/images; \
308
	fi
Yadd's avatar
Yadd committed
309
	@rm -rf $$(find ${RMANAGERDIR} ${RMANAGERSKINSDIR} \
310 311
		${RSESSIONSEXPLORERDIR} $(RSESSIONSEXPLORERDATADIR) \
		$(RCONFDIR) -type d -name .svn)
312 313 314 315

install_portal_site:	install_conf_dir
	# Portal install
	@install -v -d $(RPORTALDIR) $(RPORTALSKINSDIR) \
316
		$(RPORTALDIR)/skins/ \
317
		$(RCRONDIR) $(RCONFDIR)
318 319 320
	@if [ "$(WITHLA)" -eq "1" ]; then \
		install -v -d $(RLASPPORTALDIR); \
	fi
321
	@for skin in $$(ls lemonldap-ng-portal/example/skins/); do \
Yadd's avatar
Yadd committed
322 323
		[ -h $(RPORTALDIR)/skins/$$skin ] && rm -f $(RPORTALDIR)/skins/$$skin; \
		install -v -d $(RPORTALSKINSDIR)/$$skin; \
324
	done
Yadd's avatar
Yadd committed
325 326
	@cp -pR --remove-destination ${SRCPORTALDIR}/example/index_skin.pl ${RPORTALDIR}/index.pl
	@cp -pR --remove-destination ${SRCPORTALDIR}/example/error.pl ${RPORTALDIR}
327
	@cp -pR --remove-destination ${SRCPORTALDIR}/example/mail.pl ${RPORTALDIR}
Clément OUDOT's avatar
SAML:  
Clément OUDOT committed
328
	@cp -pR --remove-destination ${SRCPORTALDIR}/example/metadata.pl ${RPORTALDIR}
Yadd's avatar
Yadd committed
329 330 331
	@cp -pR --remove-destination ${SRCPORTALDIR}/example/apps ${RPORTALDIR}
	@cp -pR --remove-destination ${SRCPORTALDIR}/example/skins/* $(RPORTALSKINSDIR)
	@if [ "$(PORTALDIR)/skins/" != "$(PORTALSKINSDIR)/" ]; then \
332
		for skin in $$(ls lemonldap-ng-portal/example/skins/); do \
Yadd's avatar
Yadd committed
333 334
			rm -rf $(RPORTALDIR)/skins/$$skin/; \
			ln -s $(PORTALSKINSDIR)/$$skin $(RPORTALDIR)/skins/$$skin; \
335 336 337
		done; \
	fi
	# L-A portal install
338 339 340 341
	@if [ "$(WITHLA)" -eq "1" ]; then \
		cp -pR --remove-destination ${SRCPORTALDIR}/example/AuthLA/* $(RLASPPORTALDIR); \
		$(PERL) -i -pe 's#__DIR__#$(LASPPORTALDIR)/#g' $(RLASPPORTALDIR)/index.pl; \
	fi
342
	# Cron files
343
	@cp --remove-destination lemonldap-ng-portal/example/scripts/purgeCentralCache.cron.d $(RCRONDIR)/lemonldap-ng
344
	@if [ ! "$(APACHEUSER)" ]; then \
Yadd's avatar
Yadd committed
345
		$(PERL) -i -pe 's#__APACHEUSER__#root#g;' $(RCRONDIR)/lemonldap-ng; \
346
	else \
Yadd's avatar
Yadd committed
347
		$(PERL) -i -pe 's#__APACHEUSER__#$(APACHEUSER)#g;' $(RCRONDIR)/lemonldap-ng; \
348
	fi
Yadd's avatar
Yadd committed
349
	@$(PERL) -i -pe 's#__BINDIR__#$(BINDIR)#g;' $(RCRONDIR)/lemonldap-ng
350
	# Clean SVN files
351
	@rm -rf $$(find ${RPORTALDIR} $(RPORTALSKINSDIR) $(RLASPPORTALDIR) $(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
	@rm -rf $$(find $(RHANDLERDIR) -type d -name .svn)
358 359

install_test_site:
360
	# Test site install
361 362
	@install -v -d $(RTESTDIR)
	@cp -pR --remove-destination _example/test/* $(RTESTDIR)
363
	@rm -rf $$(find $(RTESTDIR) -type d -name .svn)
Yadd's avatar
Yadd committed
364
	@$(PERL) -i -pe 's/__DNSDOMAIN__/$(DNSDOMAIN)/g' $(RTESTDIR)/index.pl
365
	@rm -rf $$(find $(RTESTDIR) -type d -name .svn)
366 367

install_examples_site:
368
	# Examples install
369
	@install -v -d $(REXAMPLESDIR)
370
	@for i in manager portal handler; do \
371 372
		cp -dpR --remove-destination lemonldap-ng-$$i/example $(REXAMPLESDIR)/$$i; \
	done
Yadd's avatar
Yadd committed
373
	@rm -rf $(REXAMPLESDIR)/portal/skins \
Yadd's avatar
Yadd committed
374
		$(REXAMPLESDIR)/manager/skins \
Yadd's avatar
Yadd committed
375
		$(REXAMPLESDIR)/manager/images \
376
	@rm -rf $$(find $(REXAMPLESDIR) -type d -name .svn)
377 378 379
	@if [ "$(WITHLA)" -eq "1" ]; then \
		$(PERL) -i -pe 's#__DIR__#$(LASPPORTALDIR)#g' $(REXAMPLESDIR)/portal/AuthLA/index.pl; \
	fi
380
	@$(PERL) -i -pe 's#__SESSIONDIR__#$(APACHESESSIONFILEDIR)/#g;' $(REXAMPLESDIR)/portal/*.pl
381

382 383 384 385
install_doc_site:
	@install -v -d $(RDOCDIR)
	@cp -R --remove-destination doc/* $(RDOCDIR)

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

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

426
postconf_hosts:
Yadd's avatar
Yadd committed
427
	@cat ${SYSTEMCONFDIR}/for_etc_hosts >> /etc/hosts
428 429
	@echo "/etc/hosts was updated"

430
postconf: postconf_hosts
431 432
	@echo "Post configuration done"

433 434
uninstall:	configure handler_uninstall portal_uninstall manager_uninstall

435 436 437 438
common_uninstall:	common
	@$(MAKE) -C ${SRCCOMMONDIR} uninstall
	@rm -vf common_uninstall

439
handler_uninstall:	handler
440
	@$(MAKE) -C ${SRCHANDLERDIR} uninstall
441
	@rm -vf handler_uninstall
442 443

portal_uninstall:		portal
444
	@$(MAKE) -C ${SRCPORTALDIR} uninstall
445
	@rm -vf portal_uninstall
446 447

manager_uninstall:	manager
448
	@$(MAKE) -C ${SRCMANAGERDIR} uninstall
449
	@rm -vf manager_uninstall
450

451
dist:	clean
452
	@mkdir -p lemonldap-ng-$(VERSION)
453
	@- cp -pR lemonldap-ng-common/ lemonldap-ng-manager/ lemonldap-ng-portal/ lemonldap-ng-handler/ * lemonldap-ng-$(VERSION)
454
	@- dir=lemonldap-ng-$(VERSION); find $$dir -name .svn -exec rm -rf {} \; 2>/dev/null
455
	@- find $$dir -name '*.bak' -delete
456
	@rm -rf lemonldap-ng-$(VERSION)/lemonldap-ng-$(VERSION)
Yadd's avatar
Yadd committed
457
	@$(COMPRESS) lemonldap-ng-$(VERSION).$(COMPRESSSUFFIX) lemonldap-ng-$(VERSION)
458
	@rm -rf lemonldap-ng-$(VERSION)
459

460
debian-dist:	dist
Yadd's avatar
Yadd committed
461 462 463 464
	@mv lemonldap-ng-$(VERSION).$(COMPRESSSUFFIX) lemonldap-ng_$(VERSION).orig.$(COMPRESSSUFFIX)

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

Yadd's avatar
Yadd committed
466 467 468 469 470 471 472 473
manifest:   configure
	@for i in ${SRCCOMMONDIR} ${SRCHANDLERDIR} ${SRCPORTALDIR} ${SRCMANAGERDIR}; do \
		cd $$i; \
		make manifest; \
		rm -vf MANIFEST.*; \
		cd -; \
	done

474
cpan:	clean configure common_cpan handler_cpan portal_cpan manager_cpan
Yadd's avatar
Yadd committed
475 476 477
	@for i in Common Portal Handler Manager; do \
		$(UNCOMPRESS) Lemonldap-NG-$$i-*.$(COMPRESSSUFFIX) \
			$$($(COMPRESS) tzf Lemonldap-NG-$$i-*.$(COMPRESSSUFFIX) |grep META.yml); \
Yadd's avatar
Yadd committed
478
		mv Lemonldap-NG-$$i-*/META.yml lemonldap-ng-$$($(PERL) -e "print lc('$$i')")/; \
Yadd's avatar
Yadd committed
479
		rm -rf Lemonldap-NG-$$i*/; \
Yadd's avatar
Yadd committed
480
		done
481 482 483 484

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

handler_cpan:	handler_conf
487 488
	@$(MAKE) -C ${SRCHANDLERDIR} dist
	@mv ${SRCHANDLERDIR}/Lemonldap*.gz .
489 490

portal_cpan:		portal_conf
491 492
	@$(MAKE) -C ${SRCPORTALDIR} dist
	@mv ${SRCPORTALDIR}/Lemonldap*.gz .
493 494

manager_cpan:	manager_conf
495 496
	@$(MAKE) -C ${SRCMANAGERDIR} dist
	@mv ${SRCMANAGERDIR}/Lemonldap*.gz .
497

Yadd's avatar
Yadd committed
498
sub_static_example: install_site
Yadd's avatar
Yadd committed
499 500 501
	mkdir -p ${EXAMPLEROOT}/static
	cd ${EXAMPLEROOT}/static/;cp -a ../manager/{skins} .;cd -
	../scripts/make_static_example.pl ${DESTMANAGERDIR}/index.pl ${SCRIPTSDIR}/static/index.html $(EXAMPLELANG)
502

Yadd's avatar
Yadd committed
503
static_example:
Yadd's avatar
Yadd committed
504
	@$(MAKE) sub_static_example LMPREFIX=$(EXAMPLEROOT)
Yadd's avatar
Yadd committed
505

506
documentation:
507
	@cd doc/ && ../scripts/doc.pl
508

509
doxygen:	clean
Yadd's avatar
Yadd committed
510
	$(PERL) -i -pe 's/^(PROJECT_NUMBER\s*=\s*)\d.*$$/$${1}'$(VERSION)'/' Doxyfile
511 512 513 514 515 516
	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
517
	$(PERL) -i -pe 's/Graphical Class Hierarchy/Class Collaboration Graph/' doc/devel/html/inherits.html doc/devel/html/tree.html
518

519 520 521
distclean:	clean

clean:		common_clean handler_clean portal_clean manager_clean
Yadd's avatar
Yadd committed
522
	@rm -f $$(find */ -name '*bak' -delete)
Yadd's avatar
Yadd committed
523
	@rm -rf $(EXAMPLEROOT) example/ doc/devel
Yadd's avatar
Yadd committed
524 525
	@rm -vf *gz *zip
	@echo "Cleaned"
526 527

common_clean:
Yadd's avatar
Yadd committed
528
	@if test -e ${SRCCOMMONDIR}/Makefile;then $(MAKE) -C ${SRCCOMMONDIR} distclean;fi
529 530 531
	@rm -vf common*

handler_clean:
Yadd's avatar
Yadd committed
532
	@if test -e ${SRCHANDLERDIR}/Makefile;then $(MAKE) -C ${SRCHANDLERDIR} distclean;fi
533 534 535
	@rm -vf handler*

portal_clean:
Yadd's avatar
Yadd committed
536
	@if test -e ${SRCPORTALDIR}/Makefile;then $(MAKE) -C ${SRCPORTALDIR} distclean;fi
537 538 539
	@rm -vf portal*

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

543
debian-packages: debian-dist
Yadd's avatar
Yadd committed
544
	mv lemonldap-ng_$(VERSION).orig.$(COMPRESSSUFFIX) /tmp/
545 546
	version=$(VERSION) && \
	cd /tmp/ && \
Yadd's avatar
Yadd committed
547
	rm -rf lemonldap-ng-$$version && \
Yadd's avatar
Yadd committed
548
	$(UNCOMPRESS) lemonldap-ng_$$version.orig.$(COMPRESSSUFFIX) && \
549
	cd lemonldap-ng-$$version && \
Yadd's avatar
Yadd committed
550 551 552 553
	export LOCALBUILD=1; debuild -us -uc

debian-install: debian-packages
	cd /tmp/lemonldap-ng-$(VERSION) && \
Yadd's avatar
Yadd committed
554 555 556 557 558 559
	$(SU) debi

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

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

Yadd's avatar
Yadd committed
561
debian-diff:
Yadd's avatar
Yadd committed
562 563 564 565 566 567 568
	@# Portal
	@$(DIFF) lemonldap-ng-portal/lib/Lemonldap/NG/Portal /usr/share/perl5/Lemonldap/NG/Portal ||true
	@$(DIFF) lemonldap-ng-portal/example/scripts/purgeCentralCache /usr/share/lemonldap-ng/bin/purgeCentralCache ||true
	@$(DIFF) lemonldap-ng-portal/example/scripts/buildPortalWSDL /usr/share/lemonldap-ng/bin/buildPortalWSDL ||true
	@for i in $(PORTALSKINS); do \
		$(DIFF) -x 'jquery*' lemonldap-ng-portal/example/skins/$$i /usr/share/lemonldap-ng/portal-skins/$$i; \
	done ||true
Clément OUDOT's avatar
Portal:  
Clément OUDOT committed
569 570 571
	@$(DIFF) lemonldap-ng-portal/example/index_skin.pl /var/lib/lemonldap-ng/portal/index.pl ||true
	@$(DIFF) lemonldap-ng-portal/example/error.pl /var/lib/lemonldap-ng/portal/error.pl ||true
	@$(DIFF) lemonldap-ng-portal/example/mail.pl /var/lib/lemonldap-ng/portal/mail.pl ||true
Clément OUDOT's avatar
SAML:  
Clément OUDOT committed
572
	@$(DIFF) lemonldap-ng-portal/example/metadata.pl /var/lib/lemonldap-ng/portal/metadata.pl ||true
Yadd's avatar
Yadd committed
573 574 575 576 577 578 579 580 581 582 583
	@# Handler
	@$(DIFF) lemonldap-ng-handler/lib/Lemonldap/NG/Handler /usr/share/perl5/Lemonldap/NG/Handler ||true
	@# Common
	@$(DIFF) lemonldap-ng-common/lib/Lemonldap/NG/Common /usr/share/perl5/Lemonldap/NG/Common ||true
	@$(DIFF) lemonldap-ng-common/lib/Lemonldap/NG/Common.pm /usr/share/perl5/Lemonldap/NG/Common.pm ||true
	@$(DIFF) lemonldap-ng-common/scripts/lmMigrateConfFiles2ini /usr/share/lemonldap-ng/bin/lmMigrateConfFiles2ini ||true
	@$(DIFF) lemonldap-ng-common/scripts/convertConfig /usr/share/lemonldap-ng/bin/convertConfig ||true
	@# Manager
	@$(DIFF) lemonldap-ng-manager/lib/Lemonldap/NG/Manager /usr/share/perl5/Lemonldap/NG/Manager ||true
	@$(DIFF) lemonldap-ng-manager/lib/Lemonldap/NG/Manager.pm /usr/share/perl5/Lemonldap/NG/Manager.pm ||true
	@$(DIFF) lemonldap-ng-manager/example/images /usr/share/lemonldap-ng/sessions-explorer-imgs ||true
584 585
	@$(DIFF) lemonldap-ng-manager/example/index.pl /var/lib/lemonldap-ng/manager/index.pl ||true
	@$(DIFF) lemonldap-ng-manager/example/sessions.pl /var/lib/lemonldap-ng/manager/sessions.pl ||true
Yadd's avatar
Yadd committed
586
	@for i in $(MANAGERSKINS); do \
Yadd's avatar
Yadd committed
587 588 589
		$(DIFF) -x 'jquery*' lemonldap-ng-manager/example/skins/$$i /usr/share/lemonldap-ng/manager-skins/$$i; \
	done ||true

590 591 592 593 594 595
default-diff:
	@# Portal
	@$(DIFF) lemonldap-ng-portal/lib/Lemonldap/NG/Portal /usr/local/share/perl/5.10.0/Lemonldap/NG/Portal ||true
	@$(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
596 597 598
	@$(DIFF) lemonldap-ng-portal/example/index_skin.pl $(LMPREFIX)/htdocs/portal/index.pl ||true
	@$(DIFF) lemonldap-ng-portal/example/error.pl $(LMPREFIX)/htdocs/portal/error.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
599
	@$(DIFF) lemonldap-ng-portal/example/metadata.pl $(LMPREFIX)/htdocs/portal/metadata.pl ||true
600 601 602 603 604 605 606 607 608 609 610 611 612
	@# Handler
	@$(DIFF) lemonldap-ng-handler/lib/Lemonldap/NG/Handler /usr/local/share/perl/5.10.0/Lemonldap/NG/Handler ||true
	@$(DIFF) lemonldap-ng-handler/example/MyHandler.pm $(LMPREFIX)/handler/MyHandler.pm ||true
	@# Common
	@$(DIFF) lemonldap-ng-common/lib/Lemonldap/NG/Common /usr/local/share/perl/5.10.0/Lemonldap/NG/Common ||true
	@$(DIFF) lemonldap-ng-common/lib/Lemonldap/NG/Common.pm /usr/local/share/perl/5.10.0/Lemonldap/NG/Common.pm ||true
	@$(DIFF) lemonldap-ng-common/scripts/lmMigrateConfFiles2ini $(LMPREFIX)/bin/lmMigrateConfFiles2ini ||true
	@$(DIFF) lemonldap-ng-common/scripts/convertConfig $(LMPREFIX)/bin/convertConfig ||true
	@# Manager
	@$(DIFF) lemonldap-ng-manager/lib/Lemonldap/NG/Manager /usr/local/share/perl/5.10.0/Lemonldap/NG/Manager ||true
	@$(DIFF) lemonldap-ng-manager/lib/Lemonldap/NG/Manager.pm /usr/local/share/perl/5.10.0/Lemonldap/NG/Manager.pm ||true
	@$(DIFF) lemonldap-ng-manager/example/images $(LMPREFIX)/htdocs/manager/images ||true
	@$(DIFF) lemonldap-ng-manager/example/skins $(LMPREFIX)/htdocs/manager/skins ||true
613
	@$(DIFF) lemonldap-ng-manager/example/index.pl $(LMPREFIX)/htdocs/manager/index.pl ||true
614 615
	@$(DIFF) lemonldap-ng-manager/example/sessions.pl $(LMPREFIX)/htdocs/manager/sessions.pl ||true

Yadd's avatar
Yadd committed
616 617 618 619
tidy: clean
	find lemon*/ -type f -name '*.pm' -exec perltidy -b {} \;
	find lemon*/ -name '*.bak' -delete