Makefile 38.9 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
BINDIR=$(LMPREFIX)/bin
RBINDIR=$(DESTDIR)/$(BINDIR)
34 35 36 37 38 39
SBINDIR=$(LMPREFIX)/sbin
RSBINDIR=$(DESTDIR)/$(SBINDIR)
INITDIR=$(LMPREFIX)/etc/init.d
RINITDIR=$(DESTDIR)/$(INITDIR)
ETCDEFAULTDIR=$(LMPREFIX)/etc/default
RETCDEFAULTDIR=$(DESTDIR)/$(ETCDEFAULTDIR)
40 41
DATADIR=$(LMPREFIX)/data
RDATADIR=$(DESTDIR)/$(DATADIR)
42

43
EXAMPLEROOT=`pwd`/example
44 45

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

# Handler dir
75 76
HANDLERDIR=$(LMPREFIX)/handler
RHANDLERDIR=$(DESTDIR)/$(HANDLERDIR)
77 78

# Configuration dir
79 80 81 82
CONFDIR=$(LMPREFIX)/etc
RCONFDIR=$(DESTDIR)/$(CONFDIR)
CRONDIR=$(LMPREFIX)/etc/cron.d
RCRONDIR=$(DESTDIR)/$(CRONDIR)
83 84
CONFFILENAME=lemonldap-ng.ini
STORAGECONFFILE=$(CONFDIR)/$(CONFFILENAME)
85

86
# LL::NG configuration storage dir
87 88
FILECONFIGDIR=$(DATADIR)/conf
RFILECONFIGDIR=$(DESTDIR)/$(FILECONFIGDIR)
89

90
# LL::NG sessions storage dir
91 92 93
APACHESESSIONFILEDIR=$(DATADIR)/sessions
RAPACHESESSIONFILEDIR=$(DESTDIR)/$(APACHESESSIONFILEDIR)
APACHESESSIONFILELOCKDIR=$(APACHESESSIONFILEDIR)/lock
94
RAPACHESESSIONFILELOCKDIR=$(DESTDIR)/$(APACHESESSIONFILELOCKDIR)
95

96 97 98 99 100 101 102
# LL::NG persistent sessions storage dir
APACHEPSESSIONFILEDIR=$(DATADIR)/psessions
RAPACHEPSESSIONFILEDIR=$(DESTDIR)/$(APACHEPSESSIONFILEDIR)
APACHEPSESSIONFILELOCKDIR=$(APACHEPSESSIONFILEDIR)/lock
RAPACHEPSESSIONFILELOCKDIR=$(DESTDIR)/$(APACHEPSESSIONFILELOCKDIR)

# LL::NG notifications storage dir
103 104
APACHEFILENOTIFDIR=$(DATADIR)/notifications
RFILENOTIFDIR=$(DESTDIR)/$(APACHEFILENOTIFDIR)
105

106 107
# LL::NG captcha dir
CAPTCHADIR=$(DATADIR)/captcha
108 109
RCAPTCHADIR=$(DESTDIR)/$(CAPTCHADIR)

110
# Apache user/group
111 112
APACHEUSER=
APACHEGROUP=
113 114 115 116

# FastCGI
FASTCGISOCKDIR=$(PREFIX)/run
RFASTCGISOCKDIR=$(DESTDIR)/$(FASTCGISOCKDIR)
117 118
FASTCGIUSER=$(APACHEUSER)
FASTCGIGROUP=$(APACHEGROUP)
119

120
# Apache version
121
APACHEVERSION=2.X
122

123
# DNS Domain for cookie and virtual hosts
124 125
DNSDOMAIN=example.com

126
# Virtual Host Listen IP and Port (*, *:80, ...)
Xavier Guimard's avatar
Xavier Guimard committed
127 128
PORT=80
VHOSTLISTEN="*:$(PORT)"
129
TESTWEBSERVER=apache
Xavier Guimard's avatar
Xavier Guimard committed
130
TESTWEBSERVERPORT=19876
131

132
# Other
133 134 135 136
SRCCOMMONDIR=lemonldap-ng-common
SRCHANDLERDIR=lemonldap-ng-handler
SRCPORTALDIR=lemonldap-ng-portal
SRCMANAGERDIR=lemonldap-ng-manager
137 138 139

VERSION=`head -n1 changelog |sed -e 's/lemonldap-ng (//' -e 's/).*$$//'`
PORTALSKINS=`ls $(SRCPORTALDIR)/example/skins/`
140
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.*'
141 142
DIFFPREFIX=

143

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

147 148
MANAGERLIBSTOREMOVEFORDEBIAN=$(RMANAGERSTATICDIR)/bwr/jquery/ \
			$(RMANAGERSTATICDIR)/bwr/angular/ \
149
			$(RMANAGERSTATICDIR)/bwr/angular-animate/ \
