]> mj.ucw.cz Git - libucw.git/blobdiff - build/Makebottom
Doc: Simplified rule for compilation of manpages.
[libucw.git] / build / Makebottom
index 92bc47eab91ca65df7d7395418843610d5a0572c..b66959624576f20acfe86252a0e1c39d8c9beb67 100644 (file)
@@ -1,9 +1,11 @@
 # Bottom part of Makefile for the UCW Libraries
 # Bottom part of Makefile for the UCW Libraries
-# (c) 1997--2007 Martin Mares <mj@ucw.cz>
+# (c) 1997--2008 Martin Mares <mj@ucw.cz>
 
 # The run tree
 
 
 # The run tree
 
-runtree: run/.tree-stamp $(addsuffix /.dir-stamp,$(addprefix $(o)/,$(DIRS)))
+DOCDIR=doc
+
+runtree: run/.tree-stamp $(addsuffix /.dir-stamp,$(addprefix $(o)/,$(DIRS)) $(addprefix run/$(DOCDIR)/,$(DOC_MODULES)))
 
 run/.tree-stamp: $(o)/config.mk
        $(M)Creating runtree
 
 run/.tree-stamp: $(o)/config.mk
        $(M)Creating runtree
@@ -16,6 +18,7 @@ programs: $(PROGS)
 datafiles: $(DATAFILES)
 tests: $(TESTS)
 configs: $(addprefix run/$(CONFIG_DIR)/,$(CONFIGS))
 datafiles: $(DATAFILES)
 tests: $(TESTS)
 configs: $(addprefix run/$(CONFIG_DIR)/,$(CONFIGS))
+docs: runtree $(DOCS) $(DOC_INDICES) $(MANPAGES)
 
 tags:
        etags `find . -name "*.[ch]"`
 
 tags:
        etags `find . -name "*.[ch]"`
@@ -28,7 +31,7 @@ tags:
 -include $(o)/depend
 
 $(o)/depend: force
 -include $(o)/depend
 
 $(o)/depend: force
-       $(Q)if [ -s $(o)/depend.new ] ; then $(s)/build/mergedeps $(o)/depend $(o)/depend.new ; >$(o)/depend.new ; fi
+       $(Q)if [ -s $(o)/depend.new ] ; then $(BUILDSYS)/mergedeps $(o)/depend $(o)/depend.new ; >$(o)/depend.new ; fi
 
 force:
 
 
 force:
 
@@ -39,13 +42,13 @@ force:
 
 # Rules for configuration files
 
 
 # Rules for configuration files
 
-run/$(CONFIG_DIR)/%: $(s)/$(CONFIG_DIR)/% $(o)/config.mk $(s)/build/genconf
+run/$(CONFIG_DIR)/%: $(s)/$(CONFIG_SRC_DIR)/% $(o)/config.mk $(BUILDSYS)/genconf
        $(M)CF $<
        $(M)CF $<
-       $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
+       $(Q)$(BUILDSYS)/genconf $< $@ $(o)/config.mk
 
 
-$(o)/%.cf: $(s)/%.cf $(o)/config.mk $(s)/build/genconf
+$(o)/%.cf: $(s)/%.cf $(o)/config.mk $(BUILDSYS)/genconf
        $(M)CF $<
        $(M)CF $<
-       $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
+       $(Q)$(BUILDSYS)/genconf $< $@ $(o)/config.mk
        $(Q)cp $@ run/$(CONFIG_DIR)/$(basename $(@F))
 
 # Rules for libraries
        $(Q)cp $@ run/$(CONFIG_DIR)/$(basename $(@F))
 
 # Rules for libraries
@@ -60,12 +63,21 @@ endif
 
 %.so:
        $(M)LD $@
 
 %.so:
        $(M)LD $@
