Makefile 31.6 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
MANAGERSITEDIR=$(MANAGERDIR)
Xavier Guimard's avatar
Xavier Guimard committed
38
RMANAGERSITEDIR=$(DESTDIR)/$(MANAGERSITEDIR)
39 40
MANAGERSTATICDIR=$(MANAGERSITEDIR)/static
RMANAGERSTATICDIR=$(DESTDIR)/$(MANAGERSTATICDIR)
Xavier Guimard's avatar
Xavier Guimard committed
41
MANAGERRELATIVESTATICDIR=/static
42 43 44 45
MANAGERPSGIDIR=$(MANAGERSITEDIR)/psgi
RMANAGERPSGIDIR=$(DESTDIR)/$(MANAGERPSGIDIR)
MANAGERTEMPLATESDIR=$(MANAGERSITEDIR)/templates
RMANAGERTEMPLATESDIR=$(DESTDIR)/$(MANAGERTEMPLATESDIR)
46
DOCDIR=$(DOCUMENTROOT)
47
RDOCDIR=$(DESTDIR)/$(DOCDIR)
48 49 50
DEFDOCDIR=$(DOCUMENTROOT)/doc
RDEFDOCDIR=$(DESTDIR)/$(DEFDOCDIR)
FRDOCDIR=$(DOCUMENTROOT)/fr-doc
51 52 53 54 55 56
TESTDIR=$(DOCUMENTROOT)/test
RTESTDIR=$(DESTDIR)/$(TESTDIR)
EXAMPLESDIR=$(LMPREFIX)/examples
REXAMPLESDIR=$(DESTDIR)/$(EXAMPLESDIR)
TOOLSDIR=$(LMPREFIX)/tools
RTOOLSDIR=$(DESTDIR)/$(TOOLSDIR)
57 58

# Handler dir
59 60
HANDLERDIR=$(LMPREFIX)/handler
RHANDLERDIR=$(DESTDIR)/$(HANDLERDIR)
61 62

# Configuration dir
63 64 65 66
CONFDIR=$(LMPREFIX)/etc
RCONFDIR=$(DESTDIR)/$(CONFDIR)
CRONDIR=$(LMPREFIX)/etc/cron.d
RCRONDIR=$(DESTDIR)/$(CRONDIR)
67 68
CONFFILENAME=lemonldap-ng.ini
STORAGECONFFILE=$(CONFDIR)/$(CONFFILENAME)
69

70
# LL::NG configuration storage dir
71 72
FILECONFIGDIR=$(DATADIR)/conf
RFILECONFIGDIR=$(DESTDIR)/$(FILECONFIGDIR)
73

74
# LL::NG sessions storage dir
75 76 77
APACHESESSIONFILEDIR=$(DATADIR)/sessions
RAPACHESESSIONFILEDIR=$(DESTDIR)/$(APACHESESSIONFILEDIR)
APACHESESSIONFILELOCKDIR=$(APACHESESSIONFILEDIR)/lock
78
RAPACHESESSIONFILELOCKDIR=$(DESTDIR)/$(APACHESESSIONFILELOCKDIR)
79

80 81 82 83 84 85 86
# LL::NG persistent sessions storage dir
APACHEPSESSIONFILEDIR=$(DATADIR)/psessions
RAPACHEPSESSIONFILEDIR=$(DESTDIR)/$(APACHEPSESSIONFILEDIR)
APACHEPSESSIONFILELOCKDIR=$(APACHEPSESSIONFILEDIR)/lock
RAPACHEPSESSIONFILELOCKDIR=$(DESTDIR)/$(APACHEPSESSIONFILELOCKDIR)

# LL::NG notifications storage dir
87 88
APACHEFILENOTIFDIR=$(DATADIR)/notifications
RFILENOTIFDIR=$(DESTDIR)/$(APACHEFILENOTIFDIR)
89

90 91
# LL::NG captcha dir
CAPTCHADIR=$(DATADIR)/captcha
92 93
RCAPTCHADIR=$(DESTDIR)/$(CAPTCHADIR)

94
# Apache user/group
95 96 97
APACHEUSER=
APACHEGROUP=

98
# Apache version
99
APACHEVERSION=2.X
100

101
# DNS Domain for cookie and virtual hosts
102 103
DNSDOMAIN=example.com

104 105
# Virtual Host Listen IP and Port (*, *:80, ...)
VHOSTLISTEN=*:80
106
WEBSERVERPORT=19876
107

108
# Other
109
VERSION=`head -n1 changelog |sed -e 's/lemonldap-ng (//' -e 's/).*$$//'`
Xavier Guimard's avatar
Xavier Guimard committed
110
PORTALSKINS=`ls lemonldap-ng-portal/example/skins/`
111
DIFF=diff -aurN -x '*.bak' -x .svn -x '*.swp' --ignore-matching-lines='.*jquery.*' --ignore-matching-lines='.*lemonldap-ng\.ini.*'
112

113 114 115 116
SRCCOMMONDIR=lemonldap-ng-common
SRCHANDLERDIR=lemonldap-ng-handler
SRCPORTALDIR=lemonldap-ng-portal
SRCMANAGERDIR=lemonldap-ng-manager
117
EXAMPLELANG=en # For static Manager example only
Clément OUDOT's avatar
Clément OUDOT committed
118
ERASECONFIG=1 # Set to 0 if you do not want to replace your configuration
119

Xavier Guimard's avatar
Xavier Guimard committed
120 121
DIFFPREFIX=

122
all:	configure common handler manager portal
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
	@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 :"
148
	@echo "   - install_doc_site      ($(DEFDOCDIR))"
149 150
	@echo "   - install_examples_site ($(EXAMPLESDIR))"
	@echo
Xavier Guimard's avatar
Xavier Guimard committed
151
	@echo "Other languages documentation (fr only for now)"
152 153
	@echo " - fr-doc                  (needs OmegaT)"
	@echo " - install_fr_doc_site"
Xavier Guimard's avatar
Xavier Guimard committed
154
	@echo
155

156 157 158
#
# Perl libraries configuration
#
159

160 161 162 163 164
json:	manager_json

manager_json:
	@cd lemonldap-ng-manager && ./scripts/jsongenerator.pl && cd -

165 166 167
configure:	common_conf handler_conf portal_conf manager_conf

