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

3 4 5
# Prefix for packaging
DESTDIR=

6
# Flag for optimizations
7 8
USEDEBIANLIBS=no
PROD=$(USEDEBIANLIBS)
9
USEEXTERNALLIBS=no
10 11 12 13 14

# Compression
JSCOMPRESS=$(PROD)
CSSCOMPRESS=$(PROD)

15
PERL=$$(which perl)
16
PERLVERSION=`perl -e '$$version = $$^V; $$version =~ s/v//; print $$version'`
Xavier Guimard's avatar
Xavier Guimard committed
17 18 19
SU=su -c
COMPRESS=tar czf
UNCOMPRESS=tar xzf
Clément OUDOT's avatar
Clément OUDOT committed
20
LISTCOMPRESSED=tar tzf
Xavier Guimard's avatar
Xavier Guimard committed
21
COMPRESSSUFFIX=tar.gz
Xavier Guimard's avatar
Xavier Guimard committed
22
NGINX=/usr/sbin/nginx
23 24 25 26 27
# Perl options
#PERLOPTIONS="INSTALLDIRS=vendor"
PERLOPTIONS=

# Default directories install
28 29 30
PREFIX=/usr/local
LMPREFIX=$(PREFIX)/lemonldap-ng
RLMPREFIX=$(DESTDIR)/$(LMPREFIX)
31
# BIN dirs
32 33 34 35
BINDIR=$(LMPREFIX)/bin
RBINDIR=$(DESTDIR)/$(BINDIR)
DATADIR=$(LMPREFIX)/data
RDATADIR=$(DESTDIR)/$(DATADIR)
36

37
EXAMPLEROOT=`pwd`/example
38 39

# Document roots for Apache VirtualHosts
40 41 42 43 44 45 46
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
47
MANAGERSITEDIR=$(MANAGERDIR)
Xavier Guimard's avatar
Xavier Guimard committed
48
RMANAGERSITEDIR=$(DESTDIR)/$(MANAGERSITEDIR)
49 50
MANAGERSTATICDIR=$(MANAGERSITEDIR)/static
RMANAGERSTATICDIR=$(DESTDIR)/$(MANAGERSTATICDIR)
Xavier Guimard's avatar
Xavier Guimard committed
51
MANAGERRELATIVESTATICDIR=/static
52 53 54 55
MANAGERPSGIDIR=$(MANAGERSITEDIR)/psgi
RMANAGERPSGIDIR=$(DESTDIR)/$(MANAGERPSGIDIR)
MANAGERTEMPLATESDIR=$(MANAGERSITEDIR)/templates
RMANAGERTEMPLATESDIR=$(DESTDIR)/$(MANAGERTEMPLATESDIR)
56
DOCDIR=$(DOCUMENTROOT)
57
RDOCDIR=$(DESTDIR)/$(DOCDIR)
58 59 60
DEFDOCDIR=$(DOCUMENTROOT)/doc
RDEFDOCDIR=$(DESTDIR)/$(DEFDOCDIR)
FRDOCDIR=$(DOCUMENTROOT)/fr-doc
61 62 63 64 65 66
TESTDIR=$(DOCUMENTROOT)/test
RTESTDIR=$(DESTDIR)/$(TESTDIR)
EXAMPLESDIR=$(LMPREFIX)/examples
REXAMPLESDIR=$(DESTDIR)/$(EXAMPLESDIR)
TOOLSDIR=$(LMPREFIX)/tools
RTOOLSDIR=$(DESTDIR)/$(TOOLSDIR)
67 68

# Handler dir
69 70
HANDLERDIR=$(LMPREFIX)/handler
RHANDLERDIR=$(DESTDIR)/$(HANDLERDIR)
71 72

# Configuration dir
73 74 75 76
CONFDIR=$(LMPREFIX)/etc
RCONFDIR=$(DESTDIR)/$(CONFDIR)
CRONDIR=$(LMPREFIX)/etc/cron.d
RCRONDIR=$(DESTDIR)/$(CRONDIR)
77 78
CONFFILENAME=lemonldap-ng.ini
STORAGECONFFILE=$(CONFDIR)/$(CONFFILENAME)
79

80
# LL::NG configuration storage dir
81 82
FILECONFIGDIR=$(DATADIR)/conf
RFILECONFIGDIR=$(DESTDIR)/$(FILECONFIGDIR)
83

84
# LL::NG sessions storage dir
85 86 87
APACHESESSIONFILEDIR=$(DATADIR)/sessions
RAPACHESESSIONFILEDIR=$(DESTDIR)/$(APACHESESSIONFILEDIR)
APACHESESSIONFILELOCKDIR=$(APACHESESSIONFILEDIR)/lock
88
RAPACHESESSIONFILELOCKDIR=$(DESTDIR)/$(APACHESESSIONFILELOCKDIR)
89

90 91 92 93 94 95 96
# LL::NG persistent sessions storage dir
APACHEPSESSIONFILEDIR=$(DATADIR)/psessions
RAPACHEPSESSIONFILEDIR=$(DESTDIR)/$(APACHEPSESSIONFILEDIR)
APACHEPSESSIONFILELOCKDIR=$(APACHEPSESSIONFILEDIR)/lock
RAPACHEPSESSIONFILELOCKDIR=$(DESTDIR)/$(APACHEPSESSIONFILELOCKDIR)

# LL::NG notifications storage dir
97 98
APACHEFILENOTIFDIR=$(DATADIR)/notifications
RFILENOTIFDIR=$(DESTDIR)/$(APACHEFILENOTIFDIR)
99

100 101
# LL::NG captcha dir
CAPTCHADIR=$(DATADIR)/captcha
102 103
RCAPTCHADIR=$(DESTDIR)/$(CAPTCHADIR)

104
# Apache user/group
105 106 107
APACHEUSER=
APACHEGROUP=

108
# Apache version
109
APACHEVERSION=2.X
110

111
# DNS Domain for cookie and virtual hosts
112 113
DNSDOMAIN=example.com

114
# Virtual Host Listen IP and Port (*, *:80, ...)
Xavier Guimard's avatar
Xavier Guimard committed
115 116
PORT=80
VHOSTLISTEN="*:$(PORT)"
117
TESTWEBSERVER=apache
Xavier Guimard's avatar
Xavier Guimard committed
118 119
TESTWEBSERVERPORT=19876
PSGISERVERSOCKET=unix:/run/llng.sock
120

121
# Other
122 123 124 125
SRCCOMMONDIR=lemonldap-ng-common
SRCHANDLERDIR=lemonldap-ng-handler
SRCPORTALDIR=lemonldap-ng-portal
SRCMANAGERDIR=lemonldap-ng-manager
126 127 128

VERSION=`head -n1 changelog |sed -e 's/lemonldap-ng (//' -e 's/).*$$//'`
PORTALSKINS=`ls $(SRCPORTALDIR)/example/skins/`
129
DIFF=diff -aurN -x '*.tpl' -x '*.bak' -x .svn -x '*.map' -x '*.min.js' -x '*.min.css' -x '*.swp' --ignore-matching-lines='.*jquery.*' --ignore-matching-lines='.*lemonldap-ng\.ini.*'
130 131
DIFFPREFIX=

132

