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/
Xavier Guimard's avatar
Xavier Guimard committed
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

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

405 406 407
#
# INSTALL
#
Xavier Guimard's avatar
Xavier Guimard committed
408
install:	install_libs install_bin install_fastcgi_server install_site
409

410 411 412
#
# Perl libraires install
#
Xavier Guimard's avatar
Xavier Guimard committed
413
install_libs:	common_install_libs install_handler_libs install_portal_libs install_manager_libs
414 415

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

418
install_handler_libs:	handler
419
	@$(MAKE) -C ${SRCHANDLERDIR} install
420

421
install_portal_libs:		portal
422
	@$(MAKE) -C ${SRCPORTALDIR} install
423

424
install_manager_libs:	manager
425
	@$(MAKE) -C ${SRCMANAGERDIR} install
426

427
example:
Xavier Guimard's avatar
Xavier Guimard committed
428
	$(MAKE) install_site install_bin LMPREFIX=$(EXAMPLEROOT)
429

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

726
postconf: postconf_hosts
727 728
	@echo "Post configuration done"

729 730
uninstall:	configure handler_uninstall portal_uninstall manager_uninstall

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

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

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

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

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

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

766

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

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

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

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

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

handler_cpan:	handler_conf
804 805
	@$(MAKE) -C ${SRCHANDLERDIR} dist
	@mv ${SRCHANDLERDIR}/Lemonldap*.gz .
806 807

portal_cpan:		portal_conf
808 809
	@$(MAKE) -C ${SRCPORTALDIR} dist
	@mv ${SRCPORTALDIR}/Lemonldap*.gz .
810 811

manager_cpan:	manager_conf
812 813
	@$(MAKE) -C ${SRCMANAGERDIR} dist
	@mv ${SRCMANAGERDIR}/Lemonldap*.gz .
814

815
documentation:
816
	@cd doc/ && ../scripts/doc.pl
817

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

830 831
distclean:	clean

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

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

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

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

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

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

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

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

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

Xavier Guimard's avatar
Xavier Guimard committed
888
debian-diff:
Xavier Guimard's avatar
Xavier Guimard committed
889
	@# Portal
890 891 892
	@$(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
893
	@for i in $(PORTALSKINS); do \