common_conf:
Xavier Guimard's avatar
Xavier Guimard committed
168
	@cd ${SRCCOMMONDIR}; LMNGCONFFILE=$(STORAGECONFFILE) $(PERL) Makefile.PL $(PERLOPTIONS)
169 170 171
	@touch common_conf

handler_conf:
Xavier Guimard's avatar
Xavier Guimard committed
172
	@cd ${SRCHANDLERDIR}; $(PERL) Makefile.PL $(PERLOPTIONS)
173 174 175
	@touch handler_conf

portal_conf:
Xavier Guimard's avatar
Xavier Guimard committed
176
	@cd ${SRCPORTALDIR}; $(PERL) Makefile.PL $(PERLOPTIONS)
177 178 179
	@touch portal_conf

manager_conf:
Xavier Guimard's avatar
Xavier Guimard committed
180
	@cd ${SRCMANAGERDIR}; $(PERL) Makefile.PL $(PERLOPTIONS)
181
	@touch manager_conf
182

183 184 185
#
# Perl libraries make
#
186 187 188
common:		common_conf
	@$(MAKE) -C ${SRCCOMMONDIR}
	@touch common
189

Xavier Guimard's avatar
Xavier Guimard committed
190
handler:	handler_conf common
191
	@$(MAKE) -C ${SRCHANDLERDIR}
192
	@touch handler
193

Xavier Guimard's avatar
Xavier Guimard committed
194
portal:		portal_conf common
195
	@$(MAKE) -C ${SRCPORTALDIR}
196
	@touch portal
197

Xavier Guimard's avatar
Xavier Guimard committed
198
manager:	manager_conf handler
199
	@$(MAKE) -C ${SRCMANAGERDIR}
200
	@touch manager
201

Xavier Guimard's avatar
Xavier Guimard committed
202
test:		all common_test handler_test portal_test manager_test extra_test
203 204 205 206

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

Xavier Guimard's avatar
Xavier Guimard committed
207
handler_test:	handler
208
	@$(MAKE) -C ${SRCHANDLERDIR} test FULLPERL="$(PERL) -I../${SRCCOMMONDIR}/blib/lib/"
209

Xavier Guimard's avatar
Xavier Guimard committed
210
portal_test:	portal
211
	@$(MAKE) -C ${SRCPORTALDIR} test FULLPERL="$(PERL) -I../${SRCCOMMONDIR}/blib/lib/ -I../${SRCHANDLERDIR}/blib/lib/"
212

Xavier Guimard's avatar
Xavier Guimard committed
213
manager_test:	manager
214
	@$(MAKE) -C ${SRCMANAGERDIR} test FULLPERL="$(PERL) -I../${SRCCOMMONDIR}/blib/lib/ -I../${SRCHANDLERDIR}/blib/lib/"
215

Xavier Guimard's avatar
Xavier Guimard committed
216
extra_test:	all
217
	cd ${SRCPORTALDIR} && prove -b -I ../lemonldap-ng-common/blib/lib -I ../lemonldap-ng-handler/blib/lib -I../${SRCPORTALDIR}/blib/lib/ xt
218
#	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
Xavier Guimard's avatar
Xavier Guimard committed
219

220 221 222 223
e2e_test:	all prepare_test_server start_web_server launch_protractor stop_web_server

prepare_test_server:
	@mkdir -p e2e-tests/conf/lock
224 225 226
	$(MAKE) install_webserver_conf \
		RCONFDIR=e2e-tests/conf \
		ERASECONFIG=1 \
227
		VHOSTLISTEN='*:$(WEBSERVERPORT)' \
228 229 230 231 232
		PORTALDIR=`pwd`/lemonldap-ng-portal/example \
		MANAGERDIR=`pwd`/lemonldap-ng-manager/site \
		MANAGERPSGIDIR=`pwd`/e2e-tests \
		DEFDOCDIR=`pwd`/doc \
		FRDOCDIR=`pwd`/po-doc/fr
233
	cp e2e-tests/lmConf-1.js e2e-tests/lemonldap-ng.ini e2e-tests/env.conf e2e-tests/conf/
234
	perl -i -pe 'BEGIN{$$p=`pwd`;chomp $$p}s#__pwd__#$$p#;s/__port__/$(WEBSERVERPORT)/' e2e-tests/conf/lemonldap-ng.ini e2e-tests/conf/lmConf-1.js e2e-tests/conf/env.conf
235 236

start_web_server: prepare_test_server
237
	# Clean old server
238
	-@[ -e e2e-tests/conf/apache2.pid ] && kill `cat e2e-tests/conf/apache2.pid` && sleep 1
239
	# Start web server (designed for Debian, path may be broken else)
240 241 242
	@LLNG_DEFAULTCONFFILE=`pwd`/e2e-tests/conf/lemonldap-ng.ini /usr/sbin/apache2 -d `pwd`/e2e-tests -f apache2.conf -k start

launch_protractor:
243
	# Start e2e tests
Xavier Guimard's avatar
Xavier Guimard committed
244 245
	# NB: you must have protractor installed (using npm install -g protractor)
	# and have run update-webdriver at least once
246
	@WEBSERVERPORT=$(WEBSERVERPORT) protractor e2e-tests/protractor-conf.js
247 248 249

stop_web_server:
	# Stop web server
250
	@kill `cat e2e-tests/conf/apache2.pid`
251
	# Clean
252
	@rm -rf e2e-tests/conf
253

254 255
restart_web_server: start_web_server

256 257 258 259
#
# INSTALL
#
install:	install_libs install_bin install_site
260

261 262 263
#
# Perl libraires install
#
264
install_libs:	common_install_libs install_handler_libs install_portal_libs install_manager_libs
265 266

common_install_libs:		common
267
	@$(MAKE) -C ${SRCCOMMONDIR} install
268

269
install_handler_libs:	handler
270
	@$(MAKE) -C ${SRCHANDLERDIR} install
271

272
install_portal_libs:		portal
273
	@$(MAKE) -C ${SRCPORTALDIR} install
274

275
install_manager_libs:	manager
276
	@$(MAKE) -C ${SRCMANAGERDIR} install
277

278
example:
Xavier Guimard's avatar
Xavier Guimard committed
279
	$(MAKE) install_site install_bin LMPREFIX=$(EXAMPLEROOT)
