File: rules

package info (click to toggle)
lcgdm 1.9.0-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 17,600 kB
  • ctags: 15,632
  • sloc: ansic: 228,091; sh: 13,576; perl: 11,575; python: 11,537; cpp: 5,716; sql: 1,824; makefile: 1,253; fortran: 113
file content (717 lines) | stat: -rwxr-xr-x 24,845 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
#!/usr/bin/make -f
# -*- makefile -*-

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

-include /usr/share/dpkg/buildflags.mk

INSTALLDIR = $(CURDIR)/debian/tmp

_prefix = /usr
_bindir = $(_prefix)/bin
_sbindir = $(_prefix)/sbin
_libdir = $(_prefix)/lib
_includedir = $(_prefix)/include
_sysconfdir = /etc
_localstatedir = /var
_initrddir = $(_sysconfdir)/init.d
_datadir = $(_prefix)/share
_mandir = $(_datadir)/man
_docdir = $(_datadir)/doc
_archlib = $(shell perl -MConfig -e 'print $$Config{vendorarch}')

VERSION=1.9.0

configure: configure-stamp

configure-stamp:
	dh_testdir

	chmod 644 security/globus_gsi_gss_constants.h \
		  security/globus_i_gsi_credential.h \
		  security/gssapi_openssl.h
	chmod 644 doc/lfc/INSTALL-*

	# LFC with mysql backend

	mkdir lfc-mysql
	cp -pr Imakefile Makefile.ini config configure VERSION scripts \
	    h lib shlib common ns rfio dpm \
	    srmv1 srmv2 srmv2.2 security dli dicomcopy dpmcopy \
	    test lfc-mysql

	# The code violates the strict aliasing rules all over the place...
	# Need to use -fnostrict-aliasing so that the -O2 optimization in
	# CFLAGS doesn't try to use them.
	sed 's!^CC +=!& $(CPPFLAGS) $(CFLAGS) -fno-strict-aliasing!' \
	    -i lfc-mysql/config/linux.cf

	sed 's!^CXXFLAGS =!& $(CPPFLAGS) $(CXXFLAGS)!' \
	    -i lfc-mysql/common/Imakefile

	cd lfc-mysql && \
	gsoapversion=`soapcpp2 -v < /dev/null 2>&1 | grep C++ | sed 's/.* //'` && \
	./configure lfc --with-mysql \
		--libdir=\'lib/$(DEB_HOST_MULTIARCH)\' \
		--with-gsoap-version=$$gsoapversion \
		--with-id-map-file=$(_sysconfdir)/lcgdm-mapfile \
		--with-ns-config-file=$(_sysconfdir)/NSCONFIG \
		--with-etc-dir='$$(prefix)/../etc' \
		--with-sysconf-dir=EtcDir/default \
		--with-initrc-dir=EtcDir/init.d \
		--with-emi \
		--without-argus

	sed 's!$$(prefix)/var!$$(prefix)/../var!' -i lfc-mysql/config/site.def

	cd lfc-mysql && \
	make -f Makefile.ini Makefiles

	# LFC with postgres backend

	mkdir lfc-postgres
	cp -pr Imakefile Makefile.ini config configure VERSION scripts \
	    h lib shlib common ns rfio dpm \
	    srmv1 srmv2 srmv2.2 security dli dicomcopy dpmcopy \
	    test lfc-postgres

	# The code violates the strict aliasing rules all over the place...
	# Need to use -fnostrict-aliasing so that the -O2 optimization in
	# CFLAGS doesn't try to use them.
	sed 's!^CC +=!& $(CPPFLAGS) $(CFLAGS) -fno-strict-aliasing!' \
	    -i lfc-postgres/config/linux.cf

	sed 's!^CXXFLAGS =!& $(CPPFLAGS) $(CXXFLAGS)!' \
	    -i lfc-postgres/common/Imakefile

	cd lfc-postgres && \
	gsoapversion=`soapcpp2 -v < /dev/null 2>&1 | grep C++ | sed 's/.* //'` && \
	./configure lfc --with-postgres \
		--libdir=\'lib/$(DEB_HOST_MULTIARCH)\' \
		--with-gsoap-version=$$gsoapversion \
		--with-id-map-file=$(_sysconfdir)/lcgdm-mapfile \
		--with-ns-config-file=$(_sysconfdir)/NSCONFIG \
		--with-etc-dir='$$(prefix)/../etc' \
		--with-sysconf-dir=EtcDir/default \
		--with-initrc-dir=EtcDir/init.d \
		--with-emi \
		--without-argus

	sed 's!$$(prefix)/var!$$(prefix)/../var!' -i lfc-postgres/config/site.def

	sed -e 's/\(BuildDLI	*\)YES/\1NO/' \
	    -e 's/\(BuildInterfaces	*\)YES/\1NO/' \
	    -e 's/\(BuildNameServerClient	*\)YES/\1NO/' \
	    -e 's/\(BuildNameServerLibrary	*\)YES/\1NO/' \
	    -i lfc-postgres/config/site.def
	sed '/^\#define.*YES/d' -i lfc-postgres/config/Project.tmpl \
				   lfc-postgres/config/Library.tmpl
	sed '/^SECURITYDIR =/d' -i lfc-postgres/config/Project.tmpl
	sed 's/\(install:\).*/\1/' -i lfc-postgres/h/Imakefile

	cd lfc-postgres && \
	make -f Makefile.ini Makefiles

	# DPM with mysql backend

	mkdir dpm-mysql
	cp -pr Imakefile Makefile.ini config configure VERSION scripts \
	    h lib shlib common ns rfio dpm \
	    srmv1 srmv2 srmv2.2 security dli dicomcopy dpmcopy \
	    test dpm-mysql

	# The code violates the strict aliasing rules all over the place...
	# Need to use -fnostrict-aliasing so that the -O2 optimization in
	# CFLAGS doesn't try to use them.
	sed 's!^CC +=!& $(CPPFLAGS) $(CFLAGS) -fno-strict-aliasing!' \
	    -i dpm-mysql/config/linux.cf

	sed 's!^CXXFLAGS =!& $(CPPFLAGS) $(CXXFLAGS)!' \
	    -i dpm-mysql/common/Imakefile

	cd dpm-mysql && \
	gsoapversion=`soapcpp2 -v < /dev/null 2>&1 | grep C++ | sed 's/.* //'` && \
	./configure dpm --with-mysql \
		--libdir=\'lib/$(DEB_HOST_MULTIARCH)\' \
		--with-gsoap-version=$$gsoapversion \
		--with-dpm-config-file=$(_sysconfdir)/DPMCONFIG \
		--with-id-map-file=$(_sysconfdir)/lcgdm-mapfile \
		--with-ns-config-file=$(_sysconfdir)/DPNSCONFIG \
		--with-etc-dir='$$(prefix)/../etc' \
		--with-sysconf-dir=EtcDir/default \
		--with-initrc-dir=EtcDir/init.d \
		--with-emi \
		--without-argus

	sed 's!$$(prefix)/var!$$(prefix)/../var!' -i dpm-mysql/config/site.def

	sed -e '/^SECURITYDIR =/d' \
	    -e '/^COMMONDIR =/d' -i dpm-mysql/config/Project.tmpl
	sed -e 's/:.*(lcgdm).*/:/' -i dpm-mysql/lib/Imakefile
	sed -e 's/:.*(lcgdm).*/:/' -i dpm-mysql/shlib/Imakefile

	cd dpm-mysql && \
	make -f Makefile.ini Makefiles

	# DPM with postgres backend

	mkdir dpm-postgres
	cp -pr Imakefile Makefile.ini config configure VERSION scripts \
	    h lib shlib common ns rfio dpm \
	    srmv1 srmv2 srmv2.2 security dli dicomcopy dpmcopy \
	    test dpm-postgres

	# The code violates the strict aliasing rules all over the place...
	# Need to use -fnostrict-aliasing so that the -O2 optimization in
	# CFLAGS doesn't try to use them.
	sed 's!^CC +=!& $(CPPFLAGS) $(CFLAGS) -fno-strict-aliasing!' \
	    -i dpm-postgres/config/linux.cf

	sed 's!^CXXFLAGS =!& $(CPPFLAGS) $(CXXFLAGS)!' \
	    -i dpm-postgres/common/Imakefile

	cd dpm-postgres && \
	gsoapversion=`soapcpp2 -v < /dev/null 2>&1 | grep C++ | sed 's/.* //'` && \
	./configure dpm --with-postgres \
		--libdir=\'lib/$(DEB_HOST_MULTIARCH)\' \
		--with-gsoap-version=$$gsoapversion \
		--with-dpm-config-file=$(_sysconfdir)/DPMCONFIG \
		--with-id-map-file=$(_sysconfdir)/lcgdm-mapfile \
		--with-ns-config-file=$(_sysconfdir)/DPNSCONFIG \
		--with-etc-dir='$$(prefix)/../etc' \
		--with-sysconf-dir=EtcDir/default \
		--with-initrc-dir=EtcDir/init.d \
		--with-emi \
		--without-argus

	sed 's!$$(prefix)/var!$$(prefix)/../var!' -i dpm-postgres/config/site.def

	sed -e 's/\(BuildDPMClient	*\)YES/\1NO/' \
	    -e 's/\(BuildInterfaces	*\)YES/\1NO/' \
	    -e 's/\(BuildNameServerClient	*\)YES/\1NO/' \
	    -e 's/\(BuildNameServerLibrary	*\)YES/\1NO/' \
	    -e 's/\(BuildRfioClient	*\)YES/\1NO/' \
	    -e 's/\(BuildRfioServer	*\)YES/\1NO/' \
	    -i dpm-postgres/config/site.def
	sed '/^\#define.*YES/d' -i dpm-postgres/config/Project.tmpl \
				-i dpm-postgres/config/Library.tmpl
	sed '/^SECURITYDIR =/d' -i dpm-postgres/config/Project.tmpl
	sed 's/\(install:\).*/\1/' -i dpm-postgres/h/Imakefile

	cd dpm-postgres && \
	make -f Makefile.ini Makefiles

	touch $@