133
EXAMPLELANG=en # For static Manager example only
Clément OUDOT's avatar
Clément OUDOT committed
134
ERASECONFIG=1 # Set to 0 if you do not want to replace your configuration
135

136 137
MANAGERLIBSTOREMOVEFORDEBIAN=$(RMANAGERSTATICDIR)/bwr/jquery/ \
			$(RMANAGERSTATICDIR)/bwr/angular/ \
138
			$(RMANAGERSTATICDIR)/bwr/angular-animate/ \
139 140 141 142 143 144 145 146
			$(RMANAGERSTATICDIR)/bwr/angular-cookie/ \
			$(RMANAGERSTATICDIR)/bwr/bootstrap/ \
			$(RMANAGERSTATICDIR)/bwr/es5-shim/
PORTALLIBSTOREMOVEFORDEBIAN=$(RPORTALSKINSDIR)/bootstrap/fonts \
			$(RPORTALSKINSDIR)/bootstrap/css/bootstrap* \
			$(RPORTALSKINSDIR)/bootstrap/js/bootstrap* \
			$(RPORTALSKINSDIR)/common/js/jquery-* \
			$(RPORTALSKINSDIR)/common/js/jquery.cookie*
147 148
MANAGEREXTERNALLIBS=$(RMANAGERSTATICDIR)/bwr/
PORTALEXTERNALLIBS=$(PORTALLIBSTOREMOVEFORDEBIAN) $(RPORTALSKINSDIR)/common/js/jquery*
149

150
# GENERATED SRC FILESlemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/DefaultValues.pm
151
MANAGERJSONSRC= scripts/jsongenerator.pl \
Xavier Guimard's avatar
Xavier Guimard committed
152
		$(SRCMANAGERDIR)/lib/Lemonldap/NG/Manager/Build.pm \
153
		$(SRCMANAGERDIR)/lib/Lemonldap/NG/Manager/Build/Attributes.pm \
154 155
		$(SRCMANAGERDIR)/lib/Lemonldap/NG/Manager/Build/Tree.pm \
		$(SRCMANAGERDIR)/lib/Lemonldap/NG/Manager/Conf/Zero.pm
156 157
MANAGERJSONDST=$(SRCMANAGERDIR)/site/static/struct.json \
		$(SRCMANAGERDIR)/site/static/js/conftree.js \
Xavier Guimard's avatar
Xavier Guimard committed
158
		$(SRCMANAGERDIR)/lib/Lemonldap/NG/Manager/Attributes.pm \
159
		$(SRCMANAGERDIR)/lib/Lemonldap/NG/Manager/Constants.pm \
160
		$(SRCCOMMONDIR)/lib/Lemonldap/NG/Common/Conf/DefaultValues.pm \
161
		$(SRCCOMMONDIR)/lib/Lemonldap/NG/Common/Conf/Constants.pm \
162
		_example/conf/lmConf-1.js
163 164

# Javascript and CSS to minify
165 166
JSSRCFILES:=$(shell find $(SRCMANAGERDIR)/site/static/js $(SRCPORTALDIR)/example -type f -name '*.js' ! -name '*.min.js') \
		$(SRCMANAGERDIR)/site/static/bwr/file-saver.js/FileSaver.js
167
CSSSRCFILES:=$(shell find $(SRCMANAGERDIR)/site/static/css  $(SRCPORTALDIR)/example -type f -name '*.css' ! -name '*.min.css')
168 169 170 171

# Minified files
JSDSTFILES=$(JSSRCFILES:.js=.min.js)
CSSDSTFILES=$(CSSSRCFILES:.css=.min.css)
Xavier Guimard's avatar
Xavier Guimard committed
172

173
all:	configure common handler manager portal
174 175
	@echo
	@echo "Building succeed. Now run :"
Xavier Guimard's avatar
Error  
Xavier Guimard committed
176 177
	@echo " - 'make test' to verify your installation"
	@echo " - 'make install PROD=yes' to install all"
Xavier Guimard's avatar
Xavier Guimard committed
178 179 180 181 182
	@echo
	@echo "    MAKE INSTALL OPTIONS:"
	@echo "    - PROD=yes            : use js/css minified files"
	@echo "    - USEDEBIANLIBS=yes   : use some Debian shared js/css files"
	@echo "    - USEEXTERNALLIBS=yes : use external links for some js/css files"
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203
	@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 :"
204
	@echo "   - install_doc_site      ($(DEFDOCDIR))"
205 206
	@echo "   - install_examples_site ($(EXAMPLESDIR))"
	@echo
Xavier Guimard's avatar
Xavier Guimard committed
207
	@echo "Other languages documentation (fr only for now)"
208 209
	@echo " - fr-doc                  (needs OmegaT)"
	@echo " - install_fr_doc_site"
Xavier Guimard's avatar
Xavier Guimard committed
210
	@echo
211

Xavier Guimard's avatar
Xavier Guimard committed
212 213 214
#
# Minification
#
215 216 217
minify: $(JSDSTFILES) $(CSSDSTFILES)

%.min.css: %.css
Xavier Guimard's avatar
Fault  
Xavier Guimard committed
218
	@echo "Compressing $*.css"
219
	@yui-compressor $*.css > $*.min.css
220 221

%.min.js: %.js
Xavier Guimard's avatar
Fault  
Xavier Guimard committed
222
	@echo "Compressing $*.js"
223
	@yui-compressor $*.js > $*.min.js
224

Xavier Guimard's avatar
Xavier Guimard committed
225

226 227 228
#
# Perl libraries configuration
#
229

230
json:	$(MANAGERJSONDST)
Xavier Guimard's avatar
Xavier Guimard committed
231
	@if which yui-compressor; then $(MAKE) minify; fi
232

233
$(MANAGERJSONDST):	$(MANAGERJSONSRC)
234
	./scripts/jsongenerator.pl
235

Xavier Guimard's avatar
Xavier Guimard committed
236
configure:	json common_conf handler_conf portal_conf manager_conf
237

238 239 240 241 242 243 244 245 246
common_conf:	${SRCCOMMONDIR}/Makefile

handler_conf:	${SRCHANDLERDIR}/Makefile

portal_conf:	${SRCPORTALDIR}/Makefile

manager_conf:	${SRCMANAGERDIR}/Makefile

${SRCCOMMONDIR}/Makefile:
Xavier Guimard's avatar
Xavier Guimard committed
247
	@cd ${SRCCOMMONDIR}; LMNGCONFFILE=$(STORAGECONFFILE) $(PERL) Makefile.PL $(PERLOPTIONS)
248

249
${SRCHANDLERDIR}/Makefile:
Xavier Guimard's avatar
Xavier Guimard committed
250
	@cd ${SRCHANDLERDIR}; $(PERL) Makefile.PL $(PERLOPTIONS)
251

252
${SRCPORTALDIR}/Makefile:
Xavier Guimard's avatar
Xavier Guimard committed
253
	@cd ${SRCPORTALDIR}; $(PERL) Makefile.PL $(PERLOPTIONS)
254

255
${SRCMANAGERDIR}/Makefile:
Xavier Guimard's avatar
Xavier Guimard committed
256
	@cd ${SRCMANAGERDIR}; $(PERL) Makefile.PL $(PERLOPTIONS)
257

