diff --git a/Makefile b/Makefile index 3b3e56e..9a6e0d3 100644 --- a/Makefile +++ b/Makefile @@ -15,19 +15,27 @@ JACK := $(shell pkg-config --libs jack 2>/dev/null) OBJ = readconfig.o midizap.o jackdriver.o +# Only try to install the manual page if it's actually there, to prevent +# errors if pandoc isn't installed. +INSTALL_TARGETS = midizap $(wildcard midizap.1) + +.PHONY: all world install uninstall man pdf clean realclean + all: midizap -# This should actually go into 'all', but we keep this target separate since -# it requires special software (pandoc) to be generated. We also keep the -# midizap.1 file in the repository, so that users don't need pandoc in order -# to install this package. -man: midizap.1 +# This also creates the manual page (see below). +world: all man -install: all +install: $(INSTALL_TARGETS) install -d $(bindir) $(datadir) $(mandir) install midizap $(bindir) install -m 0644 example.midizaprc $(datadir)/midizaprc +# If present, the manual page will be installed along with the program. +ifneq ($(findstring midizap.1, $(INSTALL_TARGETS)),) install -m 0644 midizap.1 $(mandir) +else + @echo "Manual page not found, create it with 'make man'." +endif uninstall: rm -f $(bindir)/midizap $(mandir)/midizap.1 $(datadir)/midizaprc @@ -35,14 +43,26 @@ uninstall: midizap: $(OBJ) gcc $(CFLAGS) $(OBJ) -o midizap -L /usr/X11R6/lib -lX11 -lXtst $(JACK) +# This creates the manual page from the README. Requires pandoc +# (http://pandoc.org/). +man: midizap.1 + +# Manual page in pdf format. This also needs groff. +pdf: midizap.pdf + midizap.1: README.md pandoc -s -tman $< > $@ +midizap.pdf: midizap.1 +# This assumes that man does the right thing when given a file instead of a +# program name, and that it understands groff's -T option. + man -Tpdf ./midizap.1 > $@ + clean: rm -f midizap keys.h $(OBJ) realclean: - rm -f midizap midizap.1 keys.h $(OBJ) + rm -f midizap midizap.1 midizap.pdf keys.h $(OBJ) keys.h: keys.sed /usr/include/X11/keysymdef.h sed -f keys.sed < /usr/include/X11/keysymdef.h > keys.h