File: Makefile.in

package info (click to toggle)
cpm 0.26-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,292 kB
  • sloc: ansic: 7,239; makefile: 506; perl: 406; sh: 325
file content (603 lines) | stat: -rw-r--r-- 22,209 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
# ##############################################################################
# Makefile template to create the final makefile
# ##############################################################################

.SUFFIXES: .c .o


# ##############################################################################
# configuration
CC=@CC@
# I used to have -Werror here but this breaks the warning which I must have
# with lib GpgMe. :-(
CFLAGS=@CFLAGS@ @CPPFLAGS@ @DEFS@ @LIBGPGME_CFLAGS@ @LIBNCURSES_CFLAGS@ @LIBXML_CFLAGS@ -std=c99 -Wall -Wformat=2 -DLOCALEDIR='"@prefix@/share/locale"' @CDK_VERSION_DEF@
INSTALL=@INSTALL@
LDFLAGS=@LDFLAGS@ @LIBS@ @LIBGPGME_LIBS@ @LIBNCURSES_LIBS@ @LIBXML_LIBS@
SHELL=@SHELL@
DEBIAN_RELEASE=1
DEBIAN_BINARY=@PACKAGE_NAME@-@PACKAGE_VERSION@-$(DEBIAN_RELEASE)_i386.deb
GENTOO_EBUILD=`echo @PACKAGE_NAME@-@PACKAGE_VERSION@.ebuild | sed -e 's/\([0-9]\)\([a-z]\)/\1_\2/'`
BZ2_SOURCE=@PACKAGE_TARNAME@-@PACKAGE_VERSION@.tar.bz2
TAR_SOURCE=@PACKAGE_TARNAME@-@PACKAGE_VERSION@.tar.gz
XMLLINT=@LIBXML_XMLLINT@
WRAPPER_NECESSARY=@WRAPPER_NECESSARY@

prefix=@prefix@
sysconfdir=@sysconfdir@
exec_prefix=@exec_prefix@
bindir=@bindir@
sbindir=@sbindir@
mandir=@prefix@/man
localedir=@prefix@/share/locale

OBJECTS=cpm.o configuration.o general.o gpg.o interface_cli.o interface_gui.o interface_keys.o interface_utf8.o interface_xml.o listhandler.o memory.o patternparser.o options.o resource.o security.o string.o xml.o zlib.o


# ##############################################################################
# build rules

.c.o:
	$(CC) $(CFLAGS) $(CPPFLAGS) -c $<

.o:
	$(CC) $^ $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@


# ##############################################################################
# do all
.PHONY: all
all: dependencies cpm


# ##############################################################################
# run the tests
.PHONY: check
check: permissions cpm gettext check_backup check_clisearch check_compress check_configtest check_decrypt check_encrypt check_environment check_garbage check_searchpattern check_gettext

OK=\t\t\t\tok
ERROR=\t\t\t\tfailed
GPG_ENV=GNUPGHOME=./tests GPG_AGENT_INFO=

.PHONY: check_backup
check_backup:
	@echo -n "Testing backup 1         "; \
		rm -f check-backup.log tests/cryptdb~; \
		$(GPG_ENV) ./cpm --config=tests/cpmrc-crypt-tests --testrun=backup > check-backup.log 2>&1 || exit 1; \
		diff --brief check-backup.log tests/backup-result.txt > /dev/null; \
		if [ $${?} -ne 0 ]; then \
			echo -e "$(ERROR)"; \
			exit 1; \
		else \
			echo -e "$(OK)"; \
		fi; \
		echo -n "Testing backup 2         "; \
		diff --brief tests/cryptdb tests/cryptdb~ > /dev/null; \
		if [ $${?} -ne 0 ]; then \
			echo -e "$(ERROR)"; \
			exit 1; \
		else \
			echo -e "$(OK)"; \
			rm -f check-backup.log tests/cryptdb~; \
		fi