258 259 260
#
# Perl libraries make
#
261
common:		common_conf
262
	@$(MAKE) -C ${SRCCOMMONDIR}
263

Xavier Guimard's avatar
Xavier Guimard committed
264
handler:	handler_conf common
265
	@$(MAKE) -C ${SRCHANDLERDIR}
266

Xavier Guimard's avatar
Xavier Guimard committed
267
portal:		portal_conf common
268
	@$(MAKE) -C ${SRCPORTALDIR}
269

Xavier Guimard's avatar
Xavier Guimard committed
270
manager:	manager_conf handler
271
	$(MAKE) -C ${SRCMANAGERDIR}
272

273 274 275
################
# Test targets #
################
Xavier Guimard's avatar
Xavier Guimard committed
276
test:		all common_test handler_test portal_test manager_test extra_test
277 278 279 280

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

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

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

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

Xavier Guimard's avatar
Xavier Guimard committed
290
extra_test:	all
291
	cd ${SRCPORTALDIR} && prove -b -I ../$(SRCCOMMONDIR)/blib/lib -I ../$(SRCHANDLERDIR)/blib/lib -I../${SRCPORTALDIR}/blib/lib/ xt
292
#	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
293

294
# End-to-end tests
295 296 297
e2e_test:	all prepare_test_server start_web_server launch_protractor stop_web_server

prepare_test_server:
298
	@mkdir -p e2e-tests/conf/sessions/lock e2e-tests/conf/persistents/lock
Xavier Guimard's avatar
Xavier Guimard committed
299
	@$(MAKE) install_webserver_conf \
300 301
		RCONFDIR=e2e-tests/conf \
		ERASECONFIG=1 \
Xavier Guimard's avatar
Xavier Guimard committed
302 303 304
		VHOSTLISTEN='*:$(TESTWEBSERVERPORT)' \
		PORT=$(TESTWEBSERVERPORT) \
		PSGISERVERSOCKET=unix:`pwd`/e2e-tests/conf/llng.sock \
305 306
		PORTALDIR=`pwd`/$(SRCPORTALDIR)/example \
		MANAGERDIR=`pwd`/$(SRCMANAGERDIR)/site \
307 308 309
		MANAGERPSGIDIR=`pwd`/e2e-tests \
		DEFDOCDIR=`pwd`/doc \
		FRDOCDIR=`pwd`/po-doc/fr
Xavier Guimard's avatar
Xavier Guimard committed
310
	@cp e2e-tests/lmConf-1.js e2e-tests/lemonldap-ng.ini e2e-tests/env.conf e2e-tests/conf/
Xavier Guimard's avatar
Xavier Guimard committed
311
	@perl -i -pe 'BEGIN{$$p=`pwd`;chomp $$p}s#__pwd__#$$p#;s/__port__/$(TESTWEBSERVERPORT)/' e2e-tests/conf/lemonldap-ng.ini e2e-tests/conf/lmConf-1.js e2e-tests/conf/env.conf
312

Xavier Guimard's avatar
Xavier Guimard committed
313 314 315
e2e-tests/conf/apache2.pid: start_web_server

start_web_server:	all prepare_test_server
Xavier Guimard's avatar
Xavier Guimard committed
316
	# Clean old server if launched
317
	-@[ -e e2e-tests/conf/apache2.pid ] && kill `cat e2e-tests/conf/apache2.pid` && sleep 1
318
	-@[ -e e2e-tests/conf/nginx.pid ] && kill `cat e2e-tests/conf/nginx.pid`
319
	# Start web server (designed for Debian, path may be broken else)
320 321 322 323 324 325 326 327 328 329 330 331
	@if test "$(TESTWEBSERVER)" = "apache"; then \
		LLNG_DEFAULTCONFFILE=`pwd`/e2e-tests/conf/lemonldap-ng.ini /usr/sbin/apache2 -d `pwd`/e2e-tests -f apache2.conf -k start; \
	elif test "$(TESTWEBSERVER)" = "nginx"; then \
		@$(NGINX) -p `pwd`/e2e-tests \
			-g 'error_log /home/xavier/dev/lemonldap/e2e-tests/conf/nginx.log;' \
			-c `pwd`/e2e-tests/nginx.conf \
			2>&1 | grep -v 'Permission denied' || true; \
	else \
		echo "!!!!! Unknown test server: $(TESTWEBSERVER) !!!!!" >&2; \
		exit 1; \
	fi
		
332

Xavier Guimard's avatar
Xavier Guimard committed
333
reload_web_server:
334 335
	@if [ -e e2e-tests/conf/apache2.pid ]; then \
		LLNG_DEFAULTCONFFILE=`pwd`/e2e-tests/conf/lemonldap-ng.ini /usr/sbin/apache2 -d `pwd`/e2e-tests -f apache2.conf -k graceful; \
336 337
	elif [ -e e2e-tests/conf/nginx.pid ]; then \
		kill -HUP `cat e2e-tests/conf/nginx.pid`; \
338 339 340 341
	else \
		$(MAKE) start_web_server; \
	fi

Xavier Guimard's avatar
Xavier Guimard committed
342
launch_protractor:	all e2e-tests/conf/apache2.pid
343
	# Start e2e tests
Xavier Guimard's avatar
Xavier Guimard committed
344
	# NB: you must have protractor installed (using npm install -g protractor)
Xavier Guimard's avatar
Xavier Guimard committed
345
	# and have run update-webdriver at least once and have a node.js > 4.0
Xavier Guimard's avatar
Xavier Guimard committed
346
	@TESTWEBSERVERPORT=$(TESTWEBSERVERPORT) protractor e2e-tests/protractor-conf.js
347 348 349

stop_web_server:
	# Stop web server
350 351
	-@[ -e e2e-tests/conf/apache2.pid ] && kill `cat e2e-tests/conf/apache2.pid`
	-@[ -e e2e-tests/conf/nginx.pid ] && kill `cat e2e-tests/conf/nginx.pid`
352
	# Clean
353
	@rm -rf e2e-tests/conf
354

355 356
restart_web_server: start_web_server

357 358 359 360
#
# INSTALL
#
install:	install_libs install_bin install_site
361

362 363 364
#
# Perl libraires install
#
365
install_libs:	common_install_libs install_handler_libs install_portal_libs install_manager_libs
366 367

common_install_libs:		common
368
	@$(MAKE) -C ${SRCCOMMONDIR} install
369

370
install_handler_libs:	handler
371
	@$(MAKE) -C ${SRCHANDLERDIR} install
372

373
install_portal_libs:		portal
374
	@$(MAKE) -C ${SRCPORTALDIR} install
375

376
install_manager_libs:	manager
377
	@$(MAKE) -C ${SRCMANAGERDIR} install
378

379
example:
Xavier Guimard's avatar
Xavier Guimard committed
380
	$(MAKE) install_site install_bin LMPREFIX=$(EXAMPLEROOT)
381

Xavier Guimard's avatar
Xavier Guimard committed
382
install_bin:	install_conf_dir
383 384
	# Binary install
	@install -v -d $(RBINDIR)
Xavier Guimard's avatar
Xavier Guimard committed
385
	@cp -f\
386
		${SRCHANDLERDIR}/example/scripts/purgeLocalCache \
