Makefile 38.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)
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
FASTCGIUSER=$(APACHEUSER)
FASTCGIGROUP=$(APACHEGROUP)
115

116
# Apache version
117
APACHEVERSION=2.X
118

119
# DNS Domain for cookie and virtual hosts
120 121
DNSDOMAIN=example.com

122
# Virtual Host Listen IP and Port (*, *:80, ...)
Xavier Guimard's avatar
Xavier Guimard committed
123 124
PORT=80
VHOSTLISTEN="*:$(PORT)"
125
TESTWEBSERVER=apache
Xavier Guimard's avatar
Xavier Guimard committed
126 127
TESTWEBSERVERPORT=19876
PSGISERVERSOCKET=unix:/run/llng.sock
128

129
# Other
130 131 132 133
SRCCOMMONDIR=lemonldap-ng-common
SRCHANDLERDIR=lemonldap-ng-handler
SRCPORTALDIR=lemonldap-ng-portal
SRCMANAGERDIR=lemonldap-ng-manager
134 135 136

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

140

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

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

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

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

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

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

Xavier Guimard's avatar
Xavier Guimard committed
222 223 224
#
# Minification
#
225 226 227
minify: $(JSDSTFILES) $(CSSDSTFILES)

%.min.css: %.css
Xavier Guimard's avatar
Fault  
Xavier Guimard committed
228
	@echo "Compressing $*.css"
229
	@yui-compressor $*.css > $*.min.css
230 231

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

Xavier Guimard's avatar
Xavier Guimard committed
235

236 237 238
#
# Perl libraries configuration
#
239

Xavier Guimard's avatar
Xavier Guimard committed
240
json:	$(MANAGERJSONDST) debian/llng-fastcgi-server.1p
Xavier Guimard's avatar
Xavier Guimard committed
241
	@if which yui-compressor; then $(MAKE) minify; fi
242

243
$(MANAGERJSONDST):	$(MANAGERJSONSRC)
244
	./scripts/jsongenerator.pl
245

Xavier Guimard's avatar
Xavier Guimard committed
246 247 248
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
249
configure:	json common_conf handler_conf portal_conf manager_conf
250

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

262
${SRCHANDLERDIR}/Makefile:
Xavier Guimard's avatar
Xavier Guimard committed
263
	@cd ${SRCHANDLERDIR}; $(PERL) Makefile.PL $(PERLOPTIONS)
264

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

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

271 272 273
#
# Perl libraries make
#
274
common:		common_conf
275
	@$(MAKE) -C ${SRCCOMMONDIR}
276

Xavier Guimard's avatar
Xavier Guimard committed
277
handler:	handler_conf common
278
	@$(MAKE) -C ${SRCHANDLERDIR}
279

Xavier Guimard's avatar
Xavier Guimard committed
280
portal:		portal_conf common
281
	@$(MAKE) -C ${SRCPORTALDIR}
282

Xavier Guimard's avatar
Xavier Guimard committed
283
manager:	manager_conf handler
284
	$(MAKE) -C ${SRCMANAGERDIR}
285

286 287 288
################
# Test targets #
################
Xavier Guimard's avatar
Xavier Guimard committed
289
test:		all common_test handler_test portal_test manager_test extra_test
290 291 292 293

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

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

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

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

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

307
# End-to-end tests
308 309 310
e2e_test:	all prepare_test_server start_web_server launch_protractor stop_web_server

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

Xavier Guimard's avatar
Xavier Guimard committed
331 332 333
e2e-tests/conf/apache2.pid: start_web_server

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

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

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

stop_web_server:
	# Stop web server