-       $(Q)$(CC) $(LSHARED) $(LDFLAGS) -o $@ $^
-       $(Q)$(call symlink-alias,$@,run/lib,$(*F)$(SONAME_INFIX).so$(SONAME_SUFFIX))
-
-$(o)/%.pc: $(s)/%.pc $(o)/%.$(LS)
+       $(Q)$(CC) $(LSHARED) $(LDFLAGS) -o $@ $(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" PKG_CONFIG_OPTS="$(PKG_CONFIG_OPTS)" $(BUILDSYS)/lib-flags $^) $(LIBS)
+       $(Q)$(call symlink-alias,$@,run/$(SO_RUNDIR),$(*F)$(SONAME_INFIX).so$(SONAME_SUFFIX))
+       $(Q)ln -fs $(*F)$(SONAME_INFIX).so$(SONAME_SUFFIX) run/$(SO_RUNDIR)/$(*F)$(SONAME_INFIX).so
+
+# On Darwin, gcc expects shared libraries in *.dylib instead of *.so.
+# Surprisingly, when a program is run, it suffices to have *.so files.
+# We don't want to mess up the whole build system with configurable
+# suffices and we also don't want to incur an overhead on Linux, so we
+# just create symbolic links on Darwin, if requested.
+%.dylib: %.so
+       cd $(dir $<) && ln -fs $(notdir $<) $(notdir $@)
+
+$(o)/%.pc: $(s)/%.pc $(o)/%$(LV).$(LS)
        $(M)PC $<
        $(M)PC $<
-       $(Q)DEPS="$(shell $(s)/build/lib-deps $^)" LIBDIR=$(@D) $(s)/build/genconf $< $@ $(o)/config.mk
+       $(Q)DEPS="$(shell $(BUILDSYS)/lib-deps $^)" LIBDIR=$(@D) $(BUILDSYS)/genconf $< $@ $(o)/config.mk
        $(Q)mkdir -p $(o)/pkgconfig
        $(Q)$(call symlink,$@,$(o)/pkgconfig)
 
        $(Q)mkdir -p $(o)/pkgconfig
        $(Q)$(call symlink,$@,$(o)/pkgconfig)
 
@@ -86,7 +98,7 @@ INSTALL_RUNDIRS+=include lib/pkgconfig
 api: $(API_INCLUDES) $(addprefix run/lib/pkgconfig/,$(addsuffix .pc,$(API_LIBS)))
 
 $(o)/%/.include-stamp:
 api: $(API_INCLUDES) $(addprefix run/lib/pkgconfig/,$(addsuffix .pc,$(API_LIBS)))
 
 $(o)/%/.include-stamp:
-       $(Q)$(s)/build/install-includes $(<D) run/include/$(IDST) $(?F)
+       $(Q)$(BUILDSYS)/install-includes $(<D) run/include/$(IDST) $(?F)
        $(Q)touch $@
 
 run/lib/pkgconfig/%.pc:                # RHS supplied in the sub-makefile
        $(Q)touch $@
 
 run/lib/pkgconfig/%.pc:                # RHS supplied in the sub-makefile
@@ -131,11 +143,11 @@ $(o)/%-tt.o: $(s)/%.c $(o)/autoconf.h
 
 $(o)/%-t: $(o)/%-tt.o $(TESTING_DEPS)
        $(M)LD-TEST $@
 
 $(o)/%-t: $(o)/%-tt.o $(TESTING_DEPS)
        $(M)LD-TEST $@
-       $(Q)$(CC) $(LDFLAGS) -o $@ $(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" $(s)/build/lib-flags $^) $(LIBS)
+       $(Q)$(CC) $(LDFLAGS) -o $@ $(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" PKG_CONFIG_OPTS="$(PKG_CONFIG_OPTS)" $(BUILDSYS)/lib-flags $^) $(LIBS)
 
 
-$(o)/%.test: $(s)/%.t $(s)/build/tester
+$(o)/%.test: $(s)/%.t $(BUILDSYS)/tester
        $(M)TEST $@
        $(M)TEST $@
-       $(Q)$(s)/build/tester --rundir=run $(TESTERFLAGS) $< && touch $@
+       $(Q)$(BUILDSYS)/tester --rundir=run $(TESTERFLAGS) $< && touch $@
 
 # Rules for binaries
 
 
 # Rules for binaries
 
@@ -143,30 +155,30 @@ BINDIR=bin
 
 $(o)/%: $(o)/%.o
        $(M)LD $@
 
 $(o)/%: $(o)/%.o
        $(M)LD $@
-       $(Q)$(CC) $(LDFLAGS) -o $@ $(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" $(s)/build/lib-flags $^) $(LIBS)
+       $(Q)$(CC) $(LDFLAGS) -o $@ $(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" PKG_CONFIG_OPTS="$(PKG_CONFIG_OPTS)" $(BUILDSYS)/lib-flags $^) $(LIBS)
        $(Q)$(call symlink,$@,run/$(BINDIR))
 
        $(Q)$(call symlink,$@,run/$(BINDIR))
 
-$(o)/%: $(s)/%.sh $(o)/config.mk $(s)/build/genconf
+$(o)/%: $(s)/%.sh $(o)/config.mk $(BUILDSYS)/genconf
        $(M)PP $<
        $(M)PP $<
-       $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
+       $(Q)$(BUILDSYS)/genconf $< $@ $(o)/config.mk
        $(Q)chmod +x $@
        $(Q)$(call symlink,$@,run/$(BINDIR))
 
        $(Q)chmod +x $@
        $(Q)$(call symlink,$@,run/$(BINDIR))
 
-$(o)/%: %.sh $(o)/config.mk $(s)/build/genconf
+$(o)/%: %.sh $(o)/config.mk $(BUILDSYS)/genconf
        $(M)PP $<
        $(M)PP $<
-       $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
+       $(Q)$(BUILDSYS)/genconf $< $@ $(o)/config.mk
        $(Q)chmod +x $@
        $(Q)$(call symlink,$@,run/$(BINDIR))
 
        $(Q)chmod +x $@
        $(Q)$(call symlink,$@,run/$(BINDIR))
 
-$(o)/%: $(s)/%.pl $(o)/config.mk $(s)/build/genconf
+$(o)/%: $(s)/%.pl $(o)/config.mk $(BUILDSYS)/genconf
        $(M)PP $<
        $(M)PP $<
-       $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
+       $(Q)$(BUILDSYS)/genconf $< $@ $(o)/config.mk
        $(Q)chmod +x $@
        $(Q)$(call symlink,$@,run/$(BINDIR))
 
        $(Q)chmod +x $@
        $(Q)$(call symlink,$@,run/$(BINDIR))
 
-$(o)/%: %.pl $(o)/config.mk $(s)/build/genconf
+$(o)/%: %.pl $(o)/config.mk $(BUILDSYS)/genconf
        $(M)PP $<
        $(M)PP $<
-       $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
+       $(Q)$(BUILDSYS)/genconf $< $@ $(o)/config.mk
        $(Q)chmod +x $@
        $(Q)$(call symlink,$@,run/$(BINDIR))
 
        $(Q)chmod +x $@
        $(Q)$(call symlink,$@,run/$(BINDIR))
 
@@ -191,14 +203,32 @@ $(DATAFILES): $(o)/%: $(s)/%
        $(Q)cp $^ $@
        $(Q)$(call symlink,$@,run/$(DATADIR))
 
        $(Q)cp $^ $@
        $(Q)$(call symlink,$@,run/$(DATADIR))
 
-# Default installation target
+# Rules for documentation
+
+$(o)/%.html: $(o)/%.txt $(BUILDSYS)/asciidoc.conf $(BUILDSYS)/asciidoc-xhtml.conf run/$(DOCDIR)/$(DOC_MODULE)/.dir-stamp
+       $(M)"DOC-HTML $<"
+       $(Q)asciidoc -e -f $(BUILDSYS)/asciidoc.conf -f $(BUILDSYS)/asciidoc-xhtml.conf -f $(HOST_PREFIX)/etc/asciidoc/asciidoc.conf -f $(HOST_PREFIX)/etc/asciidoc/xhtml11.conf $<
+       $(Q)$(call symlink,$@,run/$(DOCDIR)/$(DOC_MODULE))
+
+$(MANPAGES): $(o)/%.1: $(s)/%.txt
+       $(M)"DOC-MANPAGE $<"
+       $(Q)a2x -d manpage -f manpage -D $(dir $@) $<
+
+# In reality, we do not depend on the .txt files, but on the corresponding .deflist's.
+# However, the Makefile language cannot express that doc-extract generates both .txt
+# and .deflist, so we always use the .txt's in dependencies.
+$(patsubst %.html,%.txt,$(DOC_INDICES)): $(o)/%.txt: $(patsubst %.html,%.txt,$(DOCS)) $(BUILDSYS)/doc-defs
+       $(M)"DOC-DEFS $@"
+       $(Q)echo $@: $(DOC_HEAD) $(DOC_LIST) >> $(o)/depend.new
+       $(Q)$(BUILDSYS)/doc-defs $(DOC_HEAD) $@ $(DOC_LIST)
 
 
-default-install:
-       SH_EXTRA_RUNDIRS="$(sort $(EXTRA_RUNDIRS))" SH_INSTALL_RUNDIRS="$(sort $(INSTALL_RUNDIRS))" SH_CONFIGS="$(sort $(CONFIGS))" SH_AUTO_CONFIRM="$(CONFIRM)" $(s)/build/installer $(INSTALL_DIR)
+$(patsubst %.html,%.txt,$(DOCS)): $(o)/%.txt: $(s)/%.txt $(BUILDSYS)/doc-extract
+       $(M)"DOC-EXT $<"
+       $(Q)$(BUILDSYS)/doc-extract $< $@ $(o)/depend.new $(s) $(patsubst %.txt,%.deflist,$@)
 
 # Don't delete intermediate targets. There shouldn't be any, but due to bugs
 # in GNU Make rules with targets in not-yet-existing directories are ignored
 # when searching for implicit rules and thence targets considered intermediate.
 .SECONDARY:
 
 
 # Don't delete intermediate targets. There shouldn't be any, but due to bugs
 # in GNU Make rules with targets in not-yet-existing directories are ignored
 # when searching for implicit rules and thence targets considered intermediate.
 .SECONDARY:
 
-.PHONY: all clean distclean runtree programs api datafiles force tags configs dust install default-install
+.PHONY: all clean distclean runtree programs api datafiles force tags configs dust install docs tests