.PHONY: check_clisearch
check_clisearch:
	@MAX=6; \
	for RUN in `seq 1 $${MAX}`; do \
		echo -n "Testing cli search 1 $${RUN}/$${MAX}   "; \
			rm -f "check-clisearch-1-$${RUN}.log"; \
			$(GPG_ENV) ./cpm --regular --noignore --config=tests/cpmrc-clisearch-tests --file=tests/clisearchdb --testrun=clisearch host$${RUN} > "check-clisearch-1-$${RUN}.log" 2>&1 || exit 1; \
			$(GPG_ENV) ./cpm --regular --noignore --config=tests/cpmrc-clisearch-tests --file=tests/clisearchdb --testrun=clisearch user$${RUN}@host$${RUN} >> "check-clisearch-1-$${RUN}.log" 2>&1 || exit 1; \
			$(GPG_ENV) ./cpm --regular --noignore --config=tests/cpmrc-clisearch-tests --file=tests/clisearchdb --testrun=clisearch service$${RUN}@host$${RUN} >> "check-clisearch-1-$${RUN}.log" 2>&1 || exit 1; \
			$(GPG_ENV) ./cpm --regular --noignore --config=tests/cpmrc-clisearch-tests --file=tests/clisearchdb --testrun=clisearch service$${RUN} user$${RUN}@host$${RUN} >> "check-clisearch-1-$${RUN}.log" 2>&1 || exit 1; \
			diff --brief "check-clisearch-1-$${RUN}.log" "tests/clisearch-1-$${RUN}-result.txt" > /dev/null; \
			if [ $${?} -ne 0 ]; then \
				echo -e "$(ERROR)"; \
				exit 1; \
			else \
				echo -en "$(OK)\r"; \
				rm -f "check-clisearch-1-$${RUN}.log"; \
			fi; \
	done; \
	echo; \
	for RUN in `seq 1 $${MAX}`; do \
		echo -n "Testing cli search 2 $${RUN}/$${MAX}   "; \
			rm -f "check-clisearch-2-$${RUN}.log"; \
			$(GPG_ENV) ./cpm --regular --ignore --config=tests/cpmrc-clisearch-tests --file=tests/clisearchdb --testrun=clisearch HOST$${RUN} > "check-clisearch-2-$${RUN}.log" 2>&1 || exit 1; \
			$(GPG_ENV) ./cpm --regular --ignore --config=tests/cpmrc-clisearch-tests --file=tests/clisearchdb --testrun=clisearch USER$${RUN}@HOST$${RUN} >> "check-clisearch-2-$${RUN}.log" 2>&1 || exit 1; \
			$(GPG_ENV) ./cpm --regular --ignore --config=tests/cpmrc-clisearch-tests --file=tests/clisearchdb --testrun=clisearch SERVICE$${RUN}@HOST$${RUN} >> "check-clisearch-2-$${RUN}.log" 2>&1 || exit 1; \
			$(GPG_ENV) ./cpm --regular --ignore --config=tests/cpmrc-clisearch-tests --file=tests/clisearchdb --testrun=clisearch service$${RUN} USER$${RUN}@HOST$${RUN} >> "check-clisearch-2-$${RUN}.log" 2>&1 || exit 1; \
			diff --brief "check-clisearch-2-$${RUN}.log" "tests/clisearch-2-$${RUN}-result.txt" > /dev/null; \
			if [ $${?} -ne 0 ]; then \
				echo -e "$(ERROR)"; \
				exit 1; \
			else \
				echo -en "$(OK)\r"; \
				rm -f "check-clisearch-2-$${RUN}.log"; \
			fi; \
	done; \
	echo; \
	for RUN in `seq 1 $${MAX}`; do \
		echo -n "Testing cli search 3 $${RUN}/$${MAX}   "; \
			rm -f "check-clisearch-3-$${RUN}.log"; \
			$(GPG_ENV) ./cpm --regex --ignore --config=tests/cpmrc-clisearch-tests --file=tests/clisearchdb --testrun=clisearch "host$${RUN}" > "check-clisearch-3-$${RUN}.log" 2>&1 || exit 1; \
			$(GPG_ENV) ./cpm --regex --ignore --config=tests/cpmrc-clisearch-tests --file=tests/clisearchdb --testrun=clisearch "user[0-9]" >> "check-clisearch-3-$${RUN}.log" 2>&1 || exit 1; \
			$(GPG_ENV) ./cpm --regex --ignore --config=tests/cpmrc-clisearch-tests --file=tests/clisearchdb --testrun=clisearch "serv[a-z]+$${RUN}" >> "check-clisearch-3-$${RUN}.log" 2>&1 || exit 1; \
			$(GPG_ENV) ./cpm --regex --ignore --config=tests/cpmrc-clisearch-tests --file=tests/clisearchdb --testrun=clisearch "servic[:alp" 2>&1 | sed -e 's/ error: .*/ error/' >> "check-clisearch-3-$${RUN}.log" || exit 1; \
			diff --brief "check-clisearch-3-$${RUN}.log" "tests/clisearch-3-$${RUN}-result.txt" > /dev/null; \
			if [ $${?} -ne 0 ]; then \
				echo -e "$(ERROR)"; \
				exit 1; \
			else \
				echo -en "$(OK)\r"; \
				rm -f "check-clisearch-3-$${RUN}.log"; \
			fi; \
	done; \
	echo

