comparison Makefile @ 1:55281f14dc9b

Add README file and manpage
author Guido Berhoerster <guido+pwm@berhoerster.name>
date Fri, 03 Feb 2017 16:11:58 +0100
parents a7e41e1a79c8
children 4269feba381e
comparison
equal deleted inserted replaced
0:a7e41e1a79c8 1:55281f14dc9b
42 INSTALL.data := $(INSTALL) -D -m 0644 42 INSTALL.data := $(INSTALL) -D -m 0644
43 INSTALL.link := $(CP) -f -P 43 INSTALL.link := $(CP) -f -P
44 PAX := pax 44 PAX := pax
45 GZIP := gzip 45 GZIP := gzip
46 SED := sed 46 SED := sed
47 XSLTPROC := xsltproc
48 DOCBOOK5_MANPAGES_STYLESHEET = http://docbook.sourceforge.net/release/xsl-ns/current/manpages/docbook.xsl
49 DOCBOOK5_MANPAGES_FLAGS = --stringparam man.authors.section.enabled 0 \
50 --stringparam man.copyright.section.enabled 0
51
52 define generate-manpage-rule =
53 $(addsuffix .%,$(basename $1)): $(addsuffix .%.xml,$(basename $(firstword $1))) docbook-update-source-data.xsl
54 $$(XSLTPROC) \
55 --xinclude \
56 --stringparam package $$(PACKAGE) \
57 --stringparam version $$(VERSION) \
58 docbook-update-source-data.xsl $$< | \
59 $$(XSLTPROC) \
60 --xinclude \
61 --output $(firstword $1) \
62 $$(DOCBOOK5_MANPAGES_FLAGS) \
63 $$(DOCBOOK5_MANPAGES_STYLESHEET) \
64 -
65 for alias in $(wordlist 2,$(words $1),$1); do \
66 ln -sf $(notdir $(firstword $1)) $$$$alias; \
67 done
68 endef
47 69
48 DESTDIR ?= 70 DESTDIR ?=
49 prefix ?= /usr/local 71 prefix ?= /usr/local
50 bindir ?= $(prefix)/bin 72 bindir ?= $(prefix)/bin
73 datadir ?= $(prefix)/share
74 mandir ?= $(datadir)/man
51 75
52 OS_NAME := $(shell uname -s) 76 OS_NAME := $(shell uname -s)
53 OS_RELEASE := $(shell uname -r) 77 OS_RELEASE := $(shell uname -r)
54 78
55 ifeq ($(OS_NAME),Linux) 79 ifeq ($(OS_NAME),Linux)
99 pwfile.o \ 123 pwfile.o \
100 pwm.o \ 124 pwm.o \
101 tok.o \ 125 tok.o \
102 util.o 126 util.o
103 127
128 MANPAGES = pwm.1
129
104 .DEFAULT_TARGET = all 130 .DEFAULT_TARGET = all
105 131
106 .PHONY: all clean clobber dist install 132 .PHONY: all clean clobber dist install
107 133
108 all: $(PACKAGE) 134 all: $(PACKAGE) $(MANPAGES)
109 135
110 XCPPFLAGS = -DPACKAGE=\"$(PACKAGE)\" \ 136 XCPPFLAGS = -DPACKAGE=\"$(PACKAGE)\" \
111 -DVERSION=\"$(VERSION)\" 137 -DVERSION=\"$(VERSION)\"
112 LDLIBS = -lpws -lnettle 138 LDLIBS = -lpws -lnettle
113 ifeq ($(HAVE_ERR_H),1) 139 ifeq ($(HAVE_ERR_H),1)
144 endif 170 endif
145 171
146 $(PACKAGE): $(OBJS) 172 $(PACKAGE): $(OBJS)
147 $(LINK.o) $^ $(LDLIBS) -o $@ 173 $(LINK.o) $^ $(LDLIBS) -o $@
148 174
175 $(eval $(call generate-manpage-rule,$(MANPAGES)))
176
149 %.o: %.c 177 %.o: %.c
150 $(MAKEDEPEND.c) $< | $(SED) -f deps.sed >$*.d 178 $(MAKEDEPEND.c) $< | $(SED) -f deps.sed >$*.d
151 $(COMPILE.c) -o $@ $< 179 $(COMPILE.c) -o $@ $<
152 180
153 install: 181 install:
154 $(INSTALL.exec) $(PACKAGE) "$(DESTDIR)$(bindir)/$(PACKAGE)" 182 $(INSTALL.exec) $(PACKAGE) "$(DESTDIR)$(bindir)/$(PACKAGE)"
183 for manpage in $(MANPAGES); do \
184 if [ -L $${manpage} ]; then \
185 $(INSTALL.link) $${manpage} \
186 "$(DESTDIR)$(mandir)/man$${manpage##*.}/$${manpage##*/}"; \
187 else \
188 $(INSTALL.data) $${manpage} \
189 "$(DESTDIR)$(mandir)/man$${manpage##*.}/$${manpage##*/}"; \
190 fi \
191 done
155 192
156 clean: 193 clean:
157 rm -f $(PACKAGE) $(OBJS) 194 rm -f $(PACKAGE) $(OBJS) $(MANPAGES)
158 195
159 clobber: clean 196 clobber: clean
160 rm -f $(patsubst %.o,%.d,$(OBJS)) 197 rm -f $(patsubst %.o,%.d,$(OBJS))
161 198
162 dist: clobber 199 dist: clobber