150 151 152 153 154 155 156 157
			$(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*
158 159
MANAGEREXTERNALLIBS=$(RMANAGERSTATICDIR)/bwr/
PORTALEXTERNALLIBS=$(PORTALLIBSTOREMOVEFORDEBIAN) $(RPORTALSKINSDIR)/common/js/jquery*
160

161
# GENERATED SRC FILESlemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/DefaultValues.pm
162
MANAGERJSONSRC= scripts/jsongenerator.pl \
Xavier Guimard's avatar
Xavier Guimard committed
163
		$(SRCMANAGERDIR)/lib/Lemonldap/NG/Manager/Build.pm \
164
		$(SRCMANAGERDIR)/lib/Lemonldap/NG/Manager/Build/Attributes.pm \
165 166
		$(SRCMANAGERDIR)/lib/Lemonldap/NG/Manager/Build/Tree.pm \
		$(SRCMANAGERDIR)/lib/Lemonldap/NG/Manager/Conf/Zero.pm
167 168
MANAGERJSONDST=$(SRCMANAGERDIR)/site/static/struct.json \
		$(SRCMANAGERDIR)/site/static/js/conftree.js \
Xavier Guimard's avatar
Xavier Guimard committed
169
		$(SRCMANAGERDIR)/lib/Lemonldap/NG/Manager/Attributes.pm \
170
		$(SRCMANAGERDIR)/lib/Lemonldap/NG/Manager/Constants.pm \
171
		$(SRCCOMMONDIR)/lib/Lemonldap/NG/Common/Conf/DefaultValues.pm \
172
		$(SRCCOMMONDIR)/lib/Lemonldap/NG/Common/Conf/Constants.pm \
173
		_example/conf/lmConf-1.js
174 175

# Javascript and CSS to minify
176 177
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
178
CSSSRCFILES:=$(shell find $(SRCMANAGERDIR)/site/static/css  $(SRCPORTALDIR)/example -type f -name '*.css' ! -name '*.min.css')
179 180 181 182

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

184
all:	configure common handler manager portal
185 186
	@echo
	@echo "Building succeed. Now run :"
Xavier Guimard's avatar
Error  
Xavier Guimard committed
187 188
	@echo " - 'make test' to verify your installation"
	@echo " - 'make install PROD=yes' to install all"
Xavier Guimard's avatar
Xavier Guimard committed
189 190 191 192 193
	@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"
194 195 196 197 198 199 200 201 202
	@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 :"
203
	@echo "   - install_libs           (all Perl libraries)"
204 205 206 207
	@echo "   - install_portal_libs"
	@echo "   - install_manager_libs"
	@echo "   - install_handler_libs"
	@echo " * Binaries install :"
208 209 210
	@echo "   - install_bin            ($(BINDIR))"
	@echo " * FastCGI server install   (required for Nginx)"
	@echo "   - install_fastcgi_server ($(SBINDIR))"
211
	@echo " * Web sites install :"
212 213 214 215
	@echo "   - install_site           (all sites including install_doc_site)"
	@echo "   - install_portal_site    ($(PORTALDIR))"
	@echo "   - install_manager_site   ($(MANAGERDIR))"
	@echo "   - install_handler_site   ($(HANDLERDIR))"
216
	@echo " * Documentation install :"
217 218
	@echo "   - install_doc_site       ($(DEFDOCDIR))"
	@echo "   - install_examples_site  ($(EXAMPLESDIR))"
219
	@echo
Xavier Guimard's avatar
Xavier Guimard committed
220
	@echo "Other languages documentation (fr only for now)"
221 222
	@echo " - fr-doc                  (needs OmegaT)"
	@echo " - install_fr_doc_site"
Xavier Guimard's avatar
Xavier Guimard committed
223
	@echo
224

Xavier Guimard's avatar
Xavier Guimard committed
225 226 227
#
# Minification
#
228 229 230
minify: $(JSDSTFILES) $(CSSDSTFILES)

%.min.css: %.css
Xavier Guimard's avatar
Fault  
Xavier Guimard committed
231
	@echo "Compressing $*.css"
232
	@yui-compressor $*.css > $*.min.css
233 234

%.min.js: %.js
Xavier Guimard's avatar
Fault  
Xavier Guimard committed
235
	@echo "Compressing $*.js"
236
	@yui-compressor $*.js > $*.min.js
237

Xavier Guimard's avatar
Xavier Guimard committed
238

239 240 241
#
# Perl libraries configuration
#
242

243
json:	$(MANAGERJSONDST) fastcgi-server/man/llng-fastcgi-server.1p
Xavier Guimard's avatar
Xavier Guimard committed
244
	@if which yui-compressor; then $(MAKE) minify; fi
245

246
$(MANAGERJSONDST):	$(MANAGERJSONSRC)
247
	./scripts/jsongenerator.pl
248

Xavier Guimard's avatar
Xavier Guimard committed
249 250 251
fastcgi-server/man/llng-fastcgi-server.1p: fastcgi-server/sbin/llng-fastcgi-server
	@pod2man -name llng-fastcgi-server fastcgi-server/sbin/llng-fastcgi-server >fastcgi-server/man/llng-fastcgi-server.1p

Xavier Guimard's avatar
Xavier Guimard committed
252
configure:	json common_conf handler_conf portal_conf manager_conf
253

254 255 256 257 258 259 260 261 262
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
263
	@cd ${SRCCOMMONDIR}; LMNGCONFFILE=$(STORAGECONFFILE) $(PERL) Makefile.PL $(PERLOPTIONS)
264

265
${SRCHANDLERDIR}/Makefile:
Xavier Guimard's avatar
Xavier Guimard committed
266
	@cd ${SRCHANDLERDIR}; $(PERL) Makefile.PL $(PERLOPTIONS)
267

268
${SRCPORTALDIR}/Makefile:
Xavier Guimard's avatar
Xavier Guimard committed
269
	@cd ${SRCPORTALDIR}; $(PERL) Makefile.PL $(PERLOPTIONS)
270

271
${SRCMANAGERDIR}/Makefile:
Xavier Guimard's avatar
Xavier Guimard committed
272
	@cd ${SRCMANAGERDIR}; $(PERL) Makefile.PL $(PERLOPTIONS)
273

274 275 276
#
# Perl libraries make
#
277
common:		common_conf
278
	@$(MAKE) -C ${SRCCOMMONDIR}
279

Xavier Guimard's avatar
Xavier Guimard committed
280
handler:	handler_conf common
281
	@$(MAKE) -C ${SRCHANDLERDIR}
282

Xavier Guimard's avatar
Xavier Guimard committed
283
portal:		portal_conf common
284
	@$(MAKE) -C ${SRCPORTALDIR}
285

Xavier Guimard's avatar
Xavier Guimard committed
286
manager:	manager_conf handler
287
	$(MAKE) -C ${SRCMANAGERDIR}
288

289 290 291
################
# Test targets #
################
Xavier Guimard's avatar
Xavier Guimard committed
292
test:		all common_test handler_test portal_test manager_test extra_test
293 294 295 296

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

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

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

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

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

310
# End-to-end tests
311 312 313
e2e_test:	all prepare_test_server start_web_server launch_protractor stop_web_server

prepare_test_server:
314
	@mkdir -p e2e-tests/conf/sessions/lock e2e-tests/conf/persistents/lock
Xavier Guimard's avatar
Xavier Guimard committed
315
	@$(MAKE) install_webserver_conf install_test_site \
316 317
		RCONFDIR=e2e-tests/conf \
		ERASECONFIG=1 \
Xavier Guimard's avatar
Xavier Guimard committed
318 319
		VHOSTLISTEN='*:$(TESTWEBSERVERPORT)' \
		PORT=$(TESTWEBSERVERPORT) \
Xavier Guimard's avatar
Xavier Guimard committed
320
		FASTCGISOCKDIR=`pwd`/e2e-tests/conf \
321 322
		PORTALDIR=`pwd`/$(SRCPORTALDIR)/example \
		MANAGERDIR=`pwd`/$(SRCMANAGERDIR)/site \
Xavier Guimard's avatar
Xavier Guimard committed
323
		TESTDIR=`pwd`/e2e-tests/conf/site \
324 325 326
		MANAGERPSGIDIR=`pwd`/e2e-tests \
		DEFDOCDIR=`pwd`/doc \
		FRDOCDIR=`pwd`/po-doc/fr
327
	@cp e2e-tests/lmConf-1.js e2e-tests/lemonldap-ng.ini e2e-tests/env.conf e2e-tests/test-nginx.conf e2e-tests/conf/
328
	@perl -i -pe 'BEGIN{$$p=`pwd`;chomp $$p}s#__pwd__#$$p#;s/__port__/$(TESTWEBSERVERPORT)/;s/__FASTCGISOCKDIR__/$(FASTCGISOCKDIR)/;' \
329 330 331 332
		e2e-tests/conf/lemonldap-ng.ini \
		e2e-tests/conf/lmConf-1.js \
		e2e-tests/conf/env.conf \
		e2e-tests/conf/test-nginx.conf
333

Xavier Guimard's avatar
Xavier Guimard committed
334 335 336
e2e-tests/conf/apache2.pid: start_web_server

start_web_server:	all prepare_test_server
Xavier Guimard's avatar
Xavier Guimard committed
337
	# Clean old server if launched
338 339 340
	-@[ -e e2e-tests/conf/apache2.pid ] && kill `cat e2e-tests/conf/apache2.pid` || true
	-@[ -e e2e-tests/conf/nginx.pid ]   && kill `cat e2e-tests/conf/nginx.pid` || true
	-@[ -e e2e-tests/conf/plackup.pid ] && kill `cat e2e-tests/conf/plackup.pid` && rm -f e2e-tests/conf/plackup.pid || true
341
	# Start web server (designed for Debian, path may be broken else)
Xavier Guimard's avatar
Xavier Guimard committed
342
	@if test "$(TESTWEBSERVER)" = "apache"; then \
343 344
		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 \
Xavier Guimard's avatar
Xavier Guimard committed
345 346 347 348 349
		echo "Testing nginx conf"; \
		$(NGINX) -t -p `pwd`/e2e-tests \
			-g 'error_log '`pwd`'/e2e-tests/conf/nginx.log;' \
			-c `pwd`/e2e-tests/nginx.conf \
			2>&1 | grep -v 'Permission denied' || true; \
350 351
		echo "Launching nginx"; \
		$(NGINX) -p `pwd`/e2e-tests \
352
			-g 'error_log '`pwd`'/e2e-tests/conf/nginx.log;' \
353 354
			-c `pwd`/e2e-tests/nginx.conf \
			2>&1 | grep -v 'Permission denied' || true; \
355
		echo "Launching plackup"; \
Xavier Guimard's avatar
Xavier Guimard committed
356
		$(MAKE) plackup; \
357 358 359 360 361
	else \
		echo "!!!!! Unknown test server: $(TESTWEBSERVER) !!!!!" >&2; \
		exit 1; \
	fi
		
362

Xavier Guimard's avatar
Xavier Guimard committed
363
reload_web_server:
364
	@if [ -e e2e-tests/conf/apache2.pid ]; then \
Xavier Guimard's avatar
Xavier Guimard committed
365 366
		LLNG_DEFAULTCONFFILE=`pwd`/e2e-tests/conf/lemonldap-ng.ini \
		/usr/sbin/apache2 -d `pwd`/e2e-tests -f apache2.conf -k graceful; \
367 368
	elif [ -e e2e-tests/conf/nginx.pid ]; then \
		kill -HUP `cat e2e-tests/conf/nginx.pid`; \
Xavier Guimard's avatar
Xavier Guimard committed
369 370
		kill `cat e2e-tests/conf/plackup.pid` || true; \
		$(MAKE) plackup; \
371 372 373 374
	else \
		$(MAKE) start_web_server; \
	fi

Xavier Guimard's avatar
Xavier Guimard committed
375
launch_protractor:	all e2e-tests/conf/apache2.pid
376
	# Start e2e tests
Xavier Guimard's avatar
Xavier Guimard committed
377
	# NB: you must have protractor installed (using npm install -g protractor)
Xavier Guimard's avatar
Xavier Guimard committed
378
	# and have run update-webdriver at least once and have a node.js > 4.0
Xavier Guimard's avatar
Xavier Guimard committed
379
	@TESTWEBSERVERPORT=$(TESTWEBSERVERPORT) protractor e2e-tests/protractor-conf.js
380 381 382

stop_web_server:
	# Stop web server
383 384 385
	-@[ -e e2e-tests/conf/apache2.pid ] && kill `cat e2e-tests/conf/apache2.pid` || true
	-@[ -e e2e-tests/conf/nginx.pid ]   && kill `cat e2e-tests/conf/nginx.pid` ||true
	-@[ -e e2e-tests/conf/plackup.pid ] && kill `cat e2e-tests/conf/plackup.pid` && rm -f e2e-tests/conf/plackup.pid || true
386
	# Clean
387
	@rm -rf e2e-tests/conf
388

389 390
restart_web_server: start_web_server

Xavier Guimard's avatar
Xavier Guimard committed
391
plackup:
Xavier Guimard's avatar
Xavier Guimard committed
392
	@LLNG_DEFAULTCONFFILE=`pwd`/e2e-tests/conf/lemonldap-ng.ini \
Xavier Guimard's avatar
Xavier Guimard committed
393
	plackup -s FCGI \
Xavier Guimard's avatar
Xavier Guimard committed
394
		--listen e2e-tests/conf/llng.sock \
Xavier Guimard's avatar
Xavier Guimard committed
395
		--pid e2e-tests/conf/plackup.pid \
Xavier Guimard's avatar
Xavier Guimard committed
396
		--nproc 1 --proc-title llng-fastcgi-server \
397
		--no-default-middleware \
Xavier Guimard's avatar
Xavier Guimard committed
398 399 400
		--app e2e-tests/llng.psgi \
		--keep-stderr 1 \
		>e2e-tests/conf/fastcgi.log 2>&1 &
Xavier Guimard's avatar
Xavier Guimard committed
401

402 403 404
#
# INSTALL
#
Xavier Guimard's avatar
Xavier Guimard committed
405
install:	install_libs install_bin install_fastcgi_server install_site
406

407 408 409
#
# Perl libraires install
#
Xavier Guimard's avatar
Xavier Guimard committed
410
install_libs:	common_install_libs install_handler_libs install_portal_libs install_manager_libs
411 412

common_install_libs:		common
413
	@$(MAKE) -C ${SRCCOMMONDIR} install
414

415
install_handler_libs:	handler
416
	@$(MAKE) -C ${SRCHANDLERDIR} install
417

418
install_portal_libs:		portal
419
	@$(MAKE) -C ${SRCPORTALDIR} install
420

421
install_manager_libs:	manager
422
	@$(MAKE) -C ${SRCMANAGERDIR} install
423

424
example:
Xavier Guimard's avatar
Xavier Guimard committed
425
	$(MAKE) install_site install_bin LMPREFIX=$(EXAMPLEROOT)
426

Xavier Guimard's avatar
Xavier Guimard committed
427
install_bin:	install_conf_dir
428 429
	# Binary install
	@install -v -d $(RBINDIR)
Xavier Guimard's avatar
Xavier Guimard committed
430
	@cp -f\
431
		${SRCHANDLERDIR}/example/scripts/purgeLocalCache \
432
		${SRCPORTALDIR}/example/scripts/purgeCentralCache \
433
		${SRCPORTALDIR}/example/scripts/buildPortalWSDL \
Xavier Guimard's avatar
Xavier Guimard committed
434
		${SRCCOMMONDIR}/scripts/convertConfig \
Xavier Guimard's avatar
Xavier Guimard committed
435
		${SRCCOMMONDIR}/scripts/lmMigrateConfFiles2ini \
436
		${SRCCOMMONDIR}/scripts/rotateOidcKeys \
Xavier Guimard's avatar
Xavier Guimard committed
437
		${SRCMANAGERDIR}/scripts/lmConfigEditor \
Xavier Guimard's avatar
Xavier Guimard committed
438
		${SRCCOMMONDIR}/scripts/lemonldap-ng-cli \
439
			$(RBINDIR)
440 441 442 443 444 445 446 447 448 449
	@if [ ! "$(APACHEUSER)" ]; then \
		$(PERL) -i -pe 's#__APACHEUSER__#nobody#g;' $(RBINDIR)/lmConfigEditor; \
	else \
		$(PERL) -i -pe 's#__APACHEUSER__#$(APACHEUSER)#g;' $(RBINDIR)/lmConfigEditor; \
	fi
	@if [ ! "$(APACHEGROUP)" ]; then \
		$(PERL) -i -pe 's#__APACHEGROUP__#nobody#g;' $(RBINDIR)/lmConfigEditor; \
	else \
		$(PERL) -i -pe 's#__APACHEGROUP__#$(APACHEGROUP)#g;' $(RBINDIR)/lmConfigEditor; \
	fi
450
	@chmod +x $(RBINDIR)/*
451

452
install_fastcgi_server:
453
	@install -v -d $(RSBINDIR) $(RINITDIR) $(RETCDEFAULTDIR) $(RFASTCGISOCKDIR)
454 455 456
	@cp -f fastcgi-server/sbin/llng-fastcgi-server $(RSBINDIR)
	@cp -f fastcgi-server/rc/llng-fastcgi-server $(RINITDIR)
	@cp -f fastcgi-server/default/llng-fastcgi-server $(RETCDEFAULTDIR)
457 458 459 460
	@$(PERL) -pi -e 's#__SBINDIR__#$(SBINDIR)#;s#__DEFAULTDIR__#$(ETCDEFAULTDIR)#;s#__FASTCGISOCKDIR__#$(FASTCGISOCKDIR)#g' \
		$(RETCDEFAULTDIR)/llng-fastcgi-server \
		$(RSBINDIR)/llng-fastcgi-server \
		$(RSBINDIR)/llng-fastcgi-server
461 462 463 464 465 466 467 468 469 470
	@if [ ! "$(FASTCGIUSER)" ]; then \
		$(PERL) -pi -e 's#__USER__#nobody#' $(RETCDEFAULTDIR)/llng-fastcgi-server; \
	else \
		$(PERL) -pi -e 's#__USER__#$(FASTCGIUSER)#' $(RETCDEFAULTDIR)/llng-fastcgi-server; \
	fi
	@if [ ! "$(FASTCGIGROUP)" ]; then \
		$(PERL) -pi -e 's#__USER__#nobody#' $(RETCDEFAULTDIR)/llng-fastcgi-server; \
	else \
		$(PERL) -pi -e 's#__USER__#$(FASTCGIGROUP)#' $(RETCDEFAULTDIR)/llng-fastcgi-server; \
	fi
471 472 473 474 475 476 477 478 479
	if [ "$(FASTCGIUSER)" != "" ]; then \
		chown $(FASTCGIUSER) $(RFASTCGISOCKDIR) || exit 1; \
		if [ "$(FASTCGIGROUP)" != "" ]; then \
			chgrp $(FASTCGIGROUP) $(RFASTCGISOCKDIR) || exit 1; \
		fi; \
		chmod 770 $(RFASTCGISOCKDIR); \
	else \
		chmod 777 $(RFASTCGISOCKDIR); \
	fi
480

481 482 483
#
# SITE INSTALL
#
484
install_site:	install_manager_site install_portal_site install_handler_site install_test_site install_examples_site install_doc_site install_webserver_conf
485
	# Site install
486
	@install -v -d $(RCONFDIR)
Clément OUDOT's avatar
Clément OUDOT committed
487 488
	# Check if erase is wanted
	@if [ "$(ERASECONFIG)" -eq "1" ]; then \
Xavier Guimard's avatar
Xavier Guimard committed
489
		cp -f _example/etc/for_etc_hosts $(RCONFDIR); \
490
	fi
Xavier Guimard's avatar
Xavier Guimard committed
491
	@$(PERL) -i -pe 's/__DNSDOMAIN__/$(DNSDOMAIN)/g' $(RCONFDIR)/for_etc_hosts
492
	# Fix a lost of rights on the main directory
Xavier Guimard's avatar
Xavier Guimard committed
493
	@chmod 755 $(RBINDIR) $(RDOCUMENTROOT) $(REXAMPLESDIR) $(RHANDLERDIR) $(RPORTALSKINSDIR) $(RMANAGERSITEDIR) $(RTOOLSDIR) $(RCONFDIR) $(RDATADIR)
494
	@echo
495
	@echo "LemonLDAP::NG v${VERSION} is installed with these parameters:"
496 497 498 499 500
	@echo "  - System configuration: ${CONFDIR}"
	@echo "  - DNS domain (for cookies and virtual hosts): ${DNSDOMAIN}"
	@echo
	@echo "To finish configuration:"
	@echo
501 502 503 504
	@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"
505
	@echo "      include ${CONFDIR}/test-apache$(APACHEVERSION).conf"
506
	@echo
507 508
	@echo "2 - Restart Apache:"
	@echo "      apache$(APACHEVERSION)ctl restart"
509
	@echo
510
	@echo "3 - Run 'make postconf' as root to update /etc/hosts if your DNS service does not known auth.$(DNSDOMAIN) and manager.$(DNSDOMAIN)"
511
	@echo
512 513 514 515 516 517
	@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"
518
	@echo
519
	@if [ ! "$(APACHEUSER)" ]; then \
520
		echo;echo "    Warning, since APACHEUSER was not set, $(APACHESESSIONFILEDIR), $(APACHEPSESSIONFILEDIR), $(CAPTCHADIR) and $(CONFDIR) have permissive permissions."; \
521 522 523
		echo "    Fix them by yourself to restrict their view to apache process only"; \
	fi
	@echo
524

525 526 527 528 529 530 531
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); \
532
		cp -f _example/etc/*nginx*.conf $(RCONFDIR); \
533 534 535 536 537 538 539
	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
540
			s#__PORT__#$(PORT)#g; \
Xavier Guimard's avatar
Xavier Guimard committed
541
			s#__FASTCGISOCKDIR__#$(FASTCGISOCKDIR)#g; \
542 543 544 545
			s#__VHOSTLISTEN__#$(VHOSTLISTEN)#g; \
			s#__DEFDOCDIR__#$(DEFDOCDIR)/#g; \
			s#__FRDOCDIR__#$(FRDOCDIR)/#g;' $(RCONFDIR)/*apache*.conf $(RCONFDIR)/*nginx*.conf

546 547
install_manager_site:	install_conf_dir
	# Manager install
Xavier Guimard's avatar
Xavier Guimard committed
548
	@install -v -d $(RMANAGERDIR) $(RMANAGERSTATICDIR) $(RMANAGERPSGIDIR) \
549 550
		$(RMANAGERTEMPLATESDIR)
	@cp -pR $(SRCMANAGERDIR)/site/static/* $(RMANAGERSTATICDIR)
551
	@for f in $(SRCMANAGERDIR)/site/templates/*.tpl; do \
552 553 554 555 556
		./scripts/transform-templates \
			usedebianlibs $(USEDEBIANLIBS) \
			useexternallibs $(USEEXTERNALLIBS) \
			jsminified $(JSCOMPRESS) \
			cssminified $(CSSCOMPRESS) <$$f \
557 558
			> $(RMANAGERTEMPLATESDIR)/`basename $$f`; \
	done
559
	@if test "$(USEEXTERNALLIBS)" = "yes"; then \
560
		rm -rvf $(MANAGEREXTERNALLIBS); \
561
	elif test "$(USEDEBIANLIBS)" = "yes"; then \
562 563
		rm -rvf $(MANAGERLIBSTOREMOVEFORDEBIAN); \
	fi
564 565
	@cp -pR $(SRCMANAGERDIR)/eg/* $(RMANAGERPSGIDIR)
	# Clean svn files
Xavier Guimard's avatar
Xavier Guimard committed
566
	@rm -rf $$(find ${RMANAGERSTATICDIR} $(RMANAGERPSGIDIR) \
567
		$(RMANAGERTEMPLATESDIR) $(RCONFDIR) -type d -name .svn)
Xavier Guimard's avatar
Xavier Guimard committed
568
	$(PERL) -i -pe 's#__MANAGERSTATICDIR__#$(MANAGERRELATIVESTATICDIR)#g' $(RCONFDIR)/$(CONFFILENAME)
569
	$(PERL) -i -pe 's#__MANAGERTEMPLATESDIR__#$(MANAGERTEMPLATESDIR)#g' $(RCONFDIR)/$(CONFFILENAME)
570 571 572 573

install_portal_site:	install_conf_dir
	# Portal install
	@install -v -d $(RPORTALDIR) $(RPORTALSKINSDIR) \
574
		$(RPORTALDIR)/skins/ \
575
		$(RCRONDIR) $(RCONFDIR)
576
	@for skin in $$(ls $(SRCPORTALDIR)/example/skins/); do \
577 578
		[ -h $(RPORTALDIR)/skins/$$skin ] && rm -f $(RPORTALDIR)/skins/$$skin; \
		install -v -d $(RPORTALSKINSDIR)/$$skin; \
579
	done
Xavier Guimard's avatar
Xavier Guimard committed
580 581 582
	@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}
583
	@cp -pR -f ${SRCPORTALDIR}/example/openid-configuration.pl ${RPORTALDIR}
Xavier Guimard's avatar
Xavier Guimard committed
584 585
	@cp -pR -f ${SRCPORTALDIR}/example/cdc.pl ${RPORTALDIR}
	@cp -pR -f ${SRCPORTALDIR}/example/register.pl ${RPORTALDIR}
586
	@tar -cf - -C ${SRCPORTALDIR}/example/skins/ $$(ls ${SRCPORTALDIR}/example/skins/) |tar -xf - -C $(RPORTALSKINSDIR)
587
	@for f in `find $(RPORTALSKINSDIR) -type f -name '*.tpl'`; do \
588
		./scripts/transform-templates usedebianlibs $(USEDEBIANLIBS) jsminified $(JSCOMPRESS) cssminified $(CSSCOMPRESS) <$$f >$$f.tmp; \
589 590
		mv -f $$f.tmp $$f; \
	done
591
	@if test "$(USEEXTERNALLIBS)" = "yes"; then \
592
		rm -rvf $(PORTALEXTERNALLIBS); \
593
	elif test "$(USEDEBIANLIBS)" = "yes"; then \
594 595
		rm -rvf $(PORTALLIBSTOREMOVEFORDEBIAN); \
	fi
596
	@if [ "$(PORTALDIR)/skins/" != "$(PORTALSKINSDIR)/" ]; then \
597
		for skin in $$(ls $(SRCPORTALDIR)/example/skins/); do \
598 599
			rm -rf $(RPORTALDIR)/skins/$$skin/; \
			ln -s $(PORTALSKINSDIR)/$$skin $(RPORTALDIR)/skins/$$skin; \
600 601 602
		done; \
	fi
	# Cron files
603
	@cp -f $(SRCPORTALDIR)/example/scripts/purgeCentralCache.cron.d $(RCRONDIR)/lemonldap-ng-portal
604
	@if [ ! "$(APACHEUSER)" ]; then \
605
		$(PERL) -i -pe 's#__APACHEUSER__#nobody#g;' $(RCRONDIR)/lemonldap-ng-portal; \
606
	else \
607
		$(PERL) -i -pe 's#__APACHEUSER__#$(APACHEUSER)#g;' $(RCRONDIR)/lemonldap-ng-portal; \
608
	fi
609
	@$(PERL) -i -pe 's#__BINDIR__#$(BINDIR)#g;' $(RCRONDIR)/lemonldap-ng-portal
610
	# Clean SVN files
611
	@rm -rf $$(find ${RPORTALDIR} $(RPORTALSKINSDIR) $(RCRONDIR) $(RCONFDIR) -type d -name .svn)
612 613

install_handler_site:	install_conf_dir
614
	# Handler install
615
	@install -v -d ${RHANDLERDIR}
616
	@cp -f $(SRCHANDLERDIR)/example/scripts/purgeLocalCache.cron.d $(RCRONDIR)/lemonldap-ng-handler
617
	@if [ ! "$(APACHEUSER)" ]; then \
618
		$(PERL) -i -pe 's#__APACHEUSER__#nobody#g;' $(RCRONDIR)/lemonldap-ng-handler; \
619 620 621 622
	else \
		$(PERL) -i -pe 's#__APACHEUSER__#$(APACHEUSER)#g;' $(RCRONDIR)/lemonldap-ng-handler; \
	fi
	@$(PERL) -i -pe 's#__BINDIR__#$(BINDIR)#g;' $(RCRONDIR)/lemonldap-ng-handler
623
	@rm -rf $$(find $(RHANDLERDIR) -type d -name .svn)
624 625

install_test_site:
626
	# Test site install
627
	@install -v -d $(RTESTDIR)
Xavier Guimard's avatar
Xavier Guimard committed
628
	@cp -pR -f _example/test/* $(RTESTDIR)
629
	@rm -rf $$(find $(RTESTDIR) -type d -name .svn)
Xavier Guimard's avatar
Xavier Guimard committed
630
	@$(PERL) -i -pe 's/__DNSDOMAIN__/$(DNSDOMAIN)/g' $(RTESTDIR)/index.pl
631
	@rm -rf $$(find $(RTESTDIR) -type d -name .svn)
632 633

install_examples_site:
634
	# Examples install
635
	@install -v -d $(REXAMPLESDIR)
636
	@for i in portal handler; do \
Xavier Guimard's avatar
Xavier Guimard committed
637
		cp -a -f lemonldap-ng-$$i/example $(REXAMPLESDIR)/$$i; \
638
	done
639 640 641
	@for i in manager; do \
		cp -a -f lemonldap-ng-$$i/eg $(REXAMPLESDIR)/$$i; \
	done
642
	@rm -rf $(REXAMPLESDIR)/portal/skins \
Xavier Guimard's avatar
Xavier Guimard committed
643
		$(REXAMPLESDIR)/manager/skins \
644
	@rm -rf $$(find $(REXAMPLESDIR) -type d -name .svn)
645
	@$(PERL) -i -pe 's#__SESSIONDIR__#$(APACHESESSIONFILEDIR)/#g;' $(REXAMPLESDIR)/portal/*.pl
646
	@$(PERL) -i -pe 's#__PSESSIONDIR__#$(APACHEPSESSIONFILEDIR)/#g;' $(REXAMPLESDIR)/portal/*.pl
647

648
install_doc_site:
649
	# Offline documentation install
650 651
	@rm -rf $(RDEFDOCDIR)
	@install -v -d $(RDEFDOCDIR)
Xavier Guimard's avatar
Xavier Guimard committed
652
	@cp -a -f doc/* $(RDEFDOCDIR)
653

654
install_conf_dir:	install_sessions_dir install_notif_dir install_captcha_dir
655
	# Configuration files install
656
	@install -v -d $(RCONFDIR) $(RFILECONFIGDIR) $(RTOOLSDIR)
Clément OUDOT's avatar
Clément OUDOT committed
657
	@if [ "$(ERASECONFIG)" -eq "1" ]; then \
Xavier Guimard's avatar
Xavier Guimard committed
658
		cp -f $(SRCCOMMONDIR)/$(CONFFILENAME) $(RCONFDIR); \
Xavier Guimard's avatar
Xavier Guimard committed
659
		$(PERL) -i -pe 's#^dirName\s*=\s*.*#dirName = $(FILECONFIGDIR)#g' $(RCONFDIR)/$(CONFFILENAME); \
Clément OUDOT's avatar
Clément OUDOT committed
660
	fi
661
	@cp _example/conf/lmConf-1.js $(RFILECONFIGDIR)
Xavier Guimard's avatar
Xavier Guimard committed
662
	@$(PERL) -i -pe 's/__DNSDOMAIN__/$(DNSDOMAIN)/g;\
663
		s#__SESSIONDIR__#$(APACHESESSIONFILEDIR)#g;\
664
		s#__PSESSIONDIR__#$(APACHEPSESSIONFILEDIR)#g;\
665
		s#__NOTIFICATIONDIR__#$(APACHEFILENOTIFDIR)#g;' $(RFILECONFIGDIR)/lmConf-1.js
666 667 668 669 670 671 672 673 674
	@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
675 676
	@cp $(SRCCOMMONDIR)/tools/lmConfig.* $(SRCCOMMONDIR)/tools/apache-session-mysql.sql $(RTOOLSDIR)
	@cp $(SRCCOMMONDIR)/tools/sso.schema $(RTOOLSDIR)
677
	$(PERL) -i -pe 's/__DNSDOMAIN__/$(DNSDOMAIN)/g' $(RCONFDIR)/$(CONFFILENAME)
678
	@rm -rf $$(find $(RCONFDIR) $(RFILECONFIGDIR) $(RTOOLSDIR) -type d -name .svn)
679 680

install_sessions_dir:
681
	@install -m 777 -v -d $(RAPACHESESSIONFILEDIR) $(RAPACHESESSIONFILELOCKDIR) $(RAPACHEPSESSIONFILEDIR) $(RAPACHEPSESSIONFILELOCKDIR)
682 683
	# Fix Apache::Session directories permissions
	@if [ "$(APACHEUSER)" != "" ]; then \
684
		chown $(APACHEUSER) $(RAPACHESESSIONFILEDIR) $(RAPACHESESSIONFILELOCKDIR) $(RAPACHEPSESSIONFILEDIR) $(RAPACHEPSESSIONFILELOCKDIR) || exit 1; \
685
		if [ "$(APACHEGROUP)" != "" ]; then \
686
			chgrp $(APACHEGROUP) $(RAPACHESESSIONFILEDIR) $(RAPACHESESSIONFILELOCKDIR) $(RAPACHEPSESSIONFILEDIR) $(RAPACHEPSESSIONFILELOCKDIR) || exit 1; \
687
		fi; \
688
		chmod 770 $(RAPACHESESSIONFILEDIR) $(RAPACHESESSIONFILELOCKDIR) $(RAPACHEPSESSIONFILEDIR) $(RAPACHEPSESSIONFILELOCKDIR); \
689
	else \
690
		chmod 777 $(RAPACHESESSIONFILEDIR) $(RAPACHESESSIONFILELOCKDIR) $(RAPACHEPSESSIONFILEDIR) $(RAPACHEPSESSIONFILELOCKDIR); \
691 692
	fi

693 694 695 696 697 698 699 700 701 702 703 704 705
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

706
install_captcha_dir:
707
	@install -m 777 -v -d $(RCAPTCHADIR)
708 709
	# Fix captcha directory permissions
	@if [ "$(APACHEUSER)" != "" ]; then \
710
		chown $(APACHEUSER) $(RCAPTCHADIR) || exit 1; \
711
		if [ "$(APACHEGROUP)" != "" ]; then \
712
			chgrp $(APACHEGROUP) $(RCAPTCHADIR) || exit 1; \
713
		fi; \
714
		chmod 770 $(RCAPTCHADIR); \
715
	else \
716
		chmod 777 $(RCAPTCHADIR); \
717 718
	fi

719
postconf_hosts:
Clément OUDOT's avatar
Clément OUDOT committed
720
	@cat ${CONFDIR}/for_etc_hosts >> /etc/hosts
721 722
	@echo "/etc/hosts was updated"

723
postconf: postconf_hosts
724 725
	@echo "Post configuration done"

726 727
uninstall:	configure handler_uninstall portal_uninstall manager_uninstall

728 729 730 731
common_uninstall:	common
	@$(MAKE) -C ${SRCCOMMONDIR} uninstall
	@rm -vf common_uninstall

732
handler_uninstall:	handler
733
	@$(MAKE) -C ${SRCHANDLERDIR} uninstall
734
	@rm -vf handler_uninstall
735 736

portal_uninstall:		portal
737
	@$(MAKE) -C ${SRCPORTALDIR} uninstall
738
	@rm -vf portal_uninstall
739 740

manager_uninstall:	manager
741
	@$(MAKE) -C ${SRCMANAGERDIR} uninstall
742
	@rm -vf manager_uninstall
743

744
dist:	clean
745 746 747 748 749 750 751 752 753
	@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)

754
rpm-dist:	clean
755
	@mkdir -p lemonldap-ng-$(VERSION)
756
	@cp -pRH $$(find * -maxdepth 0|grep -v -e "\(lemonldap-ng-$(VERSION)\|debian\)") lemonldap-ng-$(VERSION)
757 758
	@rm -rf $$(find lemonldap-ng-$(VERSION) -name .svn -print)
	@find $$dir -name '*.bak' -delete
759
	@rm -rf lemonldap-ng-$(VERSION)/lemonldap-ng-$(VERSION)
Xavier Guimard's avatar
Xavier Guimard committed
760
	@$(COMPRESS) lemonldap-ng-$(VERSION).$(COMPRESSSUFFIX) lemonldap-ng-$(VERSION)
761
	@rm -rf lemonldap-ng-$(VERSION)
762

763

764 765
debian-dist:	clean
	@mkdir -p lemonldap-ng-$(VERSION)
766
	@cp -pRH $$(find * -maxdepth 0|grep -v -e "\(lemonldap-ng-$(VERSION)\|rpm\)") lemonldap-ng-$(VERSION)
767 768
	@rm -rf $$(find lemonldap-ng-$(VERSION) -name .svn -print)
	@find $$dir -name '*.bak' -delete
769 770 771 772
	@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
773 774 775
	@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
776 777 778

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

780 781 782 783 784 785 786 787
manifest:   configure
	@for i in ${SRCCOMMONDIR} ${SRCHANDLERDIR} ${SRCPORTALDIR} ${SRCMANAGERDIR}; do \
		cd $$i; \
		make manifest; \
		rm -vf MANIFEST.*; \
		cd -; \
	done

788
cpan:	clean configure common_cpan handler_cpan portal_cpan manager_cpan
Clément OUDOT's avatar
Clément OUDOT committed
789
	for i in Common Portal Handler Manager; do \
Xavier Guimard's avatar
Xavier Guimard committed
790
		$(UNCOMPRESS) Lemonldap-NG-$$i-*.$(COMPRESSSUFFIX) \
Clément OUDOT's avatar
Clément OUDOT committed
791
			$$($(LISTCOMPRESSED) Lemonldap-NG-$$i-*.$(COMPRESSSUFFIX) |grep META.yml); \
Xavier Guimard's avatar
Xavier Guimard committed
792
		mv Lemonldap-NG-$$i-*/META.yml lemonldap-ng-$$($(PERL) -e "print lc('$$i')")/; \
793
		rm -rf Lemonldap-NG-$$i*/; \
Xavier Guimard's avatar
Xavier Guimard committed
794
		done
795 796 797 798

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

handler_cpan:	handler_conf
801 802
	@$(MAKE) -C ${SRCHANDLERDIR} dist
	@mv ${SRCHANDLERDIR}/Lemonldap*.gz .
803 804

portal_cpan:		portal_conf
805 806
	@$(MAKE) -C ${SRCPORTALDIR} dist
	@mv ${SRCPORTALDIR}/Lemonldap*.gz .
807 808

manager_cpan:	manager_conf
809 810
	@$(MAKE) -C ${SRCMANAGERDIR} dist
	@mv ${SRCMANAGERDIR}/Lemonldap*.gz .
811

812
documentation:
813
	@cd doc/ && ../scripts/doc.pl
814

815
doxygen:	clean
Xavier Guimard's avatar
Xavier Guimard committed
816
	$(PERL) -i -pe 's/^(PROJECT_NUMBER\s*=\s*)\d.*$$/$${1}'$(VERSION)'/' Doxyfile
817 818 819 820 821 822
	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
823
	$(PERL) -i -pe 's/Graphical Class Hierarchy/Class Collaboration Graph/' doc/devel/html/inherits.html doc/devel/html/tree.html
824 825
	# 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
826

827 828
distclean:	clean

829
clean:		common_clean handler_clean portal_clean manager_clean omegat-clean stop_web_server
Xavier Guimard's avatar
Xavier Guimard committed
830
	@rm -f $$(find */ -name '*bak' -delete)
831
	@rm -rf $(EXAMPLEROOT) example/ doc/devel
Xavier Guimard's avatar
Xavier Guimard committed
832
	@rm -vf *gz *zip
Xavier Guimard's avatar
Xavier Guimard committed
833
	@rm -rf lemonldap-ng-$(VERSION)
Xavier Guimard's avatar
Xavier Guimard committed
834
	@echo "Cleaned"
835 836

common_clean:
Xavier Guimard's avatar
Xavier Guimard committed
837
	@if test -e ${SRCCOMMONDIR}/Makefile;then $(MAKE) -C ${SRCCOMMONDIR} distclean;fi
838 839 840
	@rm -vf common*

handler_clean:
Xavier Guimard's avatar
Xavier Guimard committed
841
	@if test -e ${SRCHANDLERDIR}/Makefile;then $(MAKE) -C ${SRCHANDLERDIR} distclean;fi
842 843 844
	@rm -vf handler*

portal_clean:
Xavier Guimard's avatar
Xavier Guimard committed
845
	@if test -e ${SRCPORTALDIR}/Makefile;then $(MAKE) -C ${SRCPORTALDIR} distclean;fi
846 847 848
	@rm -vf portal*

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

852
debian-local-packages: debian-dist
Xavier Guimard's avatar
Xavier Guimard committed
853
	mv lemonldap-ng_$(VERSION).orig.$(COMPRESSSUFFIX) /tmp/
854 855
	version=$(VERSION) && \
	cd /tmp/ && \
Xavier Guimard's avatar
Xavier Guimard committed
856
	rm -rf lemonldap-ng-$$version && \
Xavier Guimard's avatar
Xavier Guimard committed
857
	$(UNCOMPRESS) lemonldap-ng_$$version.orig.$(COMPRESSSUFFIX) && \
858
	cd lemonldap-ng-$$version && \
Xavier Guimard's avatar
Xavier Guimard committed
859
	debuild -us -uc -b --lintian-opts -i \
Xavier Guimard's avatar
Xavier Guimard committed
860 861 862
		--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
863

864 865 866 867 868 869 870 871 872 873 874 875 876
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
877
	cd /tmp/lemonldap-ng-$(VERSION) && \
Xavier Guimard's avatar
Xavier Guimard committed
878 879 880 881 882 883
	$(SU) debi

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

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

Xavier Guimard's avatar
Xavier Guimard committed
885
debian-diff:
Xavier Guimard's avatar
Xavier Guimard committed
886
	@# Portal
887 888 889
	@$(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
890
	@for i in $(PORTALSKINS); do \
891
		$(DIFF) -x 'jquery*' $(SRCPORTALDIR)/example/skins/$$i $(DIFFPREFIX)/usr/share/lemonldap-ng/portal-skins/$$i; \
Xavier Guimard's avatar
Xavier Guimard committed
892
	done ||true