387
		${SRCPORTALDIR}/example/scripts/purgeCentralCache \
388
		${SRCPORTALDIR}/example/scripts/buildPortalWSDL \
Xavier Guimard's avatar
Xavier Guimard committed
389
		${SRCCOMMONDIR}/scripts/convertConfig \
Xavier Guimard's avatar
Xavier Guimard committed
390
		${SRCCOMMONDIR}/scripts/lmMigrateConfFiles2ini \
391
		${SRCCOMMONDIR}/scripts/rotateOidcKeys \
Xavier Guimard's avatar
Xavier Guimard committed
392 393
		${SRCMANAGERDIR}/scripts/lmConfigEditor \
		${SRCMANAGERDIR}/scripts/lemonldap-ng-cli \
394
			$(RBINDIR)
395 396
	@if [ ! "$(APACHEUSER)" ]; then \
		$(PERL) -i -pe 's#__APACHEUSER__#nobody#g;' $(RBINDIR)/lmConfigEditor; \
397
		$(PERL) -i -pe 's#__APACHEUSER__#nobody#g;' $(RBINDIR)/lemonldap-ng-cli; \
398 399
	else \
		$(PERL) -i -pe 's#__APACHEUSER__#$(APACHEUSER)#g;' $(RBINDIR)/lmConfigEditor; \
400
		$(PERL) -i -pe 's#__APACHEUSER__#$(APACHEUSER)#g;' $(RBINDIR)/lemonldap-ng-cli; \
401 402 403
	fi
	@if [ ! "$(APACHEGROUP)" ]; then \
		$(PERL) -i -pe 's#__APACHEGROUP__#nobody#g;' $(RBINDIR)/lmConfigEditor; \
404
		$(PERL) -i -pe 's#__APACHEGROUP__#nobody#g;' $(RBINDIR)/lemonldap-ng-cli; \
405 406
	else \
		$(PERL) -i -pe 's#__APACHEGROUP__#$(APACHEGROUP)#g;' $(RBINDIR)/lmConfigEditor; \
407
		$(PERL) -i -pe 's#__APACHEGROUP__#$(APACHEGROUP)#g;' $(RBINDIR)/lemonldap-ng-cli; \
408
	fi
