forked from adjacentlink/emane-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrules.mk
122 lines (96 loc) · 3.8 KB
/
rules.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# verify TOP_DIR is defined
ifeq ($(origin TOP_DIR), undefined)
$(error TOP_DIR must be defined)
endif
# Template for emane application XML files
TEMPLATE_PLATFORM ?= $(TOP_DIR)/templates/platform.xml.template
# Template for emaneeventd application XML files
TEMPLATE_EVENTDAEMON ?= $(TOP_DIR)/templates/eventdaemon.xml.template
# Template for gpsdlocationagent XML
TEMPLATE_GPSDLOCATIONAGENT ?= $(TOP_DIR)/templates/gpsdlocationagent.xml.template
# Template for mgen input files
TEMPLATE_MGEN ?= $(TOP_DIR)/templates/mgen.template
# Template for routing input conf files
TEMPLATE_ROUTING ?= $(TOP_DIR)/templates/routing.conf.template
# Template for starting demo on remote nodes
TEMPLATE_DEMOSTART ?= $(TOP_DIR)/templates/demo-start.template
# Template for stopping demo on remote nodes
TEMPLATE_DEMOSTOP ?= $(TOP_DIR)/templates/demo-stop.template
PLATFORMDEPS=$(GENERATED_PLATFORMS:%=.%-dep) $(PLATFORMS:%=.%-dep)
.PHONY: all clean verify
all: $(GENERATED_EXTRA) $(PLATFORMDEPS) $(GENERATED_EVENTDAEMONS) \
$(GENERATED_GPSDLOCATIONAGENTS) $(GENERATED_MGENINPUTS) \
$(GENERATED_ROUTINGCONFS) demo-start demo-stop
$(MAKE) all-local
all-local:
verify:
xmllint --noout --valid *.xml
edit= sed -e 's|@NEMID[@]|$*|g' \
-e 's|@NODEID[@]|$*|g' \
-e 's|@NODEIDHEX[@]|$(shell printf "%02x" $*)|g' \
-e 's|@DEMOID[@]|$(DEMO_ID)|g' \
-e 's|@NEMXML[@]|$(NEM_XML)|g ' \
-e 's|@TOPDIR[@]|$(shell dirname $$(pwd))|g' \
-e 's|@NODECOUNT[@]|$(shell if [ -n "$(NODE_COUNT)" ]; \
then \
echo $(NODE_COUNT); \
else \
echo $(PLATFORMDEPS)| wc -w; \
fi)|g'
ifdef GENERATED_PLATFORMS
platform%.xml: $(TEMPLATE_PLATFORM)
if test -f $@; then chmod u+w $@; fi
$(edit) $< > $@
chmod g-w,u-w $@
endif
$(PLATFORMDEPS): .%-dep:%
mkdir .emanegentransportxml && \
cd .emanegentransportxml && \
emanegentransportxml ../$< && \
for i in $$(ls *.xml); do chmod g-w,u-w $$i; cp -f $$i ..; done && \
cd .. && \
rm -rf .emanegentransportxml
@touch $@
eventdaemon%.xml: $(TEMPLATE_EVENTDAEMON)
if test -f $@; then chmod u+w $@; fi
$(edit) $< > $@
chmod g-w,u-w $@
gpsdlocationagent%.xml: $(TEMPLATE_GPSDLOCATIONAGENT)
if test -f $@; then chmod u+w $@; fi
$(edit) $< > $@
chmod g-w,u-w $@
mgen%: $(TEMPLATE_MGEN)
if test -f $@; then chmod u+w $@; fi
$(edit) $< > $@
chmod g-w,u-w $@
routing%.conf: $(TEMPLATE_ROUTING)
if test -f $@; then chmod u+w $@; fi
$(edit) $< > $@
chmod g-w,u-w $@
demo-start: $(TEMPLATE_DEMOSTART)
if test -f $@; then chmod u+w $@; fi
$(edit) $< > $@
chmod g-w,u-w,a+x $@
demo-stop: $(TEMPLATE_DEMOSTOP)
if test -f $@; then chmod u+w $@; fi
$(edit) $< > $@
chmod g-w,u-w,a+x $@
%: %.in
if test -f $@; then chmod u+w $@; fi
$(edit) $< > $@
chmod g-w,u-w $@
clean:
if test -n "$(GENERATED_PLATFORMS)"; then rm -f $(GENERATED_PLATFORMS); fi
if test -n "rm -f $(GENERATED_EVENTDAEMONS)"; then rm -f $(GENERATED_EVENTDAEMONS); fi
if test -n "rm -f $(GENERATED_GPSDLOCATIONAGENTS)"; then rm -f $(GENERATED_GPSDLOCATIONAGENTS); fi
if test -n "rm -f $(GENERATED_MGENINPUTS)"; then rm -f $(GENERATED_MGENINPUTS); fi
if test -n "rm -f $(GENERATED_ROUTINGCONFS)"; then rm -f $(GENERATED_ROUTINGCONFS); fi
if test -n "rm -f $(GENERATED_EXTRA)"; then rm -f $(GENERATED_EXTRA); fi
rm -f transportdaemon[0-9]*.xml
rm -f .*-dep*
rm -rf .emanegentransportxml
rm -rf persist
rm -f demo-start
rm -f demo-stop
$(MAKE) clean-local
clean-local: