Makefile 39.3 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
131

132
# Other
Yadd's avatar
Yadd committed
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*
Yadd's avatar
Yadd committed
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 \
Yadd's avatar
Yadd 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 \
Yadd's avatar
Yadd 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
Yadd's avatar
Yadd committed
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)
Yadd's avatar
Yadd committed
183

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

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

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

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

Yadd's avatar
Yadd committed
238

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

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

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

Yadd's avatar
Yadd 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

Yadd's avatar
Yadd 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:
Yadd's avatar
Yadd committed
263
	@cd ${SRCCOMMONDIR}; LMNGCONFFILE=$(STORAGECONFFILE) $(PERL) Makefile.PL $(PERLOPTIONS)
264

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

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

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

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

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

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

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

Yadd's avatar
Yadd committed
289 290 291
################
# Test targets #
################
Yadd's avatar
Yadd 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

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

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

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

Yadd's avatar
Yadd 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
Yadd's avatar
Yadd committed
309

Yadd's avatar
Yadd committed
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:
Yadd's avatar
Yadd committed
314
	@mkdir -p e2e-tests/conf/sessions/lock e2e-tests/conf/persistents/lock
Yadd's avatar
Yadd committed
315
	@$(MAKE) install_webserver_conf install_test_site \
316 317
		RCONFDIR=e2e-tests/conf \
		ERASECONFIG=1 \
Yadd's avatar
Yadd committed
318 319
		VHOSTLISTEN='*:$(TESTWEBSERVERPORT)' \
		PORT=$(TESTWEBSERVERPORT) \
Yadd's avatar
Yadd committed
320
		FASTCGISOCKDIR=`pwd`/e2e-tests/conf \
321 322
		PORTALDIR=`pwd`/$(SRCPORTALDIR)/example \
		MANAGERDIR=`pwd`/$(SRCMANAGERDIR)/site \
Yadd's avatar
Yadd 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/
Yadd's avatar
Yadd committed
328
	@cp e2e-tests/form.html e2e-tests/conf/site
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-fastcgi.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

Yadd's avatar
Yadd committed
403 404 405
install_test:
	@TESTWEBSERVERPORT=$(PORT) protractor e2e-tests/protractor-conf.js

406 407 408
#
# INSTALL
#
Yadd's avatar
Yadd committed
409
install:	install_libs install_bin install_fastcgi_server install_site
410

411 412 413
#
# Perl libraires install
#
Yadd's avatar
Yadd committed
414
install_libs:	common_install_libs install_handler_libs install_portal_libs install_manager_libs
415 416

common_install_libs:		common
417
	@$(MAKE) -C ${SRCCOMMONDIR} install
418

Yadd's avatar
Yadd committed
419
install_handler_libs:	handler
420
	@$(MAKE) -C ${SRCHANDLERDIR} install
421

Yadd's avatar
Yadd committed
422
install_portal_libs:		portal
423
	@$(MAKE) -C ${SRCPORTALDIR} install
424

Yadd's avatar
Yadd committed
425
install_manager_libs:	manager
426
	@$(MAKE) -C ${SRCMANAGERDIR} install
427

428
example:
Yadd's avatar
Yadd committed
429
	$(MAKE) install_site install_bin LMPREFIX=$(EXAMPLEROOT)
430

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

Yadd's avatar
Yadd committed
456
install_fastcgi_server:
Yadd's avatar
Yadd committed
457
	@install -v -d $(RSBINDIR) $(RINITDIR) $(RETCDEFAULTDIR) $(RFASTCGISOCKDIR)
Yadd's avatar
Yadd committed
458 459 460
	@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
461 462 463
	@$(PERL) -pi -e 's#__SBINDIR__#$(SBINDIR)#;s#__DEFAULTDIR__#$(ETCDEFAULTDIR)#;s#__FASTCGISOCKDIR__#$(FASTCGISOCKDIR)#g' \
		$(RETCDEFAULTDIR)/llng-fastcgi-server \
		$(RSBINDIR)/llng-fastcgi-server \