380 381 382
	-@[ -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
383
	# Clean
384
	@rm -rf e2e-tests/conf
385

386 387
restart_web_server: start_web_server

Xavier Guimard's avatar
Xavier Guimard committed
388
plackup:
Xavier Guimard's avatar
Xavier Guimard committed
389
	@LLNG_DEFAULTCONFFILE=`pwd`/e2e-tests/conf/lemonldap-ng.ini \
Xavier Guimard's avatar
Xavier Guimard committed
390
	plackup -s FCGI \
Xavier Guimard's avatar
Xavier Guimard committed
391
		--listen e2e-tests/conf/llng.sock \
Xavier Guimard's avatar
Xavier Guimard committed
392 393
		--daemonize --pid e2e-tests/conf/plackup.pid \
		--nproc 1 --proc-title llng-fastcgi-server \
394
		--no-default-middleware \
395
		e2e-tests/llng.psgi
Xavier Guimard's avatar
Xavier Guimard committed
396

397 398 399
#
# INSTALL
#
Xavier Guimard's avatar
Xavier Guimard committed
400
install:	install_libs install_bin install_fastcgi_server install_site
401

402 403 404
#
# Perl libraires install
#
Xavier Guimard's avatar
Xavier Guimard committed
405
install_libs:	common_install_libs install_handler_libs install_portal_libs install_manager_libs
406 407

common_install_libs:		common
408
	@$(MAKE) -C ${SRCCOMMONDIR} install
409

410
install_handler_libs:	handler
411
	@$(MAKE) -C ${SRCHANDLERDIR} install
412

413
install_portal_libs:		portal
414
	@$(MAKE) -C ${SRCPORTALDIR} install
415

416
install_manager_libs:	manager
417
	@$(MAKE) -C ${SRCMANAGERDIR} install
418

419
example:
Xavier Guimard's avatar
Xavier Guimard committed
420
	$(MAKE) install_site install_bin LMPREFIX=$(EXAMPLEROOT)
421

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

447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464
install_fastcgi_server:
	@install -v -d $(RSBINDIR) $(RINITDIR) $(RETCDEFAULTDIR)
	@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)
	$(PERL) -pi -e 's#__SBINDIR__#$(SBINDIR)#;s#__DEFAULTDIR__#$(ETCDEFAULTDIR)#' \
		$(RETCDEFAULTDIR)/llng-fastcgi-server
	@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

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

