1 # Author: Erwin Waterlander
3 # Copyright (C) 2009-2012 Erwin Waterlander
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
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
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.
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.
33 # Set additional flags for the build with variables CFLAGS_USER,
34 # DEFS_USER and LDFLAGS_USER.
48 # Native Language Support (NLS)
50 # Large File Support (LFS)
57 BIN = $(PACKAGE)$(EXE)
58 UNIX2DOS_BIN = $(UNIX2DOS)$(EXE)
59 MAC2UNIX_BIN = $(MAC2UNIX)$(EXE)
60 UNIX2MAC_BIN = $(UNIX2MAC)$(EXE)
62 # DJGPP support linking of .EXEs via 'stubify'.
63 # See djgpp.mak and http://www.delorie.com/djgpp/v2faq/faq22_5.html
69 exec_prefix = $(prefix)
70 bindir = $(exec_prefix)/bin
71 datarootdir = $(prefix)/share
72 datadir = $(datarootdir)
74 docsubdir = $(PACKAGE)-$(DOS2UNIX_VERSION)
75 docdir = $(datarootdir)/doc/$(docsubdir)
76 localedir = $(datarootdir)/locale
77 mandir = $(datarootdir)/man
78 man1dir = $(mandir)/man1
83 POT = po/$(PACKAGE).pot
84 POFILES = $(wildcard po/??.po)
85 MOFILES = $(patsubst %.po,%.mo,$(POFILES))
86 EOX_POFILES = po/eo-x.po
91 DOCFILES = $(PACKAGE).txt $(PACKAGE).$(HTMLEXT)
92 INSTALL_OBJS_DOC = README.txt NEWS.txt ChangeLog.txt COPYING.txt TODO.txt BUGS.txt $(DOCFILES)
94 #PODFILES = man/man1/dos2unix.pod $(wildcard man/*/man1/dos2unix.pod)
95 PODFILES = $(wildcard man/*/man1/dos2unix.pod)
96 MANFILES = $(patsubst %.pod,%.1,$(PODFILES))
98 # On some systems (e.g. FreeBSD 4.10) GNU install is installed as `ginstall'.
101 # On some systems (e.g. GNU Win32) GNU mkdir is installed as `gmkdir'.
105 DOS2UNIX_NLSDEFS = -DENABLE_NLS -DLOCALEDIR=\"$(localedir)\" -DPACKAGE=\"$(PACKAGE)\"
110 # ......................................................... OS flags ...
115 ifneq (, $(wildcard /boot/vmlinuz*))
121 ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN)
128 LDFLAGS_EXTRA = -lintl -liconv -Wl,--enable-auto-import
131 # allow non-cygwin clients which do not understand cygwin
132 # symbolic links to launch applications...
134 # but use symbolic links for man pages, since man client
135 # IS a cygwin app and DOES understand symlinks.
137 # Cygwin packaging standard avoids version numbers on
138 # documentation directories.
139 docsubdir = $(PACKAGE)
140 VERSIONSUFFIX = -cygwin
144 ifeq ($(findstring MSYS,$(shell uname)),MSYS)
147 VERSIONSUFFIX = -msys
151 LDFLAGS_EXTRA = -lintl -liconv
157 ifeq ($(findstring MINGW32,$(shell uname)),MINGW32)
161 VERSIONSUFFIX = -win32
165 LDFLAGS_EXTRA = -lintl -liconv
166 ZIPOBJ_EXTRA = bin/libintl-8.dll bin/libiconv-2.dll
172 ifeq ($(shell uname),MS-DOS)
176 VERSIONSUFFIX = -dos32
181 ZIPOBJ_EXTRA = bin/cwsdpmi.exe
183 LDFLAGS_EXTRA = -lintl -liconv
189 ifeq (FreeBSD, $(shell uname -s))
192 CFLAGS_OS = -I/usr/local/include
193 LDFLAGS_EXTRA = -lintl -L/usr/local/lib
198 ifeq (Darwin, $(shell uname -s))
201 CFLAGS_OS = -I/usr/local/include
202 LDFLAGS_EXTRA = -lintl -L/usr/local/lib
208 ifneq (, $(wildcard /opt/csw))
214 # Running under SunOS/Solaris
215 LDFLAGS_EXTRA = -lintl
219 ifeq (HP-UX, $(shell uname -s))
225 # Running under HP-UX
226 EXTRA_DEFS += -Dhpux -D_HPUX_SOURCE
233 # ............................................................ flags ...
235 # For systems that don't support Unicode or Latin-3, select
236 # Esperanto in X-notation format: EO_XNOTATION=1
243 CFLAGS = -O2 -Wall $(RPM_OPT_FLAGS) $(CPPFLAGS) $(CFLAGS_USER)
245 EXTRA_CFLAGS = -DVER_REVISION=\"$(DOS2UNIX_VERSION)\" \
246 -DVER_DATE=\"$(DOS2UNIX_DATE)\" \
247 -DVER_AUTHOR=\"$(DOS2UNIX_AUTHOR)\" \
256 EXTRA_CFLAGS += -static
260 EXTRA_CFLAGS += -DD2U_UNICODE
264 EXTRA_CFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
268 LDFLAGS = $(RPM_OPT_FLAGS) $(LDFLAGS_EXTRA) $(LDFLAGS_USER)
271 DEFS = $(EXTRA_DEFS) $(DEFS_USER)
273 # .......................................................... targets ...
275 all: $(BIN) $(MAC2UNIX_BIN) $(UNIX2DOS_BIN) $(UNIX2MAC_BIN) $(DOCFILES) $(MOFILES) $(EOX_POFILES) $(MANFILES) man/man1/dos2unix.1
277 common.o : common.c common.h
278 $(CC) $(DEFS) $(EXTRA_CFLAGS) $(DOS2UNIX_NLSDEFS) $(CFLAGS) -c $< -o $@
280 querycp.o : querycp.c querycp.h
281 $(CC) $(DEFS) $(EXTRA_CFLAGS) $(DOS2UNIX_NLSDEFS) $(CFLAGS) -c $< -o $@
283 dos2unix.o : dos2unix.c dos2unix.h querycp.h common.h
284 $(CC) $(DEFS) $(EXTRA_CFLAGS) $(DOS2UNIX_NLSDEFS) $(CFLAGS) -c $< -o $@
286 unix2dos.o : unix2dos.c unix2dos.h querycp.h common.h
287 $(CC) $(DEFS) $(EXTRA_CFLAGS) $(DOS2UNIX_NLSDEFS) $(CFLAGS) -c $< -o $@
289 $(BIN): dos2unix.o querycp.o common.o
290 $(CC) $+ $(LDFLAGS) -o $@
292 $(UNIX2DOS_BIN): unix2dos.o querycp.o common.o
293 $(CC) $+ $(LDFLAGS) -o $@
295 $(MAC2UNIX_BIN) : $(BIN)
301 $(UNIX2MAC_BIN) : $(UNIX2DOS_BIN)
306 html: $(PACKAGE).$(HTMLEXT)
314 doc: $(DOCFILES) $(MANFILES) man/man1/dos2unix.1
318 merge: $(POFILES) $(EOX_POFILES)
321 msgmerge -U $@ $(POT) --backup=numbered
322 # change timestamp in case .po file was not updated.
328 po/eo.mo : po/eo$(EO_NOTATION).po
331 $(POT) : dos2unix.c unix2dos.c common.c
332 xgettext -C --keyword=_ $+ -o $(POT)
334 %.txt : man/man1/%.pod
335 LC_CTYPE=C pod2text $< > $@
338 groff -man $< -T ps > $@
343 %.$(HTMLEXT) : man/man1/%.pod
344 pod2html --title="$(PACKAGE) $(DOS2UNIX_VERSION) - DOS/MAC to UNIX and vice versa text file format converter" $< > $@
347 $(MKDIR) -p -m 755 $(DESTDIR)$(bindir)
348 $(INSTALL) -m 755 $(BIN) $(DESTDIR)$(bindir)
349 $(INSTALL) -m 755 $(UNIX2DOS_BIN) $(DESTDIR)$(bindir)
351 $(INSTALL) -m 755 $(MAC2UNIX_BIN) $(DESTDIR)$(bindir)
352 $(INSTALL) -m 755 $(UNIX2MAC_BIN) $(DESTDIR)$(bindir)
354 cd $(DESTDIR)$(bindir); $(LINK) $(BIN) $(MAC2UNIX_BIN)
355 cd $(DESTDIR)$(bindir); $(LINK) $(UNIX2DOS_BIN) $(UNIX2MAC_BIN)
357 $(MKDIR) -p -m 755 $(DESTDIR)$(man1dir)
358 $(INSTALL) -m 644 man/man1/$(PACKAGE).1 $(DESTDIR)$(man1dir)
359 ifeq ($(LINK_MAN),cp -f)
360 $(INSTALL) -m 644 man/man1/$(PACKAGE).1 $(DESTDIR)$(man1dir)/$(MAC2UNIX).1
361 $(INSTALL) -m 644 man/man1/$(PACKAGE).1 $(DESTDIR)$(man1dir)/$(UNIX2DOS).1
362 $(INSTALL) -m 644 man/man1/$(PACKAGE).1 $(DESTDIR)$(man1dir)/$(UNIX2MAC).1
364 cd $(DESTDIR)$(man1dir); $(LINK_MAN) $(PACKAGE).1 $(MAC2UNIX).1
365 cd $(DESTDIR)$(man1dir); $(LINK_MAN) $(PACKAGE).1 $(UNIX2DOS).1
366 cd $(DESTDIR)$(man1dir); $(LINK_MAN) $(PACKAGE).1 $(UNIX2MAC).1
368 $(foreach manfile, $(MANFILES), $(MKDIR) -p -m 755 $(DESTDIR)$(datarootdir)/$(dir $(manfile)) ;)
369 $(foreach manfile, $(MANFILES), $(INSTALL) -m 644 $(manfile) $(DESTDIR)$(datarootdir)/$(dir $(manfile)) ;)
370 $(foreach manfile, $(MANFILES), cd $(DESTDIR)$(datarootdir)/$(dir $(manfile)) ; $(LINK_MAN) $(PACKAGE).1 $(MAC2UNIX).1 ;)
371 $(foreach manfile, $(MANFILES), cd $(DESTDIR)$(datarootdir)/$(dir $(manfile)) ; $(LINK_MAN) $(PACKAGE).1 $(UNIX2DOS).1 ;)
372 $(foreach manfile, $(MANFILES), cd $(DESTDIR)$(datarootdir)/$(dir $(manfile)) ; $(LINK_MAN) $(PACKAGE).1 $(UNIX2MAC).1 ;)
374 @echo "-- install-mo"
375 $(foreach mofile, $(MOFILES), $(MKDIR) -p -m 755 $(DESTDIR)$(localedir)/$(basename $(notdir $(mofile)))/LC_MESSAGES ;)
376 $(foreach mofile, $(MOFILES), $(INSTALL) -m 644 $(mofile) $(DESTDIR)$(localedir)/$(basename $(notdir $(mofile)))/LC_MESSAGES/$(PACKAGE).mo ;)
378 @echo "-- install-doc"
379 $(MKDIR) -p -m 755 $(DESTDIR)$(docdir)
380 $(INSTALL) -m 644 $(INSTALL_OBJS_DOC) $(wildcard $(PACKAGE).ps) $(wildcard $(PACKAGE).pdf) $(DESTDIR)$(docdir)
383 @echo "-- target: uninstall"
384 -rm -f $(DESTDIR)$(bindir)/$(BIN)
385 -rm -f $(DESTDIR)$(bindir)/$(MAC2UNIX_BIN)
386 -rm -f $(DESTDIR)$(bindir)/$(UNIX2DOS_BIN)
387 -rm -f $(DESTDIR)$(bindir)/$(UNIX2MAC_BIN)
389 $(foreach mofile, $(MOFILES), rm -f $(DESTDIR)$(localedir)/$(basename $(notdir $(mofile)))/LC_MESSAGES/$(PACKAGE).mo ;)
391 -rm -f $(DESTDIR)$(mandir)/man1/$(PACKAGE).1
392 -rm -f $(DESTDIR)$(mandir)/man1/$(MAC2UNIX).1
393 -rm -f $(DESTDIR)$(mandir)/man1/$(UNIX2DOS).1
394 -rm -f $(DESTDIR)$(mandir)/man1/$(UNIX2MAC).1
395 $(foreach manfile, $(MANFILES), rm -f $(DESTDIR)$(datarootdir)/$(manfile) ;)
396 -rm -rf $(DESTDIR)$(docdir)
400 rm -f $(BIN) $(UNIX2DOS_BIN) $(MAC2UNIX_BIN) $(UNIX2MAC_BIN)
403 rm -f man/man1/*.bak man/man1/*~
404 rm -f man/*/man1/*.bak man/*/man1/*~
409 rm -f $(DOCFILES) $(PACKAGE).ps $(PACKAGE).pdf
415 maintainer-clean: distclean
417 realclean: maintainer-clean
420 ZIPOBJ = bin/$(BIN) \
421 bin/$(MAC2UNIX_BIN) \
422 bin/$(UNIX2DOS_BIN) \
423 bin/$(UNIX2MAC_BIN) \
424 share/man/man1/$(PACKAGE).1 \
425 share/man/man1/$(MAC2UNIX).1 \
426 share/man/man1/$(UNIX2DOS).1 \
427 share/man/man1/$(UNIX2MAC).1 \
428 share/man/*/man1/$(PACKAGE).1 \
429 share/man/*/man1/$(MAC2UNIX).1 \
430 share/man/*/man1/$(UNIX2DOS).1 \
431 share/man/*/man1/$(UNIX2MAC).1 \
432 share/doc/$(docsubdir) \
436 ZIPOBJ += share/locale/*/LC_MESSAGES/$(PACKAGE).mo
439 ZIPFILE = $(PACKAGE)-$(DOS2UNIX_VERSION)$(VERSIONSUFFIX)$(NLSSUFFIX).zip
440 TGZFILE = $(PACKAGE)-$(DOS2UNIX_VERSION)$(VERSIONSUFFIX)$(NLSSUFFIX).tar.gz
441 TBZFILE = $(PACKAGE)-$(DOS2UNIX_VERSION)$(VERSIONSUFFIX)$(NLSSUFFIX).tar.bz2
444 rm -f $(prefix)/$(ZIPFILE)
445 cd $(prefix) ; unix2dos share/doc/$(docsubdir)/*.txt share/man/man1/$(PACKAGE).1 share/man/man1/$(MAC2UNIX).1 share/man/man1/$(UNIX2DOS).1 share/man/man1/$(UNIX2MAC).1
446 cd $(prefix) ; unix2dos share/doc/$(docsubdir)/*.$(HTMLEXT)
447 cd $(prefix) ; unix2dos share/man/*/man1/$(PACKAGE).1 share/man/*/man1/$(MAC2UNIX).1 share/man/*/man1/$(UNIX2DOS).1 share/man/*/man1/$(UNIX2MAC).1
448 cd $(prefix) ; zip -r $(ZIPFILE) $(ZIPOBJ)
449 mv -f $(prefix)/$(ZIPFILE) ..
452 cd $(prefix) ; dos2unix share/doc/$(docsubdir)/*.txt share/man/man1/$(PACKAGE).1 share/man/man1/$(MAC2UNIX).1 share/man/man1/$(UNIX2DOS).1 share/man/man1/$(UNIX2MAC).1
453 cd $(prefix) ; dos2unix share/man/*/man1/$(PACKAGE).1 share/man/*/man1/$(MAC2UNIX).1 share/man/*/man1/$(UNIX2DOS).1 share/man/*/man1/$(UNIX2MAC).1
454 cd $(prefix) ; tar cvzf $(TGZFILE) $(ZIPOBJ)
455 mv $(prefix)/$(TGZFILE) ..
458 cd $(prefix) ; dos2unix share/doc/$(docsubdir)/*.txt share/man/man1/$(PACKAGE).1 share/man/man1/$(MAC2UNIX).1 share/man/man1/$(UNIX2DOS).1 share/man/man1/$(UNIX2MAC).1
459 cd $(prefix) ; dos2unix share/man/*/man1/$(PACKAGE).1 share/man/*/man1/$(MAC2UNIX).1 share/man/*/man1/$(UNIX2DOS).1 share/man/*/man1/$(UNIX2MAC).1
460 cd $(prefix) ; tar cvjf $(TBZFILE) $(ZIPOBJ)
461 mv $(prefix)/$(TBZFILE) ..
467 $(STRIP) $(UNIX2DOS_BIN)
469 $(STRIP) $(MAC2UNIX_BIN)
470 $(STRIP) $(UNIX2MAC_BIN)