1
2DISTNAME = $(pkgname)-$(pkgversion)
3INSTALL = install
4INSTALL_PROGRAM = $(INSTALL) -m 755
5INSTALL_DATA = $(INSTALL) -m 644
6INSTALL_DIR = $(INSTALL) -d -m 755
7SHELL = /bin/sh
8CAN_RUN_INSTALLINFO = $(SHELL) -c "install-info --version" > /dev/null 2>&1
9
10objs = arg_parser.o alone_to_lz.o lzip_index.o list.o dump_remove.o \
11       lunzcrash.o md5.o merge.o mtester.o nrep_stats.o range_dec.o \
12       repair.o reproduce.o split.o decoder.o main.o
13unzobjs = arg_parser.o unzcrash.o
14
15
16.PHONY : all install install-bin install-info install-man \
17         install-strip install-compress install-strip-compress \
18         install-bin-strip install-info-compress install-man-compress \
19         install-as-lzip \
20         uninstall uninstall-bin uninstall-info uninstall-man \
21         doc info man check dist clean distclean
22
23all : $(progname)
24
25$(progname) : $(objs)
26	$(CXX) $(LDFLAGS) $(CXXFLAGS) -o $@ $(objs)
27
28unzcrash : $(unzobjs)
29	$(CXX) $(LDFLAGS) $(CXXFLAGS) -o $@ $(unzobjs)
30
31main.o : main.cc
32	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -DPROGVERSION=\"$(pkgversion)\" -c -o $@ $<
33
34unzcrash.o : unzcrash.cc
35	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -DPROGVERSION=\"$(pkgversion)\" -c -o $@ $<
36
37%.o : %.cc
38	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
39
40$(objs)       : Makefile
41alone_to_lz.o : lzip.h mtester.h
42arg_parser.o  : arg_parser.h
43decoder.o     : lzip.h decoder.h
44dump_remove.o : lzip.h lzip_index.h
45list.o        : lzip.h lzip_index.h
46lunzcrash.o   : lzip.h md5.h mtester.h lzip_index.h
47lzip_index.o  : lzip.h lzip_index.h
48main.o        : arg_parser.h lzip.h decoder.h main_common.cc
49md5.o         : md5.h
50merge.o       : lzip.h decoder.h lzip_index.h
51mtester.o     : lzip.h md5.h mtester.h
52nrep_stats.o  : lzip.h lzip_index.h
53range_dec.o   : lzip.h decoder.h lzip_index.h
54repair.o      : lzip.h mtester.h lzip_index.h
55reproduce.o   : lzip.h md5.h mtester.h lzip_index.h
56split.o       : lzip.h lzip_index.h
57unzcrash.o    : Makefile arg_parser.h main_common.cc
58
59
60doc : info man
61
62info : $(VPATH)/doc/$(pkgname).info
63
64$(VPATH)/doc/$(pkgname).info : $(VPATH)/doc/$(pkgname).texi
65	cd $(VPATH)/doc && makeinfo $(pkgname).texi
66
67man : $(VPATH)/doc/$(progname).1
68
69$(VPATH)/doc/$(progname).1 : $(progname)
70	help2man -n 'recovers data from damaged lzip files' -o $@ ./$(progname)
71
72Makefile : $(VPATH)/configure $(VPATH)/Makefile.in
73	./config.status
74
75check : all
76	@$(VPATH)/testsuite/check.sh $(VPATH)/testsuite $(pkgversion)
77
78install : install-bin install-info install-man
79install-strip : install-bin-strip install-info install-man
80install-compress : install-bin install-info-compress install-man-compress
81install-strip-compress : install-bin-strip install-info-compress install-man-compress
82
83install-bin : all
84	if [ ! -d "$(DESTDIR)$(bindir)" ] ; then $(INSTALL_DIR) "$(DESTDIR)$(bindir)" ; fi
85	$(INSTALL_PROGRAM) ./$(progname) "$(DESTDIR)$(bindir)/$(progname)"
86
87install-bin-strip : all
88	$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install-bin
89
90install-info :
91	if [ ! -d "$(DESTDIR)$(infodir)" ] ; then $(INSTALL_DIR) "$(DESTDIR)$(infodir)" ; fi
92	-rm -f "$(DESTDIR)$(infodir)/$(pkgname).info"*
93	$(INSTALL_DATA) $(VPATH)/doc/$(pkgname).info "$(DESTDIR)$(infodir)/$(pkgname).info"
94	-if $(CAN_RUN_INSTALLINFO) ; then \
95	  install-info --info-dir="$(DESTDIR)$(infodir)" "$(DESTDIR)$(infodir)/$(pkgname).info" ; \
96	fi
97
98install-info-compress : install-info
99	lzip -v -9 "$(DESTDIR)$(infodir)/$(pkgname).info"
100
101install-man :
102	if [ ! -d "$(DESTDIR)$(mandir)/man1" ] ; then $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1" ; fi
103	-rm -f "$(DESTDIR)$(mandir)/man1/$(progname).1"*
104	$(INSTALL_DATA) $(VPATH)/doc/$(progname).1 "$(DESTDIR)$(mandir)/man1/$(progname).1"
105
106install-man-compress : install-man
107	lzip -v -9 "$(DESTDIR)$(mandir)/man1/$(progname).1"
108
109install-as-lzip : install
110	-rm -f "$(DESTDIR)$(bindir)/lzip"
111	cd "$(DESTDIR)$(bindir)" && ln -s $(progname) lzip
112
113uninstall : uninstall-man uninstall-info uninstall-bin
114
115uninstall-bin :
116	-rm -f "$(DESTDIR)$(bindir)/$(progname)"
117
118uninstall-info :
119	-if $(CAN_RUN_INSTALLINFO) ; then \
120	  install-info --info-dir="$(DESTDIR)$(infodir)" --remove "$(DESTDIR)$(infodir)/$(pkgname).info" ; \
121	fi
122	-rm -f "$(DESTDIR)$(infodir)/$(pkgname).info"*
123
124uninstall-man :
125	-rm -f "$(DESTDIR)$(mandir)/man1/$(progname).1"*
126
127dist : doc
128	ln -sf $(VPATH) $(DISTNAME)
129	tar -Hustar --owner=root --group=root -cvf $(DISTNAME).tar \
130	  $(DISTNAME)/AUTHORS \
131	  $(DISTNAME)/COPYING \
132	  $(DISTNAME)/ChangeLog \
133	  $(DISTNAME)/INSTALL \
134	  $(DISTNAME)/Makefile.in \
135	  $(DISTNAME)/NEWS \
136	  $(DISTNAME)/README \
137	  $(DISTNAME)/configure \
138	  $(DISTNAME)/doc/$(progname).1 \
139	  $(DISTNAME)/doc/$(pkgname).info \
140	  $(DISTNAME)/doc/$(pkgname).texi \
141	  $(DISTNAME)/*.h \
142	  $(DISTNAME)/*.cc \
143	  $(DISTNAME)/testsuite/check.sh \
144	  $(DISTNAME)/testsuite/fox6_bad1.txt \
145	  $(DISTNAME)/testsuite/test.txt \
146	  $(DISTNAME)/testsuite/test21723.txt \
147	  $(DISTNAME)/testsuite/test_bad[6-9].txt \
148	  $(DISTNAME)/testsuite/fox.lz \
149	  $(DISTNAME)/testsuite/fox_*.lz \
150	  $(DISTNAME)/testsuite/fox6.lz \
151	  $(DISTNAME)/testsuite/fox6_sc[1-6].lz \
152	  $(DISTNAME)/testsuite/fox6_bad[1-6].lz \
153	  $(DISTNAME)/testsuite/numbers.lz \
154	  $(DISTNAME)/testsuite/numbersbt.lz \
155	  $(DISTNAME)/testsuite/test.txt.lz \
156	  $(DISTNAME)/testsuite/test.txt.lzma \
157	  $(DISTNAME)/testsuite/test_bad[1-9].lz \
158	  $(DISTNAME)/testsuite/test_em.txt.lz
159	rm -f $(DISTNAME)
160	lzip -v -9 $(DISTNAME).tar
161
162clean :
163	-rm -f $(progname) $(objs)
164	-rm -f unzcrash unzcrash.o
165
166distclean : clean
167	-rm -f Makefile config.status *.tar *.tar.lz
168