409
	@chmod +x $(RBINDIR)/*
410 411 412 413

#
# SITE INSTALL
#
414
install_site:	install_manager_site install_portal_site install_handler_site install_test_site install_examples_site install_doc_site install_webserver_conf
415
	# Site install
416
	@install -v -d $(RCONFDIR)
Clément OUDOT's avatar
Clément OUDOT committed
417 418
	# Check if erase is wanted
	@if [ "$(ERASECONFIG)" -eq "1" ]; then \
Xavier Guimard's avatar
Xavier Guimard committed
419
		cp -f _example/etc/for_etc_hosts $(RCONFDIR); \
420
	fi
Xavier Guimard's avatar
Xavier Guimard committed
421
	@$(PERL) -i -pe 's/__DNSDOMAIN__/$(DNSDOMAIN)/g' $(RCONFDIR)/for_etc_hosts
422
	# Fix a lost of rights on the main directory
Xavier Guimard's avatar
Xavier Guimard committed
423
	@chmod 755 $(RBINDIR) $(RDOCUMENTROOT) $(REXAMPLESDIR) $(RHANDLERDIR) $(RPORTALSKINSDIR) $(RMANAGERSITEDIR) $(RTOOLSDIR) $(RCONFDIR) $(RDATADIR)
424
	@echo
425
	@echo "LemonLDAP::NG v${VERSION} is installed with these parameters:"
426 427 428 429 430
	@echo "  - System configuration: ${CONFDIR}"
	@echo "  - DNS domain (for cookies and virtual hosts): ${DNSDOMAIN}"
	@echo
	@echo "To finish configuration:"
	@echo
431 432 433 434
	@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"
435
	@echo "      include ${CONFDIR}/test-apache$(APACHEVERSION).conf"
436
	@echo
437 438
	@echo "2 - Restart Apache:"
	@echo "      apache$(APACHEVERSION)ctl restart"
439
	@echo
440
	@echo "3 - Run 'make postconf' as root to update /etc/hosts if your DNS service does not known auth.$(DNSDOMAIN) and manager.$(DNSDOMAIN)"
441
	@echo
442 443 444 445 446 447
	@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"
448
	@echo
449
	@if [ ! "$(APACHEUSER)" ]; then \
450
		echo;echo "    Warning, since APACHEUSER was not set, $(APACHESESSIONFILEDIR), $(APACHEPSESSIONFILEDIR), $(CAPTCHADIR) and $(CONFDIR) have permissive permissions."; \
451 452 453
		echo "    Fix them by yourself to restrict their view to apache process only"; \
	fi
	@echo
454

455 456 457 458 459 460 461
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); \
Xavier Guimard's avatar
Xavier Guimard committed
462
		cp -f _example/etc/handler-nginx.conf $(RCONFDIR); \
463 464 465 466 467 468 469
	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; \
Xavier Guimard's avatar
Xavier Guimard committed
470 471
			s#__PORT__#$(PORT)#g; \
			s#__PSGISERVERSOCKET__#$(PSGISERVERSOCKET)#g; \
472 473 474 475
			s#__VHOSTLISTEN__#$(VHOSTLISTEN)#g; \
			s#__DEFDOCDIR__#$(DEFDOCDIR)/#g; \
			s#__FRDOCDIR__#$(FRDOCDIR)/#g;' $(RCONFDIR)/*apache*.conf $(RCONFDIR)/*nginx*.conf

476 477
install_manager_site:	install_conf_dir
	# Manager install
478 479 480
	@install -v -d ${RMANAGERDIR} $(RMANAGERSTATICDIR) $(RMANAGERPSGIDIR) \
		$(RMANAGERTEMPLATESDIR)
	@cp -pR $(SRCMANAGERDIR)/site/static/* $(RMANAGERSTATICDIR)
481
	@for f in $(SRCMANAGERDIR)/site/templates/*.tpl; do \
482 483 484 485 486
		./scripts/transform-templates \
			usedebianlibs $(USEDEBIANLIBS) \
			useexternallibs $(USEEXTERNALLIBS) \
			jsminified $(JSCOMPRESS) \
			cssminified $(CSSCOMPRESS) <$$f \
487 488
			> $(RMANAGERTEMPLATESDIR)/`basename $$f`; \
	done
489
	@if test "$(USEEXTERNALLIBS)" = "yes"; then \
490
		rm -rvf $(MANAGEREXTERNALLIBS); \
491
	elif test "$(USEDEBIANLIBS)" = "yes"; then \
492 493
		rm -rvf $(MANAGERLIBSTOREMOVEFORDEBIAN); \
	fi
494 495 496 497
	@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
498
	$(PERL) -i -pe 's#__MANAGERSTATICDIR__#$(MANAGERRELATIVESTATICDIR)#g' $(RCONFDIR)/$(CONFFILENAME)
499
	$(PERL) -i -pe 's#__MANAGERTEMPLATESDIR__#$(MANAGERTEMPLATESDIR)#g' $(RCONFDIR)/$(CONFFILENAME)
500 501 502 503

install_portal_site:	install_conf_dir
	# Portal install
	@install -v -d $(RPORTALDIR) $(RPORTALSKINSDIR) \
504
		$(RPORTALDIR)/skins/ \
505
		$(RCRONDIR) $(RCONFDIR)
506
	@for skin in $$(ls $(SRCPORTALDIR)/example/skins/); do \
507 508
		[ -h $(RPORTALDIR)/skins/$$skin ] && rm -f $(RPORTALDIR)/skins/$$skin; \
		install -v -d $(RPORTALSKINSDIR)/$$skin; \
509
	done
Xavier Guimard's avatar
Xavier Guimard committed
510 511 512
	@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}
513
	@cp -pR -f ${SRCPORTALDIR}/example/openid-configuration.pl ${RPORTALDIR}
Xavier Guimard's avatar
Xavier Guimard committed
514 515
	@cp -pR -f ${SRCPORTALDIR}/example/cdc.pl ${RPORTALDIR}
	@cp -pR -f ${SRCPORTALDIR}/example/register.pl ${RPORTALDIR}
516
	@tar -cf - -C ${SRCPORTALDIR}/example/skins/ $$(ls ${SRCPORTALDIR}/example/skins/) |tar -xf - -C $(RPORTALSKINSDIR)
517
	@for f in `find $(RPORTALSKINSDIR) -type f -name '*.tpl'`; do \
518
		./scripts/transform-templates usedebianlibs $(USEDEBIANLIBS) jsminified $(JSCOMPRESS) cssminified $(CSSCOMPRESS) <$$f >$$f.tmp; \
519 520
		mv -f $$f.tmp $$f; \
	done
521
	@if test "$(USEEXTERNALLIBS)" = "yes"; then \
522
		rm -rvf $(PORTALEXTERNALLIBS); \
523
	elif test "$(USEDEBIANLIBS)" = "yes"; then \
524 525
		rm -rvf $(PORTALLIBSTOREMOVEFORDEBIAN); \
	fi
526
	@if [ "$(PORTALDIR)/skins/" != "$(PORTALSKINSDIR)/" ]; then \
527
		for skin in $$(ls $(SRCPORTALDIR)/example/skins/); do \
528 529
			rm -rf $(RPORTALDIR)/skins/$$skin/; \
			ln -s $(PORTALSKINSDIR)/$$skin $(RPORTALDIR)/skins/$$skin; \
530 531 532
		done; \
	fi
	# Cron files
533
	@cp -f $(SRCPORTALDIR)/example/scripts/purgeCentralCache.cron.d $(RCRONDIR)/lemonldap-ng-portal
534
	@if [ ! "$(APACHEUSER)" ]; then \
535
		$(PERL) -i -pe 's#__APACHEUSER__#nobody#g;' $(RCRONDIR)/lemonldap-ng-portal; \
536
	else \
537
		$(PERL) -i -pe 's#__APACHEUSER__#$(APACHEUSER)#g;' $(RCRONDIR)/lemonldap-ng-portal; \
538
	fi
539
	@$(PERL) -i -pe 's#__BINDIR__#$(BINDIR)#g;' $(RCRONDIR)/lemonldap-ng-portal
540
	# Clean SVN files
541
	@rm -rf $$(find ${RPORTALDIR} $(RPORTALSKINSDIR) $(RCRONDIR) $(RCONFDIR) -type d -name .svn)
542 543

install_handler_site:	install_conf_dir
544
	# Handler install
545
	@install -v -d ${RHANDLERDIR}
546
	@cp -f $(SRCHANDLERDIR)/example/scripts/purgeLocalCache.cron.d $(RCRONDIR)/lemonldap-ng-handler
547
	@if [ ! "$(APACHEUSER)" ]; then \
548
		$(PERL) -i -pe 's#__APACHEUSER__#nobody#g;' $(RCRONDIR)/lemonldap-ng-handler; \
549 550 551 552
	else \
		$(PERL) -i -pe 's#__APACHEUSER__#$(APACHEUSER)#g;' $(RCRONDIR)/lemonldap-ng-handler; \
	fi
	@$(PERL) -i -pe 's#__BINDIR__#$(BINDIR)#g;' $(RCRONDIR)/lemonldap-ng-handler
553
	@rm -rf $$(find $(RHANDLERDIR) -type d -name .svn)
554 555

install_test_site:
556
	# Test site install
557
	@install -v -d $(RTESTDIR)
Xavier Guimard's avatar
Xavier Guimard committed
558
	@cp -pR -f _example/test/* $(RTESTDIR)
559
	@rm -rf $$(find $(RTESTDIR) -type d -name .svn)
Xavier Guimard's avatar
Xavier Guimard committed
560
	@$(PERL) -i -pe 's/__DNSDOMAIN__/$(DNSDOMAIN)/g' $(RTESTDIR)/index.pl
561
	@rm -rf $$(find $(RTESTDIR) -type d -name .svn)
562 563

install_examples_site:
564
	# Examples install
565
	@install -v -d $(REXAMPLESDIR)
566
	@for i in manager portal handler; do \
Xavier Guimard's avatar
Xavier Guimard committed
567
		cp -a -f lemonldap-ng-$$i/example $(REXAMPLESDIR)/$$i; \
568
	done
569
	@rm -rf $(REXAMPLESDIR)/portal/skins \
Xavier Guimard's avatar
Xavier Guimard committed
570
		$(REXAMPLESDIR)/manager/skins \
571
	@rm -rf $$(find $(REXAMPLESDIR) -type d -name .svn)
572
	@$(PERL) -i -pe 's#__SESSIONDIR__#$(APACHESESSIONFILEDIR)/#g;' $(REXAMPLESDIR)/portal/*.pl
573
	@$(PERL) -i -pe 's#__PSESSIONDIR__#$(APACHEPSESSIONFILEDIR)/#g;' $(REXAMPLESDIR)/portal/*.pl
574

575
install_doc_site:
576
	# Offline documentation install
577 578
	@rm -rf $(RDEFDOCDIR)
	@install -v -d $(RDEFDOCDIR)
Xavier Guimard's avatar
Xavier Guimard committed
579
	@cp -a -f doc/* $(RDEFDOCDIR)
580

581
install_conf_dir:	install_sessions_dir install_notif_dir install_captcha_dir
582
	# Configuration files install
583
	@install -v -d $(RCONFDIR) $(RFILECONFIGDIR) $(RTOOLSDIR)
Clément OUDOT's avatar
Clément OUDOT committed
584
	@if [ "$(ERASECONFIG)" -eq "1" ]; then \
Xavier Guimard's avatar
Xavier Guimard committed
585
		cp -f $(SRCCOMMONDIR)/$(CONFFILENAME) $(RCONFDIR); \
Xavier Guimard's avatar
Xavier Guimard committed
586
		$(PERL) -i -pe 's#^dirName\s*=\s*.*#dirName = $(FILECONFIGDIR)#g' $(RCONFDIR)/$(CONFFILENAME); \
Clément OUDOT's avatar
Clément OUDOT committed
587
	fi
588
	@cp _example/conf/lmConf-1.js $(RFILECONFIGDIR)
Xavier Guimard's avatar
Xavier Guimard committed
589
	@$(PERL) -i -pe 's/__DNSDOMAIN__/$(DNSDOMAIN)/g;\
590
		s#__SESSIONDIR__#$(APACHESESSIONFILEDIR)#g;\
591
		s#__PSESSIONDIR__#$(APACHEPSESSIONFILEDIR)#g;\
592
		s#__NOTIFICATIONDIR__#$(APACHEFILENOTIFDIR)#g;' $(RFILECONFIGDIR)/lmConf-1.js
593 594 595 596 597 598 599 600 601
	@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
602 603
	@cp $(SRCCOMMONDIR)/tools/lmConfig.* $(SRCCOMMONDIR)/tools/apache-session-mysql.sql $(RTOOLSDIR)
	@cp $(SRCCOMMONDIR)/tools/sso.schema $(RTOOLSDIR)
604
	$(PERL) -i -pe 's/__DNSDOMAIN__/$(DNSDOMAIN)/g' $(RCONFDIR)/$(CONFFILENAME)
605
	@rm -rf $$(find $(RCONFDIR) $(RFILECONFIGDIR) $(RTOOLSDIR) -type d -name .svn)
606 607

install_sessions_dir:
608
	@install -m 777 -v -d $(RAPACHESESSIONFILEDIR) $(RAPACHESESSIONFILELOCKDIR) $(RAPACHEPSESSIONFILEDIR) $(RAPACHEPSESSIONFILELOCKDIR)
609 610
	# Fix Apache::Session directories permissions
	@if [ "$(APACHEUSER)" != "" ]; then \
611
		chown $(APACHEUSER) $(RAPACHESESSIONFILEDIR) $(RAPACHESESSIONFILELOCKDIR) $(RAPACHEPSESSIONFILEDIR) $(RAPACHEPSESSIONFILELOCKDIR) || exit 1; \
612
		if [ "$(APACHEGROUP)" != "" ]; then \
613
			chgrp $(APACHEGROUP) $(RAPACHESESSIONFILEDIR) $(RAPACHESESSIONFILELOCKDIR) $(RAPACHEPSESSIONFILEDIR) $(RAPACHEPSESSIONFILELOCKDIR) || exit 1; \
614
		fi; \
615
		chmod 770 $(RAPACHESESSIONFILEDIR) $(RAPACHESESSIONFILELOCKDIR) $(RAPACHEPSESSIONFILEDIR) $(RAPACHEPSESSIONFILELOCKDIR); \
616
	else \
617
		chmod 777 $(RAPACHESESSIONFILEDIR) $(RAPACHESESSIONFILELOCKDIR) $(RAPACHEPSESSIONFILEDIR) $(RAPACHEPSESSIONFILELOCKDIR); \
618 619
	fi

620 621 622 623 624 625 626 627 628 629 630 631 632
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

633
install_captcha_dir:
634
	@install -m 777 -v -d $(RCAPTCHADIR)
635 636
	# Fix captcha directory permissions
	@if [ "$(APACHEUSER)" != "" ]; then \
637
		chown $(APACHEUSER) $(RCAPTCHADIR) || exit 1; \
638
		if [ "$(APACHEGROUP)" != "" ]; then \
639
			chgrp $(APACHEGROUP) $(RCAPTCHADIR) || exit 1; \
640
		fi; \
641
		chmod 770 $(RCAPTCHADIR); \
642
	else \
643
		chmod 777 $(RCAPTCHADIR); \
644 645
	fi

646
postconf_hosts:
Clément OUDOT's avatar
Clément OUDOT committed
647
	@cat ${CONFDIR}/for_etc_hosts >> /etc/hosts
648 649
	@echo "/etc/hosts was updated"

650
postconf: postconf_hosts
651 652
	@echo "Post configuration done"

653 654
uninstall:	configure handler_uninstall portal_uninstall manager_uninstall

655 656 657 658
common_uninstall:	common
	@$(MAKE) -C ${SRCCOMMONDIR} uninstall
	@rm -vf common_uninstall

659
handler_uninstall:	handler
660
	@$(MAKE) -C ${SRCHANDLERDIR} uninstall
661
	@rm -vf handler_uninstall
662 663

portal_uninstall:		portal
664
	@$(MAKE) -C ${SRCPORTALDIR} uninstall
665
	@rm -vf portal_uninstall
666 667

manager_uninstall:	manager
668
	@$(MAKE) -C ${SRCMANAGERDIR} uninstall
669
	@rm -vf manager_uninstall
670

671
dist:	clean
672 673 674 675 676 677 678 679 680 681
	@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
682
	@mkdir -p lemonldap-ng-$(VERSION)
683
	@cp -pRH $$(find * -maxdepth 0|grep -v -e "\(lemonldap-ng-$(VERSION)\|debian\)") lemonldap-ng-$(VERSION)
684 685
	@rm -rf $$(find lemonldap-ng-$(VERSION) -name .svn -print)
	@find $$dir -name '*.bak' -delete
686
	@rm -rf lemonldap-ng-$(VERSION)/lemonldap-ng-$(VERSION)
Xavier Guimard's avatar
Xavier Guimard committed
687
	@$(COMPRESS) lemonldap-ng-$(VERSION).$(COMPRESSSUFFIX) lemonldap-ng-$(VERSION)
688
	@rm -rf lemonldap-ng-$(VERSION)
689

690

691 692
debian-dist:	clean
	@mkdir -p lemonldap-ng-$(VERSION)
693
	@cp -pRH $$(find * -maxdepth 0|grep -v -e "\(lemonldap-ng-$(VERSION)\|rpm\)") lemonldap-ng-$(VERSION)
694 695
	@rm -rf $$(find lemonldap-ng-$(VERSION) -name .svn -print)
	@find $$dir -name '*.bak' -delete
696 697 698 699
	@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
700 701 702
	@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
703 704 705

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

707 708 709 710 711 712 713 714
manifest:   configure
	@for i in ${SRCCOMMONDIR} ${SRCHANDLERDIR} ${SRCPORTALDIR} ${SRCMANAGERDIR}; do \
		cd $$i; \
		make manifest; \
		rm -vf MANIFEST.*; \
		cd -; \
	done

715
cpan:	clean configure common_cpan handler_cpan portal_cpan manager_cpan
Clément OUDOT's avatar
Clément OUDOT committed
716
	for i in Common Portal Handler Manager; do \
Xavier Guimard's avatar
Xavier Guimard committed
717
		$(UNCOMPRESS) Lemonldap-NG-$$i-*.$(COMPRESSSUFFIX) \
Clément OUDOT's avatar
Clément OUDOT committed
718
			$$($(LISTCOMPRESSED) Lemonldap-NG-$$i-*.$(COMPRESSSUFFIX) |grep META.yml); \
Xavier Guimard's avatar
Xavier Guimard committed
719
		mv Lemonldap-NG-$$i-*/META.yml lemonldap-ng-$$($(PERL) -e "print lc('$$i')")/; \
