summaryrefslogtreecommitdiff
path: root/Makefile
blob: 25400de25246b5a205c621f173e6d9cf04108ee3 (plain)
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
# Author: Erwin Waterlander
#
#   Copyright (C) 2009-2012 Erwin Waterlander
#   All rights reserved.
#
#   Redistribution and use in source and binary forms, with or without
#   modification, are permitted provided that the following conditions
#   are met:
#   1. Redistributions of source code must retain the above copyright
#      notice, this list of conditions and the following disclaimer.
#   2. Redistributions in binary form must reproduce the above copyright
#      notice in the documentation and/or other materials provided with
#      the distribution.
#
#   THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
#   EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
#   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
#   PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE
#   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
#   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
#   OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
#   BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
#   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
#   OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
#   IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
#   Description
#
#	This is a GNU Makefile that uses GNU compilers, linkers and cpp. The
#	platform specific issues are determined by the various OS teets that
#	rely on the uname(1) command and directory locations.
#
#	Set additional flags for the build with variables CFLAGS_USER,
#	DEFS_USER and LDFLAGS_USER.

include version.mk


CC		= gcc
CPP		= cpp
CPP_FLAGS_POD	= ALL
STRIP		= strip

PACKAGE		= dos2unix
UNIX2DOS	= unix2dos
MAC2UNIX	= mac2unix
UNIX2MAC	= unix2mac

# Native Language Support (NLS)
ENABLE_NLS	= 1
# Large File Support (LFS)
LFS             = 1
DEBUG = 0
UCS = 1

EXE=

BIN		= $(PACKAGE)$(EXE)
UNIX2DOS_BIN	= $(UNIX2DOS)$(EXE)
MAC2UNIX_BIN	= $(MAC2UNIX)$(EXE)
UNIX2MAC_BIN	= $(UNIX2MAC)$(EXE)

# DJGPP support linking of .EXEs via 'stubify'.
# See djgpp.mak and http://www.delorie.com/djgpp/v2faq/faq22_5.html

LINK		= ln -sf
LINK_MAN	= $(LINK)

prefix		= /usr
exec_prefix	= $(prefix)
bindir		= $(exec_prefix)/bin
datarootdir	= $(prefix)/share
datadir		= $(datarootdir)

docsubdir	= $(PACKAGE)-$(DOS2UNIX_VERSION)
docdir		= $(datarootdir)/doc/$(docsubdir)
localedir	= $(datarootdir)/locale
mandir		= $(datarootdir)/man
man1dir		= $(mandir)/man1
manext		= .1
man1ext		= .1

ifdef ENABLE_NLS
	POT		= po/$(PACKAGE).pot
	POFILES		= $(wildcard po/??.po)
	MOFILES		= $(patsubst %.po,%.mo,$(POFILES))
	EOX_POFILES	= po/eo-x.po
	NLSSUFFIX       = -nls
endif

HTMLEXT = htm
# By default we generate only English text and html manuals.
# Then we don't need "pod2text --utf8" and we have no dependency on iconv.
DOCFILES	= man/man1/$(PACKAGE).txt man/man1/$(PACKAGE).$(HTMLEXT)
INSTALL_OBJS_DOC = README.txt NEWS.txt ChangeLog.txt COPYING.txt TODO.txt BUGS.txt $(DOCFILES)

PODFILES_ALL	= man/man1/dos2unix.pod $(wildcard man/*/man1/dos2unix.pod)
PODFILES	= $(wildcard man/*/man1/dos2unix.pod)
MANFILES	= $(patsubst %.pod,%.1,$(PODFILES))
TXTFILES	= $(patsubst %.pod,%.txt,$(PODFILES_ALL))
HTMLFILES	= $(patsubst %.pod,%.$(HTMLEXT),$(PODFILES_ALL))
PSFILES 	= $(patsubst %.pod,%.ps,$(PODFILES_ALL))
PDFFILES	= $(patsubst %.pod,%.pdf,$(PODFILES_ALL))
UTF8FILES	= $(patsubst %.pod,%.ut8,$(PODFILES_ALL))

