1#   Copyright information
2#
3#       Copyright (C) 2009-2018 Erwin Waterlander
4#       Copyright (C) 2009 Jari Aalto
5#
6#   License
7#
8#       This program is free software; you can redistribute it and/or
9#       modify it under the terms of the GNU General Public License as
10#       published by the Free Software Foundation; either version 2 of the
11#       License, or (at your option) any later version
12#
13#       This program is distributed in the hope that it will be useful, but
14#       WITHOUT ANY WARRANTY; without even the implied warranty of
15#       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16#       General Public License for more details at
17#       Visit <http://www.gnu.org/copyleft/gpl.html>.
18#
19#   Description
20#
21#       This is a GNU Makefile that uses GNU compilers, linkers and cpp. The
22#       platform specific issues are determined by the various OS teets that
23#       rely on the uname(1) command and directory locations.
24#
25#   Developer notes
26#
27#       In order to clean generated POD files and manuals:
28#
29#           make maintainer-clean
30#
31#       Set additional flags for the build with variables CFLAGS_USER,
32#       DEFS_USER and LDFLAGS_USER.
33
34ifneq (,)
35This makefile requires GNU Make.
36endif
37
38include version.mk
39
40.PHONY: status uninstall install install-man install-doc install-pdf dist dist-zip dist-tgz
41.PHONY: doc man txt html ps pdf mofiles tags merge
42
43
44.PRECIOUS: %.1 %.pod
45
46CC              ?= gcc
47STATIC          =
48STRIP           = strip
49
50ENABLE_NLS = 1
51
52PACKAGE         = wcd
53EXT             = .exe
54PROGRAM         = $(PACKAGE)$(EXT)
55BIN             = $(PROGRAM)
56
57PREFIX          = /usr
58prefix          = $(PREFIX)
59exec_prefix     = $(prefix)
60bindir          = $(exec_prefix)/bin
61datarootdir     = $(prefix)/share
62datadir         = $(datarootdir)
63
64docsubdir       = $(PACKAGE)-$(VERSION)
65docdir          = $(datarootdir)/doc/$(docsubdir)
66localedir       = $(datarootdir)/locale
67sysconfdir      = /etc
68
69# 1 = regular, 5 = conf, 6 = games, 8 = daemons
70mandir          = $(datarootdir)/man
71man1dir         = $(mandir)/man1
72
73
74# On some systems (e.g. FreeBSD 4.10) GNU install is installed as `ginstall'.
75INSTALL         = install
76# On some systems (e.g. GNU Win32) GNU mkdir is installed as `gmkdir'.
77MKDIR           = mkdir
78
79INSTALL_PROGRAM = $(INSTALL) -m 755
80INSTALL_DATA    = $(INSTALL) -m 644
81INSTALL_SUID    = $(INSTALL) -m 4755
82
83INSTALL_OBJS_BIN   = $(BIN)
84HTMLEXT = htm
85
86# English manual
87MANFILES_EN  = man/man1/wcd.1
88TXTFILES_EN  = man/man1/wcd.txt
89HTMLFILES_EN  = man/man1/wcd.$(HTMLEXT)
90PSFILES_EN  = man/man1/wcd.ps
91PDFFILES_EN  = man/man1/wcd.pdf
92
93# Documents for end users, not for developers:
94INSTALL_OBJS_DOC   = \
95  ../doc/faq.txt \
96  ../doc/whatsnew.txt \
97  ../doc/README.txt \
98  ../doc/problems.txt \
99  ../doc/todo.txt \
100  ../doc/INSTALL.txt \
101  ../doc/UNIX.txt \
102  ../doc/copying.txt
103
104ifdef ENABLE_NLS
105POT             = po/$(PACKAGE).pot
106POFILES         = $(wildcard po/*.po)
107MOFILES         = $(patsubst %.po,%.mo,$(POFILES))
108NLSSUFFIX       = -nls
109endif
110
111# International manuals
112ifdef ENABLE_NLS
113MANPOTFILE      = po-man/wcd-man.pot
114MANPOFILES      = $(wildcard po-man/*.po)
115MANPODFILES     = $(patsubst po-man/%.po,man/%/man1/wcd.pod,$(MANPOFILES))
116endif
117MANFILES        = $(patsubst %.pod,%.1,$(MANPODFILES))
118TXTFILES        = $(patsubst %.pod,%.txt,$(MANPODFILES))
119HTMLFILES       = $(patsubst %.pod,%.$(HTMLEXT),$(MANPODFILES))
120PSFILES         = $(patsubst %.pod,%.ps,$(MANPODFILES))
121PDFFILES        = $(patsubst %.pod,%.pdf,$(MANPODFILES))
122
123CPP             = cpp
124CFLAGS_VERSION  = -DVERSION=\"$(VERSION)\" -DVERSION_DATE=\"$(VERSION_DATE)\"
125DEF_UNIX        = -DUNIX
126EXTRA_DEFS      =
127
128VERSIONSUFFIX   = -bin
129
130# Large File Support (LFS)
131LFS             = 1
132# DEBUG=1 adds the -g option to CFLAGS, for adding debug symbols.
133DEBUG = 0
134# DEBUGMSG=1 adds -DDEBUG=1 to CFLAGS, for extra verbose messages.
135DEBUGMSG = 0
136
137wcd_os := $(shell uname)
138
139# Enble Unicode
140UCS = 1
141ifdef WCD_UTF8
142        # WCD_UTF8 was used in older versions.
143        UCS=1
144endif
145ifdef UNINORM
146        UCS = 1
147endif
148
149
150ZIPOBJ          = bin/$(BIN) \
151                  share/man/man1/$(PACKAGE).1 \
152                  share/doc/$(docsubdir)/*.* \
153                  $(ZIPOBJ_EXTRA)
154
155INSTALL_TARGETS = install-bin install-man install-doc
156
157ifdef ENABLE_NLS
158        INSTALL_TARGETS += install-mo
159        ZIPOBJ += share/locale/*/LC_MESSAGES/$(PACKAGE).mo
160        ZIPOBJ += share/man/*/man1/$(PACKAGE).1
161        ZIPOBJ += share/doc/$(docsubdir)/*/*
162endif
163
164ifdef ENABLE_NLS
165        NLSDEFS    = -DENABLE_NLS -DLOCALEDIR=\"$(localedir)\" -DPACKAGE=\"$(PACKAGE)\"
166endif
167
168# ......................................................... OS flags ...
169
170OS =
171
172ifndef OS
173ifeq ($(findstring CYGWIN,$(wcd_os)),CYGWIN)
174        OS = cygwin
175endif
176endif
177
178ifndef OS
179ifeq ($(findstring MSYS,$(wcd_os)),MSYS)
180        OS = msys
181# MSYS 1 does not support locales and no Unicode.
182ifeq ($(shell ./chk_loc.sh en_US.utf8),no)
183        MSYS_VERSION=1
184else
185        MSYS_VERSION=2
186endif
187endif
188endif
189
190ifndef OS
191ifeq ($(findstring MINGW,$(wcd_os)),MINGW)
192        OS = mingw
193endif
194endif
195
196ifndef OS
197ifneq ($(DJGPP),)
198        OS = msdos
199endif
200endif
201
202ifndef OS
203ifneq (, $(wildcard /opt/csw))
204        OS = sun
205endif
206endif
207
208ifndef OS
209        OS=$(shell echo $(wcd_os) | tr '[A-Z]' '[a-z]')
210endif
211
212
213ifeq (cygwin,$(OS))
214ifdef ENABLE_NLS
215        LIBS_EXTRA    = -lintl -liconv -lmpr
216else
217        LIBS_EXTRA    = -lmpr
218endif
219        UNINORM = 1
220        LDFLAGS_EXTRA = -Wl,--enable-auto-import
221        INSTALL_TARGETS += install-profile
222        docsubdir       = $(PACKAGE)
223        MACHINE := $(subst -pc-cygwin,,$(shell gcc -dumpmachine))
224        VERSIONSUFFIX   = -cygwin-$(MACHINE)
225endif
226
227ifeq (os/2,$(OS))
228        prefix = c:/usr
229        PROGRAM = wcdos2.exe
230        DEF_UNIX =
231        UCS =
232        UNINORM =
233        LDFLAGS_EXTRA = -Zhigh-mem -Zomf -Zargs-resp
234        ZIPOBJ_EXTRA=bin/wcd.cmd
235        VERSIONSUFFIX = -os2
236        LIBS_EXTRA =
237ifdef ENABLE_NLS
238        LIBS_EXTRA += -lintl
239endif
240endif
241
242ifeq (mingw,$(OS))
243        CC = gcc
244        DEF_UNIX =
245        LIBS_EXTRA = -lkernel32 -luser32 -lmpr
246ifdef ENABLE_NLS
247        LIBS_EXTRA += -lintl -liconv
248endif
249endif
250
251ifeq (msdos,$(OS))
252        CC = gcc
253        DEF_UNIX =
254        UCS =
255        UNINORM =
256endif
257
258ifeq (msys,$(OS))
259        CC = gcc
260        CFLAGS_OS = -DWCD_MSYS
261        PROGRAM = wcdmsys.exe
262        LIBS_EXTRA  = -lkernel32 -luser32 -lmpr
263        MACHINE := $(subst -pc-msys,,$(shell gcc -dumpmachine))
264ifeq ($(MSYS_VERSION),1)
265        UCS =
266        UNINORM =
267        VERSIONSUFFIX = -msys1-$(MACHINE)-$(CURSES)
268else
269        UCS = 1
270        UNINORM = 1
271        VERSIONSUFFIX = -msys2-$(MACHINE)
272endif
273ifdef ENABLE_NLS
274        LIBS_EXTRA += -lintl -liconv
275endif
276endif
277
278ifeq (dragonfly,$(OS))
279	# Running under DragonFly
280ifdef ENABLE_NLS
281	CFLAGS_OS     = -I/usr/local/include
282	LDFLAGS_EXTRA = -L/usr/local/lib
283	LIBS_EXTRA    = -lintl
284endif
285endif
286
287ifeq (freebsd,$(OS))
288        # Running under FreeBSD
289ifdef ENABLE_NLS
290        CFLAGS_OS     = -I/usr/local/include
291        LDFLAGS_EXTRA = -L/usr/local/lib
292        LIBS_EXTRA    = -lintl
293endif
294endif
295
296ifeq (darwin, $(OS))
297ifdef ENABLE_NLS
298        CFLAGS_OS     = -I/usr/local/include
299        LDFLAGS_EXTRA = -L/usr/local/lib
300        LIBS_EXTRA    = -lintl
301endif
302endif
303
304
305ifeq (sun,$(OS))
306        # Running under SunOS/Solaris
307        LIBS_EXTRA = -lintl
308endif
309
310ifeq (hp-ux,$(OS))
311        # Running under HP-UX
312        EXTRA_DEFS += -Dhpux -D_HPUX_SOURCE -D_XOPEN_SOURCE_EXTENDED
313
314        # These flags were for native HP compiler
315        # CFLAGS_OS = -O -Aa
316endif
317
318# .......................................................... unicode ...
319
320ifdef UCS
321        CFLAGS_UCS = -std=gnu99
322        WDEFS      = -DWCD_UNICODE
323endif
324ifdef UNINORM
325        CFLAGS_UCS = -std=gnu99
326        WDEFS      = -DWCD_UNICODE -DWCD_UNINORM
327        LIB_UNISTRING  = -lunistring
328endif
329
330ifdef UCS
331UCSSUFFIX = -ucs
332EXTRA_OBJ += matchw.o
333endif
334
335# ........................................................... curses ...
336
337# possible values: ncurses, curses, pdcurses, pdcursesw or <empty>
338
339ifdef UCS
340        CURSES = ncursesw
341else
342        CURSES = ncurses
343endif
344
345
346# The default console for msys1 is the cmd.exe console.  rxvt and mintty are
347# available for msys1, but I guess most people use cmd, console, or conemu for
348# msys1.  Therefore we use pdcurses for msys1.  msys2's default console is
349# mintty. For msys2 we use ncurses.
350ifeq (msys,$(OS))
351ifeq ($(MSYS_VERSION),1)
352        CURSES = pdcurses
353endif
354endif
355
356# The native Windows versions use PDCurses, because there are problems
357# with the ncurses mingw port.
358# All native Windows versions (with and without Unicode support) use wide
359# (Unicode) curses functions.
360ifeq (mingw,$(OS))
361        CURSES = pdcursesw
362endif
363
364ifdef CURSES
365ifdef UCS
366EXTRA_OBJ += wcwidth.o
367endif
368endif
369
370ifneq (,$(CURSES))
371        DEFS_CURSES = -DWCD_USECURSES
372        LIB_CURSES  = -l$(CURSES)
373ifeq (os/2,$(OS))
374        LIB_CURSES  += -ltinfo
375endif
376endif
377
378
379INCPREFIX=/usr
380ifeq ($(findstring MINGW,$(wcd_os)),MINGW)
381ifeq ($(shell gcc -dumpmachine),i686-w64-mingw32)
382INCPREFIX=/mingw32
383CFLAGS_COMPILER = -DWCD_MINGW32_W64=1
384else
385ifeq ($(shell gcc -dumpmachine),x86_64-w64-mingw32)
386INCPREFIX=/mingw64
387else
388INCPREFIX=/mingw
389endif
390endif
391endif
392
393# Each ncurses variant has its own include directory
394# ncurses (normal)/ncursesw (wide char)/ncursest (threads)
395ifeq ($(findstring ncurses,$(CURSES)),ncurses)
396ifneq ($(wildcard $(INCPREFIX)/include/$(CURSES)/curses.h),)
397        INCFLAGS = -I$(INCPREFIX)/include/$(CURSES) -I$(INCPREFIX)/include
398endif
399ifeq ($(NCURSES_DEBUG), 1)
400        LIB_CURSES  = -l$(CURSES)_g
401endif
402else
403        INCFLAGS = -I$(INCPREFIX)/include
404endif
405
406ifeq ($(CURSES),ncursesw)
407        EXTRA_DEFS += -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED
408endif
409
410ifeq ($(CURSES),pdcursesw)
411        EXTRA_DEFS += -DPDC_STATIC_BUILD -DPDC_WIDE
412endif
413
414# Local installation prefix of ncurses.
415#LOCAL_NCURSES  = $(HOME)
416#
417#ifneq (, $(wildcard $(LOCAL_NCURSES)/include/ncurses.h))
418#       NCFLAG = -I$(LOCAL_NCURSES)/include
419#       NLFLAG = -L$(LOCAL_NCURSES)/lib
420#endif
421
422# ............................................................ flags ...
423
424# Statically linking of a specific library can be done by linking
425# to a lib*.a library file instead a lib*.s* library file.
426# To link ncurses statically (if your system links by default
427# dynamically) comment the LDFLAGS line and add the 'libncurses.a' file
428# (often found as /usr/lib/libncurses.a) to the OBJS1 list.
429
430CFLAGS_USER     =
431ifeq ($(DEBUG), 1)
432CFLAGS_OPT = -O0
433else
434CFLAGS_OPT = -O2
435endif
436
437CFLAGS  ?=
438CFLAGS  += $(CFLAGS_OPT)
439ifeq ($(DEBUG), 1)
440        CFLAGS += -g
441endif
442CFLAGS  += -Wall -Wextra -Wno-unused-parameter -Wconversion $(RPM_OPT_FLAGS) $(CPPFLAGS) $(CFLAGS_USER)
443
444
445EXTRA_CFLAGS    = -Ic3po \
446                  $(CFLAGS_VERSION) \
447                  $(CFLAGS_OS) \
448                  $(CFLAGS_UCS) \
449                  $(CFLAGS_COMPILER) \
450                  $(WDEFS) \
451                  $(NLSDEFS) \
452                  $(NCFLAG) \
453                  $(INCFLAGS) \
454                  -DDEBUG=$(DEBUGMSG)
455
456ifdef LFS
457        EXTRA_CFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
458endif
459
460ifdef ASCII_TREE
461        EXTRA_CFLAGS += -DASCII_TREE
462endif
463
464ifdef STATIC
465        LDFLAG_STATIC = -static
466endif
467
468LDFLAGS_USER   =
469LDFLAGS ?=
470LDFLAGS += $(RPM_LD_FLAGS) \
471           $(LDFLAGS_EXTRA) \
472           $(NLFLAG) \
473           $(LDFLAG_STATIC) \
474           $(LDFLAGS_USER)
475
476LIBS = $(LIB_CURSES) \
477       $(LIB_UNISTRING) \
478       $(LIBS_EXTRA)
479
480DEFS_USER   =
481DEFS            = $(DEF_UNIX) $(DEFS_CURSES) $(EXTRA_DEFS) $(DEFS_USER)
482
483# .......................................................... targets ...
484
485OBJS1 = \
486        wcd.o \
487        match.o \
488        stack.o \
489        nameset.o \
490        intset.o \
491        Error.o \
492        Text.o \
493        WcdStack.o \
494        dirnode.o \
495        display.o \
496        wfixpath.o \
497        wcddir.o \
498        matchl.o \
499        querycp.o \
500        finddirs.o \
501        $(EXTRA_OBJ)
502
503ifneq (,$(CURSES))
504OBJS1 += colors.o \
505        graphics.o
506endif
507
508all: $(BIN) doc mofiles man
509
510status:
511	@echo "-- $(PACKAGE) Makefile settings begin --"
512	@echo "OS            = $(OS)"
513	@echo "prefix        = $(prefix)"
514	@echo "EXT           = $(EXT)"
515	@echo "UNINORM       = $(UNINORM)"
516	@echo "STATIC        = $(STATIC)"
517	@echo "UCS           = $(UCS)"
518	@echo "ENABLE_NLS    = $(ENABLE_NLS)"
519	@echo "CURSES        = $(CURSES)"
520	@echo "DEFS          = $(DEFS)"
521	@echo "DEFS_CURSES   = $(DEFS_CURSES)"
522	@echo "EXTRA_DEFS    = $(EXTRA_DEFS)"
523	@echo "LDFLAGS       = $(LDFLAGS)"
524	@echo "LDFLAGS_EXTRA = $(LDFLAGS_EXTRA)"
525	@echo "LIBS          = $(LIBS)"
526	@echo "CFLAGS        = $(CFLAGS)"
527	@echo "CFLAGS_OS     = $(CFLAGS_OS)"
528	@echo "EXTRA_CFLAGS  = $(EXTRA_CFLAGS)"
529	@echo "DEBUG         = $(DEBUG)"
530	@echo "DEBUGMSG      = $(DEBUGMSG)"
531	@echo "-- $(PACKAGE) Makefile settings end --"
532
533$(BIN): $(OBJS1)
534	$(MAKE) status
535	$(CC) $(OBJS1) $(LDFLAGS) $(LIBS) -o $@
536
537%.o: %.c
538	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(DEFS) -c $< -o $@
539
540wcd.o: wcd.c wcd.h version.mk
541	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(DEFS) -c $< -o $@
542
543%.o: c3po/%.c
544	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(DEFS) -c $< -o $@
545
546%.pdf: %.ps
547	ps2pdf $< $@
548
549$(MANPOTFILE) : man/man1/wcd.pod
550	$(MAKE) -C man/man1 ../../po-man/$(notdir $@)
551
552#  WARNING: Backward-incompatibility since GNU make 3.82.
553#  The pattern-specific variables and pattern rules are now applied in the
554#  shortest stem first order instead of the definition order (variables
555#  and rules with the same stem length are still applied in the definition
556#  order).
557#  In order to stay compatible with GNU make < 3.82 we put the rule with
558#  the shortest stem first.
559
560po/%.po : $(POT)
561	msgmerge --no-wrap -U $@ $(POT) --backup=numbered
562	# change timestamp in case .po file was not updated.
563	touch $@
564
565%.po : man/man1/wcd.pod
566	$(MAKE) -C man/man1 $(subst po-man/,../../po-man/,$@)
567
568man/%/man1/wcd.pod : po-man/%.po
569	$(MAKE) -C man/man1 $(subst man/,../,$@)
570
571# Empty recipe to break circular dependency.
572man/man1/wcd.pod : ;
573
574%.1 : %.pod
575	$(MAKE) -C man/man1 PODCENTER=$(VERSION_DATE) $(subst man/,../,$@)
576
577%.txt : %.pod
578	pod2text $< > $@
579
580%.ps : %.1
581	groff -man $< -T ps > $@
582
583%.$(HTMLEXT) : %.pod
584	PERL_UNICODE=SDA pod2html --title="$(PACKAGE) $(VERSION) - Wherever Change Directory" $< > $@
585
586man/uk/man1/$(PACKAGE).$(HTMLEXT) : man/uk/man1/$(PACKAGE).pod
587	PERL_UNICODE=SDA pod2html --title="$(PACKAGE) $(VERSION) - довільна зміна каталогу (Wherever Change Directory)" $< > $@
588
589
590man: $(MANFILES_EN) $(MANFILES) $(MANPOTFILE)
591
592html: $(HTMLFILES_EN) $(HTMLFILES)
593
594txt: $(TXTFILES_EN) $(TXTFILES)
595
596ps: $(PSFILES_EN) $(PSFILES)
597
598pdf: $(PDFFILES_EN) $(PDFFILES)
599
600mofiles: $(MOFILES)
601
602doc: txt html
603
604tags: $(POT)
605
606merge: $(POFILES)
607
608# Get new po files from the Translation Project.
609getpo:
610	rsync -Lrtvz  translationproject.org::tp/latest/wcd/  po/incoming/
611
612getpoman:
613	rsync -Lrtvz  translationproject.org::tp/latest/wcd-man/  po-man/incoming/
614
615%.mo : %.po
616	msgfmt -c $< -o $@
617
618$(POT) : wcd.c wcddir.c stack.c display.c graphics.c wfixpath.c finddirs.c c3po/Error.c
619	xgettext --no-wrap -C --keyword=_ $+ -o $(POT)
620
621ZIPFILE = $(PACKAGE)-$(VERSION)$(VERSIONSUFFIX)$(NLSSUFFIX)$(UCSSUFFIX).zip
622TGZFILE = $(PACKAGE)-$(VERSION)$(VERSIONSUFFIX)$(NLSSUFFIX)$(UCSSUFFIX).tar.gz
623
624dist-zip:
625	rm -f $(prefix)/$(ZIPFILE)
626	cd $(prefix) ; zip -r $(ZIPFILE) $(ZIPOBJ)
627	mv -f $(prefix)/$(ZIPFILE) ../..
628
629dist-tgz:
630	cd $(prefix) ; tar cvzf $(TGZFILE) $(ZIPOBJ)
631	mv -f $(prefix)/$(TGZFILE) ../..
632
633dist: dist-tgz
634
635
636strip:
637	@echo "-- target: strip"
638	$(STRIP) $(BIN)
639
640mostlyclean:
641	@echo "-- target: mostlyclean"
642	-rm -f \
643		$(BIN) \
644		*.exe \
645		*.o \
646		*.tmp \
647		*/*.o \
648		po/*.mo \
649		../*/*.bck \
650		../*/*.bak \
651		../*/*[#~] \
652		*.\#* \
653		*/*.bak \
654		*/*.bck \
655		*/*~ \
656		*/*/*.bak \
657		*/*/*~ \
658		*/*/*/*.bak \
659		*/*/*/*~ \
660		*.stackdump
661
662clean: mostlyclean
663	@echo "-- target: clean"
664	rm -f man/man1/*.ps
665	rm -f man/man1/*.pdf
666	rm -f man/*/man1/*.ps
667	rm -f man/*/man1/*.pdf
668
669distclean: clean
670	@echo "-- target: distclean"
671
672maintainer-clean: distclean
673	@echo "-- target: maintainer-clean:"
674	rm -f man/man1/*.1
675	rm -f man/man1/*.txt
676	rm -f man/man1/*.$(HTMLEXT)
677	rm -f po-man/wcd-man.pot
678	rm -f man/*/man1/*.1
679	rm -f man/*/man1/*.txt
680	rm -f man/*/man1/*.pod
681	rm -f man/*/man1/*.$(HTMLEXT)
682
683# 'maintainer-clean' was 'realclean' in old GNU standards.
684realclean: maintainer-clean
685
686# Install shell function (sh) and alias (csh).
687# If DOTWCD=1, the shell scripts define WCDHOME=$HOME/.wcd
688install-profile:
689	@echo "-- target: install-profile"
690	mkdir -p $(DESTDIR)$(sysconfdir)/profile.d
691ifdef DOTWCD
692	sed -e "s#BINDIR#$(bindir)#" -e "s/PROGRAM/$(BIN)/" -e 's/##//' etc/profile.d/wcd.sh > $(DESTDIR)$(sysconfdir)/profile.d/wcd.sh
693	sed -e "s#BINDIR#$(bindir)#" -e "s/PROGRAM/$(BIN)/" -e 's/##//' etc/profile.d/wcd.csh > $(DESTDIR)$(sysconfdir)/profile.d/wcd.csh
694else
695	sed -e "s#BINDIR#$(bindir)#" -e "s/PROGRAM/$(BIN)/" etc/profile.d/wcd.sh > $(DESTDIR)$(sysconfdir)/profile.d/wcd.sh
696	sed -e "s#BINDIR#$(bindir)#" -e "s/PROGRAM/$(BIN)/" etc/profile.d/wcd.csh > $(DESTDIR)$(sysconfdir)/profile.d/wcd.csh
697endif
698
699# Old versions of install(1) don't support option -D. Use
700# mkdir instead. Was seen on HP-UX 11 and DOS DJGPP.
701
702install-mo: mofiles
703	@echo "-- target: install-mo"
704	$(foreach mofile, $(MOFILES), $(MKDIR) -p -m 755 $(DESTDIR)$(localedir)/$(basename $(notdir $(mofile)))/LC_MESSAGES ;)
705	$(foreach mofile, $(MOFILES), $(INSTALL_DATA) $(mofile) $(DESTDIR)$(localedir)/$(basename $(notdir $(mofile)))/LC_MESSAGES/$(PACKAGE).mo ;)
706
707install-doc: doc
708	@echo "-- target: install-doc"
709	$(MKDIR) -p -m 755 $(DESTDIR)$(docdir)
710	$(INSTALL_DATA) $(INSTALL_OBJS_DOC) $(DESTDIR)$(docdir)
711	$(INSTALL_DATA) $(TXTFILES_EN) $(DESTDIR)$(docdir)
712	$(INSTALL_DATA) $(HTMLFILES_EN) $(DESTDIR)$(docdir)
713ifdef ENABLE_NLS
714	$(foreach txtfile, $(TXTFILES), $(MKDIR) -p -m 755 $(DESTDIR)$(docdir)/$(word 2,$(subst /, ,$(txtfile),)) ;)
715	$(foreach txtfile, $(TXTFILES), $(INSTALL_DATA) $(txtfile) $(DESTDIR)$(docdir)/$(word 2,$(subst /, ,$(txtfile),)) ;)
716	$(foreach htmlfile, $(HTMLFILES), $(MKDIR) -p -m 755 $(DESTDIR)$(docdir)/$(word 2,$(subst /, ,$(htmlfile),)) ;)
717	$(foreach htmlfile, $(HTMLFILES), $(INSTALL_DATA) $(htmlfile) $(DESTDIR)$(docdir)/$(word 2,$(subst /, ,$(htmlfile),)) ;)
718endif
719
720# No dependency. Install pdf/ps only when they have been manually generated.
721install-pdf:
722	@echo "-- target: install-pdf"
723	$(MKDIR) -p -m 755 $(DESTDIR)$(docdir)
724	$(foreach pdffile, $(wildcard man/man1/*.pdf), $(INSTALL_DATA) $(pdffile) $(DESTDIR)$(docdir) ;)
725	$(foreach psfile, $(wildcard man/man1/*.ps), $(INSTALL_DATA) $(psfile) $(DESTDIR)$(docdir) ;)
726ifdef ENABLE_NLS
727	$(foreach pdffile, $(wildcard man/*/man1/*.pdf), $(MKDIR) -p -m 755 $(DESTDIR)$(docdir)/$(word 2,$(subst /, ,$(pdffile),)) ;)
728	$(foreach pdffile, $(wildcard man/*/man1/*.pdf), $(INSTALL_DATA) $(pdffile) $(DESTDIR)$(docdir)/$(word 2,$(subst /, ,$(pdffile),)) ;)
729	$(foreach psfile, $(wildcard man/*/man1/*.ps), $(MKDIR) -p -m 755 $(DESTDIR)$(docdir)/$(word 2,$(subst /, ,$(psfile),)) ;)
730	$(foreach psfile, $(wildcard man/*/man1/*.ps), $(INSTALL_DATA) $(psfile) $(DESTDIR)$(docdir)/$(word 2,$(subst /, ,$(psfile),)) ;)
731endif
732
733install-man: man
734	@echo "-- target: install-man"
735	$(MKDIR) -p -m 755 $(DESTDIR)$(man1dir)
736	$(INSTALL_DATA) $(MANFILES_EN) $(DESTDIR)$(man1dir)
737ifdef ENABLE_NLS
738	$(foreach manfile, $(MANFILES), $(MKDIR) -p -m 755 $(DESTDIR)$(prefix)/$(dir $(manfile)) ;)
739	$(foreach manfile, $(MANFILES), $(INSTALL_DATA) $(manfile) $(DESTDIR)$(prefix)/$(dir $(manfile)) ;)
740endif
741
742install-bin: $(BIN)
743	@echo "-- target: install-bin"
744	$(MKDIR) -p -m 755 $(DESTDIR)$(bindir)
745	$(INSTALL_PROGRAM) $(INSTALL_OBJS_BIN) $(DESTDIR)$(bindir)
746ifeq (os/2,$(OS))
747	$(INSTALL_PROGRAM) ../os2/$(PACKAGE).cmd $(DESTDIR)$(bindir)
748endif
749
750install: $(INSTALL_TARGETS)
751	# Run a new instance of 'make' otherwise the $$(wildcard ) function my not have been expanded,
752	# because the files may not have been there when make was started.
753	$(MAKE) install-pdf
754
755uninstall:
756	@echo "-- target: uninstall"
757	-rm -f $(DESTDIR)$(bindir)/$(BIN)
758	-rm -f $(DESTDIR)$(mandir)/man1/$(PACKAGE).1
759	-rm -rf $(DESTDIR)$(docdir)
760ifdef ENABLE_NLS
761	$(foreach mofile, $(MOFILES), rm -f $(DESTDIR)$(localedir)/$(basename $(notdir $(mofile)))/LC_MESSAGES/$(PACKAGE).mo ;)
762	$(foreach manfile, $(MANFILES), rm -f $(DESTDIR)$(prefix)/$(manfile) ;)
763endif
764
765# End of file
766