]> mj.ucw.cz Git - libucw.git/blobdiff - build/Makebottom
ucw docs: parser units
[libucw.git] / build / Makebottom
index b15ce14d0c68699dac96a6a8d4218aa7164fda2b..ed4b30f7bcd3f3287d6cd5d182a2b6ab1e4b5788 100644 (file)
@@ -3,11 +3,13 @@
 
 # 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
-       $(Q)mkdir -p run $(addprefix run/, cf $(EXTRA_RUNDIRS) $(INSTALL_RUNDIRS))
+       $(Q)mkdir -p run $(addprefix run/, $(CONFIG_DIR) $(EXTRA_RUNDIRS) $(INSTALL_RUNDIRS))
        $(Q)touch run/.tree-stamp
 
 # Miscellaneous targets
@@ -15,7 +17,8 @@ run/.tree-stamp: $(o)/config.mk
 programs: $(PROGS)
 datafiles: $(DATAFILES)
 tests: $(TESTS)
-configs: $(addprefix run/cf/,$(CONFIGS))
+configs: $(addprefix run/$(CONFIG_DIR)/,$(CONFIGS))
+docs: runtree $(DOCS) $(DOC_INDICES)
 
 tags:
        etags `find . -name "*.[ch]"`
@@ -39,13 +42,14 @@ force:
 
 # Rules for configuration files
 
-run/cf/%: custom/cf/% $(o)/config.mk $(s)/build/genconf
+run/$(CONFIG_DIR)/%: $(s)/$(CONFIG_DIR)/% $(o)/config.mk $(s)/build/genconf
        $(M)CF $<
        $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
 
-run/cf/%: $(s)/cf/% $(o)/config.mk $(s)/build/genconf
+$(o)/%.cf: $(s)/%.cf $(o)/config.mk $(s)/build/genconf
        $(M)CF $<
        $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
+       $(Q)cp $@ run/$(CONFIG_DIR)/$(basename $(@F))
 
 # Rules for libraries
 
@@ -54,13 +58,13 @@ run/cf/%: $(s)/cf/% $(o)/config.mk $(s)/build/genconf
        $(Q)rm -f $@
        $(Q)ar rcs $@ $^
 ifdef CONFIG_INSTALL_API
-       $(Q)$(call symlink,$@,run/lib)
+       $(Q)$(call symlink-alias,$@,run/lib,$(*F)$(LIBNAME_INFIX).a)
 endif
 
 %.so:
        $(M)LD $@
        $(Q)$(CC) $(LSHARED) $(LDFLAGS) -o $@ $^
-       $(Q)$(call symlink,$@,run/lib)
+       $(Q)$(call symlink-alias,$@,run/lib,$(*F)$(SONAME_INFIX).so$(SONAME_SUFFIX))
 
 $(o)/%.pc: $(s)/%.pc $(o)/%.$(LS)
        $(M)PC $<
@@ -72,7 +76,15 @@ $(o)/%.pc: $(s)/%.pc $(o)/%.$(LS)
 
 ifdef CONFIG_INSTALL_API
 
-API_ROOT:=$(shell cd run && pwd)
+ifdef CONFIG_LOCAL
+# Need an absolute path
+API_ROOT:=$(shell pwd)/run
+API_LIBDIR=$(API_ROOT)/lib
+API_INCDIR=$(API_ROOT)/include
+else
+API_LIBDIR=$(INSTALL_LIB_DIR)
+API_INCDIR=$(INSTALL_INCLUDE_DIR)
+endif
 INSTALL_RUNDIRS+=include lib/pkgconfig
 api: $(API_INCLUDES) $(addprefix run/lib/pkgconfig/,$(addsuffix .pc,$(API_LIBS)))
 
@@ -80,9 +92,9 @@ $(o)/%/.include-stamp:
        $(Q)$(s)/build/install-includes $(<D) run/include/$(IDST) $(?F)
        $(Q)touch $@
 
-run/lib/pkgconfig/%.pc: $(o)/pkgconfig/%.pc
-       $(M)PC $@
-       $(Q)sed <$< >$@ "s@^libdir=.*@libdir=$(API_ROOT)/lib@;s@^incdir=.*@incdir=$(API_ROOT)/include@"
+run/lib/pkgconfig/%.pc:                # RHS supplied in the sub-makefile
+       $(M)PC-API $@
+       $(Q)sed <$< >$@ "s@^libdir=.*@libdir=$(API_LIBDIR)@;s@^incdir=.*@incdir=$(API_INCDIR)@"
 
 else
 api:
@@ -90,43 +102,43 @@ endif
 
 # Rules for compiling C
 
-$(o)/%.o: $(s)/%.c $(o)/lib/autoconf.h
+$(o)/%.o: $(s)/%.c $(o)/autoconf.h
        $(M)CC $<
        $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -c -o $@ $<
 
-$(o)/%.o: %.c $(o)/lib/autoconf.h
+$(o)/%.o: %.c $(o)/autoconf.h
        $(M)CC $<
        $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -c -o $@ $<
 
-%.o: %.c $(o)/lib/autoconf.h
+%.o: %.c $(o)/autoconf.h
        $(M)CC $<
        $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -c -o $@ $<
 
