comparison Makefile @ 1:e1309515d111

Add README file and manpages
author Guido Berhoerster <guido+libpws@berhoerster.name>
date Wed, 25 Mar 2015 17:10:23 +0100
parents d541e748cfd8
children 97097b4b6bfb
comparison
equal deleted inserted replaced
0:d541e748cfd8 1:e1309515d111
43 INSTALL.lib := $(INSTALL) -D -m 0644 43 INSTALL.lib := $(INSTALL) -D -m 0644
44 INSTALL.data := $(INSTALL) -D -m 0644 44 INSTALL.data := $(INSTALL) -D -m 0644
45 PAX := pax 45 PAX := pax
46 GZIP := gzip 46 GZIP := gzip
47 SED := sed 47 SED := sed
48 XSLTPROC := xsltproc
49 DOCBOOK5_MANPAGES_STYLESHEET = http://docbook.sourceforge.net/release/xsl-ns/current/manpages/docbook.xsl
50 DOCBOOK5_MANPAGES_FLAGS = --stringparam funcsynopsis.style 'ansi' \
51 --stringparam man.authors.section.enabled 0 \
52 --stringparam man.copyright.section.enabled 0
53 DOCBOOK5_XHTML_STYLESHEET = http://docbook.sourceforge.net/release/xsl-ns/current/xhtml/docbook.xsl
54 DOCBOOK5_XHTML_FLAGS = --stringparam funcsynopsis.style 'ansi' \
55 --stringparam generate.consistent.ids 1 \
56 --stringparam refentry.generate.name 1 \
57 --stringparam refentry.generate.title 0 \
58 --stringparam refentry.xref.manvolnum 1 \
59 --stringparam generate.id.attributes 1 \
60 --stringparam make.valid.html 1 \
61 --stringparam make.clean.html 1 \
62 --stringparam html.cleanup 1 \
63 --stringparam html.longdesc 0 \
64 --stringparam ulink.target '' \
65 --stringparam docbook.css.source '' \
66 --stringparam css.decoration 0 \
67 --stringparam default.table.width '100%'
68
69 define generate-manpage-rule =
70 $(addsuffix .%,$(basename $1)): $(addsuffix .%.xml,$(basename $(firstword $1))) docbook-update-source-data.xsl
71 $$(XSLTPROC) \
72 --xinclude \
73 --stringparam package $$(PACKAGE) \
74 --stringparam version $$(VERSION) \
75 docbook-update-source-data.xsl $$< | \
76 $$(XSLTPROC) \
77 --xinclude \
78 --output $(firstword $1) \
79 $$(DOCBOOK5_MANPAGES_FLAGS) \
80 $$(DOCBOOK5_MANPAGES_STYLESHEET) \
81 -
82 $$(SED) 's,^\.HP \\w.*$$$$,.HP 4n,' $$@ >$$(@).tmp && mv $$(@).tmp $$@
83 for alias in $(wordlist 2,$(words $1),$1); do \
84 ln -sf $(notdir $(firstword $1)) $$$$alias; \
85 done
86 endef
48 87
49 DESTDIR ?= 88 DESTDIR ?=
50 prefix ?= /usr/local 89 prefix ?= /usr/local
51 bindir ?= $(prefix)/bin 90 bindir ?= $(prefix)/bin
52 libdir ?= $(prefix)/lib 91 libdir ?= $(prefix)/lib
102 LIBPWS_LIB = $(PACKAGE).a 141 LIBPWS_LIB = $(PACKAGE).a
103 LIBPWS_LIB_MEMBERS = $(LIBPWS_OBJS:%.o=$(LIBPWS_LIB)(%.o)) 142 LIBPWS_LIB_MEMBERS = $(LIBPWS_OBJS:%.o=$(LIBPWS_LIB)(%.o))
104 143
105 OBJS = $(LIBPWS_OBJS) 144 OBJS = $(LIBPWS_OBJS)
106 145
146 LIBPWS_MANPAGES = libpws.3
147
148 PWS_INIT_MANPAGES = pws_init.3 \
149 pws_finalize.3 \
150 pws_set_alloc_functions.3 \
151 pws_generate_uuid.3
152
153 PWS3_FILE_CREATE_MANPAGES = pws3_file_create.3 \
154 pws3_file_destroy.3 \
155 pws3_file_get_error_code.3 \
156 pws3_file_get_error_message.3 \
157 pws3_file_read_mem.3 \
158 pws3_file_read_stream.3 \
159 pws3_file_write_mem.3 \
160 pws3_file_write_stream.3 \
161 pws3_file_set_header_field.3 \
162 pws3_file_get_header_field.3 \
163 pws3_file_remove_header_field.3 \
164 pws3_file_insert_empty_group.3 \
165 pws3_file_get_empty_group.3 \
166 pws3_file_remove_empty_group.3 \
167 pws3_file_first_empty_group.3 \
168 pws3_file_last_empty_group.3 \
169 pws3_file_next_empty_group.3 \
170 pws3_file_prev_empty_group.3 \
171 pws3_file_insert_record.3 \
172 pws3_file_get_record.3 \
173 pws3_file_remove_record.3 \
174 pws3_file_first_record.3 \
175 pws3_file_last_record.3 \
176 pws3_file_next_record.3 \
177 pws3_file_prev_record.3 \
178 pws3_field_create.3 \
179 pws3_field_destroy.3 \
180 pws3_field_is_header.3 \
181 pws3_field_get_type.3 \
182 pws3_field_get_data_type.3 \
183 pws3_field_set_uuid.3 \
184 pws3_field_set_text.3 \
185 pws3_field_set_time.3 \
186 pws3_field_set_uint8.3 \
187 pws3_field_set_uint16.3 \
188 pws3_field_set_uint32.3 \
189 pws3_field_set_bytes.3 \
190 pws3_field_get_uuid.3 \
191 pws3_field_get_text.3 \
192 pws3_field_get_time.3 \
193 pws3_field_get_uint8.3 \
194 pws3_field_get_uint16.3 \
195 pws3_field_get_uint32.3 \
196 pws3_field_get_bytes.3 \
197 pws3_record_create.3 \
198 pws3_record_destroy.3 \
199 pws3_record_set_field.3 \
200 pws3_record_get_field.3 \
201 pws3_record_remove_field.3
202
203 MANPAGES = $(LIBPWS_MANPAGES) \
204 $(PWS_INIT_MANPAGES) \
205 $(PWS3_FILE_CREATE_MANPAGES)
206
207 XHTML_DOCUMENTATION = $(addsuffix .xhtml,$(firstword $(LIBPWS_MANPAGES)) \
208 $(firstword $(PWS_INIT_MANPAGES)) \
209 $(firstword $(PWS3_FILE_CREATE_MANPAGES)))
210
107 .DEFAULT_TARGET = all 211 .DEFAULT_TARGET = all
108 212
109 .PHONY: all clean clobber dist install 213 .PHONY: all clean clobber dist install
110 214
111 all: $(LIBPWS_LIB) 215 all: $(LIBPWS_LIB) $(MANPAGES)
216
217 doc: $(MANPAGES) $(XHTML_DOCUMENTATION)
112 218
113 XCPPFLAGS = -Iinclude 219 XCPPFLAGS = -Iinclude
114 ifeq ($(HAVE_ARC4RANDOM),1) 220 ifeq ($(HAVE_ARC4RANDOM),1)
115 XCPPFLAGS += -DHAVE_ARC4RANDOM 221 XCPPFLAGS += -DHAVE_ARC4RANDOM
116 endif 222 endif
144 XCPPFLAGS += -D_XOPEN_SOURCE=600 250 XCPPFLAGS += -D_XOPEN_SOURCE=600
145 endif 251 endif
146 252
147 $(LIBPWS_LIB): $(LIBPWS_LIB_MEMBERS) 253 $(LIBPWS_LIB): $(LIBPWS_LIB_MEMBERS)
148 254
255 $(eval $(call generate-manpage-rule,$(LIBPWS_MANPAGES)))
256
257 $(eval $(call generate-manpage-rule,$(PWS_INIT_MANPAGES)))
258
259 $(eval $(call generate-manpage-rule,$(PWS3_FILE_CREATE_MANPAGES)))
260
149 %.o: %.c 261 %.o: %.c
150 $(MAKEDEPEND.c) $< | $(SED) -f deps.sed >$*.d 262 $(MAKEDEPEND.c) $< | $(SED) -f deps.sed >$*.d
151 $(COMPILE.c) -o $@ $< 263 $(COMPILE.c) -o $@ $<
152 264
153 (%): % 265 (%): %
154 $(AR) $(ARFLAGS) $@ $< 266 $(AR) $(ARFLAGS) $@ $<
155 $(RANLIB) $@ 267 $(RANLIB) $@
156 268
269 %.xhtml: %.xml docbook-update-source-data.xsl
270 $(XSLTPROC) \
271 --xinclude \
272 --stringparam package $(PACKAGE) \
273 --stringparam version $(VERSION) \
274 docbook-update-source-data.xsl $< | \
275 $(XSLTPROC) \
276 --xinclude \
277 --output $@ \
278 $(DOCBOOK5_XHTML_FLAGS) \
279 $(DOCBOOK5_XHTML_STYLESHEET) \
280 -
281
157 install: 282 install:
158 for header in include/*.h; do \ 283 for header in include/*.h; do \
159 $(INSTALL.data) $${header} \ 284 $(INSTALL.data) $${header} \
160 "$(DESTDIR)$(includedir)/$(PACKAGE)/$${header##*/}"; \ 285 "$(DESTDIR)$(includedir)/$${header##*/}"; \
161 done 286 done
162 $(INSTALL.lib) $(LIBPWS_LIB) \ 287 $(INSTALL.lib) $(LIBPWS_LIB) \
163 "$(DESTDIR)$(libdir)/$(notdir $(LIBPWS_LIB))" 288 "$(DESTDIR)$(libdir)/$(notdir $(LIBPWS_LIB))"
289 for manpage in $(MANPAGES); do \
290 if [ -L $${manpage} ]; then \
291 $(INSTALL.link) $${manpage} \
292 "$(DESTDIR)$(mandir)/man$${manpage##*.}/$${manpage##*/}"; \
293 else \
294 $(INSTALL.data) $${manpage} \
295 "$(DESTDIR)$(mandir)/man$${manpage##*.}/$${manpage##*/}"; \
296 fi \
297 done
164 298
165 clean: 299 clean:
166 rm -f $(LIBPWS_LIB) $(LIBPWS_OBJS) 300 rm -f $(LIBPWS_LIB) $(LIBPWS_OBJS) $(MANPAGES) \
301 $(XHTML_DOCUMENTATION)
167 302
168 clobber: clean 303 clobber: clean
169 rm -f $(patsubst %.o,%.d,$(OBJS)) 304 rm -f $(patsubst %.o,%.d,$(OBJS))
170 305
171 dist: clobber 306 dist: clobber