280

Xavier Guimard's avatar
Xavier Guimard committed
281
install_bin:	install_conf_dir
282 283
	# Binary install
	@install -v -d $(RBINDIR)
Xavier Guimard's avatar
Xavier Guimard committed
284
	@cp -f\
285
		${SRCHANDLERDIR}/example/scripts/purgeLocalCache \
286
		${SRCPORTALDIR}/example/scripts/purgeCentralCache \
287
		${SRCPORTALDIR}/example/scripts/buildPortalWSDL \
Xavier Guimard's avatar
Xavier Guimard committed
288
		${SRCCOMMONDIR}/scripts/convertConfig \
Xavier Guimard's avatar
Xavier Guimard committed
289
		${SRCCOMMONDIR}/scripts/lmMigrateConfFiles2ini \
290
		${SRCCOMMONDIR}/scripts/rotateOidcKeys \
Xavier Guimard's avatar
Xavier Guimard committed
291 292
		${SRCMANAGERDIR}/scripts/lmConfigEditor \
		${SRCMANAGERDIR}/scripts/lemonldap-ng-cli \
293
			$(RBINDIR)
294 295
	@if [ ! "$(APACHEUSER)" ]; then \
		$(PERL) -i -pe 's#__APACHEUSER__#nobody#g;' $(RBINDIR)/lmConfigEditor; \
296
		$(PERL) -i -pe 's#__APACHEUSER__#nobody#g;' $(RBINDIR)/lemonldap-ng-cli; \
297 298
	else \
		$(PERL) -i -pe 's#__APACHEUSER__#$(APACHEUSER)#g;' $(RBINDIR)/lmConfigEditor; \
299
		$(PERL) -i -pe 's#__APACHEUSER__#$(APACHEUSER)#g;' $(RBINDIR)/lemonldap-ng-cli; \
300 301 302
	fi
	@if [ ! "$(APACHEGROUP)" ]; then \
		$(PERL) -i -pe 's#__APACHEGROUP__#nobody#g;' $(RBINDIR)/lmConfigEditor; \
303
		$(PERL) -i -pe 's#__APACHEGROUP__#nobody#g;' $(RBINDIR)/lemonldap-ng-cli; \
304 305
	else \
		$(PERL) -i -pe 's#__APACHEGROUP__#$(APACHEGROUP)#g;' $(RBINDIR)/lmConfigEditor; \
306
		$(PERL) -i -pe 's#__APACHEGROUP__#$(APACHEGROUP)#g;' $(RBINDIR)/lemonldap-ng-cli; \
307
	fi