-$(o)/%.oo: $(s)/%.c $(o)/lib/autoconf.h
+$(o)/%.oo: $(s)/%.c $(o)/autoconf.h
        $(M)CC-SO $<
        $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) $(CSHARED) -c -o $@ $<
 
-$(o)/%.oo: %.c $(o)/lib/autoconf.h
+$(o)/%.oo: %.c $(o)/autoconf.h
        $(M)CC-SO $<
        $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) $(CSHARED) -c -o $@ $<
 
-%.oo: %.c $(o)/lib/autoconf.h
+%.oo: %.c $(o)/autoconf.h
        $(M)CC-SO $<
        $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) $(CSHARED) -c -o $@ $<
 
-$(o)/%-tt.o: $(s)/%.c $(o)/lib/autoconf.h
+$(o)/%-tt.o: $(s)/%.c $(o)/autoconf.h
        $(M)CC-TEST $<
        $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -DTEST -c -o $@ $<
 
 # Rules for testing
 
-$(o)/%-t: $(o)/%-tt.o $(LIBSH)
+$(o)/%-t: $(o)/%-tt.o $(TESTING_DEPS)
        $(M)LD-TEST $@
-       $(Q)$(CC) $(LDFLAGS) -o $@ $^ $(shell $(s)/build/lib-flags $^) $(LIBS)
+       $(Q)$(CC) $(LDFLAGS) -o $@ $(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" $(s)/build/lib-flags $^) $(LIBS)
 
 $(o)/%.test: $(s)/%.t $(s)/build/tester
        $(M)TEST $@
-       $(Q)$(s)/build/tester $< && touch $@
+       $(Q)$(s)/build/tester --rundir=run $(TESTERFLAGS) $< && touch $@
 
 # Rules for binaries
 
@@ -134,7 +146,7 @@ BINDIR=bin
 
 $(o)/%: $(o)/%.o
        $(M)LD $@
-       $(Q)$(CC) $(LDFLAGS) -o $@ $(shell $(s)/build/lib-flags $^) $(LIBS)
+       $(Q)$(CC) $(LDFLAGS) -o $@ $(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" $(s)/build/lib-flags $^) $(LIBS)
        $(Q)$(call symlink,$@,run/$(BINDIR))
 
 $(o)/%: $(s)/%.sh $(o)/config.mk $(s)/build/genconf
@@ -161,15 +173,17 @@ $(o)/%: %.pl $(o)/config.mk $(s)/build/genconf
        $(Q)chmod +x $@
        $(Q)$(call symlink,$@,run/$(BINDIR))
 
+PERL_MODULE_DIR=UCW
+
 $(o)/%.pm: $(s)/%.pm
-       $(M)PM $<
+       $(M)"PM $< -> run/lib/perl5/$(PERL_MODULE_DIR)/$(@F)"
        $(Q)cp $^ $@
-       $(Q)$(call symlink,$@,run/lib/perl5/Sherlock)
+       $(Q)$(call symlink,$@,run/lib/perl5/$(PERL_MODULE_DIR))
 
 $(o)/%.pm: %.pm
-       $(M)PM $<
+       $(M)"PM $< -> run/lib/perl/$(PERL_MODULE_DIR)/$(@F)"
        $(Q)cp $^ $@
-       $(Q)$(call symlink,$@,run/lib/perl5/Sherlock)
+       $(Q)$(call symlink,$@,run/lib/perl5/$(PERL_MODULE_DIR))
 
 # Rules for data files
 
@@ -180,14 +194,34 @@ $(DATAFILES): $(o)/%: $(s)/%
        $(Q)cp $^ $@
        $(Q)$(call symlink,$@,run/$(DATADIR))
 
+# Rules for documentation
+
+
+$(o)/%.html: $(o)/%.txt $(s)/build/asciidoc.conf $(s)/build/asciidoc-xhtml.conf run/$(DOCDIR)/$(DOC_MODULE)/.dir-stamp
+       $(M)"DOC-HTML $<"
+       $(Q)asciidoc -e -f $(s)/build/asciidoc.conf -f $(s)/build/asciidoc-xhtml.conf -f /etc/asciidoc/asciidoc.conf -f /etc/asciidoc/xhtml11.conf $<
+       $(Q)$(call symlink,$@,run/$(DOCDIR)/$(DOC_MODULE))
+
+# 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)) $(s)/build/doc-defs
+       $(M)"DOC-DEFS $@"
+       $(Q)echo $@: $(DOC_HEAD) $(DOC_LIST) >> $(o)/depend.new
+       $(Q)$(s)/build/doc-defs $(DOC_HEAD) $@ $(DOC_LIST)
+
+$(patsubst %.html,%.txt,$(DOCS)): $(o)/%.txt: $(s)/%.txt $(s)/build/doc-extract
+       $(M)"DOC-EXT $<"
+       $(Q)$(s)/build/doc-extract $< $@ $(o)/depend.new $(s) $(patsubst %.txt,%.deflist,$@)
+
 # Default installation target
 
 default-install:
-       SH_EXTRA_RUNDIRS="$(sort $(EXTRA_RUNDIRS))" SH_INSTALL_RUNDIRS="$(sort $(INSTALL_RUNDIRS))" SH_CONFIGS="$(sort $(CONFIGS))" $(s)/build/installer $(INSTALL_DIR)
+       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)
 
 # 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 default-install docs