509 510 511 512 513 514 515
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); \
516
		cp -f _example/etc/*nginx*.conf $(RCONFDIR); \
517 518 519 520 521 522 523
	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
524 525
			s#__PORT__#$(PORT)#g; \
			s#__PSGISERVERSOCKET__#$(PSGISERVERSOCKET)#g; \
526 527 528 529
			s#__VHOSTLISTEN__#$(VHOSTLISTEN)#g; \
			s#__DEFDOCDIR__#$(DEFDOCDIR)/#g; \
			s#__FRDOCDIR__#$(FRDOCDIR)/#g;' $(RCONFDIR)/*apache*.conf $(RCONFDIR)/*nginx*.conf

530 531
install_manager_site:	install_conf_dir
	# Manager install
Xavier Guimard's avatar
Xavier Guimard committed
532
	@install -v -d $(RMANAGERSTATICDIR) $(RMANAGERPSGIDIR) \
533 534
		$(RMANAGERTEMPLATESDIR)
	@cp -pR $(SRCMANAGERDIR)/site/static/* $(RMANAGERSTATICDIR)
535
	@for f in $(SRCMANAGERDIR)/site/templates/*.tpl; do \
536 537 538 539 540
		./scripts/transform-templates \
			usedebianlibs $(USEDEBIANLIBS) \
			useexternallibs $(USEEXTERNALLIBS) \
			jsminified $(JSCOMPRESS) \
			cssminified $(CSSCOMPRESS) <$$f \
541 542
			> $(RMANAGERTEMPLATESDIR)/`basename $$f`; \
	done
543
	@if test "$(USEEXTERNALLIBS)" = "yes"; then \
544
		rm -rvf $(MANAGEREXTERNALLIBS); \
545
	elif test "$(USEDEBIANLIBS)" = "yes"; then \
546 547
		rm -rvf $(MANAGERLIBSTOREMOVEFORDEBIAN); \
	fi
548 549
	@cp -pR $(SRCMANAGERDIR)/eg/* $(RMANAGERPSGIDIR)
	# Clean svn files
Xavier Guimard's avatar
Xavier Guimard committed
550
	@rm -rf $$(find ${RMANAGERSTATICDIR} $(RMANAGERPSGIDIR) \
551
		$(RMANAGERTEMPLATESDIR) $(RCONFDIR) -type d -name .svn)
Xavier Guimard's avatar
Xavier Guimard committed
552
	$(PERL) -i -pe 's#__MANAGERSTATICDIR__#$(MANAGERRELATIVESTATICDIR)#g' $(RCONFDIR)/$(CONFFILENAME)
553
	$(PERL) -i -pe 's#__MANAGERTEMPLATESDIR__#$(MANAGERTEMPLATESDIR)#g' $(RCONFDIR)/$(CONFFILENAME)
554 555 556 557

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

install_handler_site:	install_conf_dir
598
	# Handler install
599
	@install -v -d ${RHANDLERDIR}
600
	@cp -f $(SRCHANDLERDIR)/example/scripts/purgeLocalCache.cron.d $(RCRONDIR)/lemonldap-ng-handler
601
	@if [ ! "$(APACHEUSER)" ]; then \
602
		$(PERL) -i -pe 's#__APACHEUSER__#nobody#g;' $(RCRONDIR)/lemonldap-ng-handler; \
603 604 605 606
	else \
		$(PERL) -i -pe 's#__APACHEUSER__#$(APACHEUSER)#g;' $(RCRONDIR)/lemonldap-ng-handler; \
	fi
	@$(PERL) -i -pe 's#__BINDIR__#$(BINDIR)#g;' $(RCRONDIR)/lemonldap-ng-handler
607
	@rm -rf $$(find $(RHANDLERDIR) -type d -name .svn)
608 609

install_test_site:
610
	# Test site install
611
	@install -v -d $(RTESTDIR)
Xavier Guimard's avatar
Xavier Guimard committed
612
	@cp -pR -f _example/test/* $(RTESTDIR)
613
	@rm -rf $$(find $(RTESTDIR) -type d -name .svn)
Xavier Guimard's avatar
Xavier Guimard committed
614
	@$(PERL) -i -pe 's/__DNSDOMAIN__/$(DNSDOMAIN)/g' $(RTESTDIR)/index.pl
615
	@rm -rf $$(find $(RTESTDIR) -type d -name .svn)
616 617

install_examples_site:
618
	# Examples install
619
	@install -v -d $(REXAMPLESDIR)
620
	@for i in manager portal handler; do \
Xavier Guimard's avatar
Xavier Guimard committed
621
		cp -a -f lemonldap-ng-$$i/example $(REXAMPLESDIR)/$$i; \
622
	done
623
	@rm -rf $(REXAMPLESDIR)/portal/skins \
Xavier Guimard's avatar
Xavier Guimard committed
624
		$(REXAMPLESDIR)/manager/skins \
625
	@rm -rf $$(find $(REXAMPLESDIR) -type d -name .svn)
626
	@$(PERL) -i -pe 's#__SESSIONDIR__#$(APACHESESSIONFILEDIR)/#g;' $(REXAMPLESDIR)/portal/*.pl
627
	@$(PERL) -i -pe 's#__PSESSIONDIR__#$(APACHEPSESSIONFILEDIR)/#g;' $(REXAMPLESDIR)/portal/*.pl
628

629
install_doc_site:
630
	# Offline documentation install
631 632
	@rm -rf $(RDEFDOCDIR)
	@install -v -d $(RDEFDOCDIR)
Xavier Guimard's avatar
Xavier Guimard committed
633
	@cp -a -f doc/* $(RDEFDOCDIR)
634

635
install_conf_dir:	install_sessions_dir install_notif_dir install_captcha_dir
636
	# Configuration files install
637
	@install -v -d $(RCONFDIR) $(RFILECONFIGDIR) $(RTOOLSDIR)
Clément OUDOT's avatar
Clément OUDOT committed
638
	@if [ "$(ERASECONFIG)" -eq "1" ]; then \
Xavier Guimard's avatar
Xavier Guimard committed
639
		cp -f $(SRCCOMMONDIR)/$(CONFFILENAME) $(RCONFDIR); \
Xavier Guimard's avatar
Xavier Guimard committed
640
		$(PERL) -i -pe 's#^dirName\s*=\s*.*#dirName = $(FILECONFIGDIR)#g' $(RCONFDIR)/$(CONFFILENAME); \
Clément OUDOT's avatar
Clément OUDOT committed
641
	fi
642
	@cp _example/conf/lmConf-1.js $(RFILECONFIGDIR)
Xavier Guimard's avatar
Xavier Guimard committed
643
	@$(PERL) -i -pe 's/__DNSDOMAIN__/$(DNSDOMAIN)/g;\
644
		s#__SESSIONDIR__#$(APACHESESSIONFILEDIR)#g;\
645
		s#__PSESSIONDIR__#$(APACHEPSESSIONFILEDIR)#g;\
646
		s#__NOTIFICATIONDIR__#$(APACHEFILENOTIFDIR)#g;' $(RFILECONFIGDIR)/lmConf-1.js
647 648 649 650 651 652 653 654 655
	@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
656 657
	@cp $(SRCCOMMONDIR)/tools/lmConfig.* $(SRCCOMMONDIR)/tools/apache-session-mysql.sql $(RTOOLSDIR)
	@cp $(SRCCOMMONDIR)/tools/sso.schema $(RTOOLSDIR)
658
	$(PERL) -i -pe 's/__DNSDOMAIN__/$(DNSDOMAIN)/g' $(RCONFDIR)/$(CONFFILENAME)
659
	@rm -rf $$(find $(RCONFDIR) $(RFILECONFIGDIR) $(RTOOLSDIR) -type d -name .svn)
660 661

install_sessions_dir:
662
	@install -m 777 -v -d $(RAPACHESESSIONFILEDIR) $(RAPACHESESSIONFILELOCKDIR) $(RAPACHEPSESSIONFILEDIR) $(RAPACHEPSESSIONFILELOCKDIR)
663 664
	# Fix Apache::Session directories permissions
	@if [ "$(APACHEUSER)" != "" ]; then \
665
		chown $(APACHEUSER) $(RAPACHESESSIONFILEDIR) $(RAPACHESESSIONFILELOCKDIR) $(RAPACHEPSESSIONFILEDIR) $(RAPACHEPSESSIONFILELOCKDIR) || exit 1; \
666
		if [ "$(APACHEGROUP)" != "" ]; then \
667
			chgrp $(APACHEGROUP) $(RAPACHESESSIONFILEDIR) $(RAPACHESESSIONFILELOCKDIR) $(RAPACHEPSESSIONFILEDIR) $(RAPACHEPSESSIONFILELOCKDIR) || exit 1; \
668
		fi; \
669
		chmod 770 $(RAPACHESESSIONFILEDIR) $(RAPACHESESSIONFILELOCKDIR) $(RAPACHEPSESSIONFILEDIR) $(RAPACHEPSESSIONFILELOCKDIR); \
670
	else \
671
		chmod 777 $(RAPACHESESSIONFILEDIR) $(RAPACHESESSIONFILELOCKDIR) $(RAPACHEPSESSIONFILEDIR) $(RAPACHEPSESSIONFILELOCKDIR); \
672 673
	fi

674 675 676 677 678 679 680 681 682 683 684 685 686
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

687
install_captcha_dir:
688
	@install -m 777 -v -d $(RCAPTCHADIR)
689 690
	# Fix captcha directory permissions
	@if [ "$(APACHEUSER)" != "" ]; then \
691
		chown $(APACHEUSER) $(RCAPTCHADIR) || exit 1; \
692
		if [ "$(APACHEGROUP)" != "" ]; then \
693
			chgrp $(APACHEGROUP) $(RCAPTCHADIR) || exit 1; \
694
		fi; \
695
		chmod 770 $(RCAPTCHADIR); \
696
	else \
697
		chmod 777 $(RCAPTCHADIR); \
698 699
	fi

700
postconf_hosts:
Clément OUDOT's avatar
Clément OUDOT committed
701
	@cat ${CONFDIR}/for_etc_hosts >> /etc/hosts
702 703
	@echo "/etc/hosts was updated"

704
postconf: postconf_hosts
705 706
	@echo "Post configuration done"

707 708
uninstall:	configure handler_uninstall portal_uninstall manager_uninstall

709 710 711 712
common_uninstall:	common
	@$(MAKE) -C ${SRCCOMMONDIR} uninstall
	@rm -vf common_uninstall

713
handler_uninstall:	handler
714
	@$(MAKE) -C ${SRCHANDLERDIR} uninstall
715
	@rm -vf handler_uninstall
716 717

portal_uninstall:		portal
718
	@$(MAKE) -C ${SRCPORTALDIR} uninstall
719
	@rm -vf portal_uninstall
720 721

manager_uninstall:	manager
722
	@$(MAKE) -C ${SRCMANAGERDIR} uninstall
723
	@rm -vf manager_uninstall
724

725
dist:	clean
726 727 728 729 730 731 732 733 734 735
	@mkdir -p lemonldap-ng-$(VERSION)
	@cp -pRH $$(find * -maxdepth 0|grep -v -e "\(lemonldap-ng-$(VERSION)\|debian\|rpm\)") lemonldap-ng-$(VERSION)
	@rm -rf $$(find lemonldap-ng-$(VERSION) -name .svn -print)
	@rm -rf lemonldap-ng-$(VERSION)/po-doc/fr/*
	@find $$dir -name '*.bak' -delete
	@rm -rf lemonldap-ng-$(VERSION)/lemonldap-ng-$(VERSION)
	@$(COMPRESS) lemonldap-ng-$(VERSION).$(COMPRESSSUFFIX) lemonldap-ng-$(VERSION)
	@rm -rf lemonldap-ng-$(VERSION)

rpm-dist:	clean
736
	@mkdir -p lemonldap-ng-$(VERSION)
737
	@cp -pRH $$(find * -maxdepth 0|grep -v -e "\(lemonldap-ng-$(VERSION)\|debian\)") lemonldap-ng-$(VERSION)
738 739
	@rm -rf $$(find lemonldap-ng-$(VERSION) -name .svn -print)
	@find $$dir -name '*.bak' -delete
740
	@rm -rf lemonldap-ng-$(VERSION)/lemonldap-ng-$(VERSION)
Xavier Guimard's avatar
Xavier Guimard committed
741
	@$(COMPRESS) lemonldap-ng-$(VERSION).$(COMPRESSSUFFIX) lemonldap-ng-$(VERSION)
742
	@rm -rf lemonldap-ng-$(VERSION)
743

744

745 746
debian-dist:	clean
	@mkdir -p lemonldap-ng-$(VERSION)
747
	@cp -pRH $$(find * -maxdepth 0|grep -v -e "\(lemonldap-ng-$(VERSION)\|rpm\)") lemonldap-ng-$(VERSION)
748 749
	@rm -rf $$(find lemonldap-ng-$(VERSION) -name .svn -print)
	@find $$dir -name '*.bak' -delete
750 751 752 753
	@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
754 755 756
	@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
757 758 759

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

761 762 763 764 765 766 767 768
manifest:   configure
	@for i in ${SRCCOMMONDIR} ${SRCHANDLERDIR} ${SRCPORTALDIR} ${SRCMANAGERDIR}; do \
		cd $$i; \
		make manifest; \
		rm -vf MANIFEST.*; \
		cd -; \
	done

769
cpan:	clean configure common_cpan handler_cpan portal_cpan manager_cpan
Clément OUDOT's avatar
Clément OUDOT committed
770
	for i in Common Portal Handler Manager; do \
Xavier Guimard's avatar
Xavier Guimard committed
771
		$(UNCOMPRESS) Lemonldap-NG-$$i-*.$(COMPRESSSUFFIX) \
Clément OUDOT's avatar
Clément OUDOT committed
772
			$$($(LISTCOMPRESSED) Lemonldap-NG-$$i-*.$(COMPRESSSUFFIX) |grep META.yml); \
Xavier Guimard's avatar
Xavier Guimard committed
773
		mv Lemonldap-NG-$$i-*/META.yml lemonldap-ng-$$($(PERL) -e "print lc('$$i')")/; \
