Overhauled llvm/clang docs builds. Closes PR6613.
[oota-llvm.git] / docs / mk / common.rules.mk
1 ##===- docs/mk/common.rules.mk -----------------------------*- Makefile -*-===##
2
3 #                     The LLVM Compiler Infrastructure
4 #
5 # This file is distributed under the University of Illinois Open Source
6 # License. See LICENSE.TXT for details.
7
8 ##===----------------------------------------------------------------------===##
9
10 # Emit an error for any missing variables which are required to be defined
11 # before including this makefile-module.
12 #
13 _DOCS.vars.missing := $(foreach v,$(DOCS.vars.mandatory),$(if $($v),,$v))
14
15 ifneq (,$(strip $(_DOCS.vars.missing)))
16 $(call fn.DUMP.errorn,undefined variable,$(_DOCS.vars.missing))
17 endif
18
19 ##===----------------------------------------------------------------------===##
20
21 # Basic target to build directory of output files.
22 # Opaque file lists not visible to target rules need not be added here.
23 #
24 $(sort $(dir $(DOCS.mkdir.files))):
25         $(Echo) Creating directory $(@:$(PROJ_OBJ_ROOT)/%=%)
26         $(Verb) $(MKDIR) $@
27
28 ##===----------------------------------------------------------------------===##
29
30 # Print help defined by variables added to the help list.
31 #
32 .PHONY:
33 help:
34         $(foreach h,$(HELP.sections),$(info $())$(info $($h)))
35         $(info $())
36
37 ##===----------------------------------------------------------------------===##
38
39 printvars:: $(DOCS.vars.mandatory:%=%.print.var)
40 printvars:: $(DOCS.vars.print:%=%.print.var)
41
42 .PHONY: %.printvar
43 %.print.var:
44         @echo '$($*)' | awk -v name='$*' '{ printf("llvm[$(MAKELEVEL)]: %-13s:  %s\n",name,$$0) }'
45
46 ##===----------------------------------------------------------------------===##
47
48 .PHONY: vars
49 vars: $(sort $(foreach n,$(filter-out \
50     .VARIABLES $(HELP.sections) HELP.%,$(.VARIABLES)),$n.print2.var))
51
52 .PHONY: %.print2.var
53 %.print2.var:
54         @echo "$* = $($*)"