RN rnmake  3.0.0
Rules.netmsgs.mk
Go to the documentation of this file.
1 ################################################################################
2 #
3 # Rules.netmsgs.mk
4 #
5 ifdef RNMAKE_DOXY
6 /*!
7 \file
8 
9 \brief Special rules file to make RoadNarrows NetMsgs generated file(s).
10 
11 Include this file in each local make file (usually near the bottom).
12 
13 \par Key RNMAKE Variables:
14  \li NETMSGS_XML_FILES - list of RN NetMsgs XML specification files.
15  \li NETMSGS_H_DIR - generated .h files output directory.
16  default: . (current directory)
17  \li NETMSGS_C_DIR - generated .c files output directory.
18  default: . (current directory)
19  \li NETMSGS_CFLAGS - additional netmsgs c flags.
20  \li NETMSGS_PY_DIR - generated .py files output directory.
21  default: . (current directory)
22  \li NETMSGS_PYFLAGS - additional netmsgs python flags.
23  \li NETMSGS_SHARE_DIR - share directory to copy XML files.
24  default: $(RNMAKE_PKG_ROOT)/share
25 
26 \pkgsynopsis
27 RN Make System
28 
29 \pkgfile{Rules.netmsgs.mk}
30 
31 \pkgauthor{Robin Knight,robin.knight@roadnarrows.com}
32 
33 \pkgcopyright{2010-2018,RoadNarrows LLC,http://www.roadnarrows.com}
34 
35 \license{MIT}
36 
37 \EulaBegin
38 \EulaEnd
39 
40 \cond RNMAKE_DOXY
41  */
42 endif
43 #
44 ################################################################################
45 
46 _RULES_NETMSGS_MK = 1
47 
48 # NetMsgs source generator command
49 NETMSGSGEN = netmsgsgen
50 
51 #
52 # Files
53 #
54 NETMSGS_BASES = $(basename $(NETMSGS_XML_FILES))
55 
56 NETMSGS_H_DIR ?= .
57 NETMSGS_H_FILES = $(addprefix $(NETMSGS_H_DIR)/,\
58  $(addsuffix .h,$(NETMSGS_BASES)))
59 
60 NETMSGS_C_DIR ?= .
61 NETMSGS_C_FILES = $(addprefix $(NETMSGS_C_DIR)/,\
62  $(addsuffix .c,$(NETMSGS_BASES)))
63 
64 NETMSGS_PY_DIR ?= .
65 NETMSGS_PY_FILES = $(addprefix $(NETMSGS_PY_DIR)/,\
66  $(addsuffix .py,$(NETMSGS_BASES)))
67 
68 NETMSGS_SHARE_DIR ?= $(RNMAKE_PKG_ROOT)/share
69 NETMSGS_SHARE_FILES = $(addprefix $(NETMSGS_SHARE_DIR)/,$(NETMSGS_XML_FILES))
70 
71 define xml2c
72  $(addprefix $(NETMSGS_C_DIR)/,$(addsuffix .c,$(basename $(1))))
73 endef
74 
75 .PHONY: netmsgs-all netmsgs-all-c netmsgs-all-py netmsgs-all-share
76 netmsgs-all: netmsgs-all-c netmsgs-all-py netmsgs-all-share
77 
78 netmsgs-all-c: $(NETMSGS_H_FILES)
79 
80 netmsgs-all-py: $(NETMSGS_PY_FILES)
81 
82 netmsgs-all-share: $(NETMSGS_SHARE_FILES)
83 
84 .PHONY: netmsgs-clean
85 netmsgs-clean:
86  $(RM) $(NETMSGS_H_FILES)
87  $(RM) $(NETMSGS_C_FILES)
88  $(RM) $(NETMSGS_PY_FILES)
89  $(RM) $(NETMSGS_SHARE_FILES)
90 
91 # Generate NetMsgs C .h and .c message files from XML
92 $(NETMSGS_H_DIR)/%.h : %.xml
93  @printf "\n"
94  @printf "$(color_tgt_file) $(<)$(color_end)\n"
95  @test -d "$(NETMSGS_H_DIR)" || $(MKDIR) $(NETMSGS_H_DIR)
96  $(NETMSGSGEN) --lang=c --xml=$(<) $(NETMSGS_CFLAGS) $(@) $(call xml2c,$(<))
97 
98 # Generate NetMsgs Python .py files from XML
99 $(NETMSGS_PY_DIR)/%.py : %.xml
100  @printf "\n"
101  @printf "$(color_tgt_file) $(<)$(color_end)\n"
102  @test -d "$(NETMSGS_PY_DIR)" || $(MKDIR) $(NETMSGS_PY_DIR)
103  $(NETMSGSGEN) --lang=python --xml=$(<) $(NETMSGS_PYFLAGS) $(@)
104 
105 # Copy NetMsgs XML specification files to share
106 $(NETMSGS_SHARE_DIR)/%.xml : %.xml
107  @printf "\n"
108  @printf "$(color_tgt_file) $(<)$(color_end)\n"
109  @test -d "$(NETMSGS_SHARE_DIR)" || $(MKDIR) $(NETMSGS_SHARE_DIR)
110  $(CP) $(<) $(@)
111 
112 ifdef RNMAKE_DOXY
113 /*! \endcond RNMAKE_DOXY */
114 endif