.PHONY: check_compress
check_compress:
	@MAX=6; \
	for RUN in `seq 1 $${MAX}`; do \
		echo -n "Testing compression $${RUN}/$${MAX}  "; \
			rm -f "check-compress-$${RUN}.log"; \
			$(GPG_ENV) ./cpm --config=tests/cpmrc-crypt-tests --testrun="compress$${RUN}" > "check-compress-$${RUN}.log" 2>&1 || exit 1; \
			diff --brief "check-compress-$${RUN}.log" "tests/compress$${RUN}-result.txt" > /dev/null; \
			if [ $${?} -ne 0 ]; then \
				echo -e "$(ERROR)"; \
				exit 1; \
			else \
				echo -en "$(OK)\r"; \
				rm -f "check-compress-$${RUN}.log"; \
			fi; \
	done; \
	echo

.PHONY: check_configtest
check_configtest:
	@echo -n "Testing configtest 1     "; \
		rm -f check-configtest-1.log; \
		$(GPG_ENV) ./cpm --config=tests/cpmrc-crypt-tests --configtest > check-configtest-1.log 2>&1 || exit 1; \
		diff --brief check-configtest-1.log tests/configtest1-result.txt > /dev/null; \
		if [ $${?} -ne 0 ]; then \
			echo -e "$(ERROR)"; \
			exit 1; \
		else \
			echo -e "$(OK)"; \
			rm -f check-configtest-1.log; \
		fi; \
	echo -n "Testing configtest 2     "; \
		rm -f check-configtest-2.log; \
		$(GPG_ENV) ./cpm --config=tests/cpmrc-broken --configtest > check-configtest-2.log 2>&1; \
		diff --brief check-configtest-2.log tests/configtest2-result.txt > /dev/null; \
		if [ $${?} -ne 0 ]; then \
			echo -e "$(ERROR)"; \
			exit 1; \
		else \
			echo -e "$(OK)"; \
			rm -f check-configtest-2.log; \
		fi

.PHONY: check_decrypt
check_decrypt:
	@echo -n "Testing decryption       "; \
		rm -f check-decrypt.log; \
		$(GPG_ENV) ./cpm --config=tests/cpmrc-crypt-tests --testrun=decrypt > check-decrypt.log 2>&1 || exit 1; \
		diff --brief check-decrypt.log tests/decrypt-result.txt > /dev/null; \
		if [ $${?} -ne 0 ]; then \
			echo -e "$(ERROR)"; \
			exit 1; \
		else \
			echo -e "$(OK)"; \
			rm -f check-decrypt.log; \
		fi