build: build-indep build-arch

build-indep: build-stamp

build-arch: build-stamp

build-stamp: configure-stamp
	dh_testdir

	cd lfc-mysql && \
	$(MAKE) SOAPFLG="$(shell pkg-config --cflags gsoap)" \
		DEB_HOST_MULTIARCH=$(DEB_HOST_MULTIARCH) \
		SYSCONFDIR=$(_sysconfdir) \
		LDFLAGS="$(LDFLAGS) -Wl,-z,defs" \
		SHLIBLDFLAGS="-shared $(LDFLAGS) -Wl,-z,defs"

	cd lfc-postgres/shlib && ln -s ../../lfc-mysql/shlib/liblcgdm.so* .
	cd lfc-postgres/shlib && ln -s ../../lfc-mysql/shlib/liblfc.so* .

	cd lfc-postgres && \
	$(MAKE) SOAPFLG="$(shell pkg-config --cflags gsoap)" \
		DEB_HOST_MULTIARCH=$(DEB_HOST_MULTIARCH) \
		SYSCONFDIR=$(_sysconfdir) \
		LDFLAGS="$(LDFLAGS) -Wl,-z,defs" \
		SHLIBLDFLAGS="-shared $(LDFLAGS) -Wl,-z,defs" \
		POSINC=-I/usr/include/postgresql

	cd dpm-mysql/shlib && ln -s ../../lfc-mysql/shlib/liblcgdm.so* .

	cd dpm-mysql && \
	$(MAKE) SOAPFLG="$(shell pkg-config --cflags gsoap)" \
		DEB_HOST_MULTIARCH=$(DEB_HOST_MULTIARCH) \
		SYSCONFDIR=$(_sysconfdir) \
		LDFLAGS="$(LDFLAGS) -Wl,-z,defs" \
		SHLIBLDFLAGS="-shared $(LDFLAGS) -Wl,-z,defs"

	cd dpm-postgres/shlib && ln -s ../../lfc-mysql/shlib/liblcgdm.so* .
	cd dpm-postgres/shlib && ln -s ../../dpm-mysql/shlib/libdpm.so* .

	cd dpm-postgres && \
	$(MAKE) SOAPFLG="$(shell pkg-config --cflags gsoap)" \
		DEB_HOST_MULTIARCH=$(DEB_HOST_MULTIARCH) \
		SYSCONFDIR=$(_sysconfdir) \
		LDFLAGS="$(LDFLAGS) -Wl,-z,defs" \
		SHLIBLDFLAGS="-shared $(LDFLAGS) -Wl,-z,defs" \
		POSINC=-I/usr/include/postgresql

	touch $@

