1 # Makefile for CDimgtools
2 # Copyright © 2012,2013 Géraud Meyer <graud@gmx.com>
3 # This file is part of CDimgtools.
5 # CDimgtools is free software; you can redistribute it and/or modify it under
6 # the terms of the GNU General Public License version 2 as published by the
7 # Free Software Foundation.
9 # This package is distributed in the hope that it will be useful, but WITHOUT
10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 # You should have received a copy of the GNU General Public License
15 # along with CDimgtools. If not, see <http://www.gnu.org/licenses/>.
17 # This a GNU Makefile. Under BSD systems run gmake.
19 # Include the settings chosen by the configure script
20 # If it is not found, default values are used
23 prefix ?
= $(HOME
)/.local
24 bindir ?
= $(prefix)/bin
25 datarootdir ?
= $(prefix)/share
26 sysconfdir ?
= $(prefix)/etc
27 docdir ?
= $(datarootdir
)/doc
/$(PACKAGE_TARNAME
)
28 mandir ?
= $(datarootdir
)/man
29 # DESTDIR = # distributors set this on the command line
32 tab
:= $(empty
) $(empty
)
34 PACKAGE_NAME ?
= CDimgtools
35 PACKAGE_TARNAME ?
= cdimgtools
36 HAVE_CONFIG_H
= $(shell test -e config.h
&& echo
1 || echo
0)
38 # Get the version via git or from the VERSION file or from the project
40 VERSION
= $(shell test -x version.sh
&& .
/version.sh
$(PACKAGE_TARNAME
) \
41 || echo
"unknown_version")
42 # Allow either to be overwritten by setting DIST_VERSION on the command line.
44 VERSION
= $(DIST_VERSION
)
46 PACKAGE_VERSION
= $(VERSION
)
48 # Remove the _g<SHA1> part from the $VERSION
49 RPM_VERSION
= $(shell echo
$(VERSION
) |
$(SED
) -e
's/_g[0-9a-z]\+//')
50 # Get the release from the spec file
51 RPM_RELEASE
= $(shell $(SED
) -n
-e
's/^Release:[ $(tab)]\+\(.*\)%.*$$/\1/p' \
52 $(PACKAGE_TARNAME
).spec.in
)
55 PROGS
= cssdec dvdimgdecss
56 SCRIPTS
= raw96cdconv nrgtool
58 SOURCE
= README INSTALL COPYING BUGS NEWS
59 PERLDOC
= raw96cdconv nrgtool
60 MANDOC
= $(PERLDOC
:%=%.1) $(PROGS
:%=%.1)
61 HTMLDOC
= $(PERLDOC
:%=%.1.html
) $(PROGS
:%=%.1.html
) README.html INSTALL.html NEWS.html
62 RELEASEDOC
= $(MANDOC
) $(HTMLDOC
)
63 ALLDOC
= $(PERLDOC
:%=%.1.txt
) $(MANDOC
) $(HTMLDOC
)
65 TARNAME
= $(PACKAGE_TARNAME
)-$(RPM_VERSION
)
75 TAR_FLAGS
= --owner root
--group root
--mode a
+rX
,o-w
--mtime .
76 RPMBUILD_FLAGS
= --nodeps
# in case we are not on an rpm system
77 DEBUILD_FLAGS
= -d
# in case we are not on a deb system
79 AUTORECONF ?
= autoreconf
81 ASCIIDOC_FLAGS
= -apackagename
="$(PACKAGE_NAME)" -aversion
="$(VERSION)"
83 POD2MAN_FLAGS
= --utf8
-c
"$(PACKAGE_NAME) commands" -r
"$(PACKAGE_NAME) $(VERSION)"
88 SHA512SUM ?
= sha512sum
94 @echo
"Available targets for $(PACKAGE_NAME) Makefile:"
95 @echo
" .help all configure build clean doc doc-txt doc-man doc-html"
96 @echo
" ChangeLog dist rpm deb distclean maintainer-clean debclean"
97 @echo
" install install-doc install-doc-man install-doc-html"
98 @echo
"Useful variables for $(PACKAGE_NAME) Makefile:"
99 @echo
" CFLAGS CPPFLAGS LDFLAGS prefix DESTDIR RPMBUILD_FLAGS DEBUILD_FLAGS"
101 .PHONY
: .help help
all build
clean doc doc-txt doc-man doc-html \
102 dist nodocdist rpm deb deborig
distclean maintainer-clean debuild_clean debclean \
103 install install-doc install-doc-man install-doc-html
105 build
: $(PROGS
) $(TESTS
)
107 doc-txt
: $(PERLDOC
:%=%.1.txt
)
112 $(MKDIR
) -p
$(DESTDIR
)$(bindir)
113 set
-e
; for prog in
$(SCRIPTS
); do \
114 $(SED
) -e
'1 s#/usr/bin/perl#$(PERL)#' "$$prog" > "$$prog".ins
; \
116 set
-e
; for prog in
$(PROGS
) $(SCRIPTS
:%=%.ins
); do \
117 $(INSTALL
) -p
-m
0755 "$$prog" "$(DESTDIR)$(bindir)/$${prog%.ins}"; \
119 rm $(SCRIPTS
:%=%.ins
)
120 install-doc
: install-doc-man install-doc-html
121 install-doc-man
: doc-man
122 $(MKDIR
) -p
$(DESTDIR
)$(mandir)/man1
123 set
-e
; for doc in
$(MANDOC
); do \
124 gzip
-9 <"$$doc" >"$$doc".gz
; \
125 $(INSTALL
) -p
-m
0644 "$$doc".gz
"$(DESTDIR)$(mandir)/man1/"; \
128 install-doc-html
: doc-html
129 $(MKDIR
) -p
$(DESTDIR
)$(docdir
)
130 set
-e
; for doc in
$(HTMLDOC
); do \
132 (*.html
) $(INSTALL
) -p
-m
0644 "$$doc" "$(DESTDIR)$(docdir)/" ;; \
138 $(RM
) $(PACKAGE_TARNAME
)-*.
tar $(PACKAGE_TARNAME
)-*.
tar.gz \
139 $(PACKAGE_TARNAME
)-*.
tar.gz.md5
$(PACKAGE_TARNAME
)-*.
tar.gz.sha512 \
140 $(PACKAGE_TARNAME
)-*.
tar.gz.sig
$(PACKAGE_TARNAME
)-*.
tar.gz.asc
141 $(RM
) $(PROGS
) $(TESTS
) *.xml pod2htm
* *~
143 $(RM
) -r autom4te.cache
/
144 $(RM
) $(ALLDOC
) $(PACKAGE_TARNAME
).spec aclocal.m4 autoscan.log
145 $(RM
) config.h config.log config.make config.status
146 maintainer-clean
: distclean
147 $(RM
) configure config.h.in debian
/changelog
148 test ! -d .git
&& test ! -f .git ||
$(RM
) ChangeLog
151 debclean
: debuild_clean maintainer-clean
152 $(RM
) -r .
pc/ debian
/patches
/
154 $(TARNAME
).
tar: configure config.h.in ChangeLog
$(PACKAGE_TARNAME
).spec debian
/changelog
155 $(MKDIR
) -p
$(TARNAME
)/debian
156 echo
$(VERSION
) > $(TARNAME
)/VERSION
157 $(CP
) -p configure config.h.in ChangeLog
$(PACKAGE_TARNAME
).spec
$(TARNAME
)
158 $(CP
) -p debian
/changelog
$(TARNAME
)/debian
159 git archive
--format
=tar --prefix=$(TARNAME
)/ HEAD
> $(TARNAME
).
tar
160 $(TAR
) $(TAR_FLAGS
) -rf
$(TARNAME
).
tar $(TARNAME
)
162 dist: $(TARNAME
).
tar.gz
164 $(MAKE
) $(TARNAME
).
tar.gz NODOCDIST
=yes
167 if
test -f ..
/$(TARNAME
).
tar.gz
; then \
168 echo NOTE
: re-using already existing ..
/$(TARNAME
).
tar.gz
; \
169 $(CP
) ..
/$(TARNAME
).
tar.gz .
; \
171 if
test -d .git ||
test -f .git
; then \
172 $(MAKE
) $(TARNAME
).
tar; \
174 echo WARNING
: re-building the distribution archive in ..
/$(TARNAME
).
tar; \
177 # most generated distribution files are preserved \
178 $(MAKE
) $(PACKAGE_TARNAME
).spec
; \
179 ( cd ..
&& $(TAR
) $(TAR_FLAGS
) --mtime
$(TARNAME
) -cvf
$(TARNAME
).
tar $(TARNAME
) \
180 && $(MV
) $(TARNAME
).
tar $(TARNAME
)/ ); \
182 if
test x
$(NODOCDIST
) = x
; then \
183 $(MAKE
) $(RELEASEDOC
); \
184 $(MKDIR
) $(TARNAME
); \
185 $(CP
) -p
-P
$(RELEASEDOC
) $(TARNAME
); \
186 $(TAR
) $(TAR_FLAGS
) -rf
$(TARNAME
).
tar $(TARNAME
); \
187 $(RM
) -r
$(TARNAME
); \
189 gzip
-f
-9 $(TARNAME
).
tar; \
191 $(MD5SUM
) $(TARNAME
).
tar.gz
> $(TARNAME
).
tar.gz.md5
192 $(SHA512SUM
) $(TARNAME
).
tar.gz
> $(TARNAME
).
tar.gz.sha512
194 rpmbuild
$(RPMBUILD_FLAGS
) -ta
$(TARNAME
).
tar.gz
196 set
-e
; if
test -f ..
/$(PACKAGE_TARNAME
)_
$(RPM_VERSION
).orig.
tar.gz
; then \
197 echo
"WARNING: re-using ../$(PACKAGE_TARNAME)_$(RPM_VERSION).orig.tar.gz"; \
200 $(MAKE
) $(TARNAME
).
tar.gz
; \
201 $(MV
) $(TARNAME
).
tar.gz ..
/$(PACKAGE_TARNAME
)_
$(RPM_VERSION
).orig.
tar.gz
; \
203 deb
: deborig debian
/changelog
204 debuild
$(DEBUILD_FLAGS
)
206 configure
: configure.ac
208 #config.h.in: configure
211 ( echo
"# $@ - automatically generated from the VCS's history"; \
213 .
/gitchangelog.sh
--tags --tag-pattern
'version\/[^\n]*' \
214 -- - --date-order
) \
215 |
$(SED
) 's/^\[version/\f\[version/' \
217 $(PACKAGE_TARNAME
).spec
: $(PACKAGE_TARNAME
).spec.in
218 $(SED
) -e
's/@@VERSION@@/$(RPM_VERSION)/g' \
219 -e
's/@@RELEASE@@/$(RPM_RELEASE)/g' < $< > $@
220 debian
/changelog
: debian
/changelog.in
221 $(SED
) -e
's/@@VERSION@@/$(RPM_VERSION)/g' \
222 -e
's/@@RELEASE@@/$(DEB_RELEASE)/g' < $< > $@
226 $(CC
) $(CPPFLAGS
) -DHAVE_CONFIG_H
=$(HAVE_CONFIG_H
) \
227 $(CFLAGS
) $(LDFLAGS
) -o
$@
$< -ldvdcss
228 dvdimgdecss
: dvdimgdecss.c
229 $(CC
) $(CPPFLAGS
) -DHAVE_CONFIG_H
=$(HAVE_CONFIG_H
) \
230 $(CFLAGS
) $(LDFLAGS
) -o
$@
$< -ldvdcss
-ldvdread
233 README.html
: README BUGS asciidoc.conf
234 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b xhtml11
-d article
-a readme
$<
235 INSTALL.html
: INSTALL asciidoc.conf
236 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b xhtml11
-d article
-a readme
$<
237 NEWS.html
: NEWS asciidoc.conf
238 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b xhtml11
-d article
$<
240 $(PERLDOC
:%=%.1): $(PERLDOC
)
241 $(POD2MAN
) $(POD2MAN_FLAGS
) $(patsubst %.1,%,$@
) >$@
242 $(PERLDOC
:%=%.1.txt
): $(PERLDOC
)
243 $(POD2TEXT
) --utf8
$(patsubst %.1.txt
,%,$@
) >$@
244 $(PERLDOC
:%=%.1.html
): $(PERLDOC
)
245 $(POD2HTML
) --noindex
$(patsubst %.1.html
,%,$@
) >$@
247 %.html
: %.txt asciidoc.conf
248 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b xhtml11
-d manpage
$<
249 %.xml
: %.txt asciidoc.conf
250 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b docbook
-d manpage
$<