diff options
author | B. Watson <yalhcru@gmail.com> | 2020-05-16 15:11:26 -0400 |
---|---|---|
committer | B. Watson <yalhcru@gmail.com> | 2020-05-16 15:11:26 -0400 |
commit | ae5188220c82c164e2fa01b71e1a4929d162bfea (patch) | |
tree | 22bd6085e659d32cc649fc28df3d14e86bd21a3c /Makefile | |
parent | 7b119c34ca624c863230455144bdb0c09300a94e (diff) | |
download | unsaver-ae5188220c82c164e2fa01b71e1a4929d162bfea.tar.gz |
make the Makefile fancier
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 95 |
1 files changed, 84 insertions, 11 deletions
@@ -1,8 +1,7 @@ # GNU Makefile for jsmond -PROJ=jsmond -# the .rst is the authoritative source for the version number. -VERSION=$(shell fgrep '.. |version| replace::' $(PROJ).rst | cut -d' ' -f4) +#### +# Packagers: override these on the make command line as needed. # maximum number of devices we can monitor. 16 seems like an awful lot... MAX_STICKS=16 @@ -11,14 +10,50 @@ MAX_STICKS=16 # appended to it during autodetection JSDEVBASE="/dev/input/js" -# Override this, not CFLAGS -OPTFLAGS=-Wall -ansi -pedantic -std=c89 -g - # If you can think of a reason to compile without X11 support, # set this to 0 (or anything other than 1). Note that you can # compile with X11 and then disable it at runtime with -x. HAVE_X11=1 +# Intended for optimizations, but you could include other flags here. +# Override this, not CFLAGS +OPTFLAGS=-Wall -ansi -pedantic -std=c89 -g + +# -L, -l, and maybe -Wl flags here. +LDEXTRA= + +# Where 'make install' puts things. +PREFIX=/usr/local +BINDIR=$(PREFIX)/bin +MANDIR=$(PREFIX)/share/man +MAN1DIR=$(MANDIR)/man1 +DOCDIR=$(PREFIX)/share/doc/$(PROJ) +DESTDIR= + +# Booleans: 'y' or 'n' for these. +STRIPBIN=y +GZIPMAN=y + +# Normally these will end up as root and root (or possibly wheel). You +# could also set 'CHOWN=/bin/true' to skip it. +OWNER=$(shell id -nu 0) +GROUP=$(shell id -ng 0) + +# These are only used if you're rebuilding the man and/or html pages, +# e.g. because you've patched them. +RST2MAN=rst2man.py +RST2HTML=rst2html4.py + +# +### + +# Hopefully, no user-serviceable parts below this line. + +PROJ=jsmond + +# the .rst is the authoritative source for the version number. +VERSION=$(shell fgrep '.. |version| replace::' $(PROJ).rst | cut -d' ' -f4) + DEFINES=-DVERSION=\"$(VERSION)\" -DMAX_STICKS=$(MAX_STICKS) -DJSDEVBASE=\"$(JSDEVBASE)\" ifeq ($(HAVE_X11),1) @@ -29,13 +64,51 @@ endif CFLAGS=$(OPTFLAGS) $(DEFINES) +LDFLAGS+=$(LDEXTRA) + +all: $(PROJ) -all: jsmond +man: $(PROJ).1 -man: jsmond.rst - rst2man.py jsmond.rst > jsmond.1 +html: $(PROJ).html clean: - rm -f $(PROJ) + rm -f $(PROJ) core + +%.1: %.rst + $(RST2MAN) $< > $@ || rm -f $@ + +%.html: %.rst + $(RST2HTML) $< > $@ || rm -f $@ + +ifeq ($(shell whoami),root) +CHOWN=chown +else +CHOWN=: chown +endif + +install: all man html + mkdir -p $(DESTDIR)$(BINDIR) $(DESTDIR)$(MAN1DIR) $(DESTDIR)$(DOCDIR) + cp $(PROJ) $(DESTDIR)$(BINDIR) + $(CHOWN) $(OWNER):$(GROUP) $(DESTDIR)$(BINDIR)/$(PROJ) + chmod 755 $(DESTDIR)$(BINDIR)/$(PROJ) +ifeq ($(STRIPBIN),y) + strip $(DESTDIR)$(BINDIR)/$(PROJ) +endif + cp $(PROJ).1 $(DESTDIR)$(MAN1DIR) +ifeq ($(GZIPMAN),y) + gzip -9 $(DESTDIR)$(MAN1DIR)/$(PROJ).1 +endif + $(CHOWN) root:root $(DESTDIR)$(MAN1DIR)/$(PROJ).1 + chmod 644 $(DESTDIR)$(MAN1DIR)/$(PROJ).1 + cp README $(DESTDIR)$(DOCDIR) + chmod 644 $(DESTDIR)$(DOCDIR)/README + $(CHOWN) $(OWNER):$(GROUP) $(DESTDIR)$(DOCDIR)/README + +push: all man html + git add $(PROJ).1 $(PROJ).html + git commit -m'auto-regenerate man/html pages' || true + git push + -.PHONY: all man clean +.PHONY: all man clean html install push |