clean:
	dh_testdir
	dh_testroot

	rm -rf lfc-mysql
	rm -rf lfc-postgres
	rm -rf dpm-mysql
	rm -rf dpm-postgres

	rm -f debian/libdpm-perl.install debian/liblfc-perl.install

	rm -f build-stamp configure-stamp

	dh_clean

install: build-stamp
	dh_testdir
	dh_testroot
	mkdir -p debian/liblcgdm-dev$(_docdir)
	ln -s liblcgdm1 debian/liblcgdm-dev$(_docdir)/liblgcdm-dev
	mkdir -p debian/liblfc-dev$(_docdir)
	ln -s liblfc1 debian/liblfc-dev$(_docdir)/liblfc-dev
	mkdir -p debian/libdpm-dev$(_docdir)
	ln -s libdpm1 debian/libdpm-dev$(_docdir)/libdpm-dev
	dh_prep

	mkdir -p debian/tmp/etc/default

	# LFC with mysql backend

	cd lfc-mysql && \
	$(MAKE) SOAPFLG="$(shell pkg-config --cflags gsoap)" \
		DEB_HOST_MULTIARCH=$(DEB_HOST_MULTIARCH) \
		SYSCONFDIR=$(INSTALLDIR)$(_sysconfdir) \
		LDFLAGS="$(LDFLAGS) -Wl,-z,defs" \
		SHLIBLDFLAGS="-shared $(LDFLAGS) -Wl,-z,defs" \
		prefix=$(INSTALLDIR)$(_prefix) install install.man

	mv $(INSTALLDIR)$(_libdir)/$(DEB_HOST_MULTIARCH)/lfc-mysql \
	   $(INSTALLDIR)$(_libdir)/lfc-mysql

	# lfcdaemon startup script
	sed -e 's/LD_LIBRARY_PATH=$$LD_LIBRARY_PATH //' \
	    -e '/LD_LIBRARY_PATH/d' \
	    -e 's!\$$PREFIX/etc!/etc!' \
	    -e 's!mysqld!mysql!' \
	    -i $(INSTALLDIR)$(_sysconfdir)/lfc-mysql/lfcdaemon.init

	# lfcdaemon configuration file
	sed -e 's/\(RUN_LFCDAEMON=\).*/\1"no"/' \
	    -e 's!/opt/lcg!!' -e 's!export SEMSGCONFIGFILE!#&!' \
	    -i $(INSTALLDIR)$(_sysconfdir)/lfc-mysql/lfcdaemon.conf

	# lfcdaemon man page
	sed -e 's!/opt/lcg!!g' \
	    -e 's/lfc-shutdown(1)/lfc-shutdown(8)/g' \
	    -i $(INSTALLDIR)$(_libdir)/lfc-mysql/lfcdaemon.8
	gzip -n -9 $(INSTALLDIR)$(_libdir)/lfc-mysql/lfcdaemon.8

	# lfc-shutdown man page
	gzip -n -9 $(INSTALLDIR)$(_libdir)/lfc-mysql/lfc-shutdown.8

	# lfc-dli startup script
	sed -e 's/LD_LIBRARY_PATH=$$LD_LIBRARY_PATH //' \
	    -e '/LD_LIBRARY_PATH/d' \
	    -e 's!\$$PREFIX/etc!/etc!' \
	    -e 's!/var/log/dli!/var/log/lfc-dli!g' \
	    -i  $(INSTALLDIR)$(_sysconfdir)/init.d/lfc-dli

	# lfc-dli configuration file
	sed -e 's!/var/log/dli!/var/log/lfc-dli!g' \
	    -e 's/\(LFC_HOST=\).*/\1`hostname -f`/' \
	    -e 's/\(RUN_DLIDAEMON=\).*/\1"no"/' \
	    -i $(INSTALLDIR)$(_sysconfdir)/lfc-dli
	mv $(INSTALLDIR)$(_sysconfdir)/lfc-dli \
	   $(INSTALLDIR)$(_sysconfdir)/default/lfc-dli

	# lfc-dli log rotation configuration
	sed -e 's!/var/log/dli!/var/log/lfc-dli!g' \
	    -i $(INSTALLDIR)$(_sysconfdir)/logrotate.d/lfc-dli

	# lfc-dli man page
	sed -e 's/\(\.TH [^ ]* \)1/\18/' \
	    -e 's!/var/log/dli!/var/log/lfc-dli!g' \
	    -e 's/lfcdaemon(1)/lfc-server(8)/g' \
	    -i $(INSTALLDIR)$(_mandir)/man8/lfc-dli.8

	# Add the star accounting scripts
	mkdir $(INSTALLDIR)$(_datadir)/lcgdm/scripts
	install -m 755 scripts/StAR-accounting/star-accounting.py \
	    $(INSTALLDIR)$(_datadir)/lcgdm/scripts
	sed 's!/usr/bin/env python!/usr/bin/python!' \
	    -i $(INSTALLDIR)$(_datadir)/lcgdm/scripts/star-accounting.py

	# Add the LFC info provider script
	sed 's/\(^LFC_VERSION=\).*/\1$(VERSION)/' \
	    scripts/lcg-info-provider-lfc > \
	    $(INSTALLDIR)$(_datadir)/lcgdm/lcg-info-provider-lfc
	chmod 755 $(INSTALLDIR)$(_datadir)/lcgdm/lcg-info-provider-lfc

	# Create lfc user home and certificate directories
	mkdir -p $(INSTALLDIR)$(_localstatedir)/lib/lfc
	mkdir -p $(INSTALLDIR)$(_sysconfdir)/grid-security/lfcmgr

	# Remove due to name conflict
	rm $(INSTALLDIR)$(_mandir)/man3/log.3

	# LFC with postgres backend

	cd lfc-postgres && \
	$(MAKE) SOAPFLG="$(shell pkg-config --cflags gsoap)" \
		DEB_HOST_MULTIARCH=$(DEB_HOST_MULTIARCH) \
		SYSCONFDIR=$(INSTALLDIR)$(_sysconfdir) \
		LDFLAGS="$(LDFLAGS) -Wl,-z,defs" \
		SHLIBLDFLAGS="-shared $(LDFLAGS) -Wl,-z,defs" \
		prefix=$(INSTALLDIR)$(_prefix) install install.man

	mv $(INSTALLDIR)$(_libdir)/$(DEB_HOST_MULTIARCH)/lfc-postgres \
	   $(INSTALLDIR)$(_libdir)/lfc-postgres

	# lfcdaemon startup script
	sed -e 's/LD_LIBRARY_PATH=$$LD_LIBRARY_PATH //' \
	    -e '/LD_LIBRARY_PATH/d' \
	    -e 's!\$$PREFIX/etc!/etc!' \
	    -i $(INSTALLDIR)$(_sysconfdir)/lfc-postgres/lfcdaemon.init

	# lfcdaemon configuration file
	sed -e 's/\(RUN_LFCDAEMON=\).*/\1"no"/' \
	    -e 's!/opt/lcg!!' -e 's!export SEMSGCONFIGFILE!#&!' \
	    -i $(INSTALLDIR)$(_sysconfdir)/lfc-postgres/lfcdaemon.conf

	# lfcdaemon man page
	sed -e 's!/opt/lcg!!g' \
	    -e 's/lfc-shutdown(1)/lfc-shutdown(8)/g' \
	    -i $(INSTALLDIR)$(_libdir)/lfc-postgres/lfcdaemon.8
	gzip -n -9 $(INSTALLDIR)$(_libdir)/lfc-postgres/lfcdaemon.8

	# lfc-shutdown man page
	gzip -n -9 $(INSTALLDIR)$(_libdir)/lfc-postgres/lfc-shutdown.8

	# Create lfc user home and certificate directories
	mkdir -p $(INSTALLDIR)$(_localstatedir)/lib/lfc
	mkdir -p $(INSTALLDIR)$(_sysconfdir)/grid-security/lfcmgr

	# This doesn't quite work...
	sed '/CREATE DATABASE/d' -i \
	    $(INSTALLDIR)$(_datadir)/lcgdm/create_lfc_tables_postgres.sql

	# DPM with mysql backend

	cd dpm-mysql && \
	$(MAKE) SOAPFLG="$(shell pkg-config --cflags gsoap)" \
		DEB_HOST_MULTIARCH=$(DEB_HOST_MULTIARCH) \
		SYSCONFDIR=$(INSTALLDIR)$(_sysconfdir) \
		LDFLAGS="$(LDFLAGS) -Wl,-z,defs" \
		SHLIBLDFLAGS="-shared $(LDFLAGS) -Wl,-z,defs" \
		prefix=$(INSTALLDIR)$(_prefix) install install.man

	mv $(INSTALLDIR)$(_libdir)/$(DEB_HOST_MULTIARCH)/dpm-mysql \
	   $(INSTALLDIR)$(_libdir)/dpm-mysql

	sed 's!/usr/bin/env python!/usr/bin/python!' \
	    -i $(INSTALLDIR)$(_bindir)/dpm-listspaces

	# dpm startup script
	sed -e 's/LD_LIBRARY_PATH=$$LD_LIBRARY_PATH //' \
	    -e '/LD_LIBRARY_PATH/d' \
	    -e 's!\$$PREFIX/etc!/etc!' \
	    -e 's!mysqld!mysql!' \
	    -i $(INSTALLDIR)$(_sysconfdir)/dpm-mysql/dpm.init

	# dpm configuration file
	sed -e 's/\(^DPNS_HOST=\).*/\1`hostname -f`/' \
	    -e 's/\(^RUN_DPMDAEMON=\).*/\1"no"/' \
	    -e 's!/opt/lcg!!' -e 's!export SEMSGCONFIGFILE!#&!' \
	    -i $(INSTALLDIR)$(_sysconfdir)/dpm-mysql/dpm.conf

	# dpm man page
	sed -e 's/dpm-shutdown(1)/dpm-shutdown(8)/g' \
	    -i $(INSTALLDIR)$(_libdir)/dpm-mysql/dpm.8
	gzip -n -9 $(INSTALLDIR)$(_libdir)/dpm-mysql/dpm.8

	mv $(INSTALLDIR)$(_libdir)/dpm-mysql/NSCONFIG.templ \
	   $(INSTALLDIR)$(_libdir)/dpm-mysql/DPNSCONFIG.templ

	# dpm-shutdown man page
	gzip -n -9 $(INSTALLDIR)$(_libdir)/dpm-mysql/dpm-shutdown.8

	# dpm-buildfsv man page
	gzip -n -9 $(INSTALLDIR)$(_libdir)/dpm-mysql/dpm-buildfsv.8

	# dpnsdaemon startup script
	sed -e 's/LD_LIBRARY_PATH=$$LD_LIBRARY_PATH //' \
	    -e '/LD_LIBRARY_PATH/d' \
	    -e 's!\$$PREFIX/etc!/etc!' \
	    -e 's!mysqld!mysql!' \
	    -i $(INSTALLDIR)$(_sysconfdir)/dpm-mysql/dpnsdaemon.init

	# dpnsdaemon configuration file
	sed -e 's/\(^RUN_DPNSDAEMON=\).*/\1"no"/' \
	    -e 's!/opt/lcg!!' -e 's!export SEMSGCONFIGFILE!#&!' \
	    -i $(INSTALLDIR)$(_sysconfdir)/dpm-mysql/dpnsdaemon.conf

	# dpnsdaemon man page
	sed -e 's!/opt/lcg!!g' \
	    -e 's!/etc/NSCONFIG!/etc/DPNSCONFIG!g' \
	    -e 's/dpns-shutown(1)/dpns-shutdown(8)/g' \
	    -i $(INSTALLDIR)$(_libdir)/dpm-mysql/dpnsdaemon.8
	gzip -n -9 $(INSTALLDIR)$(_libdir)/dpm-mysql/dpnsdaemon.8

	# dpns-shutdown man page
	gzip -n -9 $(INSTALLDIR)$(_libdir)/dpm-mysql/dpns-shutdown.8

	# dpmcopyd startup script
	sed -e 's/LD_LIBRARY_PATH=$$LD_LIBRARY_PATH //' \
	    -e '/LD_LIBRARY_PATH/d' \
	    -e 's!\$$PREFIX/etc!/etc!' \
	    -e 's!mysqld!mysql!' \
	    -i $(INSTALLDIR)$(_sysconfdir)/dpm-mysql/dpmcopyd.init

	# dpmcopyd configuration file
	sed -e 's/\(^DPNS_HOST=\).*/\1`hostname -f`/' \
	    -e 's/\(^DPM_HOST=\).*/\1`hostname -f`/' \
	    -e 's/\(^RUN_DPMCOPYDAEMON=\).*/\1"no"/' \
	    -i $(INSTALLDIR)$(_sysconfdir)/dpm-mysql/dpmcopyd.conf

	# dpmcopyd man page
	gzip -n -9 $(INSTALLDIR)$(_libdir)/dpm-mysql/dpmcopyd.8

	for svc in srmv1 srmv2 srmv2.2 ; do \
	    sed -e 's/LD_LIBRARY_PATH=$$LD_LIBRARY_PATH //' \
		-e '/LD_LIBRARY_PATH/d' \
		-e 's!\$$PREFIX/etc!/etc!' \
		-e "s/$${svc}/dpm-$${svc}/g" \
		-e 's!mysqld!mysql!' \
		-i $(INSTALLDIR)$(_sysconfdir)/dpm-mysql/$${svc}.init ; \
	    mv $(INSTALLDIR)$(_sysconfdir)/dpm-mysql/$${svc}.init \
	       $(INSTALLDIR)$(_sysconfdir)/dpm-mysql/dpm-$${svc}.init ; \
	    sed -e "s/$${svc}/dpm-$${svc}/g" \
		-e 's/\(^DPNS_HOST=\).*/\1`hostname -f`/' \
		-e 's/\(^DPM_HOST=\).*/\1`hostname -f`/' \
		-e 's/\(^RUN_SRMV1DAEMON=\).*/\1"no"/' \
		-e 's/\(^RUN_SRMV2DAEMON=\).*/\1"no"/' \
		-i $(INSTALLDIR)$(_sysconfdir)/dpm-mysql/$${svc}.conf ; \
	    mv $(INSTALLDIR)$(_sysconfdir)/dpm-mysql/$${svc}.conf \
	       $(INSTALLDIR)$(_sysconfdir)/dpm-mysql/dpm-$${svc}.conf ; \
	    rmdir $(INSTALLDIR)$(_localstatedir)/log/$${svc} ; \
	    mkdir -p $(INSTALLDIR)$(_localstatedir)/log/dpm-$${svc} ; \
	    sed -e "s/$${svc}/dpm-$${svc}/g" \
		-i $(INSTALLDIR)$(_sysconfdir)/dpm-mysql/$${svc}.logrotate ; \
	    mv $(INSTALLDIR)$(_sysconfdir)/dpm-mysql/$${svc}.logrotate \
	       $(INSTALLDIR)$(_sysconfdir)/dpm-mysql/dpm-$${svc}.logrotate ; \
	    mv $(INSTALLDIR)$(_libdir)/dpm-mysql/$${svc} \
	       $(INSTALLDIR)$(_libdir)/dpm-mysql/dpm-$${svc} ; \
	    sed -e "s/$${svc}/dpm-$${svc}/g" \
		-e 's/dpm(1)/dpm(8)/g' \
		-i $(INSTALLDIR)$(_libdir)/dpm-mysql/$${svc}.8 ; \
	    mv $(INSTALLDIR)$(_libdir)/dpm-mysql/$${svc}.8 \
	       $(INSTALLDIR)$(_libdir)/dpm-mysql/dpm-$${svc}.8 ; \
	    gzip -n -9 $(INSTALLDIR)$(_libdir)/dpm-mysql/dpm-$${svc}.8 ; \
	done

	# rfiod startup script
	sed -e 's/LD_LIBRARY_PATH=$$LD_LIBRARY_PATH //' \
	    -e '/LD_LIBRARY_PATH/d' \
	    -e 's!\$$PREFIX/etc!/etc!' \
	    -e 's/rfiod/dpm-rfiod/g' \
	    -e 's!/var/log/rfio!/var/log/dpm-rfiod!g' \
	    -i $(INSTALLDIR)$(_sysconfdir)/init.d/rfiod
	mv $(INSTALLDIR)$(_sysconfdir)/init.d/rfiod \
	   $(INSTALLDIR)$(_sysconfdir)/init.d/dpm-rfiod

	# rfiod configuration file
	sed -e 's/rfiod/dpm-rfiod/g' \
	    -e 's!/var/log/rfio!/var/log/dpm-rfiod!g' \
	    -e 's/\(^DPNS_HOST=\).*/\1`hostname -f`/' \
	    -e 's/\(^DPM_HOST=\).*/\1`hostname -f`/' \
	    -e 's/\(^RUN_RFIOD=\).*/\1"no"/' \
	    -i $(INSTALLDIR)$(_sysconfdir)/rfiod
	mv $(INSTALLDIR)$(_sysconfdir)/rfiod \
	   $(INSTALLDIR)$(_sysconfdir)/default/dpm-rfiod

	# rfiod log directory and log rotation configuration
	rmdir $(INSTALLDIR)$(_localstatedir)/log/rfio
	mkdir -p $(INSTALLDIR)$(_localstatedir)/log/dpm-rfiod
	sed -e 's!/var/log/rfio!/var/log/dpm-rfiod!g' \
	    -i $(INSTALLDIR)$(_sysconfdir)/logrotate.d/rfiod
	mv $(INSTALLDIR)$(_sysconfdir)/logrotate.d/rfiod \
	   $(INSTALLDIR)$(_sysconfdir)/logrotate.d/dpm-rfiod

	# rfiod binary and man page
	mv $(INSTALLDIR)$(_sbindir)/rfiod \
	   $(INSTALLDIR)$(_sbindir)/dpm-rfiod
	sed -e 's/rfiod/dpm-rfiod/g' \
	    -e 's!/usr/local/bin!/usr/sbin!g' \
	    -i $(INSTALLDIR)$(_mandir)/man8/rfiod.8
	mv $(INSTALLDIR)$(_mandir)/man8/rfiod.8 \
	   $(INSTALLDIR)$(_mandir)/man8/dpm-rfiod.8

	# Create dpm user home and certificate directories
	mkdir -p $(INSTALLDIR)$(_localstatedir)/lib/dpm
	mkdir -p $(INSTALLDIR)$(_sysconfdir)/grid-security/dpmmgr

	# DPM with postgres backend

	cd dpm-postgres && \
	$(MAKE) SOAPFLG="$(shell pkg-config --cflags gsoap)" \
		DEB_HOST_MULTIARCH=$(DEB_HOST_MULTIARCH) \
		SYSCONFDIR=$(INSTALLDIR)$(_sysconfdir) \
		LDFLAGS="$(LDFLAGS) -Wl,-z,defs" \
		SHLIBLDFLAGS="-shared $(LDFLAGS) -Wl,-z,defs" \
		prefix=$(INSTALLDIR)$(_prefix) install install.man

	mv $(INSTALLDIR)$(_libdir)/$(DEB_HOST_MULTIARCH)/dpm-postgres \
	   $(INSTALLDIR)$(_libdir)/dpm-postgres

	# dpm startup script
	sed -e 's/LD_LIBRARY_PATH=$$LD_LIBRARY_PATH //' \
	    -e '/LD_LIBRARY_PATH/d' \
	    -e 's!\$$PREFIX/etc!/etc!' \
	    -i $(INSTALLDIR)$(_sysconfdir)/dpm-postgres/dpm.init

	# dpm configuration file
	sed -e 's/\(^DPNS_HOST=\).*/\1`hostname -f`/' \
	    -e 's/\(^RUN_DPMDAEMON=\).*/\1"no"/' \
	    -i $(INSTALLDIR)$(_sysconfdir)/dpm-postgres/dpm.conf

	# dpm man page
	sed -e 's/dpm-shutdown(1)/dpm-shutdown(8)/g' \
	    -i $(INSTALLDIR)$(_libdir)/dpm-postgres/dpm.8
	gzip -n -9 $(INSTALLDIR)$(_libdir)/dpm-postgres/dpm.8

	mv $(INSTALLDIR)$(_libdir)/dpm-postgres/NSCONFIG.templ \
	   $(INSTALLDIR)$(_libdir)/dpm-postgres/DPNSCONFIG.templ

	# dpm-shutdown man page
	gzip -n -9 $(INSTALLDIR)$(_libdir)/dpm-postgres/dpm-shutdown.8

	# dpm-buildfsv man page
	gzip -n -9 $(INSTALLDIR)$(_libdir)/dpm-postgres/dpm-buildfsv.8

	# dpnsdaemon startup script
	sed -e 's/LD_LIBRARY_PATH=$$LD_LIBRARY_PATH //' \
	    -e '/LD_LIBRARY_PATH/d' \
	    -e 's!\$$PREFIX/etc!/etc!' \
	    -i $(INSTALLDIR)$(_sysconfdir)/dpm-postgres/dpnsdaemon.init

	# dpnsdaemon configuration file
	sed -e 's/\(^RUN_DPNSDAEMON=\).*/\1"no"/' \
	    -e 's!/opt/lcg!!' -e 's!export SEMSGCONFIGFILE!#&!' \
	    -i $(INSTALLDIR)$(_sysconfdir)/dpm-postgres/dpnsdaemon.conf

	# dpnsdaemon man page
	sed -e 's!/opt/lcg!!g' \
	    -e 's!/etc/NSCONFIG!/etc/DPNSCONFIG!g' \
	    -e 's/dpns-shutdown(1)/dpns-shutdown(8)/g' \
	    -i $(INSTALLDIR)$(_libdir)/dpm-postgres/dpnsdaemon.8
	gzip -n -9 $(INSTALLDIR)$(_libdir)/dpm-postgres/dpnsdaemon.8

	# dpns-shutdown man page
	gzip -n -9 $(INSTALLDIR)$(_libdir)/dpm-postgres/dpns-shutdown.8

	# dpmcopyd startup script
	sed -e 's/LD_LIBRARY_PATH=$$LD_LIBRARY_PATH //' \
	    -e '/LD_LIBRARY_PATH/d' \
	    -e 's!\$$PREFIX/etc!/etc!' \
	    -i $(INSTALLDIR)$(_sysconfdir)/dpm-postgres/dpmcopyd.init

	# dpmcopyd configuration file
	sed -e 's/\(^DPNS_HOST=\).*/\1`hostname -f`/' \
	    -e 's/\(^DPM_HOST=\).*/\1`hostname -f`/' \
	    -e 's/\(^RUN_DPMCOPYDAEMON=\).*/\1"no"/' \
	    -i $(INSTALLDIR)$(_sysconfdir)/dpm-postgres/dpmcopyd.conf

	# dpmcopyd man page
	gzip -n -9 $(INSTALLDIR)$(_libdir)/dpm-postgres/dpmcopyd.8

	for svc in srmv1 srmv2 srmv2.2 ; do \
	    sed -e 's/LD_LIBRARY_PATH=$$LD_LIBRARY_PATH //' \
		-e '/LD_LIBRARY_PATH/d' \
		-e 's!\$$PREFIX/etc!/etc!' \
		-e "s/$${svc}/dpm-$${svc}/g" \
		-i $(INSTALLDIR)$(_sysconfdir)/dpm-postgres/$${svc}.init ; \
	    mv $(INSTALLDIR)$(_sysconfdir)/dpm-postgres/$${svc}.init \
	       $(INSTALLDIR)$(_sysconfdir)/dpm-postgres/dpm-$${svc}.init ; \
	    sed -e "s/$${svc}/dpm-$${svc}/g" \
		-e 's/\(^DPNS_HOST=\).*/\1`hostname -f`/' \
		-e 's/\(^DPM_HOST=\).*/\1`hostname -f`/' \
		-e 's/\(^RUN_SRMV1DAEMON=\).*/\1"no"/' \
		-e 's/\(^RUN_SRMV2DAEMON=\).*/\1"no"/' \
		-i $(INSTALLDIR)$(_sysconfdir)/dpm-postgres/$${svc}.conf ; \
	    mv $(INSTALLDIR)$(_sysconfdir)/dpm-postgres/$${svc}.conf \
	       $(INSTALLDIR)$(_sysconfdir)/dpm-postgres/dpm-$${svc}.conf ; \
	    rmdir $(INSTALLDIR)$(_localstatedir)/log/$${svc} ; \
	    mkdir -p $(INSTALLDIR)$(_localstatedir)/log/dpm-$${svc} ; \
	    sed -e "s/$${svc}/dpm-$${svc}/g" \
		-i $(INSTALLDIR)$(_sysconfdir)/dpm-postgres/$${svc}.logrotate ; \
	    mv $(INSTALLDIR)$(_sysconfdir)/dpm-postgres/$${svc}.logrotate \
	       $(INSTALLDIR)$(_sysconfdir)/dpm-postgres/dpm-$${svc}.logrotate ; \
	    mv $(INSTALLDIR)$(_libdir)/dpm-postgres/$${svc} \
	       $(INSTALLDIR)$(_libdir)/dpm-postgres/dpm-$${svc} ; \
	    sed -e "s/$${svc}/dpm-$${svc}/g" \
		-e 's/dpm(1)/dpm(8)/g' \
		-i $(INSTALLDIR)$(_libdir)/dpm-postgres/$${svc}.8 ; \
	    mv $(INSTALLDIR)$(_libdir)/dpm-postgres/$${svc}.8 \
	       $(INSTALLDIR)$(_libdir)/dpm-postgres/dpm-$${svc}.8 ; \
	    gzip -n -9 $(INSTALLDIR)$(_libdir)/dpm-postgres/dpm-$${svc}.8 ; \
	done

	# Create dpm user home and certificate directories
	mkdir -p $(INSTALLDIR)$(_localstatedir)/lib/dpm
	mkdir -p $(INSTALLDIR)$(_sysconfdir)/grid-security/dpmmgr

	# This doesn't quite work...
	sed '/CREATE DATABASE/d' -i \
	    $(INSTALLDIR)$(_datadir)/lcgdm/create_dpm_tables_postgres.sql \
	    $(INSTALLDIR)$(_datadir)/lcgdm/create_dpns_tables_postgres.sql

	# Dynamic paths in perl packages
	sed -e 's,@ARCHLIB@,$(_archlib),g' debian/libdpm-perl.install.in > debian/libdpm-perl.install
	sed -e 's,@ARCHLIB@,$(_archlib),g' debian/liblfc-perl.install.in > debian/liblfc-perl.install