.PHONY: check_encrypt
check_encrypt:
	@MAX=100; \
	if [ ! -x "$(XMLLINT)" ]; then \
		echo "xmllint not found in $(XMLLINT)"; \
		exit 1; \
	fi; \
	for RUN in `seq 1 $${MAX}`; do \
		echo -n "Testing encryption $${RUN}/$${MAX}  "; \
			rm -f "check-data-$${RUN}.log" check-data-$${RUN}-*.data check-data-$${RUN}-*.data~; \
			tests/testxml.pl --alphabet=tests/alphabet-ascii.txt > "check-data-$${RUN}-0.data" || exit 1; \
			cat "check-data-$${RUN}-0.data" | gzip -9 > "check-data-$${RUN}-1.data" || exit 1; \
			echo "1234567890" | GNUPGHOME=./tests GPG_AGENT_INFO= gpg --no-tty --recipient="cpm@testdomain.org" --passphrase-fd 0 --armour --sign --encrypt --compress-level 0 --output="check-data-$${RUN}-2.data" "check-data-$${RUN}-1.data" 2> /dev/null || exit 1; \
			cp "check-data-$${RUN}-2.data" "check-data-$${RUN}-3.data" || exit 1; \
			$(GPG_ENV) ./cpm --config=tests/cpmrc-crypt-tests --file="check-data-$${RUN}-3.data" --testrun=encrypt > "check-data-$${RUN}.log" 2>&1 || exit 1; \
			echo "1234567890" | GNUPGHOME=./tests GPG_AGENT_INFO= gpg --no-tty --passphrase-fd 0 --decrypt "check-data-$${RUN}-3.data" 2> /dev/null | gzip -cd > "check-data-$${RUN}-4.data" || exit 1; \
			sed -e 's/ \(created\|modified\)-[a-z]\+="[^"]\+"//g' -e 's/root version="[^"]\+"/root/' "check-data-$${RUN}-0.data" | $(XMLLINT) --dropdtd - | $(XMLLINT) --c14n > "check-data-$${RUN}-5.data"; \
			sed -e 's/ \(created\|modified\)-[a-z]\+="[^"]\+"//g' -e 's/root version="[^"]\+"/root/' "check-data-$${RUN}-4.data" | $(XMLLINT) --dropdtd - | $(XMLLINT) --c14n > "check-data-$${RUN}-6.data"; \
			diff --brief "check-data-$${RUN}-5.data" "check-data-$${RUN}-6.data" > /dev/null; \
			if [ $${?} -ne 0 ]; then \
				echo -e "$(ERROR)"; \
				exit 1; \
			else \
				echo -en "$(OK)\r"; \
				rm -f "check-data-$${RUN}.log" check-data-$${RUN}-*.data check-data-$${RUN}-*.data~; \
			fi; \
	done; \
	echo

.PHONY: check_environment
check_environment:
	@echo -n "Testing environment      "; \
		rm -f check-environment.log; \
		$(GPG_ENV) ./cpm --config=tests/cpmrc-crypt-tests --testrun=environment > check-environment.log 2>&1 || exit 1; \
		egrep -e "(^general: |^alpha |^numeric |^filename |^path )#[0-9]+: " check-environment.log > check-environment-2.log || exit 1; \
		diff --brief check-environment-2.log tests/environment-result.txt > /dev/null; \
		if [ $${?} -ne 0 ]; then \
			echo -e "$(ERROR)"; \
			exit 1; \
		else \
			echo -e "$(OK)"; \
			rm -f check-environment.log check-environment-2.log; \
		fi

.PHONY: check_garbage
check_garbage:
	@MAX=8; \
	for RUN in `seq 1 $${MAX}`; do \
		echo -n "Testing garbage $${RUN}/$${MAX}      "; \
			rm -f "check-garbagedb-$${RUN}.log"; \
			$(GPG_ENV) ./cpm --config=tests/cpmrc-crypt-tests --testrun=garbage --file="tests/garbagedb$${RUN}" > "check-garbagedb-$${RUN}.log" 2>&1; \
			diff --brief "check-garbagedb-$${RUN}.log" "tests/garbagedb$${RUN}-result.txt" > /dev/null; \
			if [ $${?} -ne 0 ]; then \
				echo -e "$(ERROR)"; \
				exit 1; \
			else \
				echo -en "$(OK)\r"; \
				rm -f "check-garbagedb-$${RUN}.log"; \
			fi; \
	done; \
	echo

.PHONY: check_gettext
check_gettext:
	@echo -n "Checking gettext 1       "; \
	@cd po; \
		tail --lines=+18 de_DE_old.po > current.txt; \
		tail --lines=+18 de_DE.po > new.txt; \
		diff -u current.txt new.txt
	@echo -n "Testing gettext 1       "; \
		INSTALLED=`locale -a | grep -c "^de_DE"`; \
		if [ $${INSTALLED} -eq 0 ]; then \
			echo -e "$(ERROR)"; \
			exit 1; \
		else \
			echo -e "$(OK)"; \
		fi
	@echo -n "Testing gettext 2       "; \
		rm -f check-gettext.log; \
		LANGUAGE=`locale -a | grep "^de_DE" | head --lines=1`; \
		$(GPG_ENV) LANG=$${LANGUAGE} ./cpm --version | tail --lines=1 > check-gettext.log 2>&1 || exit 1; \
		diff --brief check-gettext.log tests/gettext-result.txt > /dev/null; \
		if [ $${?} -ne 0 ]; then \
			echo -e "$(ERROR)"; \
			exit 1; \
		else \
			echo -e "$(OK)"; \
			rm -f check-gettext.log; \
		fi