# On some systems (e.g. FreeBSD 4.10) GNU install is installed as `ginstall'.
INSTALL		= install

# On some systems (e.g. GNU Win32) GNU mkdir is installed as `gmkdir'.
MKDIR           = mkdir

ifdef ENABLE_NLS
	DOS2UNIX_NLSDEFS = -DENABLE_NLS -DLOCALEDIR=\"$(localedir)\" -DPACKAGE=\"$(PACKAGE)\"
endif

VERSIONSUFFIX	= -bin

# ......................................................... OS flags ...

D2U_OS =

ifndef D2U_OS
ifeq (Linux, $(shell uname -s))
	D2U_OS = linux
endif
endif

ifndef D2U_OS
ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN)
	D2U_OS = cygwin
endif
endif

ifeq (cygwin,$(D2U_OS))
ifdef ENABLE_NLS
	LDFLAGS_EXTRA = -lintl -liconv -Wl,--enable-auto-import
endif
	EXE = .exe
	# allow non-cygwin clients which do not understand cygwin
	# symbolic links to launch applications...
	LINK = ln -f
	# but use symbolic links for man pages, since man client
	# IS a cygwin app and DOES understand symlinks.
	LINK_MAN = ln -fs
	# Cygwin packaging standard avoids version numbers on
	# documentation directories.
	docsubdir	= $(PACKAGE)
	VERSIONSUFFIX	= -cygwin
endif

ifndef D2U_OS
ifeq ($(findstring MSYS,$(shell uname)),MSYS)
	D2U_OS = msys
	EXE = .exe
	VERSIONSUFFIX	= -msys
	EO_XNOTATION=1
	UCS =
ifdef ENABLE_NLS
	LDFLAGS_EXTRA = -lintl -liconv
endif
endif
endif

ifndef D2U_OS
ifeq ($(findstring MINGW32,$(shell uname)),MINGW32)
	D2U_OS = mingw32
	prefix=c:/usr/local
	EXE = .exe
	VERSIONSUFFIX	= -win32
	LINK = cp -f
	EO_XNOTATION=1
ifdef ENABLE_NLS
	LDFLAGS_EXTRA = -lintl -liconv
	ZIPOBJ_EXTRA = bin/libintl-8.dll bin/libiconv-2.dll
endif
endif
endif

ifndef D2U_OS
ifneq ($(DJGPP),)
	D2U_OS = msdos
	prefix=c:/dos32
	EXE = .exe
	VERSIONSUFFIX = pm
	LINK_MAN = cp -f
	docsubdir = dos2unix
	EO_XNOTATION=1
	UCS =
	ZIPOBJ_EXTRA = bin/cwsdpmi.exe
ifdef ENABLE_NLS
	LDFLAGS_EXTRA = -lintl -liconv
endif
endif
endif

ifndef D2U_OS
ifeq ($(shell uname),OS/2)
	D2U_OS = os/2
	prefix=c:/usr
	EXE = .exe
	VERSIONSUFFIX = -os2
	LINK_MAN = cp -f
	EO_XNOTATION=1
	UCS =
	LDFLAGS_EXTRA = -Zargs-wild
ifdef ENABLE_NLS
	LDFLAGS_EXTRA += -lintl -liconv
endif
endif
endif

ifndef D2U_OS
ifeq (FreeBSD, $(shell uname -s))
	D2U_OS = freebsd
ifdef ENABLE_NLS
	CFLAGS_OS     = -I/usr/local/include
	LDFLAGS_EXTRA = -lintl -L/usr/local/lib
endif
endif
endif

ifeq (Darwin, $(shell uname -s))
	D2U_OS = Darwin
