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)
Yadd's avatar
Yadd committed
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'`
Yadd's avatar
Yadd 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
Yadd's avatar
Yadd committed
21
COMPRESSSUFFIX=tar.gz
Yadd's avatar
Yadd committed
22
NGINX=/usr/sbin/nginx
23 24 25 26 27
# Perl options
#PERLOPTIONS="INSTALLDIRS=vendor"
PERLOPTIONS=

# Default directories install
Yadd's avatar
Yadd committed
28 29 30
PREFIX=/usr/local
LMPREFIX=$(PREFIX)/lemonldap-ng
RLMPREFIX=$(DESTDIR)/$(LMPREFIX)
31
# BIN dirs
Yadd's avatar
Yadd committed
32 33
BINDIR=$(LMPREFIX)/bin
RBINDIR=$(DESTDIR)/$(BINDIR)
Yadd's avatar
Yadd committed
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)
Yadd's avatar
Yadd committed
40 41
DATADIR=$(LMPREFIX)/data
RDATADIR=$(DESTDIR)/$(DATADIR)
42

Yadd's avatar
Yadd committed
43
EXAMPLEROOT=`pwd`/example
44 45

# Document roots for Apache VirtualHosts
Yadd's avatar
Yadd committed
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)
Yadd's avatar
Yadd committed
53
MANAGERSITEDIR=$(MANAGERDIR)
Yadd's avatar
Yadd committed
54
RMANAGERSITEDIR=$(DESTDIR)/$(MANAGERSITEDIR)
Yadd's avatar
Yadd committed
55 56
MANAGERSTATICDIR=$(MANAGERSITEDIR)/static
RMANAGERSTATICDIR=$(DESTDIR)/$(MANAGERSTATICDIR)
Yadd's avatar
Yadd committed
57
MANAGERRELATIVESTATICDIR=/static
Yadd's avatar
Yadd committed
58 59 60 61
MANAGERPSGIDIR=$(MANAGERSITEDIR)/psgi
RMANAGERPSGIDIR=$(DESTDIR)/$(MANAGERPSGIDIR)
MANAGERTEMPLATESDIR=$(MANAGERSITEDIR)/templates
RMANAGERTEMPLATESDIR=$(DESTDIR)/$(MANAGERTEMPLATESDIR)
62
DOCDIR=$(DOCUMENTROOT)
Yadd's avatar
Yadd committed
63
RDOCDIR=$(DESTDIR)/$(DOCDIR)
64 65 66
DEFDOCDIR=$(DOCUMENTROOT)/doc
RDEFDOCDIR=$(DESTDIR)/$(DEFDOCDIR)
FRDOCDIR=$(DOCUMENTROOT)/fr-doc
Yadd's avatar
Yadd committed
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
Yadd's avatar
Yadd committed
75 76
HANDLERDIR=$(LMPREFIX)/handler
RHANDLERDIR=$(DESTDIR)/$(HANDLERDIR)
77 78

# Configuration dir
Yadd's avatar
Yadd committed
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
Yadd's avatar
Yadd committed
87 88
FILECONFIGDIR=$(DATADIR)/conf
RFILECONFIGDIR=$(DESTDIR)/$(FILECONFIGDIR)
89

90
# LL::NG sessions storage dir
Yadd's avatar
Yadd committed
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=
Yadd's avatar
Yadd committed
113 114 115 116

# FastCGI
FASTCGISOCKDIR=$(PREFIX)/run
RFASTCGISOCKDIR=$(DESTDIR)/$(FASTCGISOCKDIR)
Yadd's avatar
Yadd committed
117 118
FASTCGIUSER=$(APACHEUSER)
FASTCGIGROUP=$(APACHEGROUP)
119

120
# Apache version
Yadd's avatar
Yadd committed
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, ...)
Yadd's avatar
Yadd committed
127 128
PORT=80
VHOSTLISTEN="*:$(PORT)"
Yadd's avatar
Yadd committed
129
TESTWEBSERVER=apache
Yadd's avatar
Yadd committed
130
TESTWEBSERVERPORT=19876
Yadd's avatar
Yadd committed
131
PSGISERVERSOCKET=unix:$(FASTCGISOCKDIR)/llng-fastcgi.sock
132

133
# Other
Yadd's avatar
Yadd committed
134 135 136 137
SRCCOMMONDIR=lemonldap-ng-common
SRCHANDLERDIR=lemonldap-ng-handler
SRCPORTALDIR=lemonldap-ng-portal
SRCMANAGERDIR=lemonldap-ng-manager
138 139 140

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

144

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

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

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

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

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

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

Yadd's avatar
Yadd committed
226 227 228
#
# Minification
#
229 230 231
minify: $(JSDSTFILES) $(CSSDSTFILES)

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

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

Yadd's avatar
Yadd committed
239

