1 # Makefile for CDimgtools
3 # Include the settings chosen by the configure script
4 # If it is not found, default values are used
7 prefix ?
= $(HOME
)/.local
8 bindir ?
= $(prefix)/bin
9 datarootdir ?
= $(prefix)/share
10 sysconfdir ?
= $(prefix)/etc
11 docdir ?
= $(datarootdir
)/doc
12 mandir ?
= $(datarootdir
)/man
13 # DESTDIR = # distributors set this on the command line
15 PACKAGE_NAME
= cdimgtools
17 # Get the version via git or from the VERSION file or from the project
19 VERSION
= $(shell test -x version.sh
&& .
/version.sh
$(PACKAGE_NAME
) \
20 || echo
"unknown_version")
21 # Allow either to be overwritten by setting DIST_VERSION on the command line.
23 VERSION
= $(DIST_VERSION
)
26 # Remove the _g<SHA1> part from the $VERSION
27 RPM_VERSION
= $(shell echo
$(VERSION
) | sed
-e
's/_g[0-9a-z]\+//')
28 # Get the release from the spec file
29 RPM_RELEASE
= $(shell sed
-r
-n
-e
's/^Release:[[:space:]]+(.*)%.*$$/\1/p' \
30 $(PACKAGE_NAME
).spec.in
)
34 SCRIPTS
= raw96cdconv nrgtool
36 SOURCE
= README INSTALL COPYING BUGS NEWS
37 PERLDOC
= raw96cdconv nrgtool
38 MANDOC
= $(PERLDOC
:%=%.1)
39 HTMLDOC
= $(PERLDOC
:%=%.1.html
) README.html NEWS.html
40 RELEASEDOC
= $(MANDOC
) $(HTMLDOC
)
41 ALLDOC
= $(PERLDOC
:%=%.1.txt
) $(MANDOC
) $(HTMLDOC
)
43 TARNAME
= $(PACKAGE_NAME
)-$(RPM_VERSION
)
52 TAR_FLAGS
= --owner root
--group root
53 RPMBUILD_FLAGS
= --nodeps
# in case we are not on an rpm system
54 DEBUILD_FLAGS
= -d
# in case we are not on a deb system
56 AUTORECONF ?
= autoreconf
58 ASCIIDOC_FLAGS
= -aversion
=$(VERSION
) -asysconfdir
=$(sysconfdir
)
64 @echo
"Available targets for $(PACKAGE_NAME) Makefile:"
65 @echo
" .help all configure build clean doc doc-txt doc-man doc-html"
66 @echo
" Changelog dist docdist rpm deb distclean debclean"
67 @echo
" install install-doc install-doc-man install-doc-html"
68 @echo
"Useful variables for $(PACKAGE_NAME) Makefile:"
69 @echo
" prefix DESTDIR"
71 .PHONY
: .help help
all build
clean doc doc-txt doc-man doc-html \
72 dist docdist rpm deb deborig
distclean debclean \
73 install install-doc install-doc-man install-doc-html
75 build
: $(PROGS
) $(TESTS
)
77 doc-txt
: $(PERLDOC
:%=%.1.txt
)
82 $(MKDIR
) -p
$(DESTDIR
)$(bindir) && \
83 for prog in
$(PROGS
) $(SCRIPTS
); do \
84 $(INSTALL
) -p
-m
0755 "$$prog" "$(DESTDIR)$(bindir)"; \
86 install-doc
: install-doc-man install-doc-html
87 install-doc-man
: doc-man
88 $(MKDIR
) -p
$(DESTDIR
)$(mandir)/man1
89 for doc in
$(MANDOC
); do \
90 sed
's#++SYSCONFDIR++#$(sysconfdir)#' < "$$doc" > "$$doc+"; \
91 $(INSTALL
) -p
-m
0644 "$$doc+" "$(DESTDIR)$(mandir)/man1/$$doc"; \
94 install-doc-html
: doc-html
95 $(MKDIR
) -p
$(DESTDIR
)$(docdir
)/$(PACKAGE_NAME
)
96 for doc in
$(HTMLDOC
); do \
97 sed
's#++SYSCONFDIR++#$(sysconfdir)#' < "$$doc" > "$$doc+"; \
99 (*.html
) $(INSTALL
) -p
-m
0644 "$$doc+" \
100 "$(DESTDIR)$(docdir)/$(PACKAGE_NAME)/$$doc" ;; \
107 $(RM
) $(PACKAGE_NAME
)-*.
tar $(PACKAGE_NAME
)-*.
tar.gz
$(PACKAGE_NAME
)-*.
tar.gz.md5
108 $(RM
) $(PROGS
) $(TESTS
) *.xml pod2htm
*
110 $(RM
) -r autom4te.cache
/
111 $(RM
) $(ALLDOC
) $(PACKAGE_NAME
).spec aclocal.m4 configure
112 $(RM
) config.h config.log config.make config.status config.h.in
114 test -d .git
&& $(RM
) Changelog
116 $(RM
) debian
/changelog
117 $(RM
) -r .
pc/ debian
/patches
/
119 $(TARNAME
).
tar: configure Changelog
$(PACKAGE_NAME
).spec debian
/changelog
120 @
$(MKDIR
) -p
$(TARNAME
)/debian
&& \
121 echo
$(VERSION
) > $(TARNAME
)/VERSION
&& \
122 $(CP
) -p configure Changelog
$(PACKAGE_NAME
).spec
$(TARNAME
) && \
123 $(CP
) -p debian
/changelog
$(TARNAME
)/debian
124 git archive
--format
=tar --prefix=$(TARNAME
)/ HEAD \
125 |
$(TAR
) --delete
$(TARNAME
)/VERSION | cat
> $(TARNAME
).
tar && \
126 $(TAR
) $(TAR_FLAGS
) -rf
$(TARNAME
).
tar $(TARNAME
) && \
127 echo
$(TARNAME
).
tar successfully generated
130 gzip
-f
-9 $(TARNAME
).
tar && \
131 md5sum
$(TARNAME
).
tar.gz
> $(TARNAME
).
tar.gz.md5
133 rpmbuild
$(RPMBUILD_FLAGS
) -ta
$(TARNAME
).
tar.gz
135 $(MV
) $(TARNAME
).
tar.gz ..
/$(PACKAGE_NAME
)_
$(RPM_VERSION
).orig.
tar.gz
136 deb
: deborig debian
/changelog
137 debuild
$(DEBUILD_FLAGS
)
138 $(TARNAME
)-doc.
tar: $(TARNAME
).
tar $(RELEASEDOC
)
139 $(MV
) $(TARNAME
).
tar $(TARNAME
)-doc.
tar
141 $(CP
) -p
-d
$(RELEASEDOC
) $(TARNAME
)
142 $(TAR
) --mode
644 -rf
$(TARNAME
)-doc.
tar `find $(TARNAME)/*`
144 docdist
: $(TARNAME
)-doc.
tar
145 gzip
-f
-9 $(TARNAME
)-doc.
tar && \
146 md5sum
$(TARNAME
)-doc.
tar.gz
> $(TARNAME
)-doc.
tar.gz.md5
148 configure
: configure.ac
152 if
test -d .git
; then \
153 git log
--date-order
--date
=short \
154 | sed
-e
'/^commit .*$$/d' \
155 -e
'/^Merge: .*$$/d' \
157 -e
's/^Author: \s*//; s/\nDate: \s*/\n/' \
158 -e
's/^\(.*\)\s\+\([^\s]*\)\s*\n\([^\n]*\)/\3 \1 \2/' \
162 echo
"Not in a git repository."; \
165 $(PACKAGE_NAME
).spec
: $(PACKAGE_NAME
).spec.in
166 sed
-e
's/@@VERSION@@/$(RPM_VERSION)/g' \
167 -e
's/@@RELEASE@@/$(RPM_RELEASE)/g' < $< > $@
168 debian
/changelog
: debian
/changelog.in
169 sed
-e
's/@@VERSION@@/$(RPM_VERSION)/g' \
170 -e
's/@@RELEASE@@/$(DEB_RELEASE)/g' < $< > $@
174 $(CC
) $(CFLAGS
) $(VERBOSITY
:%=-DDEFAULT_VERBOSITY
=%) -o
$@
$< -ldvdcss
176 README.html
: README INSTALL BUGS asciidoc.conf
177 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b xhtml11
-d article
-a readme
$<
178 NEWS.html
: NEWS asciidoc.conf
179 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b xhtml11
-d article
$<
181 $(PERLDOC
:%=%.1): $(PERLDOC
)
182 pod2man
--utf8
$(patsubst %.1,%,$@
) >$@
183 $(PERLDOC
:%=%.1.txt
): $(PERLDOC
)
184 pod2text
--utf8
$(patsubst %.1.txt
,%,$@
) >$@
185 $(PERLDOC
:%=%.1.html
): $(PERLDOC
)
186 pod2html
--noindex
$(patsubst %.1.html
,%,$@
) >$@