ifdef ENABLE_NLS
	CFLAGS_OS     = -I/usr/local/include
	LDFLAGS_EXTRA = -lintl -L/usr/local/lib
endif
endif


ifndef D2U_OS
ifneq (, $(wildcard /opt/csw))
	D2U_OS = sun
endif
endif

ifeq (sun,$(D2U_OS))
	# Running under SunOS/Solaris
	LDFLAGS_EXTRA = -lintl
endif

ifndef D2U_OS
ifeq (HP-UX, $(shell uname -s))
	D2U_OS = hpux
endif
endif

ifeq (hpux,$(D2U_OS))
	# Running under HP-UX
	EXTRA_DEFS += -Dhpux -D_HPUX_SOURCE
endif

ifndef D2U_OS
	D2U_OS = $(shell uname -s)
endif

# ............................................................ flags ...

# For systems that don't support Unicode or Latin-3, select
# Esperanto in X-notation format: EO_XNOTATION=1

ifdef EO_XNOTATION
EO_NOTATION = -x
endif

CFLAGS_USER	=
CFLAGS		= -O2 -Wall $(RPM_OPT_FLAGS) $(CPPFLAGS) $(CFLAGS_USER)

EXTRA_CFLAGS	= -DVER_REVISION=\"$(DOS2UNIX_VERSION)\" \
		  -DVER_DATE=\"$(DOS2UNIX_DATE)\" \
		  -DVER_AUTHOR=\"$(DOS2UNIX_AUTHOR)\" \
		  -DDEBUG=$(DEBUG) \
		  $(CFLAGS_OS)

ifeq ($(DEBUG), 1)
	EXTRA_CFLAGS += -g
endif

ifdef STATIC
	EXTRA_CFLAGS += -static
endif

ifdef UCS
	EXTRA_CFLAGS += -DD2U_UNICODE
endif

ifdef LFS
	EXTRA_CFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
endif

LDFLAGS_USER	=
LDFLAGS = $(RPM_OPT_FLAGS) $(LDFLAGS_EXTRA) $(LDFLAGS_USER)

DEFS_USER	=
DEFS		= $(EXTRA_DEFS) $(DEFS_USER)

# .......................................................... targets ...

all: $(BIN) $(MAC2UNIX_BIN) $(UNIX2DOS_BIN) $(UNIX2MAC_BIN) $(DOCFILES) $(MOFILES) $(EOX_POFILES) $(MANFILES) man/man1/dos2unix.1

status:
	@echo "D2U_OS       = $(D2U_OS)"
	@echo "UCS          = $(UCS)"
	@echo "CFLAGS       = $(CFLAGS)"
	@echo "EXTRA_CFLAGS = $(EXTRA_CFLAGS)"

common.o : common.c common.h
	$(CC) $(DEFS) $(EXTRA_CFLAGS) $(DOS2UNIX_NLSDEFS) $(CFLAGS) -c $< -o $@

querycp.o : querycp.c querycp.h
	$(CC) $(DEFS) $(EXTRA_CFLAGS) $(DOS2UNIX_NLSDEFS) $(CFLAGS) -c $< -o $@

dos2unix.o : dos2unix.c dos2unix.h querycp.h common.h
	$(CC) $(DEFS) $(EXTRA_CFLAGS) $(DOS2UNIX_NLSDEFS) $(CFLAGS) -c $< -o $@

unix2dos.o : unix2dos.c unix2dos.h querycp.h common.h
	$(CC) $(DEFS) $(EXTRA_CFLAGS) $(DOS2UNIX_NLSDEFS) $(CFLAGS) -c $< -o $@

$(BIN): dos2unix.o querycp.o common.o
	$(CC) $+ $(LDFLAGS) -o $@

$(UNIX2DOS_BIN): unix2dos.o querycp.o common.o
	$(CC) $+ $(LDFLAGS) -o $@

$(MAC2UNIX_BIN) : $(BIN)
	$(LINK) $< $@