464
		$(RINITDIR)/llng-fastcgi-server
Yadd's avatar
Yadd committed
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 \
471
		$(PERL) -pi -e 's#__GROUP__#nobody#' $(RETCDEFAULTDIR)/llng-fastcgi-server; \
Yadd's avatar
Yadd committed
472
	else \
473
		$(PERL) -pi -e 's#__GROUP__#$(FASTCGIGROUP)#' $(RETCDEFAULTDIR)/llng-fastcgi-server; \
Yadd's avatar
Yadd committed
474
	fi
Yadd's avatar
Yadd committed
475 476 477 478 479 480 481 482 483
	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
484

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

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

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

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

install_handler_site:	install_conf_dir
623
	# Handler install
624
	@install -v -d ${RHANDLERDIR}
625
	@cp -f $(SRCHANDLERDIR)/example/scripts/purgeLocalCache.cron.d $(RCRONDIR)/lemonldap-ng-handler
626
	@if [ ! "$(APACHEUSER)" ]; then \
627
		$(PERL) -i -pe 's#__APACHEUSER__#nobody#g;' $(RCRONDIR)/lemonldap-ng-handler; \
628 629 630 631
	else \
		$(PERL) -i -pe 's#__APACHEUSER__#$(APACHEUSER)#g;' $(RCRONDIR)/lemonldap-ng-handler; \
	fi
	@$(PERL) -i -pe 's#__BINDIR__#$(BINDIR)#g;' $(RCRONDIR)/lemonldap-ng-handler
632
	@rm -rf $$(find $(RHANDLERDIR) -type d -name .svn)
633 634

install_test_site:
635
	# Test site install
636
	@install -v -d $(RTESTDIR)