.PHONY: check_searchpattern
check_searchpattern:
	@echo -n "Testing searchpatterns   "; \
		rm -f check-searchpattern.log; \
		$(GPG_ENV) ./cpm --config=tests/cpmrc-pattern-tests --testrun=searchpattern > check-searchpattern.log 2>&1 || exit 1; \
		diff --brief check-searchpattern.log tests/pattern-result.txt > /dev/null; \
		if [ $${?} -ne 0 ]; then \
			echo -e "$(ERROR)"; \
			exit 1; \
		else \
			echo -e "$(OK)"; \
			rm -f check-searchpattern.log; \
		fi


# ##############################################################################
# clean the directory from unused and autogenerated stuff
.PHONY: clean
clean:
	find . -name "*~" -exec rm {} \;
	rm -fr *.o check-*.data check-*.log debug.log cpm core
	rm -f cpm.po
	cd ./po; rm -fr cpm.po current.txt new.txt de_DE_old.po *.mo ./de/*
	rm -f docs/cpm.1 docs/cpm.1.gz
	rm -f docs/create-cpmdb.1 docs/create-cpmdb.1.gz
	rm -f config.log

# ##############################################################################
# dependencies
cpm: $(OBJECTS)
-include Makefile.dep


# ##############################################################################
# run the program in debug mode
.PHONY: debug
debug: cpm
	./cpm --noencryption 2> debug.log; \
		cat debug.log
# electric fence does not work with GpgMe
# 	LD_PRELOAD=libefence.so.0.0 ./cpm --noencryption 2> debug.log; \
# 		cat debug.log


# ##############################################################################
# create the dependencies file
.PHONY: dependencies
dependencies:
	@rm -f Makefile.dep; \
	for FILE in $(OBJECTS); do \
		$(CC) $(CFLAGS) $(CPPFLAGS) -MM $${FILE%%.o}.c >> Makefile.dep; \
	done


# ##############################################################################
# create the Gentoo ebuild file
.PHONY: gentoo
gentoo:
	cp ../gentoo/cpm.ebuild $(GENTOO_EBUILD)


# ##############################################################################
# compile the gettext information
.PHONY: gettext
gettext: gettext_compile

.PHONY: gettext_compile
gettext_compile: gettext_translate
	cd po; msgfmt --check --statistics --strict de_DE.po --output=de_DE.mo
	cd po; \
		mkdir -p ./de/LC_MESSAGES; \
		cp de_DE.mo ./de/LC_MESSAGES/cpm.mo


# ##############################################################################
# make new gettext file
.PHONY: gettext_translate
gettext_translate:
	xgettext -p ./po -o cpm.po --language=C --indent --width=80 --keyword=_ *.c
		mv cpm.po cpm.tmp; \
		sed -e 's/; charset=CHARSET/; charset=iso-8859-1/' cpm.tmp > cpm.po; \
		rm -f cpm.tmp
	cd ./po; \
		cp de_DE.po de_DE_old.po; \
		msgmerge --no-fuzzy-matching de_DE_old.po cpm.po > de_DE.po


# ##############################################################################
# update gettext information
.PHONY: gettext_update
gettext_update:
	cp ./po/de_DE_new.po ./po/de_DE.po


# ##############################################################################
# install everything
.PHONY: install
install: cpm gettext man
	$(INSTALL) -m 4755 -o 0 -g 0 -T @PACKAGE_NAME@ $(DESTDIR)$(bindir)/@PACKAGE_NAME@
	$(INSTALL) -m 0755 -o 0 -g 0 -T share/cpm/create-cpmdb $(DESTDIR)$(bindir)/create-cpmdb
	$(INSTALL) -m 644 -T ./po/de_DE.mo $(DESTDIR)$(localedir)/de/LC_MESSAGES/@PACKAGE_NAME@.mo


# ##############################################################################
# create the manual

.PHONY: man
man: docs/cpm.1.gz docs/create-cpmdb.1.gz

docs/create-cpmdb.1.gz: docs/create-cpmdb.1
	@>$@<$< gzip -9

docs/cpm.1.gz: docs/cpm.1
	@>$@<$< gzip -9

docs/create-cpmdb.1: docs/create-cpmdb.txt
	txt2man -s 1 -r "create-cpmdb @PACKAGE_VERSION@" -v "User Commands" -t "create-cpmdb" $< > $@

docs/cpm.1: docs/cpm.txt
	txt2man -s 1 -r "@PACKAGE_TARNAME@ @PACKAGE_VERSION@" -v "User Commands" -t "cpm" $< > $@


# ##############################################################################
# set all probably missing file permissions
.PHONY:
permissions:
	for FILE in \
		../anonymize/cpm2anonymous.pl \
		../debian/postinst \
		../import/general/convert.sh \
		../import/passwordsafe/convert.pl \
		../import/*.pl ../import/*.sh \
		../import/pms/convert.pl ../import/pms/convert.sh \
		./prepare_release.sh ./publish_release.sh \
		./tests/testxml.pl \
		../wrapper/cpm-wrapper; do \
		if [ -f "$${FILE}" ]; then \
			echo "Setting permissions for $${FILE}"; \
			chmod 755 "$${FILE}"; \
		fi; \
	done


# ##############################################################################
# clean the distribution
.PHONY: distclean
distclean: clean
	rm -fr \
		config.h \
		config.status \
		control \
		*.log \
		Makefile \
		Makefile.dep \
		*.out


# ##############################################################################
# clean all the autoconf stuff
.PHONY: realclean
realclean: clean
	rm -fr \
		tests/*~ \
		tests/random_seed \
		autom4te.cache \
		autoscan.log \
		config.h \
		config.log \
		config.status \
		configure.scan \
		configure \
		control \
		Makefile \
		Makefile.dep \
		$(DEBIAN_BINARY) \
		$(GENTOO_EBUILD) \
		$(BZ2_SOURCE) \
		$(BZ2_SOURCE).asc \
		$(TAR_SOURCE) \
		$(TAR_SOURCE).asc


# ##############################################################################
# create the Debian binary package
.PHONY: debian
debian: clean gettext man cpm
	rm -fr ./debian $(DEBIAN_BINARY)
	mkdir -p \
		./debian/usr/bin \
		./debian/etc/cpm \
		./debian/usr/share/cpm \
		./debian/usr/share/cpm/general \
		./debian/usr/share/cpm/passwordsafe \
		./debian/usr/share/cpm/pms \
		./debian/usr/share/doc/cpm/anonymize \
		./debian/usr/share/doc/cpm/wrapper \
		./debian/usr/share/locale/de/LC_MESSAGES \
		./debian/usr/share/man/man1 \
		./debian/DEBIAN
	find ./debian -type d | xargs chmod 755
	cd ..; \
		darcs changes > ChangeLog
	cp control debian/DEBIAN
	if [ $(WRAPPER_NECESSARY) -eq 1 ]; then \
		cp cpm ./debian/usr/bin/cpm.bin; \
		cp ../wrapper/cpm-wrapper ./debian/usr/bin/cpm; \
		strip --remove-section=.comment --remove-section=.note ./debian/usr/bin/cpm.bin; \
	else \
		cp cpm ./debian/usr/bin/cpm; \
		strip --remove-section=.comment --remove-section=.note ./debian/usr/bin/cpm; \
	fi
	cd ./po; \
		cp de_DE.mo ../debian/usr/share/locale/de/LC_MESSAGES/cpm.mo
	cd ../debian; \
		cp ../ChangeLog AUTHORS changelog changelog.Debian copyright ../src/debian/usr/share/doc/cpm; \
		cp conffiles postinst ../src/debian/DEBIAN/; \
		chmod 755 ../src/debian/DEBIAN/postinst
	cd ../docs; \
		cp GPLv2 README ../src/debian/usr/share/doc/cpm
	cd ../docs; \
		cp cpm.1.gz ../src/debian/usr/share/man/man1
	cd ../anonymize; \
		cp cpm2anonymous.pl ../src/debian/usr/share/doc/cpm/anonymize/
	cd ../docs; \
		cp cpmdb.dtd ../src/debian/usr/share/cpm/
	cd ../import; \
		cp convert2cpm.sh csv2cpm.pl import.sh ../src/debian/usr/share/cpm/
	cd ../import/general; \
		cp convert.sh example.txt README ../../src/debian/usr/share/cpm/general/
	cd ../import/passwordsafe; \
		cp convert.pl example.txt README ../../src/debian/usr/share/cpm/passwordsafe/
	cd ../import/pms; \
		cp convert.pl convert.sh README ../../src/debian/usr/share/cpm/pms/
	cd ../wrapper; \
		cp cpm-wrapper ../src/debian/usr/share/doc/cpm/wrapper/
	find ./debian/usr/share/doc/cpm/anonymize/ -type f -exec chmod 644 {} \;
	find ./debian/usr/share/cpm/ -type f -exec chmod 644 {} \;
	find ./debian/usr/share/cpm/ -type f \( -name "*.pl" -or -name "*.sh" \) -exec chmod 755 {} \;
	chmod 644 ./debian/usr/share/doc/cpm/wrapper/*
	gzip --best ./debian/usr/share/doc/cpm/ChangeLog
	gzip --best ./debian/usr/share/doc/cpm/changelog
	gzip --best ./debian/usr/share/doc/cpm/changelog.Debian
	cp ../conf/cpmrc-default ./debian/usr/share/doc/cpm
	cp ../conf/cpmrc-default ./debian/etc/cpm/cpmrc
	fakeroot dpkg-deb --build debian
	mv debian.deb $(DEBIAN_BINARY)
	lintian --dont-check-part chg $(DEBIAN_BINARY)
	rm -fr debian


# ##############################################################################
# create the tar packages
.PHONY: tar
tar: clean gettext man permissions
	cd ..; \
		darcs changes > ChangeLog; \
		cd -
	rm -fr @PACKAGE_TARNAME@-@PACKAGE_VERSION@
	mkdir -p @PACKAGE_TARNAME@-@PACKAGE_VERSION@
	cd @PACKAGE_TARNAME@-@PACKAGE_VERSION@; \
		mkdir -p anonymize conf docs share/cpm/general share/cpm/passwordsafe share/cpm/pms po tests wrapper
	cp \
		*.c \
		*.h \
		*.in \
		configure \
		install-sh \
		@PACKAGE_TARNAME@-@PACKAGE_VERSION@
	cp \
		../conf/cpmrc-default \
		@PACKAGE_TARNAME@-@PACKAGE_VERSION@/conf/
	cp \
		../debian/changelog \
		../ChangeLog \
		../docs/cpm.1.gz \
		../docs/cpm.pod \
		../docs/cpm.txt \
		../docs/GPLv2 \
		../docs/README \
		@PACKAGE_TARNAME@-@PACKAGE_VERSION@/docs/
	cp \
		../anonymize/cpm2anonymous.pl \
		@PACKAGE_TARNAME@-@PACKAGE_VERSION@/anonymize/
	cp \
		../docs/cpmdb.dtd \
		../import/convert2cpm.sh \
		../import/csv2cpm.pl \
		../import/import.sh \
		@PACKAGE_TARNAME@-@PACKAGE_VERSION@/share/cpm/
	cp \
		../import/general/convert.sh \
		../import/general/example.txt \
		../import/general/README \
		@PACKAGE_TARNAME@-@PACKAGE_VERSION@/share/cpm/general/
	cp \
		../import/passwordsafe/convert.pl \
		../import/passwordsafe/example.txt \
		../import/passwordsafe/README \
		@PACKAGE_TARNAME@-@PACKAGE_VERSION@/share/cpm/passwordsafe/
	cp \
		../import/pms/convert.pl \
		../import/pms/convert.sh \
		../import/pms/README \
		@PACKAGE_TARNAME@-@PACKAGE_VERSION@/share/cpm/pms/
	cp \
		../wrapper/cpm-wrapper \
		@PACKAGE_TARNAME@-@PACKAGE_VERSION@/wrapper/
	cp ./po/de_DE.mo \
		./po/de_DE.po \
		@PACKAGE_TARNAME@-@PACKAGE_VERSION@/po/
	find tests/ -maxdepth 1 -type f -exec \
		cp {} @PACKAGE_TARNAME@-@PACKAGE_VERSION@/tests/ \;
	tar cjf $(BZ2_SOURCE) @PACKAGE_TARNAME@-@PACKAGE_VERSION@/
	tar czf $(TAR_SOURCE) @PACKAGE_TARNAME@-@PACKAGE_VERSION@/
	rm -fr @PACKAGE_TARNAME@-@PACKAGE_VERSION@


# ##############################################################################