%.1 : %.pod
	$(MAKE) -C man/man1

$(UNIX2MAC_BIN) : $(UNIX2DOS_BIN)
	$(LINK) $< $@

mofiles: $(MOFILES)

html: $(HTMLFILES)

txt: $(TXTFILES)

ps: $(PSFILES)

pdf: $(PDFFILES)

doc: $(DOCFILES) $(MANFILES) man/man1/dos2unix.1

tags: $(POT)

merge: $(POFILES) $(EOX_POFILES)

po/%.po : $(POT)
	msgmerge -U $@ $(POT) --backup=numbered
	# change timestamp in case .po file was not updated.
	touch $@

%.mo : %.po
	msgfmt -c $< -o $@

po/eo.mo : po/eo$(EO_NOTATION).po
	msgfmt -c $< -o $@

$(POT) : dos2unix.c unix2dos.c common.c
	xgettext -C --keyword=_ $+ -o $(POT)

# Convert text files to UTF-8. Notepad has no problem with UTF-8.
# Use iconv to convert to UTF-8. There are many old pod2text versions
# around that don't have the --utf8 option yet.
%.tx1 : %.pod
	pod2text $< > $@

%.txt : %.tx1
	iconv -f ISO-8859-1 -t UTF-8 $< > $@

# Create the English txt manual straight from the .pod file. It contains only ASCII.
# This saves a dependency on iconv.
man/man1/$(PACKAGE).txt : man/man1/$(PACKAGE).pod
	pod2text $< > $@

%.ps : %.1
	groff -man $< -T ps > $@

%.pdf: %.ps
	ps2pdf $< $@

# The POD files are encoded in Latin-1. See also man/man1/Makefile
# For non-English HTML it is best to use UTF-8.
%.ut8 : %.pod
	iconv -f ISO-8859-1 -t UTF-8 $< > $@

# Generic rule.
%.$(HTMLEXT) : %.ut8
	pod2html --title="$(PACKAGE) $(DOS2UNIX_VERSION) - DOS/MAC to UNIX and vice versa text file format converter" $< > $@

# Create the English html manual straight from the .pod file. It contains only ASCII.
# This saves a dependency on iconv.
man/man1/$(PACKAGE).$(HTMLEXT) : man/man1/$(PACKAGE).pod
	pod2html --title="$(PACKAGE) $(DOS2UNIX_VERSION) - DOS/MAC to UNIX and vice versa text file format converter" $< > $@

man/nl/man1/$(PACKAGE).$(HTMLEXT) : man/nl/man1/$(PACKAGE).ut8
	pod2html --title="$(PACKAGE) $(DOS2UNIX_VERSION) - DOS/Mac naar Unix en vice versa tekstbestand formaat omzetter" $< > $@

man/es/man1/$(PACKAGE).$(HTMLEXT) : man/es/man1/$(PACKAGE).ut8
	pod2html --title="$(PACKAGE) $(DOS2UNIX_VERSION) - Convertidor de archivos de texto de formato DOS/Mac a Unix y viceversa" $< > $@

install: all
	$(MKDIR) -p -m 755 $(DESTDIR)$(bindir)
	$(INSTALL)  -m 755 $(BIN) $(DESTDIR)$(bindir)
	$(INSTALL)  -m 755 $(UNIX2DOS_BIN) $(DESTDIR)$(bindir)
ifeq ($(LINK),cp -f)
	$(INSTALL)  -m 755 $(MAC2UNIX_BIN) $(DESTDIR)$(bindir)
	$(INSTALL)  -m 755 $(UNIX2MAC_BIN) $(DESTDIR)$(bindir)
else
	cd $(DESTDIR)$(bindir); $(LINK) $(BIN) $(MAC2UNIX_BIN)
	cd $(DESTDIR)$(bindir); $(LINK) $(UNIX2DOS_BIN) $(UNIX2MAC_BIN)