binary-indep:

binary-arch: install
	dh_testdir
	dh_testroot
	dh_installchangelogs
	dh_installdocs
	dh_install --fail-missing
	dh_installman
	dh_lintian
	dh_perl
	dh_python2
	dh_link
	dh_strip --dbg-package=lcgdm-dbg
	dh_compress
	dh_fixperms
	dh_makeshlibs
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary: binary-indep binary-arch

get-orig-source:
	dest="../lcgdm_$(VERSION).orig.tar.gz" ; \
	if [ -r "$$dest" ] ; then \
	  echo "'$$dest' already exists." ; \
	else \
	  uversion=LCG-DM_R_`echo $(VERSION)|tr "." "_"` ; \
	  echo "Fetching upstream svn version '$$uversion'" ; \
	  rm -rf lcgdm-$(VERSION) ; \
	  LANG=C svn export http://svn.cern.ch/guest/lcgdm/lcg-dm/tags/$$uversion lcgdm-$(VERSION) ; \
	  echo "Packing it up." ; \
	  tar -z -c -f "$$dest" lcgdm-$(VERSION) ; \
	  echo "Cleaning up." ; \
	  rm -rf lcgdm-$(VERSION) ; \
	fi

.PHONY: build-indep build-arch build clean binary-indep binary-arch binary install configure get-orig-source