308
	@chmod +x $(RBINDIR)/*
309 310 311 312

#
# SITE INSTALL
#
313
install_site:	install_manager_site install_portal_site install_handler_site install_test_site install_examples_site install_doc_site install_webserver_conf
314
	# Site install
315
	@install -v -d $(RCONFDIR)
Clément OUDOT's avatar
Clément OUDOT committed
316 317
	# Check if erase is wanted
	@if [ "$(ERASECONFIG)" -eq "1" ]; then \
Xavier Guimard's avatar
Xavier Guimard committed
318
		cp -f _example/etc/for_etc_hosts $(RCONFDIR); \
319
	fi
Xavier Guimard's avatar
Xavier Guimard committed
320
	@$(PERL) -i -pe 's/__DNSDOMAIN__/$(DNSDOMAIN)/g' $(RCONFDIR)/for_etc_hosts
321
	# Fix a lost of rights on the main directory
Xavier Guimard's avatar
Xavier Guimard committed
322
	@chmod 755 $(RBINDIR) $(RDOCUMENTROOT) $(REXAMPLESDIR) $(RHANDLERDIR) $(RPORTALSKINSDIR) $(RMANAGERSITEDIR) $(RTOOLSDIR) $(RCONFDIR) $(RDATADIR)
323
	@echo
324
	@echo "LemonLDAP::NG v${VERSION} is installed with these parameters:"
325 326 327 328 329
	@echo "  - System configuration: ${CONFDIR}"
	@echo "  - DNS domain (for cookies and virtual hosts): ${DNSDOMAIN}"
	@echo
	@echo "To finish configuration:"
	@echo
330 331 332 333
	@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"
334
	@echo "      include ${CONFDIR}/test-apache$(APACHEVERSION).conf"
335
	@echo
336 337
	@echo "2 - Restart Apache:"
	@echo "      apache$(APACHEVERSION)ctl restart"
338
	@echo
339
	@echo "3 - Run 'make postconf' as root to update /etc/hosts if your DNS service does not known auth.$(DNSDOMAIN) and manager.$(DNSDOMAIN)"
340
	@echo
341 342 343 344 345 346
	@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"
347
	@echo
348
	@if [ ! "$(APACHEUSER)" ]; then \
349
		echo;echo "    Warning, since APACHEUSER was not set, $(APACHESESSIONFILEDIR), $(APACHEPSESSIONFILEDIR), $(CAPTCHADIR) and $(CONFDIR) have permissive permissions."; \
350 351 352
		echo "    Fix them by yourself to restrict their view to apache process only"; \
	fi
	@echo
353

354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376
install_webserver_conf:
	@install -m 755 -v -d $(RCONFDIR)
	@if [ "$(ERASECONFIG)" -eq "1" ]; then \
		cp -f _example/etc/portal-apache$(APACHEVERSION).conf $(RCONFDIR); \
		cp -f _example/etc/handler-apache$(APACHEVERSION).conf $(RCONFDIR); \
		cp -f _example/etc/manager-apache$(APACHEVERSION).conf $(RCONFDIR); \
		cp -f _example/etc/test-apache$(APACHEVERSION).conf $(RCONFDIR); \
		cp -f _example/etc/handler-nginx.conf $(RCONFDIR); \
		cp -f _example/etc/test-nginx.conf $(RCONFDIR); \
		cp -f _example/etc/nginx-access-control $(RCONFDIR); \
		cp -f _example/etc/nginx-http-accounting $(RCONFDIR); \
		cp -f _example/etc/nginx-fcgi-accounting $(RCONFDIR); \
	fi
	@$(PERL) -i -pe 's/__DNSDOMAIN__/$(DNSDOMAIN)/g; \
			s#__PORTALDIR__#$(PORTALDIR)/#g; \
			s#__MANAGERDIR__#$(MANAGERDIR)/#g; \
			s#__MANAGERSTATICDIR__#$(MANAGERSTATICDIR)/#g; \
			s#__MANAGERPSGIDIR__#$(MANAGERPSGIDIR)/#g; \
			s#__TESTDIR__#$(TESTDIR)/#g; \
			s#__VHOSTLISTEN__#$(VHOSTLISTEN)#g; \
			s#__DEFDOCDIR__#$(DEFDOCDIR)/#g; \
			s#__FRDOCDIR__#$(FRDOCDIR)/#g;' $(RCONFDIR)/*apache*.conf $(RCONFDIR)/*nginx*.conf

377 378
install_manager_site:	install_conf_dir
	# Manager install
379 380 381 382 383 384 385 386
	@install -v -d ${RMANAGERDIR} $(RMANAGERSTATICDIR) $(RMANAGERPSGIDIR) \
		$(RMANAGERTEMPLATESDIR)
	@cp -pR $(SRCMANAGERDIR)/site/static/* $(RMANAGERSTATICDIR)
	@cp -pR $(SRCMANAGERDIR)/site/templates/* $(RMANAGERTEMPLATESDIR)
	@cp -pR $(SRCMANAGERDIR)/eg/* $(RMANAGERPSGIDIR)
	# Clean svn files
	@rm -rf $$(find ${RMANAGERDIR} ${RMANAGERSTATICDIR} $(RMANAGERPSGIDIR) \
		$(RMANAGERTEMPLATESDIR) $(RCONFDIR) -type d -name .svn)
Xavier Guimard's avatar
Xavier Guimard committed
387
	$(PERL) -i -pe 's#__MANAGERSTATICDIR__#$(MANAGERRELATIVESTATICDIR)#g' $(RCONFDIR)/$(CONFFILENAME)
388
	$(PERL) -i -pe 's#__MANAGERTEMPLATESDIR__#$(MANAGERTEMPLATESDIR)#g' $(RCONFDIR)/$(CONFFILENAME)
389 390 391 392

install_portal_site:	install_conf_dir
	# Portal install
	@install -v -d $(RPORTALDIR) $(RPORTALSKINSDIR) \
393
		$(RPORTALDIR)/skins/ \
394 395
		$(RCRONDIR) $(RCONFDIR)
	@for skin in $$(ls lemonldap-ng-portal/example/skins/); do \
396 397
		[ -h $(RPORTALDIR)/skins/$$skin ] && rm -f $(RPORTALDIR)/skins/$$skin; \
		install -v -d $(RPORTALSKINSDIR)/$$skin; \
398
	done
Xavier Guimard's avatar
Xavier Guimard committed
399 400 401
	@cp -pR -f ${SRCPORTALDIR}/example/index_skin.pl ${RPORTALDIR}/index.pl
	@cp -pR -f ${SRCPORTALDIR}/example/mail.pl ${RPORTALDIR}
	@cp -pR -f ${SRCPORTALDIR}/example/metadata.pl ${RPORTALDIR}
402
	@cp -pR -f ${SRCPORTALDIR}/example/openid-configuration.pl ${RPORTALDIR}
Xavier Guimard's avatar
Xavier Guimard committed
403 404
	@cp -pR -f ${SRCPORTALDIR}/example/cdc.pl ${RPORTALDIR}
	@cp -pR -f ${SRCPORTALDIR}/example/register.pl ${RPORTALDIR}
405
	@tar -cf - -C ${SRCPORTALDIR}/example/skins/ $$(ls ${SRCPORTALDIR}/example/skins/) |tar -xf - -C $(RPORTALSKINSDIR)
406
	@if [ "$(PORTALDIR)/skins/" != "$(PORTALSKINSDIR)/" ]; then \
407
		for skin in $$(ls lemonldap-ng-portal/example/skins/); do \
408 409
			rm -rf $(RPORTALDIR)/skins/$$skin/; \
			ln -s $(PORTALSKINSDIR)/$$skin $(RPORTALDIR)/skins/$$skin; \
410 411 412
		done; \
	fi
	# Cron files
Xavier Guimard's avatar
Xavier Guimard committed
413
	@cp -f lemonldap-ng-portal/example/scripts/purgeCentralCache.cron.d $(RCRONDIR)/lemonldap-ng-portal
414
	@if [ ! "$(APACHEUSER)" ]; then \
415
		$(PERL) -i -pe 's#__APACHEUSER__#nobody#g;' $(RCRONDIR)/lemonldap-ng-portal; \
416
	else \
417
		$(PERL) -i -pe 's#__APACHEUSER__#$(APACHEUSER)#g;' $(RCRONDIR)/lemonldap-ng-portal; \
418
	fi
419
	@$(PERL) -i -pe 's#__BINDIR__#$(BINDIR)#g;' $(RCRONDIR)/lemonldap-ng-portal
420
	# Clean SVN files
421
	@rm -rf $$(find ${RPORTALDIR} $(RPORTALSKINSDIR) $(RCRONDIR) $(RCONFDIR) -type d -name .svn)
422 423

install_handler_site:	install_conf_dir
424
	# Handler install
425
	@install -v -d ${RHANDLERDIR}
Xavier Guimard's avatar
Xavier Guimard committed
426
	@cp -f lemonldap-ng-handler/example/scripts/purgeLocalCache.cron.d $(RCRONDIR)/lemonldap-ng-handler
427
	@if [ ! "$(APACHEUSER)" ]; then \
428
		$(PERL) -i -pe 's#__APACHEUSER__#nobody#g;' $(RCRONDIR)/lemonldap-ng-handler; \
429 430 431 432
	else \
		$(PERL) -i -pe 's#__APACHEUSER__#$(APACHEUSER)#g;' $(RCRONDIR)/lemonldap-ng-handler; \
	fi
	@$(PERL) -i -pe 's#__BINDIR__#$(BINDIR)#g;' $(RCRONDIR)/lemonldap-ng-handler
433
	@rm -rf $$(find $(RHANDLERDIR) -type d -name .svn)
434 435

install_test_site:
436
	# Test site install
437
	@install -v -d $(RTESTDIR)
Xavier Guimard's avatar
Xavier Guimard committed
438
	@cp -pR -f _example/test/* $(RTESTDIR)
439
	@rm -rf $$(find $(RTESTDIR) -type d -name .svn)
Xavier Guimard's avatar
Xavier Guimard committed
440
	@$(PERL) -i -pe 's/__DNSDOMAIN__/$(DNSDOMAIN)/g' $(RTESTDIR)/index.pl
441
	@rm -rf $$(find $(RTESTDIR) -type d -name .svn)
442 443

install_examples_site:
444
	# Examples install
445
	@install -v -d $(REXAMPLESDIR)
446
	@for i in manager portal handler; do \
Xavier Guimard's avatar
Xavier Guimard committed
447
		cp -a -f lemonldap-ng-$$i/example $(REXAMPLESDIR)/$$i; \
448
	done
449
	@rm -rf $(REXAMPLESDIR)/portal/skins \
Xavier Guimard's avatar
Xavier Guimard committed
450
		$(REXAMPLESDIR)/manager/skins \
451
	@rm -rf $$(find $(REXAMPLESDIR) -type d -name .svn)
452
	@$(PERL) -i -pe 's#__SESSIONDIR__#$(APACHESESSIONFILEDIR)/#g;' $(REXAMPLESDIR)/portal/*.pl
453
	@$(PERL) -i -pe 's#__PSESSIONDIR__#$(APACHEPSESSIONFILEDIR)/#g;' $(REXAMPLESDIR)/portal/*.pl
454

455
install_doc_site:
456
	# Offline documentation install
457 458
	@rm -rf $(RDEFDOCDIR)
	@install -v -d $(RDEFDOCDIR)
Xavier Guimard's avatar
Xavier Guimard committed
459
	@cp -a -f doc/* $(RDEFDOCDIR)
460

461
install_conf_dir:	install_sessions_dir install_notif_dir install_captcha_dir
462
	# Configuration files install
463
	@install -v -d $(RCONFDIR) $(RFILECONFIGDIR) $(RTOOLSDIR)
Clément OUDOT's avatar
Clément OUDOT committed
464
	@if [ "$(ERASECONFIG)" -eq "1" ]; then \
Xavier Guimard's avatar
Xavier Guimard committed
465
		cp -f $(SRCCOMMONDIR)/$(CONFFILENAME) $(RCONFDIR); \
Xavier Guimard's avatar
Xavier Guimard committed
466
		$(PERL) -i -pe 's#^dirName\s*=\s*.*#dirName = $(FILECONFIGDIR)#g' $(RCONFDIR)/$(CONFFILENAME); \
Clément OUDOT's avatar
Clément OUDOT committed
467
	fi
468
	@cp _example/conf/lmConf-1.js $(RFILECONFIGDIR)
Xavier Guimard's avatar
Xavier Guimard committed
469
	@$(PERL) -i -pe 's/__DNSDOMAIN__/$(DNSDOMAIN)/g;\
470
		s#__SESSIONDIR__#$(APACHESESSIONFILEDIR)#g;\
471
		s#__PSESSIONDIR__#$(APACHEPSESSIONFILEDIR)#g;\
472
		s#__NOTIFICATIONDIR__#$(APACHEFILENOTIFDIR)#g;' $(RFILECONFIGDIR)/lmConf-1.js
473 474 475 476 477 478 479 480 481
	@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
482
	@cp lemonldap-ng-common/tools/lmConfig.* lemonldap-ng-common/tools/apache-session-mysql.sql $(RTOOLSDIR)
483
	@cp lemonldap-ng-common/tools/sso.schema $(RTOOLSDIR)
484
	$(PERL) -i -pe 's/__DNSDOMAIN__/$(DNSDOMAIN)/g' $(RCONFDIR)/$(CONFFILENAME)
485
	@rm -rf $$(find $(RCONFDIR) $(RFILECONFIGDIR) $(RTOOLSDIR) -type d -name .svn)
486 487

install_sessions_dir:
488
	@install -m 777 -v -d $(RAPACHESESSIONFILEDIR) $(RAPACHESESSIONFILELOCKDIR) $(RAPACHEPSESSIONFILEDIR) $(RAPACHEPSESSIONFILELOCKDIR)
489 490
	# Fix Apache::Session directories permissions
	@if [ "$(APACHEUSER)" != "" ]; then \
491
		chown $(APACHEUSER) $(RAPACHESESSIONFILEDIR) $(RAPACHESESSIONFILELOCKDIR) $(RAPACHEPSESSIONFILEDIR) $(RAPACHEPSESSIONFILELOCKDIR) || exit 1; \
492
		if [ "$(APACHEGROUP)" != "" ]; then \
493
			chgrp $(APACHEGROUP) $(RAPACHESESSIONFILEDIR) $(RAPACHESESSIONFILELOCKDIR) $(RAPACHEPSESSIONFILEDIR) $(RAPACHEPSESSIONFILELOCKDIR) || exit 1; \
494
		fi; \
495
		chmod 770 $(RAPACHESESSIONFILEDIR) $(RAPACHESESSIONFILELOCKDIR) $(RAPACHEPSESSIONFILEDIR) $(RAPACHEPSESSIONFILELOCKDIR); \
496
	else \
497
		chmod 777 $(RAPACHESESSIONFILEDIR) $(RAPACHESESSIONFILELOCKDIR) $(RAPACHEPSESSIONFILEDIR) $(RAPACHEPSESSIONFILELOCKDIR); \
498 499
	fi

500 501 502 503 504 505 506 507 508 509 510 511 512
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

513
install_captcha_dir:
514
	@install -m 777 -v -d $(RCAPTCHADIR)
515 516
	# Fix captcha directory permissions
	@if [ "$(APACHEUSER)" != "" ]; then \
517
		chown $(APACHEUSER) $(RCAPTCHADIR) || exit 1; \
518
		if [ "$(APACHEGROUP)" != "" ]; then \
519
			chgrp $(APACHEGROUP) $(RCAPTCHADIR) || exit 1; \
520
		fi; \
521
		chmod 770 $(RCAPTCHADIR); \
522
	else \
523
		chmod 777 $(RCAPTCHADIR); \
524 525
	fi

526
postconf_hosts:
Clément OUDOT's avatar
Clément OUDOT committed
527
	@cat ${CONFDIR}/for_etc_hosts >> /etc/hosts
528 529
	@echo "/etc/hosts was updated"

530
postconf: postconf_hosts
531 532
	@echo "Post configuration done"

533 534
uninstall:	configure handler_uninstall portal_uninstall manager_uninstall

535 536 537 538
common_uninstall:	common
	@$(MAKE) -C ${SRCCOMMONDIR} uninstall
	@rm -vf common_uninstall

539
handler_uninstall:	handler
540
	@$(MAKE) -C ${SRCHANDLERDIR} uninstall
541
	@rm -vf handler_uninstall
542 543

portal_uninstall:		portal
544
	@$(MAKE) -C ${SRCPORTALDIR} uninstall
545
	@rm -vf portal_uninstall
546 547

manager_uninstall:	manager
548
	@$(MAKE) -C ${SRCMANAGERDIR} uninstall
549
	@rm -vf manager_uninstall
550

551
dist:	clean
552 553 554 555 556 557 558 559 560 561
	@mkdir -p lemonldap-ng-$(VERSION)
	@cp -pRH $$(find * -maxdepth 0|grep -v -e "\(lemonldap-ng-$(VERSION)\|debian\|rpm\)") lemonldap-ng-$(VERSION)
	@rm -rf $$(find lemonldap-ng-$(VERSION) -name .svn -print)
	@rm -rf lemonldap-ng-$(VERSION)/po-doc/fr/*
	@find $$dir -name '*.bak' -delete
	@rm -rf lemonldap-ng-$(VERSION)/lemonldap-ng-$(VERSION)
	@$(COMPRESS) lemonldap-ng-$(VERSION).$(COMPRESSSUFFIX) lemonldap-ng-$(VERSION)
	@rm -rf lemonldap-ng-$(VERSION)

rpm-dist:	clean
562
	@mkdir -p lemonldap-ng-$(VERSION)
563
	@cp -pRH $$(find * -maxdepth 0|grep -v -e "\(lemonldap-ng-$(VERSION)\|debian\)") lemonldap-ng-$(VERSION)
564 565
	@rm -rf $$(find lemonldap-ng-$(VERSION) -name .svn -print)
	@find $$dir -name '*.bak' -delete
566
	@rm -rf lemonldap-ng-$(VERSION)/lemonldap-ng-$(VERSION)
Xavier Guimard's avatar
Xavier Guimard committed
567
	@$(COMPRESS) lemonldap-ng-$(VERSION).$(COMPRESSSUFFIX) lemonldap-ng-$(VERSION)
568
	@rm -rf lemonldap-ng-$(VERSION)
569

570

571 572
debian-dist:	clean
	@mkdir -p lemonldap-ng-$(VERSION)
573
	@cp -pRH $$(find * -maxdepth 0|grep -v -e "\(lemonldap-ng-$(VERSION)\|rpm\)") lemonldap-ng-$(VERSION)
574 575
	@rm -rf $$(find lemonldap-ng-$(VERSION) -name .svn -print)
	@find $$dir -name '*.bak' -delete
576 577 578 579
	@cp lemonldap-ng-$(VERSION)/_example/etc/handler-apache2.X.conf lemonldap-ng-$(VERSION)/_example/etc/handler-apache2.conf
	@cp lemonldap-ng-$(VERSION)/_example/etc/manager-apache2.X.conf lemonldap-ng-$(VERSION)/_example/etc/manager-apache2.conf
	@cp lemonldap-ng-$(VERSION)/_example/etc/portal-apache2.X.conf lemonldap-ng-$(VERSION)/_example/etc/portal-apache2.conf
	@cp lemonldap-ng-$(VERSION)/_example/etc/test-apache2.X.conf lemonldap-ng-$(VERSION)/_example/etc/test-apache2.conf
580 581 582
	@rm -rf lemonldap-ng-$(VERSION)/lemonldap-ng-$(VERSION)
	@$(COMPRESS) lemonldap-ng_$(VERSION).orig.$(COMPRESSSUFFIX) lemonldap-ng-$(VERSION)
	@rm -rf lemonldap-ng-$(VERSION)
Xavier Guimard's avatar
Xavier Guimard committed
583 584 585

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

587 588 589 590 591 592 593 594
manifest:   configure
	@for i in ${SRCCOMMONDIR} ${SRCHANDLERDIR} ${SRCPORTALDIR} ${SRCMANAGERDIR}; do \
		cd $$i; \
		make manifest; \
		rm -vf MANIFEST.*; \
		cd -; \
	done

595
cpan:	clean configure common_cpan handler_cpan portal_cpan manager_cpan
Clément OUDOT's avatar
Clément OUDOT committed
596
	for i in Common Portal Handler Manager; do \
Xavier Guimard's avatar
Xavier Guimard committed
597
		$(UNCOMPRESS) Lemonldap-NG-$$i-*.$(COMPRESSSUFFIX) \
Clément OUDOT's avatar
Clément OUDOT committed
598
			$$($(LISTCOMPRESSED) Lemonldap-NG-$$i-*.$(COMPRESSSUFFIX) |grep META.yml); \
Xavier Guimard's avatar
Xavier Guimard committed
599
		mv Lemonldap-NG-$$i-*/META.yml lemonldap-ng-$$($(PERL) -e "print lc('$$i')")/; \