endif
	$(MKDIR) -p -m 755 $(DESTDIR)$(man1dir)
	$(INSTALL)  -m 644 man/man1/$(PACKAGE).1 $(DESTDIR)$(man1dir)
ifeq ($(LINK_MAN),cp -f)
	$(INSTALL)  -m 644 man/man1/$(PACKAGE).1 $(DESTDIR)$(man1dir)/$(MAC2UNIX).1
	$(INSTALL)  -m 644 man/man1/$(PACKAGE).1 $(DESTDIR)$(man1dir)/$(UNIX2DOS).1
	$(INSTALL)  -m 644 man/man1/$(PACKAGE).1 $(DESTDIR)$(man1dir)/$(UNIX2MAC).1
else
	cd $(DESTDIR)$(man1dir); $(LINK_MAN) $(PACKAGE).1 $(MAC2UNIX).1
	cd $(DESTDIR)$(man1dir); $(LINK_MAN) $(PACKAGE).1 $(UNIX2DOS).1
	cd $(DESTDIR)$(man1dir); $(LINK_MAN) $(PACKAGE).1 $(UNIX2MAC).1
endif
	$(foreach manfile, $(MANFILES), $(MKDIR) -p -m 755 $(DESTDIR)$(datarootdir)/$(dir $(manfile)) ;)
	$(foreach manfile, $(MANFILES), $(INSTALL) -m 644 $(manfile) $(DESTDIR)$(datarootdir)/$(dir $(manfile)) ;)
	$(foreach manfile, $(MANFILES), cd $(DESTDIR)$(datarootdir)/$(dir $(manfile)) ; $(LINK_MAN) $(PACKAGE).1 $(MAC2UNIX).1 ;)
	$(foreach manfile, $(MANFILES), cd $(DESTDIR)$(datarootdir)/$(dir $(manfile)) ; $(LINK_MAN) $(PACKAGE).1 $(UNIX2DOS).1 ;)
	$(foreach manfile, $(MANFILES), cd $(DESTDIR)$(datarootdir)/$(dir $(manfile)) ; $(LINK_MAN) $(PACKAGE).1 $(UNIX2MAC).1 ;)
ifdef ENABLE_NLS
	@echo "-- install-mo"
	$(foreach mofile, $(MOFILES), $(MKDIR) -p -m 755 $(DESTDIR)$(localedir)/$(basename $(notdir $(mofile)))/LC_MESSAGES ;)
	$(foreach mofile, $(MOFILES), $(INSTALL) -m 644 $(mofile) $(DESTDIR)$(localedir)/$(basename $(notdir $(mofile)))/LC_MESSAGES/$(PACKAGE).mo ;)
endif
	# Run a new instance of 'make' otherwise the $$(wildcard ) function my not have been expanded,
	# because the files may not have been there when make was started.
	$(MAKE) install-doc