720
		rm -rf Lemonldap-NG-$$i*/; \
Xavier Guimard's avatar
Xavier Guimard committed
721
		done
722 723 724 725

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

handler_cpan:	handler_conf
728 729
	@$(MAKE) -C ${SRCHANDLERDIR} dist
	@mv ${SRCHANDLERDIR}/Lemonldap*.gz .
730 731

portal_cpan:		portal_conf
732 733
	@$(MAKE) -C ${SRCPORTALDIR} dist
	@mv ${SRCPORTALDIR}/Lemonldap*.gz .
734 735

manager_cpan:	manager_conf
736 737
	@$(MAKE) -C ${SRCMANAGERDIR} dist
	@mv ${SRCMANAGERDIR}/Lemonldap*.gz .
738

739
documentation:
740
	@cd doc/ && ../scripts/doc.pl
741

742
doxygen:	clean
Xavier Guimard's avatar
Xavier Guimard committed
743
	$(PERL) -i -pe 's/^(PROJECT_NUMBER\s*=\s*)\d.*$$/$${1}'$(VERSION)'/' Doxyfile
744 745 746 747 748 749
	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
750
	$(PERL) -i -pe 's/Graphical Class Hierarchy/Class Collaboration Graph/' doc/devel/html/inherits.html doc/devel/html/tree.html