Yadd's avatar
Yadd committed
637
	@cp -pR -f _example/test/* $(RTESTDIR)
638
	@rm -rf $$(find $(RTESTDIR) -type d -name .svn)
Yadd's avatar
Yadd committed
639
	@$(PERL) -i -pe 's/__DNSDOMAIN__/$(DNSDOMAIN)/g' $(RTESTDIR)/index.pl
640
	@rm -rf $$(find $(RTESTDIR) -type d -name .svn)
641 642

install_examples_site:
643
	# Examples install
644
	@install -v -d $(REXAMPLESDIR)
Yadd's avatar
Yadd committed
645
	@for i in portal handler; do \
Yadd's avatar
Yadd committed
646
		cp -a -f lemonldap-ng-$$i/example $(REXAMPLESDIR)/$$i; \
647
	done
Yadd's avatar
Yadd committed
648 649 650
	@for i in manager; do \
		cp -a -f lemonldap-ng-$$i/eg $(REXAMPLESDIR)/$$i; \
	done
Yadd's avatar
Yadd committed
651
	@rm -rf $(REXAMPLESDIR)/portal/skins \
Yadd's avatar
Yadd committed
652
		$(REXAMPLESDIR)/manager/skins \
653
	@rm -rf $$(find $(REXAMPLESDIR) -type d -name .svn)
654
	@$(PERL) -i -pe 's#__SESSIONDIR__#$(APACHESESSIONFILEDIR)/#g;' $(REXAMPLESDIR)/portal/*.pl
655
	@$(PERL) -i -pe 's#__PSESSIONDIR__#$(APACHEPSESSIONFILEDIR)/#g;' $(REXAMPLESDIR)/portal/*.pl
656

657
install_doc_site:
658
	# Offline documentation install
659 660
	@rm -rf $(RDEFDOCDIR)
	@install -v -d $(RDEFDOCDIR)
Yadd's avatar
Yadd committed
661
	@cp -a -f doc/* $(RDEFDOCDIR)
662

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

install_sessions_dir:
690
	@install -m 777 -v -d $(RAPACHESESSIONFILEDIR) $(RAPACHESESSIONFILELOCKDIR) $(RAPACHEPSESSIONFILEDIR) $(RAPACHEPSESSIONFILELOCKDIR)
691 692
	# Fix Apache::Session directories permissions
	@if [ "$(APACHEUSER)" != "" ]; then \
693
		chown $(APACHEUSER) $(RAPACHESESSIONFILEDIR) $(RAPACHESESSIONFILELOCKDIR) $(RAPACHEPSESSIONFILEDIR) $(RAPACHEPSESSIONFILELOCKDIR) || exit 1; \
694
		if [ "$(APACHEGROUP)" != "" ]; then \
695
			chgrp $(APACHEGROUP) $(RAPACHESESSIONFILEDIR) $(RAPACHESESSIONFILELOCKDIR) $(RAPACHEPSESSIONFILEDIR) $(RAPACHEPSESSIONFILELOCKDIR) || exit 1; \
696
		fi; \
697
		chmod 770 $(RAPACHESESSIONFILEDIR) $(RAPACHESESSIONFILELOCKDIR) $(RAPACHEPSESSIONFILEDIR) $(RAPACHEPSESSIONFILELOCKDIR); \
698
	else \
699
		chmod 777 $(RAPACHESESSIONFILEDIR) $(RAPACHESESSIONFILELOCKDIR) $(RAPACHEPSESSIONFILEDIR) $(RAPACHEPSESSIONFILELOCKDIR); \
700 701
	fi

702 703 704 705 706 707 708 709 710 711 712 713 714
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

715
install_captcha_dir:
716
	@install -m 777 -v -d $(RCAPTCHADIR)
717 718
	# Fix captcha directory permissions
	@if [ "$(APACHEUSER)" != "" ]; then \
719
		chown $(APACHEUSER) $(RCAPTCHADIR) || exit 1; \
720
		if [ "$(APACHEGROUP)" != "" ]; then \
721
			chgrp $(APACHEGROUP) $(RCAPTCHADIR) || exit 1; \
722
		fi; \
723
		chmod 770 $(RCAPTCHADIR); \
724
	else \
725
		chmod 777 $(RCAPTCHADIR); \
726 727
	fi

728
postconf_hosts:
Clément OUDOT's avatar
Clément OUDOT committed
729
	@cat ${CONFDIR}/for_etc_hosts >> /etc/hosts
730 731
	@echo "/etc/hosts was updated"

732
postconf: postconf_hosts
733 734
	@echo "Post configuration done"

735 736
uninstall:	configure handler_uninstall portal_uninstall manager_uninstall

737 738 739 740
common_uninstall:	common
	@$(MAKE) -C ${SRCCOMMONDIR} uninstall
	@rm -vf common_uninstall

741
handler_uninstall:	handler
742
	@$(MAKE) -C ${SRCHANDLERDIR} uninstall
743
	@rm -vf handler_uninstall
744 745

portal_uninstall:		portal
746
	@$(MAKE) -C ${SRCPORTALDIR} uninstall
747
	@rm -vf portal_uninstall
748 749

manager_uninstall:	manager
750
	@$(MAKE) -C ${SRCMANAGERDIR} uninstall
751
	@rm -vf manager_uninstall
752

753
dist:	clean
754 755 756 757 758 759 760 761 762
	@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)

763
rpm-dist:	clean
764
	@mkdir -p lemonldap-ng-$(VERSION)
Yadd's avatar
Yadd committed
765
	@cp -pRH $$(find * -maxdepth 0|grep -v -e "\(lemonldap-ng-$(VERSION)\|debian\)") lemonldap-ng-$(VERSION)
766 767
	@rm -rf $$(find lemonldap-ng-$(VERSION) -name .svn -print)
	@find $$dir -name '*.bak' -delete
768
	@rm -rf lemonldap-ng-$(VERSION)/lemonldap-ng-$(VERSION)
Yadd's avatar
Yadd committed
769
	@$(COMPRESS) lemonldap-ng-$(VERSION).$(COMPRESSSUFFIX) lemonldap-ng-$(VERSION)
770
	@rm -rf lemonldap-ng-$(VERSION)
771

772