600
		rm -rf Lemonldap-NG-$$i*/; \
Xavier Guimard's avatar
Xavier Guimard committed
601
		done
602 603 604 605

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

handler_cpan:	handler_conf
608 609
	@$(MAKE) -C ${SRCHANDLERDIR} dist
	@mv ${SRCHANDLERDIR}/Lemonldap*.gz .
610 611

portal_cpan:		portal_conf
612 613
	@$(MAKE) -C ${SRCPORTALDIR} dist
	@mv ${SRCPORTALDIR}/Lemonldap*.gz .
614 615

manager_cpan:	manager_conf
616 617
	@$(MAKE) -C ${SRCMANAGERDIR} dist
	@mv ${SRCMANAGERDIR}/Lemonldap*.gz .
618

619
documentation:
620
	@cd doc/ && ../scripts/doc.pl
621

622
doxygen:	clean
Xavier Guimard's avatar
Xavier Guimard committed
623
	$(PERL) -i -pe 's/^(PROJECT_NUMBER\s*=\s*)\d.*$$/$${1}'$(VERSION)'/' Doxyfile
624 625 626 627 628 629
	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
630
	$(PERL) -i -pe 's/Graphical Class Hierarchy/Class Collaboration Graph/' doc/devel/html/inherits.html doc/devel/html/tree.html