751 752
	# 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
753

754 755
distclean:	clean

Xavier Guimard's avatar
Xavier Guimard committed
756
clean:		common_clean handler_clean portal_clean manager_clean omegat-clean omegat-fr-clean stop_web_server
Xavier Guimard's avatar
Xavier Guimard committed
757
	@rm -f $$(find */ -name '*bak' -delete)
758
	@rm -rf $(EXAMPLEROOT) example/ doc/devel
Xavier Guimard's avatar
Xavier Guimard committed
759
	@rm -vf *gz *zip
Xavier Guimard's avatar
Xavier Guimard committed
760
	@rm -rf lemonldap-ng-$(VERSION)
Xavier Guimard's avatar
Xavier Guimard committed
761
	@echo "Cleaned"
762 763

common_clean:
Xavier Guimard's avatar
Xavier Guimard committed
764
	@if test -e ${SRCCOMMONDIR}/Makefile;then $(MAKE) -C ${SRCCOMMONDIR} distclean;fi
765 766 767
	@rm -vf common*

handler_clean:
Xavier Guimard's avatar
Xavier Guimard committed
768
	@if test -e ${SRCHANDLERDIR}/Makefile;then $(MAKE) -C ${SRCHANDLERDIR} distclean;fi
769 770 771
	@rm -vf handler*

portal_clean:
Xavier Guimard's avatar
Xavier Guimard committed
772
	@if test -e ${SRCPORTALDIR}/Makefile;then $(MAKE) -C ${SRCPORTALDIR} distclean;fi
773 774 775
	@rm -vf portal*

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

779
debian-local-packages: debian-dist
Xavier Guimard's avatar
Xavier Guimard committed
780
	mv lemonldap-ng_$(VERSION).orig.$(COMPRESSSUFFIX) /tmp/
781 782
	version=$(VERSION) && \
	cd /tmp/ && \
Xavier Guimard's avatar
Xavier Guimard committed
783
	rm -rf lemonldap-ng-$$version && \
Xavier Guimard's avatar
Xavier Guimard committed
784
	$(UNCOMPRESS) lemonldap-ng_$$version.orig.$(COMPRESSSUFFIX) && \
785
	cd lemonldap-ng-$$version && \
Xavier Guimard's avatar
Xavier Guimard committed
786
	debuild -us -uc -b --lintian-opts -i \
Xavier Guimard's avatar
Xavier Guimard committed
787 788 789
		--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
790

791 792 793 794 795 796 797 798 799 800 801 802 803
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
804
	cd /tmp/lemonldap-ng-$(VERSION) && \
Xavier Guimard's avatar
Xavier Guimard committed
805 806 807 808 809 810
	$(SU) debi

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

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

Xavier Guimard's avatar
Xavier Guimard committed
812
debian-diff:
Xavier Guimard's avatar
Xavier Guimard committed
813
	@# Portal
814 815 816
	@$(DIFF) $(SRCPORTALDIR)/lib/Lemonldap/NG/Portal $(DIFFPREFIX)/usr/share/perl5/Lemonldap/NG/Portal ||true
	@$(DIFF) $(SRCPORTALDIR)/example/scripts/purgeCentralCache $(DIFFPREFIX)/usr/share/lemonldap-ng/bin/purgeCentralCache ||true
	@$(DIFF) $(SRCPORTALDIR)/example/scripts/buildPortalWSDL $(DIFFPREFIX)/usr/share/lemonldap-ng/bin/buildPortalWSDL ||true
Xavier Guimard's avatar
Xavier Guimard committed
817
	@for i in $(PORTALSKINS); do \
818
		$(DIFF) -x 'jquery*' $(SRCPORTALDIR)/example/skins/$$i $(DIFFPREFIX)/usr/share/lemonldap-ng/portal-skins/$$i; \
Xavier Guimard's avatar
Xavier Guimard committed
819
	done ||true
820 821 822 823 824 825
	@$(DIFF) $(SRCPORTALDIR)/example/index_skin.pl $(DIFFPREFIX)/var/lib/lemonldap-ng/portal/index.pl ||true
	@$(DIFF) $(SRCPORTALDIR)/example/mail.pl $(DIFFPREFIX)/var/lib/lemonldap-ng/portal/mail.pl ||true
	@$(DIFF) $(SRCPORTALDIR)/example/metadata.pl $(DIFFPREFIX)/var/lib/lemonldap-ng/portal/metadata.pl ||true
	@$(DIFF) $(SRCPORTALDIR)/example/openid-configuration.pl $(DIFFPREFIX)/var/lib/lemonldap-ng/portal/openid-configuration.pl ||true
	@$(DIFF) $(SRCPORTALDIR)/example/cdc.pl $(DIFFPREFIX)/var/lib/lemonldap-ng/portal/cdc.pl ||true
	@$(DIFF) $(SRCPORTALDIR)/example/register.pl $(DIFFPREFIX)/var/lib/lemonldap-ng/portal/register.pl ||true
Xavier Guimard's avatar
Xavier Guimard committed
826
	@# Handler
827 828
	@$(DIFF) $(SRCHANDLERDIR)/lib/Lemonldap/NG/Handler $(DIFFPREFIX)/usr/share/perl5/Lemonldap/NG/Handler ||true
	@$(DIFF) $(SRCHANDLERDIR)/example/scripts/purgeLocalCache $(DIFFPREFIX)/usr/share/lemonldap-ng/bin/purgeLocalCache ||true
Xavier Guimard's avatar
Xavier Guimard committed
829
	@# Common
830 831 832 833 834
	@$(DIFF) $(SRCCOMMONDIR)/lib/Lemonldap/NG/Common $(DIFFPREFIX)/usr/share/perl5/Lemonldap/NG/Common ||true
	@$(DIFF) $(SRCCOMMONDIR)/lib/Lemonldap/NG/Common.pm $(DIFFPREFIX)/usr/share/perl5/Lemonldap/NG/Common.pm ||true
	@$(DIFF) $(SRCCOMMONDIR)/scripts/lmMigrateConfFiles2ini $(DIFFPREFIX)/usr/share/lemonldap-ng/bin/lmMigrateConfFiles2ini ||true
	@$(DIFF) $(SRCCOMMONDIR)/scripts/convertConfig $(DIFFPREFIX)/usr/share/lemonldap-ng/bin/convertConfig ||true
	@$(DIFF) $(SRCCOMMONDIR)/scripts/rotateOidcKeys $(DIFFPREFIX)/usr/share/lemonldap-ng/bin/rotateOidcKeys ||true