774
		rm -rf Lemonldap-NG-$$i*/; \
Xavier Guimard's avatar
Xavier Guimard committed
775
		done
776 777 778 779

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

handler_cpan:	handler_conf
782 783
	@$(MAKE) -C ${SRCHANDLERDIR} dist
	@mv ${SRCHANDLERDIR}/Lemonldap*.gz .
784 785

portal_cpan:		portal_conf
786 787
	@$(MAKE) -C ${SRCPORTALDIR} dist
	@mv ${SRCPORTALDIR}/Lemonldap*.gz .
788 789

manager_cpan:	manager_conf
790 791
	@$(MAKE) -C ${SRCMANAGERDIR} dist
	@mv ${SRCMANAGERDIR}/Lemonldap*.gz .
792

793
documentation:
794
	@cd doc/ && ../scripts/doc.pl
795

796
doxygen:	clean
Xavier Guimard's avatar
Xavier Guimard committed
797
	$(PERL) -i -pe 's/^(PROJECT_NUMBER\s*=\s*)\d.*$$/$${1}'$(VERSION)'/' Doxyfile
798 799 800 801 802 803
	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
804
	$(PERL) -i -pe 's/Graphical Class Hierarchy/Class Collaboration Graph/' doc/devel/html/inherits.html doc/devel/html/tree.html