631 632
	# 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
633

634 635
distclean:	clean

636
clean:		common_clean handler_clean portal_clean manager_clean omegat-clean omegat-fr-clean
Xavier Guimard's avatar
Xavier Guimard committed
637
	@rm -f $$(find */ -name '*bak' -delete)
638
	@rm -rf $(EXAMPLEROOT) example/ doc/devel
Xavier Guimard's avatar
Xavier Guimard committed
639
	@rm -vf *gz *zip
Xavier Guimard's avatar
Xavier Guimard committed
640
	@rm -rf lemonldap-ng-$(VERSION)
Xavier Guimard's avatar
Xavier Guimard committed
641
	@echo "Cleaned"
642 643

common_clean:
Xavier Guimard's avatar
Xavier Guimard committed
644
	@if test -e ${SRCCOMMONDIR}/Makefile;then $(MAKE) -C ${SRCCOMMONDIR} distclean;fi
645 646 647
	@rm -vf common*

handler_clean:
Xavier Guimard's avatar
Xavier Guimard committed
648
	@if test -e ${SRCHANDLERDIR}/Makefile;then $(MAKE) -C ${SRCHANDLERDIR} distclean;fi
649 650 651
	@rm -vf handler*

portal_clean:
Xavier Guimard's avatar
Xavier Guimard committed
652
	@if test -e ${SRCPORTALDIR}/Makefile;then $(MAKE) -C ${SRCPORTALDIR} distclean;fi