Xavier Guimard's avatar
Xavier Guimard committed
835
	@# Manager
836 837 838 839 840 841 842
	@$(DIFF) $(SRCMANAGERDIR)/lib/Lemonldap/NG/Manager $(DIFFPREFIX)/usr/share/perl5/Lemonldap/NG/Manager ||true
	@$(DIFF) $(SRCMANAGERDIR)/lib/Lemonldap/NG/Manager.pm $(DIFFPREFIX)/usr/share/perl5/Lemonldap/NG/Manager.pm ||true
	@$(DIFF) $(SRCMANAGERDIR)/eg $(DIFFPREFIX)/var/lib/lemonldap-ng/manager/psgi ||true
	@$(DIFF) $(SRCMANAGERDIR)/site/static $(DIFFPREFIX)/var/lib/lemonldap-ng/manager/static ||true
	@$(DIFF) $(SRCMANAGERDIR)/site/templates $(DIFFPREFIX)/var/lib/lemonldap-ng/manager/templates ||true
	@$(DIFF) --ignore-matching-lines='set.*get.*\[2\]' $(SRCMANAGERDIR)/scripts/lmConfigEditor $(DIFFPREFIX)/usr/share/lemonldap-ng/bin/lmConfigEditor ||true
	@$(DIFF) --ignore-matching-lines='giveUpPrivileges' $(SRCMANAGERDIR)/scripts/lemonldap-ng-cli $(DIFFPREFIX)/usr/share/lemonldap-ng/bin/lemonldap-ng-cli ||true
Xavier Guimard's avatar
Xavier Guimard committed
843

844 845
default-diff:
	@# Portal
846 847 848 849 850 851 852 853 854 855
	@$(DIFF) $(SRCPORTALDIR)/lib/Lemonldap/NG/Portal /usr/local/share/perl/$(PERLVERSION)/Lemonldap/NG/Portal ||true
	@$(DIFF) $(SRCPORTALDIR)/example/scripts/purgeCentralCache $(LMPREFIX)/bin/purgeCentralCache ||true
	@$(DIFF) $(SRCPORTALDIR)/example/scripts/buildPortalWSDL $(LMPREFIX)/bin/buildPortalWSDL ||true
	@$(DIFF) $(SRCPORTALDIR)/example/skins $(LMPREFIX)/htdocs/portal/skins ||true
	@$(DIFF) $(SRCPORTALDIR)/example/index_skin.pl $(LMPREFIX)/htdocs/portal/index.pl ||true
	@$(DIFF) $(SRCPORTALDIR)/example/mail.pl $(LMPREFIX)/htdocs/portal/mail.pl ||true
	@$(DIFF) $(SRCPORTALDIR)/example/register.pl $(LMPREFIX)/htdocs/portal/register.pl ||true
	@$(DIFF) $(SRCPORTALDIR)/example/metadata.pl $(LMPREFIX)/htdocs/portal/metadata.pl ||true
	@$(DIFF) $(SRCPORTALDIR)/example/openid-configuration.pl $(LMPREFIX)/htdocs/portal/openid-configuration.pl ||true
	@$(DIFF) $(SRCPORTALDIR)/example/cdc.pl $(LMPREFIX)/htdocs/portal/cdc.pl ||true
856
	@# Handler
857 858
	@$(DIFF) $(SRCHANDLERDIR)/lib/Lemonldap/NG/Handler /usr/local/share/perl/$(PERLVERSION)/Lemonldap/NG/Handler ||true
	@$(DIFF) $(SRCHANDLERDIR)/example/scripts/purgeLocalCache $(LMPREFIX)/bin/purgeLocalCache ||true
859
	@# Common
860 861 862 863 864
	@$(DIFF) $(SRCCOMMONDIR)/lib/Lemonldap/NG/Common /usr/local/share/perl/$(PERLVERSION)/Lemonldap/NG/Common ||true
	@$(DIFF) $(SRCCOMMONDIR)/lib/Lemonldap/NG/Common.pm /usr/local/share/perl/$(PERLVERSION)/Lemonldap/NG/Common.pm ||true
	@$(DIFF) $(SRCCOMMONDIR)/scripts/lmMigrateConfFiles2ini $(LMPREFIX)/bin/lmMigrateConfFiles2ini ||true
	@$(DIFF) $(SRCCOMMONDIR)/scripts/convertConfig $(LMPREFIX)/bin/convertConfig ||true
	@$(DIFF) $(SRCCOMMONDIR)/scripts/rotateOidcKeys $(LMPREFIX)/bin/rotateOidcKeys ||true
865
	@# Manager
866 867 868 869 870 871 872
	@$(DIFF) $(SRCMANAGERDIR)/lib/Lemonldap/NG/Manager /usr/local/share/perl/$(PERLVERSION)/Lemonldap/NG/Manager ||true
	@$(DIFF) $(SRCMANAGERDIR)/lib/Lemonldap/NG/Manager.pm /usr/local/share/perl/$(PERLVERSION)/Lemonldap/NG/Manager.pm ||true
	@$(DIFF) $(SRCMANAGERDIR)/eg $(LMPREFIX)/htdocs/manager/psgi ||true
	@$(DIFF) $(SRCMANAGERDIR)/site/static $(LMPREFIX)/htdocs/manager/static ||true
	@$(DIFF) $(SRCMANAGERDIR)/site/templates $(LMPREFIX)/htdocs/manager/templates ||true
	@$(DIFF) --ignore-matching-lines='set.*get.*\[2\]' $(SRCMANAGERDIR)/scripts/lmConfigEditor $(LMPREFIX)/bin/lmConfigEditor ||true
	@$(DIFF) --ignore-matching-lines='giveUpPrivileges' $(SRCMANAGERDIR)/scripts/lemonldap-ng-cli $(LMPREFIX)/bin/lemonldap-ng-cli ||true
873

874
tidy: clean
Xavier Guimard's avatar
Xavier Guimard committed
875
	find lemon*/ -type f \( -name '*.pm' -or -name '*.pl' -or -name '*.t' \) -print -exec perltidy -b {} \;
876
	find lemon*/ -name '*.bak' -delete
877
	$(MAKE) json
878

Xavier Guimard's avatar
Xavier Guimard committed
879
tidy-js: clean
880
	@find $(SRCMANAGERDIR)/site/static/js/ e2e-tests/ $(SRCPORTALDIR)/example \
881 882 883 884 885 886 887 888
		  -type f \
		  -name '*.js' \
		! -name 'jq*' \
		! -name 'bootstrap*' \
		! -name '*.min.js' \
		! -name conftree.js \
		  -print \
		  -exec js_beautify -o -s=2 {} \;
Xavier Guimard's avatar
Xavier Guimard committed
889

890 891 892 893
# TRANSLATION TARGETS #

# 1. Internal targets

894 895
language_code:
	perl -e ' \
Xavier Guimard's avatar
Xavier Guimard committed
896 897 898
		print { \
			fr=> "FR-FR", \
		}->{$(1)}'
899 900 901 902 903 904 905

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

906 907
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
908

909
translation: omegat-configuration-file