Imported Upstream version 6.0.5
[platform/upstream/dos2unix.git] / Makefile
1 # Author: Erwin Waterlander
2 #
3 #   Copyright (C) 2009-2014 Erwin Waterlander
4 #   All rights reserved.
5 #
6 #   Redistribution and use in source and binary forms, with or without
7 #   modification, are permitted provided that the following conditions
8 #   are met:
9 #   1. Redistributions of source code must retain the above copyright
10 #      notice, this list of conditions and the following disclaimer.
11 #   2. Redistributions in binary form must reproduce the above copyright
12 #      notice in the documentation and/or other materials provided with
13 #      the distribution.
14 #
15 #   THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
16 #   EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 #   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 #   PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE
19 #   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 #   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21 #   OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
22 #   BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 #   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
24 #   OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
25 #   IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #
27 #   Description
28 #
29 #       This is a GNU Makefile that uses GNU compilers, linkers and cpp. The
30 #       platform specific issues are determined by the various OS teets that
31 #       rely on the uname(1) command and directory locations.
32 #
33 #       Set additional flags for the build with variables CFLAGS_USER,
34 #       DEFS_USER and LDFLAGS_USER.
35
36 include version.mk
37
38 .PHONY: man txt html pdf mofiles tags merge
39
40 .PRECIOUS: %.1 %.pod
41
42 CC              ?= gcc
43 CPP             ?= cpp
44 CPP_FLAGS_POD   = ALL
45 STRIP           = strip
46
47 PACKAGE         = dos2unix
48 UNIX2DOS        = unix2dos
49 MAC2UNIX        = mac2unix
50 UNIX2MAC        = unix2mac
51
52 # Native Language Support (NLS)
53 ENABLE_NLS      = 1
54 # Large File Support (LFS)
55 LFS             = 1
56 DEBUG = 0
57 UCS = 1
58
59 EXE=
60
61 BIN             = $(PACKAGE)$(EXE)
62 UNIX2DOS_BIN    = $(UNIX2DOS)$(EXE)
63 MAC2UNIX_BIN    = $(MAC2UNIX)$(EXE)
64 UNIX2MAC_BIN    = $(UNIX2MAC)$(EXE)
65
66 # DJGPP support linking of .EXEs via 'stubify'.
67 # See djgpp.mak and http://www.delorie.com/djgpp/v2faq/faq22_5.html
68
69 LINK            = ln -sf
70 LINK_MAN        = $(LINK)
71
72 prefix          = /usr
73 exec_prefix     = $(prefix)
74 bindir          = $(exec_prefix)/bin
75 datarootdir     = $(prefix)/share
76 datadir         = $(datarootdir)
77
78 docsubdir       = $(PACKAGE)-$(DOS2UNIX_VERSION)
79 docdir          = $(datarootdir)/doc/$(docsubdir)
80 localedir       = $(datarootdir)/locale
81 mandir          = $(datarootdir)/man
82 man1dir         = $(mandir)/man1
83 manext          = .1
84 man1ext         = .1
85
86 ifdef ENABLE_NLS
87         POT             = po/$(PACKAGE).pot
88         POFILES         = $(wildcard po/??.po) $(wildcard po/??_??.po)
89         MOFILES         = $(patsubst %.po,%.mo,$(POFILES))
90         NLSSUFFIX       = -nls
91 endif
92
93 HTMLEXT = htm
94 # By default we generate only English text and html manuals.
95 DOCFILES        = man/man1/$(PACKAGE).txt man/man1/$(PACKAGE).$(HTMLEXT)
96 INSTALL_OBJS_DOC = README.txt INSTALL.txt NEWS.txt ChangeLog.txt COPYING.txt TODO.txt BUGS.txt $(DOCFILES)
97
98 MANPOTFILE      = man/man1/dos2unix-man.pot
99 MANPOFILES      = $(wildcard man/*/man1/dos2unix.po)
100 PODFILES        = $(patsubst %.po,%.pod,$(MANPOFILES))
101 PODFILES_ALL    = man/man1/dos2unix.pod $(PODFILES)
102 MANFILES        = $(patsubst %.pod,%.1,$(PODFILES))
103 TXTFILES        = $(patsubst %.pod,%.txt,$(PODFILES_ALL))
104 HTMLFILES       = $(patsubst %.pod,%.$(HTMLEXT),$(PODFILES_ALL))
105 PSFILES         = $(patsubst %.pod,%.ps,$(PODFILES_ALL))
106 PDFFILES        = $(patsubst %.pod,%.pdf,$(PODFILES_ALL))
107
108 # On some systems (e.g. FreeBSD 4.10) GNU install is installed as `ginstall'.
109 INSTALL         = install
110
111 # On some systems (e.g. GNU Win32) GNU mkdir is installed as `gmkdir'.
112 MKDIR           = mkdir
113
114 ifdef ENABLE_NLS
115         DOS2UNIX_NLSDEFS = -DENABLE_NLS -DLOCALEDIR=\"$(localedir)\" -DPACKAGE=\"$(PACKAGE)\"
116 endif
117
118 VERSIONSUFFIX   = -bin
119
120 # ......................................................... OS flags ...
121
122 D2U_OS =
123
124 ifndef D2U_OS
125 ifeq (Linux, $(shell uname -s))
126         D2U_OS = linux
127 endif
128 endif
129
130 ifndef D2U_OS
131 ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN)
132         D2U_OS = cygwin
133 endif
134 endif
135
136 ifeq (cygwin,$(D2U_OS))
137 ifdef ENABLE_NLS
138         LIBS_EXTRA = -lintl -liconv
139 endif
140         LDFLAGS_EXTRA = -Wl,--enable-auto-import
141         EXE = .exe
142         # allow non-cygwin clients which do not understand cygwin
143         # symbolic links to launch applications...
144         LINK = ln -f
145         # but use symbolic links for man pages, since man client
146         # IS a cygwin app and DOES understand symlinks.
147         LINK_MAN = ln -fs
148         # Cygwin packaging standard avoids version numbers on
149         # documentation directories.
150         docsubdir       = $(PACKAGE)
151         VERSIONSUFFIX   = -cygwin
152 endif
153
154 ifndef D2U_OS
155 ifeq ($(findstring MSYS,$(shell uname)),MSYS)
156         CC=gcc
157         D2U_OS = msys
158         EXE = .exe
159         VERSIONSUFFIX   = -msys
160         UCS =
161 ifdef ENABLE_NLS
162         LIBS_EXTRA = -lintl -liconv
163 endif
164 endif
165 endif
166
167 ifndef D2U_OS
168 ifeq ($(findstring MINGW32,$(shell uname)),MINGW32)
169         D2U_OS = mingw32
170         prefix=c:/usr/local
171         EXE = .exe
172         VERSIONSUFFIX   = -win32
173         LINK = cp -f
174 ifdef ENABLE_NLS
175         LIBS_EXTRA = -lintl -liconv
176         ZIPOBJ_EXTRA = bin/libintl-8.dll bin/libiconv-2.dll
177 endif
178 ifeq ($(findstring w64-mingw32,$(shell gcc -dumpmachine)),w64-mingw32)
179         CFLAGS_COMPILER = -DD2U_COMPILER=MINGW32_W64
180 endif
181 endif
182 endif
183
184 ifndef D2U_OS
185 ifneq ($(DJGPP),)
186         D2U_OS = msdos
187         prefix=c:/dos32
188         EXE = .exe
189         VERSIONSUFFIX = pm
190         LINK_MAN = cp -f
191         docsubdir = dos2unix
192         UCS =
193         ZIPOBJ_EXTRA = bin/cwsdpmi.exe
194 ifdef ENABLE_NLS
195         LIBS_EXTRA = -lintl -liconv
196 endif
197 endif
198 endif
199
200 ifndef D2U_OS
201 ifeq ($(shell uname),OS/2)
202         D2U_OS = os/2
203         prefix=c:/usr
204         EXE = .exe
205         VERSIONSUFFIX = -os2
206         LINK_MAN = cp -f
207         UCS =
208         LDFLAGS_EXTRA = -Zargs-wild
209 ifdef ENABLE_NLS
210         LIBS_EXTRA += -lintl -liconv
211 endif
212 endif
213 endif
214
215 ifndef D2U_OS
216 ifeq (FreeBSD, $(shell uname -s))
217         D2U_OS = freebsd
218 ifdef ENABLE_NLS
219         CFLAGS_OS     = -I/usr/local/include
220         LDFLAGS_EXTRA = -L/usr/local/lib
221         LIBS_EXTRA    = -lintl
222 endif
223 endif
224 endif
225
226 ifeq (Darwin, $(shell uname -s))
227         D2U_OS = Darwin
228 ifdef ENABLE_NLS
229         CFLAGS_OS     = -I/usr/local/include
230         LDFLAGS_EXTRA = -L/usr/local/lib
231         LIBS_EXTRA    = -lintl
232 endif
233 endif
234
235
236 ifndef D2U_OS
237 ifneq (, $(wildcard /opt/csw))
238         D2U_OS = sun
239 endif
240 endif
241
242 ifeq (sun,$(D2U_OS))
243         # Running under SunOS/Solaris
244         LIBS_EXTRA = -lintl
245 endif
246
247 ifndef D2U_OS
248 ifeq (HP-UX, $(shell uname -s))
249         D2U_OS = hpux
250 endif
251 endif
252
253 ifeq (hpux,$(D2U_OS))
254         # Running under HP-UX
255         EXTRA_DEFS += -Dhpux -D_HPUX_SOURCE
256 endif
257
258 ifndef D2U_OS
259         D2U_OS = $(shell uname -s)
260 endif
261
262 # ............................................................ flags ...
263
264 # PostScript and PDF generation from UTF-8 manuals is not working,
265 # or I don't know how to do it.
266
267 CFLAGS_USER     =
268 CFLAGS          ?= -O2
269 CFLAGS          += -Wall $(RPM_OPT_FLAGS) $(CPPFLAGS) $(CFLAGS_USER)
270
271 EXTRA_CFLAGS    = -DVER_REVISION=\"$(DOS2UNIX_VERSION)\" \
272                   -DVER_DATE=\"$(DOS2UNIX_DATE)\" \
273                   -DVER_AUTHOR=\"$(DOS2UNIX_AUTHOR)\" \
274                   -DDEBUG=$(DEBUG) \
275                   $(CFLAGS_OS) \
276                   $(CFLAGS_COMPILER)
277
278 ifeq ($(DEBUG), 1)
279         EXTRA_CFLAGS += -g
280 endif
281
282 ifdef STATIC
283         EXTRA_CFLAGS += -static
284 endif
285
286 ifdef UCS
287         EXTRA_CFLAGS += -DD2U_UNICODE
288 endif
289
290 ifdef LFS
291         EXTRA_CFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
292 endif
293
294 LDFLAGS_USER    =
295 LDFLAGS = $(RPM_OPT_FLAGS) $(LDFLAGS_EXTRA) $(LDFLAGS_USER)
296 LIBS    = $(LIBS_EXTRA)
297
298 DEFS_USER       =
299 DEFS            = $(EXTRA_DEFS) $(DEFS_USER)
300
301 # .......................................................... targets ...
302
303 all: $(BIN) $(MAC2UNIX_BIN) $(UNIX2DOS_BIN) $(UNIX2MAC_BIN) $(DOCFILES) $(MOFILES) man/man1/dos2unix.1 $(MANFILES) $(MANPOTFILE)
304
305 status:
306         @echo "D2U_OS       = $(D2U_OS)"
307         @echo "UCS          = $(UCS)"
308         @echo "CFLAGS       = $(CFLAGS)"
309         @echo "EXTRA_CFLAGS = $(EXTRA_CFLAGS)"
310         @echo "LDFLAGS      = $(LDFLAGS)"
311         @echo "LIBS         = $(LIBS)"
312
313 common.o : common.c common.h
314         $(CC) $(DEFS) $(EXTRA_CFLAGS) $(DOS2UNIX_NLSDEFS) $(CFLAGS) -c $< -o $@
315
316 querycp.o : querycp.c querycp.h
317         $(CC) $(DEFS) $(EXTRA_CFLAGS) $(DOS2UNIX_NLSDEFS) $(CFLAGS) -c $< -o $@
318
319 dos2unix.o : dos2unix.c dos2unix.h querycp.h common.h version.mk
320         $(CC) $(DEFS) $(EXTRA_CFLAGS) $(DOS2UNIX_NLSDEFS) $(CFLAGS) -c $< -o $@
321
322 unix2dos.o : unix2dos.c unix2dos.h querycp.h common.h version.mk
323         $(CC) $(DEFS) $(EXTRA_CFLAGS) $(DOS2UNIX_NLSDEFS) $(CFLAGS) -c $< -o $@
324
325 $(BIN): dos2unix.o querycp.o common.o
326         $(CC) $+ $(LDFLAGS) $(LIBS) -o $@
327
328 $(UNIX2DOS_BIN): unix2dos.o querycp.o common.o
329         $(CC) $+ $(LDFLAGS) $(LIBS) -o $@
330
331 $(MAC2UNIX_BIN) : $(BIN)
332         $(LINK) $< $@
333
334 $(UNIX2MAC_BIN) : $(UNIX2DOS_BIN)
335         $(LINK) $< $@
336
337 $(MANPOTFILE) : man/man1/dos2unix.pod
338         $(MAKE) -C man/man1 $(notdir $@)
339
340 #  WARNING: Backward-incompatibility since GNU make 3.82.
341 #  The pattern-specific variables and pattern rules are now applied in the
342 #  shortest stem first order instead of the definition order (variables
343 #  and rules with the same stem length are still applied in the definition
344 #  order).
345 #  In order to stay compatible with GNU make < 3.82 we put the rule with
346 #  the shortest stem first.
347
348 po/%.po : $(POT)
349         msgmerge -U $@ $(POT) --backup=numbered
350         # change timestamp in case .po file was not updated.
351         touch $@
352
353 %.po : man/man1/dos2unix.pod
354         $(MAKE) -C man/man1 $(subst man/,../,$@)
355
356 %.pod : %.po
357         $(MAKE) -C man/man1 $(subst man/,../,$@)
358
359 # empty recipe to break circular dependency
360 man/man1/dos2unix.pod : ;
361
362 %.1 : %.pod
363         $(MAKE) -C man/man1 $(subst man/,../,$@)
364
365 mofiles: $(MOFILES)
366
367 html: $(HTMLFILES)
368
369 txt: $(TXTFILES)
370
371 ps: $(PSFILES)
372
373 pdf: $(PDFFILES)
374
375 man: man/man1/dos2unix.1 $(MANFILES) $(MANPOTFILE)
376
377 doc: $(DOCFILES)
378
379 tags: $(POT)
380
381 merge: $(POFILES)
382
383 # Get new po files from the Translation Project.
384 getpo:
385         rsync -Lrtvz  translationproject.org::tp/latest/dos2unix/  po/incoming/
386
387 getpoman:
388         rsync -Lrtvz  translationproject.org::tp/latest/dos2unix-man/  man/incoming/
389
390 %.mo : %.po
391         msgfmt -c $< -o $@
392
393 $(POT) : dos2unix.c unix2dos.c common.c
394         xgettext -C --keyword=_ $+ -o $(POT)
395
396 %.txt : %.pod
397         pod2text $< > $@
398
399 README.txt INSTALL.txt NEWS.txt ChangeLog.txt COPYING.txt TODO.txt BUGS.txt: ;
400
401 %.ps : %.1
402         groff -man $< -T ps > $@
403
404 %.pdf: %.ps
405         ps2pdf $< $@
406
407 # Generic rule.
408 %.$(HTMLEXT) : %.pod
409         pod2html --title="$(PACKAGE) $(DOS2UNIX_VERSION) - DOS/MAC to UNIX and vice versa text file format converter" $< > $@
410
411 man/de/man1/$(PACKAGE).$(HTMLEXT) : man/de/man1/$(PACKAGE).pod
412         pod2html --title="$(PACKAGE) $(DOS2UNIX_VERSION) - Formatumwandlung für Textdateien von DOS/Mac nach Unix und umgekehrt" $< > $@
413
414 man/es/man1/$(PACKAGE).$(HTMLEXT) : man/es/man1/$(PACKAGE).pod
415         pod2html --title="$(PACKAGE) $(DOS2UNIX_VERSION) - Convertidor de archivos de texto de formato DOS/Mac a Unix y viceversa" $< > $@
416
417 man/fr/man1/$(PACKAGE).$(HTMLEXT) : man/fr/man1/$(PACKAGE).pod
418         pod2html --title="$(PACKAGE) $(DOS2UNIX_VERSION) - Convertit les fichiers textes du format DOS/Mac vers Unix et inversement" $< > $@
419
420 man/nl/man1/$(PACKAGE).$(HTMLEXT) : man/nl/man1/$(PACKAGE).pod
421         pod2html --title="$(PACKAGE) $(DOS2UNIX_VERSION) - DOS/Mac naar Unix en vice versa tekstbestand formaat omzetter" $< > $@
422
423 man/pl/man1/$(PACKAGE).$(HTMLEXT) : man/pl/man1/$(PACKAGE).pod
424         pod2html --title="$(PACKAGE) $(DOS2UNIX_VERSION) - konwerter formatu plików tekstowych między systemami DOS/Mac a Uniksem" $< > $@
425
426 man/pt_BR/man1/$(PACKAGE).$(HTMLEXT) : man/pt_BR/man1/$(PACKAGE).pod
427         pod2html --title="$(PACKAGE) $(DOS2UNIX_VERSION) - Conversor de formato de arquivo texto de DOS/Mac para Unix e vice-versa" $< > $@
428
429 man/uk/man1/$(PACKAGE).$(HTMLEXT) : man/uk/man1/$(PACKAGE).pod
430         pod2html --title="$(PACKAGE) $(DOS2UNIX_VERSION) - програма для перетворення даних у текстовому форматі DOS/Mac у формат Unix, і навпаки" $< > $@
431
432 install: all
433         $(MKDIR) -p -m 755 $(DESTDIR)$(bindir)
434         $(INSTALL)  -m 755 $(BIN) $(DESTDIR)$(bindir)
435         $(INSTALL)  -m 755 $(UNIX2DOS_BIN) $(DESTDIR)$(bindir)
436 ifeq ($(LINK),cp -f)
437         $(INSTALL)  -m 755 $(MAC2UNIX_BIN) $(DESTDIR)$(bindir)
438         $(INSTALL)  -m 755 $(UNIX2MAC_BIN) $(DESTDIR)$(bindir)
439 else
440         cd $(DESTDIR)$(bindir); $(LINK) $(BIN) $(MAC2UNIX_BIN)
441         cd $(DESTDIR)$(bindir); $(LINK) $(UNIX2DOS_BIN) $(UNIX2MAC_BIN)
442 endif
443         $(MKDIR) -p -m 755 $(DESTDIR)$(man1dir)
444         $(INSTALL)  -m 644 man/man1/$(PACKAGE).1 $(DESTDIR)$(man1dir)
445 ifeq ($(LINK_MAN),cp -f)
446         $(INSTALL)  -m 644 man/man1/$(PACKAGE).1 $(DESTDIR)$(man1dir)/$(MAC2UNIX).1
447         $(INSTALL)  -m 644 man/man1/$(PACKAGE).1 $(DESTDIR)$(man1dir)/$(UNIX2DOS).1
448         $(INSTALL)  -m 644 man/man1/$(PACKAGE).1 $(DESTDIR)$(man1dir)/$(UNIX2MAC).1
449 else
450         cd $(DESTDIR)$(man1dir); $(LINK_MAN) $(PACKAGE).1 $(MAC2UNIX).1
451         cd $(DESTDIR)$(man1dir); $(LINK_MAN) $(PACKAGE).1 $(UNIX2DOS).1
452         cd $(DESTDIR)$(man1dir); $(LINK_MAN) $(PACKAGE).1 $(UNIX2MAC).1
453 endif
454         $(foreach manfile, $(MANFILES), $(MKDIR) -p -m 755 $(DESTDIR)$(datarootdir)/$(dir $(manfile)) ;)
455         $(foreach manfile, $(MANFILES), $(INSTALL) -m 644 $(manfile) $(DESTDIR)$(datarootdir)/$(dir $(manfile)) ;)
456         $(foreach manfile, $(MANFILES), cd $(DESTDIR)$(datarootdir)/$(dir $(manfile)) ; $(LINK_MAN) $(PACKAGE).1 $(MAC2UNIX).1 ;)
457         $(foreach manfile, $(MANFILES), cd $(DESTDIR)$(datarootdir)/$(dir $(manfile)) ; $(LINK_MAN) $(PACKAGE).1 $(UNIX2DOS).1 ;)
458         $(foreach manfile, $(MANFILES), cd $(DESTDIR)$(datarootdir)/$(dir $(manfile)) ; $(LINK_MAN) $(PACKAGE).1 $(UNIX2MAC).1 ;)
459 ifdef ENABLE_NLS
460         @echo "-- install-mo"
461         $(foreach mofile, $(MOFILES), $(MKDIR) -p -m 755 $(DESTDIR)$(localedir)/$(basename $(notdir $(mofile)))/LC_MESSAGES ;)
462         $(foreach mofile, $(MOFILES), $(INSTALL) -m 644 $(mofile) $(DESTDIR)$(localedir)/$(basename $(notdir $(mofile)))/LC_MESSAGES/$(PACKAGE).mo ;)
463 endif
464         # Run a new instance of 'make' otherwise the $$(wildcard ) function my not have been expanded,
465         # because the files may not have been there when make was started.
466         $(MAKE) install-doc
467
468
469 install-doc: $(INSTALL_OBJS_DOC)
470         @echo "-- install-doc"
471         $(MKDIR) -p -m 755 $(DESTDIR)$(docdir)
472         $(INSTALL) -m 644 $(INSTALL_OBJS_DOC) $(DESTDIR)$(docdir)
473         # Install translated manuals when they have been generated.
474         $(foreach txtfile, $(wildcard man/*/man1/*.txt), $(MKDIR) -p -m 755 $(DESTDIR)$(docdir)/$(word 2,$(subst /, ,$(txtfile),)) ;)
475         $(foreach txtfile, $(wildcard man/*/man1/*.txt), $(INSTALL) -m 644 $(txtfile) $(DESTDIR)$(docdir)/$(word 2,$(subst /, ,$(txtfile),)) ;)
476         $(foreach htmlfile, $(wildcard man/*/man1/*.$(HTMLEXT)), $(MKDIR) -p -m 755 $(DESTDIR)$(docdir)/$(word 2,$(subst /, ,$(htmlfile),)) ;)
477         $(foreach htmlfile, $(wildcard man/*/man1/*.$(HTMLEXT)), $(INSTALL) -m 644 $(htmlfile) $(DESTDIR)$(docdir)/$(word 2,$(subst /, ,$(htmlfile),)) ;)
478         $(foreach pdffile, $(wildcard man/*/man1/*.pdf), $(MKDIR) -p -m 755 $(DESTDIR)$(docdir)/$(word 2,$(subst /, ,$(pdffile),)) ;)
479         $(foreach pdffile, $(wildcard man/*/man1/*.pdf), $(INSTALL) -m 644 $(pdffile) $(DESTDIR)$(docdir)/$(word 2,$(subst /, ,$(pdffile),)) ;)
480         $(foreach pdffile, $(wildcard man/man1/*.pdf), $(INSTALL) -m 644 $(pdffile) $(DESTDIR)$(docdir) ;)
481         $(foreach psfile, $(wildcard man/*/man1/*.ps), $(MKDIR) -p -m 755 $(DESTDIR)$(docdir)/$(word 2,$(subst /, ,$(psfile),)) ;)
482         $(foreach psfile, $(wildcard man/*/man1/*.ps), $(INSTALL) -m 644 $(psfile) $(DESTDIR)$(docdir)/$(word 2,$(subst /, ,$(psfile),)) ;)
483         $(foreach psfile, $(wildcard man/man1/*.ps), $(INSTALL) -m 644 $(psfile) $(DESTDIR)$(docdir) ;)
484
485 uninstall:
486         @echo "-- target: uninstall"
487         -rm -f $(DESTDIR)$(bindir)/$(BIN)
488         -rm -f $(DESTDIR)$(bindir)/$(MAC2UNIX_BIN)
489         -rm -f $(DESTDIR)$(bindir)/$(UNIX2DOS_BIN)
490         -rm -f $(DESTDIR)$(bindir)/$(UNIX2MAC_BIN)
491 ifdef ENABLE_NLS
492         $(foreach mofile, $(MOFILES), rm -f $(DESTDIR)$(localedir)/$(basename $(notdir $(mofile)))/LC_MESSAGES/$(PACKAGE).mo ;)
493 endif
494         -rm -f $(DESTDIR)$(mandir)/man1/$(PACKAGE).1
495         -rm -f $(DESTDIR)$(mandir)/man1/$(MAC2UNIX).1
496         -rm -f $(DESTDIR)$(mandir)/man1/$(UNIX2DOS).1
497         -rm -f $(DESTDIR)$(mandir)/man1/$(UNIX2MAC).1
498         $(foreach manfile, $(MANFILES), rm -f $(DESTDIR)$(datarootdir)/$(manfile) ;)
499         -rm -rf $(DESTDIR)$(docdir)
500
501 mostlyclean:
502         rm -f *.o
503         rm -f $(BIN) $(UNIX2DOS_BIN) $(MAC2UNIX_BIN) $(UNIX2MAC_BIN)
504         rm -f *.bak *~
505         rm -f *.tmp
506         rm -f man/man1/*.bak man/man1/*~
507         rm -f man/*/man1/*.bak man/*/man1/*~
508         rm -f po/*.bak po/*~
509         rm -f po/*.mo
510
511 # Don't distribute PostScript and PDF manuals in the source package.
512 # We don't want binary PDF files in the source package, because
513 # some packagers check in the source files. PostScript is not used
514 # a lot.
515
516 clean: mostlyclean
517         rm -f man/man1/*.ps
518         rm -f man/man1/*.pdf
519         rm -f man/*/man1/*.ps
520         rm -f man/*/man1/*.pdf
521
522 distclean: clean
523
524 # Because there is so much trouble with generating man pages with
525 # pod2man, due to old Perl versions (< 5.10.1) on many systems, I include the
526 # man pages in the source tar file.
527 # Old pod2man versions do not have the --utf8 option. Old pod2man, pod2text,
528 # and pod2html do not support the =encoding command.
529 # Perl 5.18 pod2man demands an =encoding command for Latin-1 encoded POD files.
530 #
531 # Newer perl/pod2man versions produce better output. It is better to include
532 # man pages in the source package, than that people generate them themselves
533 # with old perl versions.
534
535 maintainer-clean: distclean
536         @echo 'This command is intended for maintainers to use; it'
537         @echo 'deletes files that may need special tools to rebuild.'
538         rm -f man/man1/*.1
539         rm -f man/man1/*.txt
540         rm -f man/man1/*.$(HTMLEXT)
541         rm -f man/man1/dos2unix-man.pot
542         rm -f man/*/man1/*.1
543         rm -f man/*/man1/*.txt
544         rm -f man/*/man1/*.pod
545         rm -f man/*/man1/*.$(HTMLEXT)
546
547 realclean: maintainer-clean
548
549
550 ZIPOBJ  = bin/$(BIN) \
551           bin/$(MAC2UNIX_BIN) \
552           bin/$(UNIX2DOS_BIN) \
553           bin/$(UNIX2MAC_BIN) \
554           share/man/man1/$(PACKAGE).1 \
555           share/man/man1/$(MAC2UNIX).1 \
556           share/man/man1/$(UNIX2DOS).1 \
557           share/man/man1/$(UNIX2MAC).1 \
558           share/man/*/man1/$(PACKAGE).1 \
559           share/man/*/man1/$(MAC2UNIX).1 \
560           share/man/*/man1/$(UNIX2DOS).1 \
561           share/man/*/man1/$(UNIX2MAC).1 \
562           share/doc/$(docsubdir) \
563           $(ZIPOBJ_EXTRA)
564
565 ifdef ENABLE_NLS
566 ZIPOBJ += share/locale/*/LC_MESSAGES/$(PACKAGE).mo
567 endif
568
569 ZIPFILE = $(PACKAGE)-$(DOS2UNIX_VERSION)$(VERSIONSUFFIX)$(NLSSUFFIX).zip
570 TGZFILE = $(PACKAGE)-$(DOS2UNIX_VERSION)$(VERSIONSUFFIX)$(NLSSUFFIX).tar.gz
571 TBZFILE = $(PACKAGE)-$(DOS2UNIX_VERSION)$(VERSIONSUFFIX)$(NLSSUFFIX).tar.bz2
572
573 dist-zip:
574         rm -f $(prefix)/$(ZIPFILE)
575         cd $(prefix) ; unix2dos --keepdate share/man/man1/*.1 share/man/*/man1/*.1
576         -cd $(prefix) ; unix2dos --keepdate --add-bom share/doc/$(docsubdir)/*.txt share/doc/$(docsubdir)/*/*.txt
577         -cd $(prefix) ; unix2dos --keepdate share/doc/$(docsubdir)/*.$(HTMLEXT) share/doc/$(docsubdir)/*/*.$(HTMLEXT)
578         cd $(prefix) ; unix2dos --keepdate share/man/*/man1/$(PACKAGE).1 share/man/*/man1/$(MAC2UNIX).1 share/man/*/man1/$(UNIX2DOS).1 share/man/*/man1/$(UNIX2MAC).1
579         cd $(prefix) ; zip -r $(ZIPFILE) $(ZIPOBJ)
580         mv -f $(prefix)/$(ZIPFILE) ..
581
582 dist-tgz:
583         cd $(prefix) ; dos2unix --keepdate share/man/man1/*.1 share/man/*/man1/*.1
584         -cd $(prefix) ; dos2unix --keepdate share/doc/$(docsubdir)/*.txt share/doc/$(docsubdir)/*/*.txt
585         -cd $(prefix) ; dos2unix --keepdate share/doc/$(docsubdir)/*.$(HTMLEXT) share/doc/$(docsubdir)/*/*.$(HTMLEXT)
586         cd $(prefix) ; tar cvzf $(TGZFILE) $(ZIPOBJ)
587         mv $(prefix)/$(TGZFILE) ..
588
589 dist-tbz:
590         cd $(prefix) ; dos2unix --keepdate share/man/man1/*.1 share/man/*/man1/*.1
591         -cd $(prefix) ; dos2unix --keepdate share/doc/$(docsubdir)/*.txt dos2unix share/doc/$(docsubdir)/*/*.txt
592         -cd $(prefix) ; dos2unix --keepdate share/doc/$(docsubdir)/*.$(HTMLEXT) dos2unix share/doc/$(docsubdir)/*/*.$(HTMLEXT)
593         cd $(prefix) ; tar cvjf $(TBZFILE) $(ZIPOBJ)
594         mv $(prefix)/$(TBZFILE) ..
595
596 dist: dist-tgz
597
598 strip:
599         $(STRIP) $(BIN)
600         $(STRIP) $(UNIX2DOS_BIN)
601 ifeq ($(LINK),cp -f)
602         $(STRIP) $(MAC2UNIX_BIN)
603         $(STRIP) $(UNIX2MAC_BIN)
604 endif
605
606 # End of file