653 654 655
	@rm -vf portal*

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

659
debian-local-packages: debian-dist
Xavier Guimard's avatar
Xavier Guimard committed
660
	mv lemonldap-ng_$(VERSION).orig.$(COMPRESSSUFFIX) /tmp/
661 662
	version=$(VERSION) && \
	cd /tmp/ && \
Xavier Guimard's avatar
Xavier Guimard committed
663
	rm -rf lemonldap-ng-$$version && \
Xavier Guimard's avatar
Xavier Guimard committed
664
	$(UNCOMPRESS) lemonldap-ng_$$version.orig.$(COMPRESSSUFFIX) && \
665
	cd lemonldap-ng-$$version && \
Xavier Guimard's avatar
Xavier Guimard committed
666 667 668 669
	export LOCALBUILD=1; debuild -e LOCALBUILD -us -uc -b --lintian-opts -i \
		--lintian-opts -v --lintian-opts -I --lintian-opts -E \
		--lintian-opts --color --lintian-opts auto --lintian-opts -L \
		--lintian-opts +=pedantic
Xavier Guimard's avatar
Xavier Guimard committed
670

671 672 673 674 675 676 677 678 679 680 681 682 683
debian-packages: debian-dist
	mv lemonldap-ng_$(VERSION).orig.$(COMPRESSSUFFIX) /tmp/
	version=$(VERSION) && \
	cd /tmp/ && \
	rm -rf lemonldap-ng-$$version && \
	$(UNCOMPRESS) lemonldap-ng_$$version.orig.$(COMPRESSSUFFIX) && \
	cd lemonldap-ng-$$version && \
	debuild -us -uc -b --lintian-opts -i \
		--lintian-opts -v --lintian-opts -I --lintian-opts -E \
		--lintian-opts --color --lintian-opts auto --lintian-opts -L \
		--lintian-opts +=pedantic

debian-install: debian-local-packages
Xavier Guimard's avatar
Xavier Guimard committed
684
	cd /tmp/lemonldap-ng-$(VERSION) && \
Xavier Guimard's avatar
Xavier Guimard committed
685 686 687 688 689 690
	$(SU) debi

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

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

Xavier Guimard's avatar
Xavier Guimard committed
692
debian-diff:
Xavier Guimard's avatar
Xavier Guimard committed
693
	@# Portal
