fe01d9ce702ffb24a5c4573d5798ca63ccd628ca
[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 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 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 -Wextra -Wconversion $(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 dos2unix.h unix2dos.h version.mk
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
320         $(CC) $(DEFS) $(EXTRA_CFLAGS) $(DOS2UNIX_NLSDEFS) $(CFLAGS) -c $< -o $@
321
322 unix2dos.o : unix2dos.c unix2dos.h querycp.h common.h
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 test: all
433         cd test; $(MAKE) test
434
435 check: test
436
437 install: all
438         $(MKDIR) -p -m 755 $(DESTDIR)$(bindir)
439         $(INSTALL)  -m 755 $(BIN) $(DESTDIR)$(bindir)
440         $(INSTALL)  -m 755 $(UNIX2DOS_BIN) $(DESTDIR)$(bindir)
441 ifeq ($(LINK),cp -f)
442         $(INSTALL)  -m 755 $(MAC2UNIX_BIN) $(DESTDIR)$(bindir)
443         $(INSTALL)  -m 755 $(UNIX2MAC_BIN) $(DESTDIR)$(bindir)
444 else
445         cd $(DESTDIR)$(bindir); $(LINK) $(BIN) $(MAC2UNIX_BIN)
446         cd $(DESTDIR)$(bindir); $(LINK) $(UNIX2DOS_BIN) $(UNIX2MAC_BIN)
447 endif
448         $(MKDIR) -p -m 755 $(DESTDIR)$(man1dir)
449         $(INSTALL)  -m 644 man/man1/$(PACKAGE).1 $(DESTDIR)$(man1dir)
450 ifeq ($(LINK_MAN),cp -f)
451         $(INSTALL)  -m 644 man/man1/$(PACKAGE).1 $(DESTDIR)$(man1dir)/$(MAC2UNIX).1
452         $(INSTALL)  -m 644 man/man1/$(PACKAGE).1 $(DESTDIR)$(man1dir)/$(UNIX2DOS).1
453         $(INSTALL)  -m 644 man/man1/$(PACKAGE).1 $(DESTDIR)$(man1dir)/$(UNIX2MAC).1
454 else
455         cd $(DESTDIR)$(man1dir); $(LINK_MAN) $(PACKAGE).1 $(MAC2UNIX).1
456         cd $(DESTDIR)$(man1dir); $(LINK_MAN) $(PACKAGE).1 $(UNIX2DOS).1
457         cd $(DESTDIR)$(man1dir); $(LINK_MAN) $(PACKAGE).1 $(UNIX2MAC).1
458 endif
459         $(foreach manfile, $(MANFILES), $(MKDIR) -p -m 755 $(DESTDIR)$(datarootdir)/$(dir $(manfile)) ;)
460         $(foreach manfile, $(MANFILES), $(INSTALL) -m 644 $(manfile) $(DESTDIR)$(datarootdir)/$(dir $(manfile)) ;)
461         $(foreach manfile, $(MANFILES), cd $(DESTDIR)$(datarootdir)/$(dir $(manfile)) ; $(LINK_MAN) $(PACKAGE).1 $(MAC2UNIX).1 ;)
462         $(foreach manfile, $(MANFILES), cd $(DESTDIR)$(datarootdir)/$(dir $(manfile)) ; $(LINK_MAN) $(PACKAGE).1 $(UNIX2DOS).1 ;)
463         $(foreach manfile, $(MANFILES), cd $(DESTDIR)$(datarootdir)/$(dir $(manfile)) ; $(LINK_MAN) $(PACKAGE).1 $(UNIX2MAC).1 ;)
464 ifdef ENABLE_NLS
465         @echo "-- install-mo"
466         $(foreach mofile, $(MOFILES), $(MKDIR) -p -m 755 $(DESTDIR)$(localedir)/$(basename $(notdir $(mofile)))/LC_MESSAGES ;)
467         $(foreach mofile, $(MOFILES), $(INSTALL) -m 644 $(mofile) $(DESTDIR)$(localedir)/$(basename $(notdir $(mofile)))/LC_MESSAGES/$(PACKAGE).mo ;)
468 endif
469         # Run a new instance of 'make' otherwise the $$(wildcard ) function my not have been expanded,
470         # because the files may not have been there when make was started.
471         $(MAKE) install-doc
472
473
474 install-doc: $(INSTALL_OBJS_DOC)
475         @echo "-- install-doc"
476         $(MKDIR) -p -m 755 $(DESTDIR)$(docdir)
477         $(INSTALL) -m 644 $(INSTALL_OBJS_DOC) $(DESTDIR)$(docdir)
478         # Install translated manuals when they have been generated.
479         $(foreach txtfile, $(wildcard man/*/man1/*.txt), $(MKDIR) -p -m 755 $(DESTDIR)$(docdir)/$(word 2,$(subst /, ,$(txtfile),)) ;)
480         $(foreach txtfile, $(wildcard man/*/man1/*.txt), $(INSTALL) -m 644 $(txtfile) $(DESTDIR)$(docdir)/$(word 2,$(subst /, ,$(txtfile),)) ;)
481         $(foreach htmlfile, $(wildcard man/*/man1/*.$(HTMLEXT)), $(MKDIR) -p -m 755 $(DESTDIR)$(docdir)/$(word 2,$(subst /, ,$(htmlfile),)) ;)
482         $(foreach htmlfile, $(wildcard man/*/man1/*.$(HTMLEXT)), $(INSTALL) -m 644 $(htmlfile) $(DESTDIR)$(docdir)/$(word 2,$(subst /, ,$(htmlfile),)) ;)
483         $(foreach pdffile, $(wildcard man/*/man1/*.pdf), $(MKDIR) -p -m 755 $(DESTDIR)$(docdir)/$(word 2,$(subst /, ,$(pdffile),)) ;)
484         $(foreach pdffile, $(wildcard man/*/man1/*.pdf), $(INSTALL) -m 644 $(pdffile) $(DESTDIR)$(docdir)/$(word 2,$(subst /, ,$(pdffile),)) ;)
485         $(foreach pdffile, $(wildcard man/man1/*.pdf), $(INSTALL) -m 644 $(pdffile) $(DESTDIR)$(docdir) ;)
486         $(foreach psfile, $(wildcard man/*/man1/*.ps), $(MKDIR) -p -m 755 $(DESTDIR)$(docdir)/$(word 2,$(subst /, ,$(psfile),)) ;)
487         $(foreach psfile, $(wildcard man/*/man1/*.ps), $(INSTALL) -m 644 $(psfile) $(DESTDIR)$(docdir)/$(word 2,$(subst /, ,$(psfile),)) ;)
488         $(foreach psfile, $(wildcard man/man1/*.ps), $(INSTALL) -m 644 $(psfile) $(DESTDIR)$(docdir) ;)
489
490 uninstall:
491         @echo "-- target: uninstall"
492         -rm -f $(DESTDIR)$(bindir)/$(BIN)
493         -rm -f $(DESTDIR)$(bindir)/$(MAC2UNIX_BIN)
494         -rm -f $(DESTDIR)$(bindir)/$(UNIX2DOS_BIN)
495         -rm -f $(DESTDIR)$(bindir)/$(UNIX2MAC_BIN)
496 ifdef ENABLE_NLS
497         $(foreach mofile, $(MOFILES), rm -f $(DESTDIR)$(localedir)/$(basename $(notdir $(mofile)))/LC_MESSAGES/$(PACKAGE).mo ;)
498 endif
499         -rm -f $(DESTDIR)$(mandir)/man1/$(PACKAGE).1
500         -rm -f $(DESTDIR)$(mandir)/man1/$(MAC2UNIX).1
501         -rm -f $(DESTDIR)$(mandir)/man1/$(UNIX2DOS).1
502         -rm -f $(DESTDIR)$(mandir)/man1/$(UNIX2MAC).1
503         $(foreach manfile, $(MANFILES), rm -f $(DESTDIR)$(datarootdir)/$(manfile) ;)
504         -rm -rf $(DESTDIR)$(docdir)
505
506 mostlyclean:
507         rm -f *.o
508         rm -f $(BIN) $(UNIX2DOS_BIN) $(MAC2UNIX_BIN) $(UNIX2MAC_BIN)
509         rm -f *.bak *~
510         rm -f *.tmp
511         rm -f man/man1/*.bak man/man1/*~
512         rm -f man/*/man1/*.bak man/*/man1/*~
513         rm -f po/*.bak po/*~
514         rm -f po/*.mo
515         cd test; $(MAKE) clean
516
517 # Don't distribute PostScript and PDF manuals in the source package.
518 # We don't want binary PDF files in the source package, because
519 # some packagers check in the source files. PostScript is not used
520 # a lot.
521
522 clean: mostlyclean
523         rm -f man/man1/*.ps
524         rm -f man/man1/*.pdf
525         rm -f man/*/man1/*.ps
526         rm -f man/*/man1/*.pdf
527
528 distclean: clean
529
530 # Because there is so much trouble with generating man pages with
531 # pod2man, due to old Perl versions (< 5.10.1) on many systems, I include the
532 # man pages in the source tar file.
533 # Old pod2man versions do not have the --utf8 option. Old pod2man, pod2text,
534 # and pod2html do not support the =encoding command.
535 # Perl 5.18 pod2man demands an =encoding command for Latin-1 encoded POD files.
536 #
537 # Newer perl/pod2man versions produce better output. It is better to include
538 # man pages in the source package, than that people generate them themselves
539 # with old perl versions.
540
541 maintainer-clean: distclean
542         @echo 'This command is intended for maintainers to use; it'
543         @echo 'deletes files that may need special tools to rebuild.'
544         rm -f man/man1/*.1
545         rm -f man/man1/*.txt
546         rm -f man/man1/*.$(HTMLEXT)
547         rm -f man/man1/dos2unix-man.pot
548         rm -f man/*/man1/*.1
549         rm -f man/*/man1/*.txt
550         rm -f man/*/man1/*.pod
551         rm -f man/*/man1/*.$(HTMLEXT)
552
553 realclean: maintainer-clean
554
555
556 ZIPOBJ  = bin/$(BIN) \
557           bin/$(MAC2UNIX_BIN) \
558           bin/$(UNIX2DOS_BIN) \
559           bin/$(UNIX2MAC_BIN) \
560           share/man/man1/$(PACKAGE).1 \
561           share/man/man1/$(MAC2UNIX).1 \
562           share/man/man1/$(UNIX2DOS).1 \
563           share/man/man1/$(UNIX2MAC).1 \
564           share/man/*/man1/$(PACKAGE).1 \
565           share/man/*/man1/$(MAC2UNIX).1 \
566           share/man/*/man1/$(UNIX2DOS).1 \
567           share/man/*/man1/$(UNIX2MAC).1 \
568           share/doc/$(docsubdir) \
569           $(ZIPOBJ_EXTRA)
570
571 ifdef ENABLE_NLS
572 ZIPOBJ += share/locale/*/LC_MESSAGES/$(PACKAGE).mo
573 endif
574
575 ZIPFILE = $(PACKAGE)-$(DOS2UNIX_VERSION)$(VERSIONSUFFIX)$(NLSSUFFIX).zip
576 TGZFILE = $(PACKAGE)-$(DOS2UNIX_VERSION)$(VERSIONSUFFIX)$(NLSSUFFIX).tar.gz
577 TBZFILE = $(PACKAGE)-$(DOS2UNIX_VERSION)$(VERSIONSUFFIX)$(NLSSUFFIX).tar.bz2
578
579 dist-zip:
580         rm -f $(prefix)/$(ZIPFILE)
581         cd $(prefix) ; unix2dos --keepdate share/man/man1/*.1 share/man/*/man1/*.1
582         -cd $(prefix) ; unix2dos --keepdate --add-bom share/doc/$(docsubdir)/*.txt share/doc/$(docsubdir)/*/*.txt
583         -cd $(prefix) ; unix2dos --keepdate share/doc/$(docsubdir)/*.$(HTMLEXT) share/doc/$(docsubdir)/*/*.$(HTMLEXT)
584         cd $(prefix) ; unix2dos --keepdate share/man/*/man1/$(PACKAGE).1 share/man/*/man1/$(MAC2UNIX).1 share/man/*/man1/$(UNIX2DOS).1 share/man/*/man1/$(UNIX2MAC).1
585         cd $(prefix) ; zip -r $(ZIPFILE) $(ZIPOBJ)
586         mv -f $(prefix)/$(ZIPFILE) ..
587
588 dist-tgz:
589         cd $(prefix) ; dos2unix --keepdate share/man/man1/*.1 share/man/*/man1/*.1
590         -cd $(prefix) ; dos2unix --keepdate share/doc/$(docsubdir)/*.txt share/doc/$(docsubdir)/*/*.txt
591         -cd $(prefix) ; dos2unix --keepdate share/doc/$(docsubdir)/*.$(HTMLEXT) share/doc/$(docsubdir)/*/*.$(HTMLEXT)
592         cd $(prefix) ; tar cvzf $(TGZFILE) $(ZIPOBJ)
593         mv $(prefix)/$(TGZFILE) ..
594
595 dist-tbz:
596         cd $(prefix) ; dos2unix --keepdate share/man/man1/*.1 share/man/*/man1/*.1
597         -cd $(prefix) ; dos2unix --keepdate share/doc/$(docsubdir)/*.txt dos2unix share/doc/$(docsubdir)/*/*.txt
598         -cd $(prefix) ; dos2unix --keepdate share/doc/$(docsubdir)/*.$(HTMLEXT) dos2unix share/doc/$(docsubdir)/*/*.$(HTMLEXT)
599         cd $(prefix) ; tar cvjf $(TBZFILE) $(ZIPOBJ)
600         mv $(prefix)/$(TBZFILE) ..
601
602 dist: dist-tgz
603
604 strip:
605         $(STRIP) $(BIN)
606         $(STRIP) $(UNIX2DOS_BIN)
607 ifeq ($(LINK),cp -f)
608         $(STRIP) $(MAC2UNIX_BIN)
609         $(STRIP) $(UNIX2MAC_BIN)
610 endif
611
612 # End of file