29ed5c8c190adfd6eabb88a719ff8cc7f2319894
[platform/upstream/dos2unix.git] / Makefile
1 # Author: Erwin Waterlander
2 #
3 #   Copyright (C) 2009-2015 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 test check
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
123 ifndef D2U_OS
124         d2u_os=$(shell uname -s)
125
126 ifeq ($(findstring CYGWIN,$(d2u_os)),CYGWIN)
127         D2U_OS = cygwin
128 endif
129
130 ifndef D2U_OS
131 ifeq ($(findstring MSYS,$(d2u_os)),MSYS)
132         D2U_OS = msys
133 endif
134 endif
135
136 ifndef D2U_OS
137 ifeq ($(findstring MINGW32,$(d2u_os)),MINGW32)
138         D2U_OS = mingw32
139 endif
140 endif
141
142 ifndef D2U_OS
143 ifneq ($(DJGPP),)
144         D2U_OS = msdos
145 endif
146 endif
147
148 ifndef D2U_OS
149 ifneq (, $(wildcard /opt/csw))
150         D2U_OS = sun
151 endif
152 endif
153
154 ifndef D2U_OS
155         D2U_OS=$(shell echo $(d2u_os) | tr [A-Z] [a-z])
156 endif
157
158 endif
159
160 ifeq (cygwin,$(D2U_OS))
161 ifdef ENABLE_NLS
162         LIBS_EXTRA = -lintl -liconv
163 endif
164         LDFLAGS_EXTRA = -Wl,--enable-auto-import
165         EXE = .exe
166         # allow non-cygwin clients which do not understand cygwin
167         # symbolic links to launch applications...
168         LINK = ln -f
169         # but use symbolic links for man pages, since man client
170         # IS a cygwin app and DOES understand symlinks.
171         LINK_MAN = ln -fs
172         # Cygwin packaging standard avoids version numbers on
173         # documentation directories.
174         docsubdir       = $(PACKAGE)
175         VERSIONSUFFIX   = -cygwin
176 endif
177
178 ifeq (msys,$(D2U_OS))
179         CC=gcc
180         EXE = .exe
181         VERSIONSUFFIX   = -msys
182 ifdef ENABLE_NLS
183         LIBS_EXTRA = -lintl -liconv
184 endif
185 endif
186
187 ifeq (mingw32,$(D2U_OS))
188         prefix=c:/usr/local
189         EXE = .exe
190         VERSIONSUFFIX   = -win32
191         LINK = cp -f
192 ifdef ENABLE_NLS
193         LIBS_EXTRA = -lintl -liconv
194         ZIPOBJ_EXTRA = bin/libintl-8.dll bin/libiconv-2.dll
195 endif
196 ifeq ($(findstring w64-mingw32,$(shell gcc -dumpmachine)),w64-mingw32)
197         CFLAGS_COMPILER = -DD2U_COMPILER=MINGW32_W64
198 endif
199 endif
200
201 ifeq (msdos,$(D2U_OS))
202         prefix=c:/dos32
203         EXE = .exe
204         VERSIONSUFFIX = pm
205         LINK_MAN = cp -f
206         docsubdir = dos2unix
207         UCS =
208         ZIPOBJ_EXTRA = bin/cwsdpmi.exe
209 ifdef ENABLE_NLS
210         LIBS_EXTRA = -lintl -liconv
211 endif
212 endif
213
214 ifeq (os/2,$(D2U_OS))
215         prefix=c:/usr
216         EXE = .exe
217         VERSIONSUFFIX = -os2
218         LINK_MAN = cp -f
219         UCS =
220         LDFLAGS_EXTRA = -Zargs-wild
221 ifdef ENABLE_NLS
222         LIBS_EXTRA += -lintl -liconv
223 endif
224 endif
225
226 ifeq (freemint,$(D2U_OS))
227         prefix=/usr
228         EXE =
229         VERSIONSUFFIX = -freemint
230         UCS=
231         ENABLE_NLS=
232 ifdef ENABLE_NLS
233         LIBS_EXTRA += -lintl -liconv
234 endif
235         EXTRA_DEFS += -Dfreemint -D__OS=\"freemint\"
236 endif
237
238 ifeq (freebsd,$(D2U_OS))
239 ifdef ENABLE_NLS
240         CFLAGS_OS     = -I/usr/local/include
241         LDFLAGS_EXTRA = -L/usr/local/lib
242         LIBS_EXTRA    = -lintl
243 endif
244 endif
245
246 ifeq (darwin,$(D2U_OS))
247 ifdef ENABLE_NLS
248         CFLAGS_OS     = -I/usr/local/include
249         LDFLAGS_EXTRA = -L/usr/local/lib
250         LIBS_EXTRA    = -lintl
251 endif
252 endif
253
254 ifeq (sun,$(D2U_OS))
255         # Running under SunOS/Solaris
256         LIBS_EXTRA = -lintl
257 endif
258
259 ifeq (hp-ux,$(D2U_OS))
260         # Running under HP-UX
261         EXTRA_DEFS += -Dhpux -D_HPUX_SOURCE
262 endif
263
264
265 # ............................................................ flags ...
266
267 # PostScript and PDF generation from UTF-8 manuals is not working,
268 # or I don't know how to do it.
269
270 CFLAGS_USER     =
271 CFLAGS          ?= -O2
272 CFLAGS          += -Wall -Wextra -Wconversion $(RPM_OPT_FLAGS) $(CPPFLAGS) $(CFLAGS_USER)
273
274 EXTRA_CFLAGS    = -DVER_REVISION=\"$(DOS2UNIX_VERSION)\" \
275                   -DVER_DATE=\"$(DOS2UNIX_DATE)\" \
276                   -DVER_AUTHOR=\"$(DOS2UNIX_AUTHOR)\" \
277                   -DDEBUG=$(DEBUG) \
278                   $(CFLAGS_OS) \
279                   $(CFLAGS_COMPILER)
280
281 ifeq ($(DEBUG), 1)
282         EXTRA_CFLAGS += -g
283 endif
284
285 ifdef STATIC
286         EXTRA_CFLAGS += -static
287 endif
288
289 ifdef UCS
290         EXTRA_CFLAGS += -DD2U_UNICODE
291 endif
292 ifdef UNIFILE
293         EXTRA_CFLAGS += -DD2U_UNIFILE
294 endif
295
296
297 ifdef LFS
298         EXTRA_CFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
299 endif
300
301 LDFLAGS_USER    =
302 LDFLAGS = $(RPM_OPT_FLAGS) $(LDFLAGS_EXTRA) $(LDFLAGS_USER)
303 LIBS    = $(LIBS_EXTRA)
304
305 DEFS_USER       =
306 DEFS            = $(EXTRA_DEFS) $(DEFS_USER)
307
308 # .......................................................... targets ...
309
310 all: $(BIN) $(MAC2UNIX_BIN) $(UNIX2DOS_BIN) $(UNIX2MAC_BIN) $(DOCFILES) $(MOFILES) man/man1/dos2unix.1 $(MANFILES) $(MANPOTFILE)
311
312 status:
313         @echo "D2U_OS       = $(D2U_OS)"
314         @echo "UCS          = $(UCS)"
315         @echo "CFLAGS       = $(CFLAGS)"
316         @echo "EXTRA_CFLAGS = $(EXTRA_CFLAGS)"
317         @echo "LDFLAGS      = $(LDFLAGS)"
318         @echo "LIBS         = $(LIBS)"
319
320 common.o : common.c common.h dos2unix.h unix2dos.h version.mk
321         $(CC) $(DEFS) $(EXTRA_CFLAGS) $(DOS2UNIX_NLSDEFS) $(CFLAGS) -c $< -o $@
322
323 querycp.o : querycp.c querycp.h
324         $(CC) $(DEFS) $(EXTRA_CFLAGS) $(DOS2UNIX_NLSDEFS) $(CFLAGS) -c $< -o $@
325
326 dos2unix.o : dos2unix.c dos2unix.h querycp.h common.h
327         $(CC) $(DEFS) $(EXTRA_CFLAGS) $(DOS2UNIX_NLSDEFS) $(CFLAGS) -c $< -o $@
328
329 unix2dos.o : unix2dos.c unix2dos.h querycp.h common.h
330         $(CC) $(DEFS) $(EXTRA_CFLAGS) $(DOS2UNIX_NLSDEFS) $(CFLAGS) -c $< -o $@
331
332 $(BIN): dos2unix.o querycp.o common.o
333         $(CC) $+ $(LDFLAGS) $(LIBS) -o $@
334
335 $(UNIX2DOS_BIN): unix2dos.o querycp.o common.o
336         $(CC) $+ $(LDFLAGS) $(LIBS) -o $@
337
338 $(MAC2UNIX_BIN) : $(BIN)
339         $(LINK) $< $@
340
341 $(UNIX2MAC_BIN) : $(UNIX2DOS_BIN)
342         $(LINK) $< $@
343
344 $(MANPOTFILE) : man/man1/dos2unix.pod
345         $(MAKE) -C man/man1 $(notdir $@)
346
347 #  WARNING: Backward-incompatibility since GNU make 3.82.
348 #  The pattern-specific variables and pattern rules are now applied in the
349 #  shortest stem first order instead of the definition order (variables
350 #  and rules with the same stem length are still applied in the definition
351 #  order).
352 #  In order to stay compatible with GNU make < 3.82 we put the rule with
353 #  the shortest stem first.
354
355 po/%.po : $(POT)
356         msgmerge --no-wrap -U $@ $(POT) --backup=numbered
357         # change timestamp in case .po file was not updated.
358         touch $@
359
360 %.po : man/man1/dos2unix.pod
361         $(MAKE) -C man/man1 $(subst man/,../,$@)
362
363 %.pod : %.po
364         $(MAKE) -C man/man1 $(subst man/,../,$@)
365
366 # empty recipe to break circular dependency
367 man/man1/dos2unix.pod : ;
368
369 %.1 : %.pod
370         $(MAKE) -C man/man1 $(subst man/,../,$@)
371
372 mofiles: $(MOFILES)
373
374 html: $(HTMLFILES)
375
376 txt: $(TXTFILES)
377
378 ps: $(PSFILES)
379
380 pdf: $(PDFFILES)
381
382 man: man/man1/dos2unix.1 $(MANFILES) $(MANPOTFILE)
383
384 doc: $(DOCFILES)
385
386 tags: $(POT)
387
388 merge: $(POFILES)
389
390 # Get new po files from the Translation Project.
391 getpo:
392         rsync -Lrtvz  translationproject.org::tp/latest/dos2unix/  po/incoming/
393
394 getpoman:
395         rsync -Lrtvz  translationproject.org::tp/latest/dos2unix-man/  man/incoming/
396
397 %.mo : %.po
398         msgfmt -c $< -o $@
399
400 $(POT) : dos2unix.c unix2dos.c common.c
401         xgettext -C -cTRANSLATORS: --no-wrap --keyword=_ $+ -o $(POT)
402
403 %.txt : %.pod
404         pod2text $< > $@
405
406 README.txt INSTALL.txt NEWS.txt ChangeLog.txt COPYING.txt TODO.txt BUGS.txt: ;
407
408 %.ps : %.1
409         groff -man $< -T ps > $@
410
411 %.pdf: %.ps
412         ps2pdf $< $@
413
414 # Since perl 5.18 pod2html generates HTML with all non-ASCII characters encoded
415 # with HTML Ampersand Character Codes. This seems to be better browser compatible
416 # than HTML in UTF-8 format. PERL_UNICODE=SDA is needed to get a correct UTF-8
417 # encoded title.
418 # With perl < 5.18 you have to remove PERL_UNICODE=SDA, and then you get HTML pages
419 # in UTF-8 format.
420
421 # Generic rule.
422 %.$(HTMLEXT) : %.pod
423         PERL_UNICODE=SDA pod2html --title="$(PACKAGE) $(DOS2UNIX_VERSION) - DOS/MAC to UNIX and vice versa text file format converter" $< > $@
424
425 man/de/man1/$(PACKAGE).$(HTMLEXT) : man/de/man1/$(PACKAGE).pod
426         PERL_UNICODE=SDA pod2html --title="$(PACKAGE) $(DOS2UNIX_VERSION) - Formatumwandlung für Textdateien von DOS/Mac nach Unix und umgekehrt" $< > $@
427
428 man/es/man1/$(PACKAGE).$(HTMLEXT) : man/es/man1/$(PACKAGE).pod
429         PERL_UNICODE=SDA pod2html --title="$(PACKAGE) $(DOS2UNIX_VERSION) - Convertidor de archivos de texto de formato DOS/Mac a Unix y viceversa" $< > $@
430
431 man/fr/man1/$(PACKAGE).$(HTMLEXT) : man/fr/man1/$(PACKAGE).pod
432         PERL_UNICODE=SDA pod2html --title="$(PACKAGE) $(DOS2UNIX_VERSION) - Convertit les fichiers textes du format DOS/Mac vers Unix et inversement" $< > $@
433
434 man/nl/man1/$(PACKAGE).$(HTMLEXT) : man/nl/man1/$(PACKAGE).pod
435         PERL_UNICODE=SDA pod2html --title="$(PACKAGE) $(DOS2UNIX_VERSION) - DOS/Mac naar Unix en vice versa tekstbestand formaat omzetter" $< > $@
436
437 man/pl/man1/$(PACKAGE).$(HTMLEXT) : man/pl/man1/$(PACKAGE).pod
438         PERL_UNICODE=SDA pod2html --title="$(PACKAGE) $(DOS2UNIX_VERSION) - konwerter formatu plików tekstowych między systemami DOS/Mac a Uniksem" $< > $@
439
440 man/pt_BR/man1/$(PACKAGE).$(HTMLEXT) : man/pt_BR/man1/$(PACKAGE).pod
441         PERL_UNICODE=SDA pod2html --title="$(PACKAGE) $(DOS2UNIX_VERSION) - Conversor de formato de arquivo texto de DOS/Mac para Unix e vice-versa" $< > $@
442
443 man/uk/man1/$(PACKAGE).$(HTMLEXT) : man/uk/man1/$(PACKAGE).pod
444         PERL_UNICODE=SDA pod2html --title="$(PACKAGE) $(DOS2UNIX_VERSION) - програма для перетворення даних у текстовому форматі DOS/Mac у формат Unix, і навпаки" $< > $@
445
446 test: all
447         cd test; $(MAKE) test
448
449 check: test
450
451 install: all
452         $(MKDIR) -p -m 755 $(DESTDIR)$(bindir)
453         $(INSTALL)  -m 755 $(BIN) $(DESTDIR)$(bindir)
454         $(INSTALL)  -m 755 $(UNIX2DOS_BIN) $(DESTDIR)$(bindir)
455 ifeq ($(LINK),cp -f)
456         $(INSTALL)  -m 755 $(MAC2UNIX_BIN) $(DESTDIR)$(bindir)
457         $(INSTALL)  -m 755 $(UNIX2MAC_BIN) $(DESTDIR)$(bindir)
458 else
459         cd $(DESTDIR)$(bindir); $(LINK) $(BIN) $(MAC2UNIX_BIN)
460         cd $(DESTDIR)$(bindir); $(LINK) $(UNIX2DOS_BIN) $(UNIX2MAC_BIN)
461 endif
462         $(MKDIR) -p -m 755 $(DESTDIR)$(man1dir)
463         $(INSTALL)  -m 644 man/man1/$(PACKAGE).1 $(DESTDIR)$(man1dir)
464 ifeq ($(LINK_MAN),cp -f)
465         $(INSTALL)  -m 644 man/man1/$(PACKAGE).1 $(DESTDIR)$(man1dir)/$(MAC2UNIX).1
466         $(INSTALL)  -m 644 man/man1/$(PACKAGE).1 $(DESTDIR)$(man1dir)/$(UNIX2DOS).1
467         $(INSTALL)  -m 644 man/man1/$(PACKAGE).1 $(DESTDIR)$(man1dir)/$(UNIX2MAC).1
468 else
469         cd $(DESTDIR)$(man1dir); $(LINK_MAN) $(PACKAGE).1 $(MAC2UNIX).1
470         cd $(DESTDIR)$(man1dir); $(LINK_MAN) $(PACKAGE).1 $(UNIX2DOS).1
471         cd $(DESTDIR)$(man1dir); $(LINK_MAN) $(PACKAGE).1 $(UNIX2MAC).1
472 endif
473         $(foreach manfile, $(MANFILES), $(MKDIR) -p -m 755 $(DESTDIR)$(datarootdir)/$(dir $(manfile)) ;)
474         $(foreach manfile, $(MANFILES), $(INSTALL) -m 644 $(manfile) $(DESTDIR)$(datarootdir)/$(dir $(manfile)) ;)
475         $(foreach manfile, $(MANFILES), cd $(DESTDIR)$(datarootdir)/$(dir $(manfile)) ; $(LINK_MAN) $(PACKAGE).1 $(MAC2UNIX).1 ;)
476         $(foreach manfile, $(MANFILES), cd $(DESTDIR)$(datarootdir)/$(dir $(manfile)) ; $(LINK_MAN) $(PACKAGE).1 $(UNIX2DOS).1 ;)
477         $(foreach manfile, $(MANFILES), cd $(DESTDIR)$(datarootdir)/$(dir $(manfile)) ; $(LINK_MAN) $(PACKAGE).1 $(UNIX2MAC).1 ;)
478 ifdef ENABLE_NLS
479         @echo "-- install-mo"
480         $(foreach mofile, $(MOFILES), $(MKDIR) -p -m 755 $(DESTDIR)$(localedir)/$(basename $(notdir $(mofile)))/LC_MESSAGES ;)
481         $(foreach mofile, $(MOFILES), $(INSTALL) -m 644 $(mofile) $(DESTDIR)$(localedir)/$(basename $(notdir $(mofile)))/LC_MESSAGES/$(PACKAGE).mo ;)
482 endif
483         # Run a new instance of 'make' otherwise the $$(wildcard ) function my not have been expanded,
484         # because the files may not have been there when make was started.
485         $(MAKE) install-doc
486
487
488 install-doc: $(INSTALL_OBJS_DOC)
489         @echo "-- install-doc"
490         $(MKDIR) -p -m 755 $(DESTDIR)$(docdir)
491         $(INSTALL) -m 644 $(INSTALL_OBJS_DOC) $(DESTDIR)$(docdir)
492         # Install translated manuals when they have been generated.
493         $(foreach txtfile, $(wildcard man/*/man1/*.txt), $(MKDIR) -p -m 755 $(DESTDIR)$(docdir)/$(word 2,$(subst /, ,$(txtfile),)) ;)
494         $(foreach txtfile, $(wildcard man/*/man1/*.txt), $(INSTALL) -m 644 $(txtfile) $(DESTDIR)$(docdir)/$(word 2,$(subst /, ,$(txtfile),)) ;)
495         $(foreach htmlfile, $(wildcard man/*/man1/*.$(HTMLEXT)), $(MKDIR) -p -m 755 $(DESTDIR)$(docdir)/$(word 2,$(subst /, ,$(htmlfile),)) ;)
496         $(foreach htmlfile, $(wildcard man/*/man1/*.$(HTMLEXT)), $(INSTALL) -m 644 $(htmlfile) $(DESTDIR)$(docdir)/$(word 2,$(subst /, ,$(htmlfile),)) ;)
497         $(foreach pdffile, $(wildcard man/*/man1/*.pdf), $(MKDIR) -p -m 755 $(DESTDIR)$(docdir)/$(word 2,$(subst /, ,$(pdffile),)) ;)
498         $(foreach pdffile, $(wildcard man/*/man1/*.pdf), $(INSTALL) -m 644 $(pdffile) $(DESTDIR)$(docdir)/$(word 2,$(subst /, ,$(pdffile),)) ;)
499         $(foreach pdffile, $(wildcard man/man1/*.pdf), $(INSTALL) -m 644 $(pdffile) $(DESTDIR)$(docdir) ;)
500         $(foreach psfile, $(wildcard man/*/man1/*.ps), $(MKDIR) -p -m 755 $(DESTDIR)$(docdir)/$(word 2,$(subst /, ,$(psfile),)) ;)
501         $(foreach psfile, $(wildcard man/*/man1/*.ps), $(INSTALL) -m 644 $(psfile) $(DESTDIR)$(docdir)/$(word 2,$(subst /, ,$(psfile),)) ;)
502         $(foreach psfile, $(wildcard man/man1/*.ps), $(INSTALL) -m 644 $(psfile) $(DESTDIR)$(docdir) ;)
503
504 uninstall:
505         @echo "-- target: uninstall"
506         -rm -f $(DESTDIR)$(bindir)/$(BIN)
507         -rm -f $(DESTDIR)$(bindir)/$(MAC2UNIX_BIN)
508         -rm -f $(DESTDIR)$(bindir)/$(UNIX2DOS_BIN)
509         -rm -f $(DESTDIR)$(bindir)/$(UNIX2MAC_BIN)
510 ifdef ENABLE_NLS
511         $(foreach mofile, $(MOFILES), rm -f $(DESTDIR)$(localedir)/$(basename $(notdir $(mofile)))/LC_MESSAGES/$(PACKAGE).mo ;)
512 endif
513         -rm -f $(DESTDIR)$(mandir)/man1/$(PACKAGE).1
514         -rm -f $(DESTDIR)$(mandir)/man1/$(MAC2UNIX).1
515         -rm -f $(DESTDIR)$(mandir)/man1/$(UNIX2DOS).1
516         -rm -f $(DESTDIR)$(mandir)/man1/$(UNIX2MAC).1
517         $(foreach manfile, $(MANFILES), rm -f $(DESTDIR)$(datarootdir)/$(manfile) ;)
518         -rm -rf $(DESTDIR)$(docdir)
519
520 mostlyclean:
521         rm -f *.o
522         rm -f $(BIN) $(UNIX2DOS_BIN) $(MAC2UNIX_BIN) $(UNIX2MAC_BIN)
523         rm -f *.bak *~
524         rm -f *.tmp
525         rm -f man/man1/*.bak man/man1/*~
526         rm -f man/*/man1/*.bak man/*/man1/*~
527         rm -f po/*.bak po/*~
528         rm -f po/*.mo
529         cd test; $(MAKE) clean
530
531 # Don't distribute PostScript and PDF manuals in the source package.
532 # We don't want binary PDF files in the source package, because
533 # some packagers check in the source files. PostScript is not used
534 # a lot.
535
536 clean: mostlyclean
537         rm -f man/man1/*.ps
538         rm -f man/man1/*.pdf
539         rm -f man/*/man1/*.ps
540         rm -f man/*/man1/*.pdf
541
542 distclean: clean
543
544 # Because there is so much trouble with generating man pages with
545 # pod2man, due to old Perl versions (< 5.10.1) on many systems, I include the
546 # man pages in the source tar file.
547 # Old pod2man versions do not have the --utf8 option. Old pod2man, pod2text,
548 # and pod2html do not support the =encoding command.
549 # Perl 5.18 pod2man demands an =encoding command for Latin-1 encoded POD files.
550 #
551 # Newer perl/pod2man versions produce better output. It is better to include
552 # man pages in the source package, than that people generate them themselves
553 # with old perl versions.
554
555 maintainer-clean: distclean
556         @echo 'This command is intended for maintainers to use; it'
557         @echo 'deletes files that may need special tools to rebuild.'
558         rm -f man/man1/*.1
559         rm -f man/man1/*.txt
560         rm -f man/man1/*.$(HTMLEXT)
561         rm -f man/man1/dos2unix-man.pot
562         rm -f man/*/man1/*.1
563         rm -f man/*/man1/*.txt
564         rm -f man/*/man1/*.pod
565         rm -f man/*/man1/*.$(HTMLEXT)
566
567 realclean: maintainer-clean
568
569
570 ZIPOBJ  = bin/$(BIN) \
571           bin/$(MAC2UNIX_BIN) \
572           bin/$(UNIX2DOS_BIN) \
573           bin/$(UNIX2MAC_BIN) \
574           share/man/man1/$(PACKAGE).1 \
575           share/man/man1/$(MAC2UNIX).1 \
576           share/man/man1/$(UNIX2DOS).1 \
577           share/man/man1/$(UNIX2MAC).1 \
578           share/man/*/man1/$(PACKAGE).1 \
579           share/man/*/man1/$(MAC2UNIX).1 \
580           share/man/*/man1/$(UNIX2DOS).1 \
581           share/man/*/man1/$(UNIX2MAC).1 \
582           share/doc/$(docsubdir) \
583           $(ZIPOBJ_EXTRA)
584
585 ifdef ENABLE_NLS
586 ZIPOBJ += share/locale/*/LC_MESSAGES/$(PACKAGE).mo
587 endif
588
589 ZIPFILE = $(PACKAGE)-$(DOS2UNIX_VERSION)$(VERSIONSUFFIX)$(NLSSUFFIX).zip
590 TGZFILE = $(PACKAGE)-$(DOS2UNIX_VERSION)$(VERSIONSUFFIX)$(NLSSUFFIX).tar.gz
591 TBZFILE = $(PACKAGE)-$(DOS2UNIX_VERSION)$(VERSIONSUFFIX)$(NLSSUFFIX).tar.bz2
592
593 dist-zip:
594         rm -f $(prefix)/$(ZIPFILE)
595         cd $(prefix) ; unix2dos --keepdate share/man/man1/*.1 share/man/*/man1/*.1
596         -cd $(prefix) ; unix2dos --keepdate --add-bom share/doc/$(docsubdir)/*.txt share/doc/$(docsubdir)/*/*.txt
597         -cd $(prefix) ; unix2dos --keepdate share/doc/$(docsubdir)/*.$(HTMLEXT) share/doc/$(docsubdir)/*/*.$(HTMLEXT)
598         cd $(prefix) ; unix2dos --keepdate share/man/*/man1/$(PACKAGE).1 share/man/*/man1/$(MAC2UNIX).1 share/man/*/man1/$(UNIX2DOS).1 share/man/*/man1/$(UNIX2MAC).1
599         cd $(prefix) ; zip -r $(ZIPFILE) $(ZIPOBJ)
600         mv -f $(prefix)/$(ZIPFILE) ..
601
602 dist-tgz:
603         cd $(prefix) ; dos2unix --keepdate share/man/man1/*.1 share/man/*/man1/*.1
604         -cd $(prefix) ; dos2unix --keepdate share/doc/$(docsubdir)/*.txt share/doc/$(docsubdir)/*/*.txt
605         -cd $(prefix) ; dos2unix --keepdate share/doc/$(docsubdir)/*.$(HTMLEXT) share/doc/$(docsubdir)/*/*.$(HTMLEXT)
606         cd $(prefix) ; tar cvzf $(TGZFILE) $(ZIPOBJ)
607         mv $(prefix)/$(TGZFILE) ..
608
609 dist-tbz:
610         cd $(prefix) ; dos2unix --keepdate share/man/man1/*.1 share/man/*/man1/*.1
611         -cd $(prefix) ; dos2unix --keepdate share/doc/$(docsubdir)/*.txt dos2unix share/doc/$(docsubdir)/*/*.txt
612         -cd $(prefix) ; dos2unix --keepdate share/doc/$(docsubdir)/*.$(HTMLEXT) dos2unix share/doc/$(docsubdir)/*/*.$(HTMLEXT)
613         cd $(prefix) ; tar cvjf $(TBZFILE) $(ZIPOBJ)
614         mv $(prefix)/$(TBZFILE) ..
615
616 dist: dist-tgz
617
618 strip:
619         $(STRIP) $(BIN)
620         $(STRIP) $(UNIX2DOS_BIN)
621 ifeq ($(LINK),cp -f)
622         $(STRIP) $(MAC2UNIX_BIN)
623         $(STRIP) $(UNIX2MAC_BIN)
624 endif
625
626 # End of file