Xavier Guimard's avatar
Xavier Guimard committed
694 695 696
	@$(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
697
	@for i in $(PORTALSKINS); do \
Xavier Guimard's avatar
Xavier Guimard committed
698
		$(DIFF) -x 'jquery*' lemonldap-ng-portal/example/skins/$$i $(DIFFPREFIX)/usr/share/lemonldap-ng/portal-skins/$$i; \
Xavier Guimard's avatar
Xavier Guimard committed
699
	done ||true
Xavier Guimard's avatar
Xavier Guimard committed
700 701 702
	@$(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
703
	@$(DIFF) lemonldap-ng-portal/example/openid-configuration.pl $(DIFFPREFIX)/var/lib/lemonldap-ng/portal/openid-configuration.pl ||true
Xavier Guimard's avatar
Xavier Guimard committed
704
	@$(DIFF) lemonldap-ng-portal/example/cdc.pl $(DIFFPREFIX)/var/lib/lemonldap-ng/portal/cdc.pl ||true
705
	@$(DIFF) lemonldap-ng-portal/example/register.pl $(DIFFPREFIX)/var/lib/lemonldap-ng/portal/register.pl ||true
Xavier Guimard's avatar
Xavier Guimard committed
706
	@# Handler
Xavier Guimard's avatar
Xavier Guimard committed
707
	@$(DIFF) lemonldap-ng-handler/lib/Lemonldap/NG/Handler $(DIFFPREFIX)/usr/share/perl5/Lemonldap/NG/Handler ||true
708
	@$(DIFF) lemonldap-ng-handler/example/scripts/purgeLocalCache $(DIFFPREFIX)/usr/share/lemonldap-ng/bin/purgeLocalCache ||true
Xavier Guimard's avatar
Xavier Guimard committed
709
	@# Common
Xavier Guimard's avatar
Xavier Guimard committed
710 711 712 713
	@$(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
714
	@$(DIFF) lemonldap-ng-common/scripts/rotateOidcKeys $(DIFFPREFIX)/usr/share/lemonldap-ng/bin/rotateOidcKeys ||true
Xavier Guimard's avatar
Xavier Guimard committed
715
	@# Manager
Xavier Guimard's avatar
Xavier Guimard committed
716 717
	@$(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
718 719 720
	@$(DIFF) lemonldap-ng-manager/eg $(DIFFPREFIX)/var/lib/lemonldap-ng/manager/psgi ||true
	@$(DIFF) lemonldap-ng-manager/site/static $(DIFFPREFIX)/var/lib/lemonldap-ng/manager/static ||true
	@$(DIFF) lemonldap-ng-manager/site/templates $(DIFFPREFIX)/var/lib/lemonldap-ng/manager/templates ||true
721 722
	@$(DIFF) --ignore-matching-lines='set.*get.*\[2\]' lemonldap-ng-manager/scripts/lmConfigEditor $(DIFFPREFIX)/usr/share/lemonldap-ng/bin/lmConfigEditor ||true
	@$(DIFF) --ignore-matching-lines='giveUpPrivileges' lemonldap-ng-manager/scripts/lemonldap-ng-cli $(DIFFPREFIX)/usr/share/lemonldap-ng/bin/lemonldap-ng-cli ||true
Xavier Guimard's avatar
Xavier Guimard committed
723

724 725
default-diff:
	@# Portal
726
	@$(DIFF) lemonldap-ng-portal/lib/Lemonldap/NG/Portal /usr/local/share/perl/$(PERLVERSION)/Lemonldap/NG/Portal ||true
727 728 729
	@$(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
730 731
	@$(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
732
	@$(DIFF) lemonldap-ng-portal/example/register.pl $(LMPREFIX)/htdocs/portal/register.pl ||true
Clément OUDOT's avatar
SAML:  
Clément OUDOT committed
733
	@$(DIFF) lemonldap-ng-portal/example/metadata.pl $(LMPREFIX)/htdocs/portal/metadata.pl ||true
734
	@$(DIFF) lemonldap-ng-portal/example/openid-configuration.pl $(LMPREFIX)/htdocs/portal/openid-configuration.pl ||true
735
	@$(DIFF) lemonldap-ng-portal/example/cdc.pl $(LMPREFIX)/htdocs/portal/cdc.pl ||true
736
	@# Handler
737
	@$(DIFF) lemonldap-ng-handler/lib/Lemonldap/NG/Handler /usr/local/share/perl/$(PERLVERSION)/Lemonldap/NG/Handler ||true
738
	@$(DIFF) lemonldap-ng-handler/example/scripts/purgeLocalCache $(LMPREFIX)/bin/purgeLocalCache ||true
739
	@# Common
740 741
	@$(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
742 743
	@$(DIFF) lemonldap-ng-common/scripts/lmMigrateConfFiles2ini $(LMPREFIX)/bin/lmMigrateConfFiles2ini ||true
	@$(DIFF) lemonldap-ng-common/scripts/convertConfig $(LMPREFIX)/bin/convertConfig ||true
744
	@$(DIFF) lemonldap-ng-common/scripts/rotateOidcKeys $(LMPREFIX)/bin/rotateOidcKeys ||true
745
	@# Manager
746 747
	@$(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
748 749 750
	@$(DIFF) lemonldap-ng-manager/eg $(LMPREFIX)/htdocs/manager/psgi ||true
	@$(DIFF) lemonldap-ng-manager/site/static $(LMPREFIX)/htdocs/manager/static ||true
	@$(DIFF) lemonldap-ng-manager/site/templates $(LMPREFIX)/htdocs/manager/templates ||true
751 752
	@$(DIFF) --ignore-matching-lines='set.*get.*\[2\]' lemonldap-ng-manager/scripts/lmConfigEditor $(LMPREFIX)/bin/lmConfigEditor ||true
	@$(DIFF) --ignore-matching-lines='giveUpPrivileges' lemonldap-ng-manager/scripts/lemonldap-ng-cli $(LMPREFIX)/bin/lemonldap-ng-cli ||true
753

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

Xavier Guimard's avatar
Xavier Guimard committed
758
tidy-js: clean
759
	find lemon*/ -type f -name '*.js' ! -name 'jq*' ! -name 'bootstrap*' -print -exec scripts/javascript-indent {} \;
Xavier Guimard's avatar
Xavier Guimard committed
760

761 762 763 764
# TRANSLATION TARGETS #

# 1. Internal targets

765 766
language_code:
	perl -e ' \
767 768 769 770 771 772 773 774 775 776
	print { \
		fr=> "FR-FR", \
	}->{$(1)}'

test_omegat_%_dir:
	 @if [ ! -d omegat.files/$* ]; then \
	 	echo "omegat.files/$* does not exist"; \
		exit 1; \
	fi

777 778
omegat-configuration-file:
	perl -pe 'BEGIN{$$p=`pwd`;chomp $$p;}s/__LANG__/$(OMEGATCODE)/;s/__PWD__/$$p/o;' omegat.files/_base.project >omegat.files/$(LANGCODE)/omegat.project
779

780
translation: omegat-configuration-file
781
	omegat omegat.files/$(LANGCODE) --quiet
782

783
translated-doc: omegat-configuration-file
784 785
	omegat omegat.files/$(LANGCODE) --mode=console-translate --quiet 2>/dev/null
	cd po-doc/$(LANGCODE)/pages/documentation && rm -rf current && ln -s $$(find * -maxdepth 0 -type d) current
786

787 788
# 2. Public targets

789
%-translation: test_omegat_%_dir omegat-%-clean
790 791
	$(eval CODE = $(call language_code,$*))
	$(MAKE) translation LANGCODE=$* OMEGATCODE=$(CODE)
792

793
%-doc: test_omegat_%_dir omegat-%-clean
794
	mkdir -p po-doc/$*
795 796
	$(eval CODE = $(call language_code,$*))
	$(MAKE) translated-doc LANGCODE=$* OMEGATCODE=$(CODE)
797 798
	
omegat-clean:
799 800 801
	rm -rf omegat.files/*/omegat.project omegat.files/*/omegat/project_save*.bak

omegat-%-clean:
802
	rm -rf po-doc/$*
803

804
install_%_doc_site:
805 806
	@rm -rf $(RDOCDIR)/$*-doc || true
	@install -v -d $(RDOCDIR)/$*-doc
Xavier Guimard's avatar
Xavier Guimard committed
807
	@cp -dR -f po-doc/$*/* $(RDOCDIR)/$*-doc
808