240 241 242
#
# Perl libraries configuration
#
Yadd's avatar
Yadd committed
243

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

247
$(MANAGERJSONDST):	$(MANAGERJSONSRC)
248
	./scripts/jsongenerator.pl
Yadd's avatar
Yadd committed
249

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

Yadd's avatar
Yadd committed
253
configure:	json common_conf handler_conf portal_conf manager_conf
254

255 256 257 258 259 260 261 262 263
common_conf:	${SRCCOMMONDIR}/Makefile

handler_conf:	${SRCHANDLERDIR}/Makefile

portal_conf:	${SRCPORTALDIR}/Makefile

manager_conf:	${SRCMANAGERDIR}/Makefile

${SRCCOMMONDIR}/Makefile:
Yadd's avatar
Yadd committed
264
	@cd ${SRCCOMMONDIR}; LMNGCONFFILE=$(STORAGECONFFILE) $(PERL) Makefile.PL $(PERLOPTIONS)
265

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

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

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

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

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

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

Yadd's avatar
Yadd committed
287
manager:	manager_conf handler
288
	$(MAKE) -C ${SRCMANAGERDIR}
289

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

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

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

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

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

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

Yadd's avatar
Yadd committed
311
# End-to-end tests
312 313 314
e2e_test:	all prepare_test_server start_web_server launch_protractor stop_web_server

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

Yadd's avatar
Yadd committed
335 336 337
e2e-tests/conf/apache2.pid: start_web_server

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

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

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

stop_web_server:
	# Stop web server
384 385 386
	-@[ -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
387
	# Clean
388
	@rm -rf e2e-tests/conf
Yadd's avatar
Yadd committed
389

390 391
restart_web_server: start_web_server

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

403 404 405
#
# INSTALL
#
Yadd's avatar
Yadd committed
406
install:	install_libs install_bin install_fastcgi_server install_site
407

408 409 410
#
# Perl libraires install
#
Yadd's avatar
Yadd committed
411
install_libs:	common_install_libs install_handler_libs install_portal_libs install_manager_libs
412 413

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

Yadd's avatar
Yadd committed
416
install_handler_libs:	handler
417
	@$(MAKE) -C ${SRCHANDLERDIR} install
418

Yadd's avatar
Yadd committed
419
install_portal_libs:		portal
420
	@$(MAKE) -C ${SRCPORTALDIR} install
421

Yadd's avatar
Yadd committed
422
install_manager_libs:	manager
423
	@$(MAKE) -C ${SRCMANAGERDIR} install
424

425
example:
Yadd's avatar
Yadd committed
426
	$(MAKE) install_site install_bin LMPREFIX=$(EXAMPLEROOT)
427

Yadd's avatar
Yadd committed
428
install_bin:	install_conf_dir
429 430
	# Binary install
	@install -v -d $(RBINDIR)
Yadd's avatar
Yadd committed
431
	@cp -f\
432
		${SRCHANDLERDIR}/example/scripts/purgeLocalCache \
Yadd's avatar
Yadd committed
433
		${SRCPORTALDIR}/example/scripts/purgeCentralCache \
434
		${SRCPORTALDIR}/example/scripts/buildPortalWSDL \
Yadd's avatar
Yadd committed
435
		${SRCCOMMONDIR}/scripts/convertConfig \
Yadd's avatar
Bugs :  
Yadd committed
436
		${SRCCOMMONDIR}/scripts/lmMigrateConfFiles2ini \
437
		${SRCCOMMONDIR}/scripts/rotateOidcKeys \
Yadd's avatar
Yadd committed
438
		${SRCMANAGERDIR}/scripts/lmConfigEditor \
Yadd's avatar
Yadd committed
439
		${SRCCOMMONDIR}/scripts/lemonldap-ng-cli \
Yadd's avatar
Yadd committed
440
			$(RBINDIR)
441 442 443 444 445 446 447 448 449 450
	@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
451
	@chmod +x $(RBINDIR)/*
452

Yadd's avatar
Yadd committed
453
install_fastcgi_server:
Yadd's avatar
Yadd committed
454
	@install -v -d $(RSBINDIR) $(RINITDIR) $(RETCDEFAULTDIR) $(RFASTCGISOCKDIR)
Yadd's avatar
Yadd committed
455 456 457
	@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)
Yadd's avatar
Yadd committed
458 459 460 461
	@$(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
Yadd's avatar
Yadd committed
462 463 464 465 466 467 468 469 470 471
	@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
Yadd's avatar
Yadd committed
472 473 474 475 476 477 478 479 480
	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
Yadd's avatar
Yadd committed
481

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

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

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

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

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

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

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

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

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

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

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

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

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

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

727 728
uninstall:	configure handler_uninstall portal_uninstall manager_uninstall

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

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

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

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

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

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

764

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