805 806
	# 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
807

808 809
distclean:	clean

Xavier Guimard's avatar
Xavier Guimard committed
810
clean:		common_clean handler_clean portal_clean manager_clean omegat-clean omegat-fr-clean stop_web_server
Xavier Guimard's avatar
Xavier Guimard committed
811
	@rm -f $$(find */ -name '*bak' -delete)
812
	@rm -rf $(EXAMPLEROOT) example/ doc/devel
Xavier Guimard's avatar
Xavier Guimard committed
813
	@rm -vf *gz *zip
Xavier Guimard's avatar
Xavier Guimard committed
814
	@rm -rf lemonldap-ng-$(VERSION)
Xavier Guimard's avatar
Xavier Guimard committed
815
	@echo "Cleaned"
816 817

common_clean:
Xavier Guimard's avatar
Xavier Guimard committed
818
	@if test -e ${SRCCOMMONDIR}/Makefile;then $(MAKE) -C ${SRCCOMMONDIR} distclean;fi
819 820 821
	@rm -vf common*

handler_clean:
Xavier Guimard's avatar
Xavier Guimard committed
822
	@if test -e ${SRCHANDLERDIR}/Makefile;then $(MAKE) -C ${SRCHANDLERDIR} distclean;fi
823 824 825
	@rm -vf handler*