install-doc: $(INSTALL_OBJS_DOC)
	@echo "-- install-doc"
	$(MKDIR) -p -m 755 $(DESTDIR)$(docdir)
	$(INSTALL) -m 644 $(INSTALL_OBJS_DOC) $(DESTDIR)$(docdir)
	# Install translated manuals when they have been generated.
	$(foreach txtfile, $(wildcard man/*/man1/*.txt), $(MKDIR) -p -m 755 $(DESTDIR)$(docdir)/$(word 2,$(subst /, ,$(txtfile),)) ;)
	$(foreach txtfile, $(wildcard man/*/man1/*.txt), $(INSTALL) -m 644 $(txtfile) $(DESTDIR)$(docdir)/$(word 2,$(subst /, ,$(txtfile),)) ;)
	$(foreach htmlfile, $(wildcard man/*/man1/*.$(HTMLEXT)), $(MKDIR) -p -m 755 $(DESTDIR)$(docdir)/$(word 2,$(subst /, ,$(htmlfile),)) ;)
	$(foreach htmlfile, $(wildcard man/*/man1/*.$(HTMLEXT)), $(INSTALL) -m 644 $(htmlfile) $(DESTDIR)$(docdir)/$(word 2,$(subst /, ,$(htmlfile),)) ;)
	$(foreach pdffile, $(wildcard man/*/man1/*.pdf), $(MKDIR) -p -m 755 $(DESTDIR)$(docdir)/$(word 2,$(subst /, ,$(pdffile),)) ;)
	$(foreach pdffile, $(wildcard man/*/man1/*.pdf), $(INSTALL) -m 644 $(pdffile) $(DESTDIR)$(docdir)/$(word 2,$(subst /, ,$(pdffile),)) ;)
	$(foreach pdffile, $(wildcard man/man1/*.pdf), $(INSTALL) -m 644 $(pdffile) $(DESTDIR)$(docdir) ;)
	$(foreach psfile, $(wildcard man/*/man1/*.ps), $(MKDIR) -p -m 755 $(DESTDIR)$(docdir)/$(word 2,$(subst /, ,$(psfile),)) ;)
	$(foreach psfile, $(wildcard man/*/man1/*.ps), $(INSTALL) -m 644 $(psfile) $(DESTDIR)$(docdir)/$(word 2,$(subst /, ,$(psfile),)) ;)
	$(foreach psfile, $(wildcard man/man1/*.ps), $(INSTALL) -m 644 $(psfile) $(DESTDIR)$(docdir) ;)

uninstall:
	@echo "-- target: uninstall"
	-rm -f $(DESTDIR)$(bindir)/$(BIN)
	-rm -f $(DESTDIR)$(bindir)/$(MAC2UNIX_BIN)
	-rm -f $(DESTDIR)$(bindir)/$(UNIX2DOS_BIN)
	-rm -f $(DESTDIR)$(bindir)/$(UNIX2MAC_BIN)
ifdef ENABLE_NLS
	$(foreach mofile, $(MOFILES), rm -f $(DESTDIR)$(localedir)/$(basename $(notdir $(mofile)))/LC_MESSAGES/$(PACKAGE).mo ;)
endif
	-rm -f $(DESTDIR)$(mandir)/man1/$(PACKAGE).1
	-rm -f $(DESTDIR)$(mandir)/man1/$(MAC2UNIX).1
	-rm -f $(DESTDIR)$(mandir)/man1/$(UNIX2DOS).1
	-rm -f $(DESTDIR)$(mandir)/man1/$(UNIX2MAC).1
	$(foreach manfile, $(MANFILES), rm -f $(DESTDIR)$(datarootdir)/$(manfile) ;)
	-rm -rf $(DESTDIR)$(docdir)

mostlyclean:
	rm -f *.o
	rm -f $(BIN) $(UNIX2DOS_BIN) $(MAC2UNIX_BIN) $(UNIX2MAC_BIN)
	rm -f *.bak *~
	rm -f *.tmp
	rm -f man/man1/*.bak man/man1/*~
	rm -f man/*/man1/*.bak man/*/man1/*~
	rm -f po/*.bak po/*~
	rm -f po/*.mo

clean: mostlyclean
	rm -f man/man1/*.1
	rm -f man/man1/*.txt
	rm -f man/man1/*.$(HTMLEXT)
	rm -f man/man1/*.ps
	rm -f man/man1/*.pdf
	rm -f man/man1/*.ut8
	rm -f man/*/man1/*.1
	rm -f man/*/man1/*.txt
	rm -f man/*/man1/*.$(HTMLEXT)
	rm -f man/*/man1/*.ps
	rm -f man/*/man1/*.pdf
	rm -f man/*/man1/*.ut8

distclean: clean

maintainer-clean: distclean
	@echo 'This command is intended for maintainers to use; it'
	@echo 'deletes files that may need special tools to rebuild.'

realclean: maintainer-clean


ZIPOBJ	= bin/$(BIN) \
	  bin/$(MAC2UNIX_BIN) \
	  bin/$(UNIX2DOS_BIN) \
	  bin/$(UNIX2MAC_BIN) \
	  share/man/man1/$(PACKAGE).1 \
	  share/man/man1/$(MAC2UNIX).1 \
	  share/man/man1/$(UNIX2DOS).1 \
	  share/man/man1/$(UNIX2MAC).1 \
	  share/man/*/man1/$(PACKAGE).1 \
	  share/man/*/man1/$(MAC2UNIX).1 \
	  share/man/*/man1/$(UNIX2DOS).1 \
	  share/man/*/man1/$(UNIX2MAC).1 \
	  share/doc/$(docsubdir) \
	  $(ZIPOBJ_EXTRA)

ifdef ENABLE_NLS
ZIPOBJ += share/locale/*/LC_MESSAGES/$(PACKAGE).mo
endif

ZIPFILE = $(PACKAGE)-$(DOS2UNIX_VERSION)$(VERSIONSUFFIX)$(NLSSUFFIX).zip
TGZFILE = $(PACKAGE)-$(DOS2UNIX_VERSION)$(VERSIONSUFFIX)$(NLSSUFFIX).tar.gz
TBZFILE = $(PACKAGE)-$(DOS2UNIX_VERSION)$(VERSIONSUFFIX)$(NLSSUFFIX).tar.bz2

dist-zip:
	rm -f $(prefix)/$(ZIPFILE)
	cd $(prefix) ; unix2dos share/man/man1/*.1 share/man/*/man1/*.1
	-cd $(prefix) ; unix2dos share/doc/$(docsubdir)/*.txt share/doc/$(docsubdir)/*/*.txt
	-cd $(prefix) ; unix2dos share/doc/$(docsubdir)/*.$(HTMLEXT) share/doc/$(docsubdir)/*/*.$(HTMLEXT)
	cd $(prefix) ; unix2dos share/man/*/man1/$(PACKAGE).1 share/man/*/man1/$(MAC2UNIX).1 share/man/*/man1/$(UNIX2DOS).1 share/man/*/man1/$(UNIX2MAC).1
	cd $(prefix) ; zip -r $(ZIPFILE) $(ZIPOBJ)
	mv -f $(prefix)/$(ZIPFILE) ..

dist-tgz:
	cd $(prefix) ; dos2unix share/man/man1/*.1 share/man/*/man1/*.1
	-cd $(prefix) ; dos2unix share/doc/$(docsubdir)/*.txt share/doc/$(docsubdir)/*/*.txt
	-cd $(prefix) ; dos2unix share/doc/$(docsubdir)/*.$(HTMLEXT) share/doc/$(docsubdir)/*/*.$(HTMLEXT)
	cd $(prefix) ; tar cvzf $(TGZFILE) $(ZIPOBJ)
	mv $(prefix)/$(TGZFILE) ..

dist-tbz:
	cd $(prefix) ; dos2unix share/man/man1/*.1 share/man/*/man1/*.1
	-cd $(prefix) ; dos2unix share/doc/$(docsubdir)/*.txt dos2unix share/doc/$(docsubdir)/*/*.txt
	-cd $(prefix) ; dos2unix share/doc/$(docsubdir)/*.$(HTMLEXT) dos2unix share/doc/$(docsubdir)/*/*.$(HTMLEXT)
	cd $(prefix) ; tar cvjf $(TBZFILE) $(ZIPOBJ)
	mv $(prefix)/$(TBZFILE) ..

dist: dist-tgz

strip:
	$(STRIP) $(BIN)
	$(STRIP) $(UNIX2DOS_BIN)
ifeq ($(LINK),cp -f)
	$(STRIP) $(MAC2UNIX_BIN)
	$(STRIP) $(UNIX2MAC_BIN)
endif

# End of file