portal_clean:
Xavier Guimard's avatar
Xavier Guimard committed
826
	@if test -e ${SRCPORTALDIR}/Makefile;then $(MAKE) -C ${SRCPORTALDIR} distclean;fi
827 828 829
	@rm -vf portal*

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

833
debian-local-packages: debian-dist
Xavier Guimard's avatar
Xavier Guimard committed
834
	mv lemonldap-ng_$(VERSION).orig.$(COMPRESSSUFFIX) /tmp/
835 836
	version=$(VERSION) && \
	cd /tmp/ && \
Xavier Guimard's avatar
Xavier Guimard committed
837
	rm -rf lemonldap-ng-$$version && \
Xavier Guimard's avatar
Xavier Guimard committed
838
	$(UNCOMPRESS) lemonldap-ng_$$version.orig.$(COMPRESSSUFFIX) && \
839
	cd lemonldap-ng-$$version && \
Xavier Guimard's avatar
Xavier Guimard committed
840
	debuild -us -uc -b --lintian-opts -i \
Xavier Guimard's avatar
Xavier Guimard committed
841 842 843
		--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
844

845 846 847 848 849 850 851 852 853 854 855 856 857
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
858
	cd /tmp/lemonldap-ng-$(VERSION) && \
Xavier Guimard's avatar
Xavier Guimard committed
859 860 861 862 863 864
	$(SU) debi

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

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

Xavier Guimard's avatar
Xavier Guimard committed
866
debian-diff:
Xavier Guimard's avatar
Xavier Guimard committed
867
	@# Portal
868 869 870
	@$(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
871
	@for i in $(PORTALSKINS); do \
872
		$(DIFF) -x 'jquery*' $(SRCPORTALDIR)/example/skins/$$i $(DIFFPREFIX)/usr/share/lemonldap-ng/portal-skins/$$i; \
Xavier Guimard's avatar
Xavier Guimard committed
873
	done ||true
874 875 876 877 878 879
	@$(DIFF) $(SRCPORTALDIR)/example/index_skin.pl $(DIFFPREFIX)/var/lib/lemonldap-ng/portal/index.pl ||true
	@$(DIFF) $(SRCPORTALDIR)/example/mail.pl $(DIFFPREFIX)/var/lib/lemonldap-ng/portal/mail.pl ||true
	@$(DIFF) $(SRCPORTALDIR)/example/metadata.pl $(DIFFPREFIX)/var/lib/lemonldap-ng/portal/metadata.pl ||true
	@$(DIFF) $(SRCPORTALDIR)/example/openid-configuration.pl $(DIFFPREFIX)/var/lib/lemonldap-ng/portal/openid-configuration.pl ||true
	@$(DIFF) $(SRCPORTALDIR)/example/cdc.pl $(DIFFPREFIX)/var/lib/lemonldap-ng/portal/cdc.pl ||true
	@$(DIFF) $(SRCPORTALDIR)/example/register.pl $(DIFFPREFIX)/var/lib/lemonldap-ng/portal/register.pl ||true
Xavier Guimard's avatar
Xavier Guimard committed
880
	@# Handler
881 882
	@$(DIFF) $(SRCHANDLERDIR)/lib/Lemonldap/NG/Handler $(DIFFPREFIX)/usr/share/perl5/Lemonldap/NG/Handler ||true
	@$(DIFF) $(SRCHANDLERDIR)/example/scripts/purgeLocalCache $(DIFFPREFIX)/usr/share/lemonldap-ng/bin/purgeLocalCache ||true
Xavier Guimard's avatar
Xavier Guimard committed
883
	@# Common
884 885 886 887 888
	@$(DIFF) $(SRCCOMMONDIR)/lib/Lemonldap/NG/Common $(DIFFPREFIX)/usr/share/perl5/Lemonldap/NG/Common ||true
	@$(DIFF) $(SRCCOMMONDIR)/lib/Lemonldap/NG/Common.pm $(DIFFPREFIX)/usr/share/perl5/Lemonldap/NG/Common.pm ||true
	@$(DIFF) $(SRCCOMMONDIR)/scripts/lmMigrateConfFiles2ini $(DIFFPREFIX)/usr/share/lemonldap-ng/bin/lmMigrateConfFiles2ini ||true
	@$(DIFF) $(SRCCOMMONDIR)/scripts/convertConfig $(DIFFPREFIX)/usr/share/lemonldap-ng/bin/convertConfig ||true
	@$(DIFF) $(SRCCOMMONDIR)/scripts/rotateOidcKeys $(DIFFPREFIX)/usr/share/lemonldap-ng/bin/rotateOidcKeys ||true
Xavier Guimard's avatar
Xavier Guimard committed
889
	@# Manager
890 891 892 893 894 895
	@$(DIFF) $(SRCMANAGERDIR)/lib/Lemonldap/NG/Manager $(DIFFPREFIX)/usr/share/perl5/Lemonldap/NG/Manager ||true
	@$(DIFF) $(SRCMANAGERDIR)/lib/Lemonldap/NG/Manager.pm $(DIFFPREFIX)/usr/share/perl5/Lemonldap/NG/Manager.pm ||true
	@$(DIFF) $(SRCMANAGERDIR)/eg $(DIFFPREFIX)/var/lib/lemonldap-ng/manager/psgi ||true
	@$(DIFF) $(SRCMANAGERDIR)/site/static $(DIFFPREFIX)/var/lib/lemonldap-ng/manager/static ||true
	@$(DIFF) $(SRCMANAGERDIR)/site/templates $(DIFFPREFIX)/var/lib/lemonldap-ng/manager/templates ||true
	@$(DIFF) --ignore-matching-lines='set.*get.*\[2\]' $(SRCMANAGERDIR)/scripts/lmConfigEditor $(DIFFPREFIX)/usr/share/lemonldap-ng/bin/lmConfigEditor ||true
896
	@$(DIFF) --ignore-matching-lines='giveUpPrivileges' $(SRCCOMMONDIR)/scripts/lemonldap-ng-cli $(DIFFPREFIX)/usr/share/lemonldap-ng/bin/lemonldap-ng-cli ||true
Xavier Guimard's avatar
Xavier Guimard committed
897

898 899
default-diff:
	@# Portal
Xavier Guimard's avatar