-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
68 lines (54 loc) · 1.46 KB
/
Makefile
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
PACKAGES := $(wildcard packages/*)
TARGET_DIR = ncs-run
TARGET_SETUP = $(TARGET_DIR)
NCS_SETUP = ncs-setup
NCS_CLI = ncs_cli
ENV_VARS =
NCS = ncs
NETSIM = ncs-netsim
all: build test
clean: clean_packages
rm -rf ncs-run
rm -rf netsim
rm -f netsim_init.xml
.PHONY: clean
build: make_packages $(TARGET_SETUP) link_packages setup_netsim
.PHONY: build
$(TARGET_SETUP):
$(NCS_SETUP) --dest $(TARGET_DIR)
make_packages: $(PACKAGES)
$(foreach pkg, $(PACKAGES), \
if [ -d "$(pkg)" ]; then $(MAKE) -C"$(pkg)/src" all; fi &&) true
.PHONY: make_packages
cli:
$(ENV_VARS) $(NCS_CLI) -u admin -g admin
.PHONY: cli
clean_packages:
$(foreach pkg, $(PACKAGES), \
if [ -d "$(pkg)" ]; then $(MAKE) -C $(pkg)/src clean; fi; )
.PHONY: clean_packages
link_packages:
$(foreach pkg, $(PACKAGES), \
if [ -d "$(pkg)" ]; then ln -sf ../../$(pkg) $(TARGET_DIR)/packages/ ; fi &&) true
.PHONY: link_packages
clean_cdb:
rm -f $(TARGET_DIR)/ncs-cdb/*.cdb
.PHONY: clean_cdb
start: start_netsim
(cd $(TARGET_DIR); $(NCS))
printf "request devices sync-from\n" | ncs_cli -u admin
printf "configure\nload merge init.xml\ncommit\n" | ncs_cli -u admin
.PHONY: start
stop: stop_netsim
$(NCS) --stop || true
.PHONY: stop
start_netsim:
$(NETSIM) start
.PHONY: start_netsim
stop_netsim:
$(NETSIM) stop || true
.PHONY: stop_netsim
setup_netsim:
$(NETSIM) create-network ./packages/router 3 ex --dir ./netsim
$(NETSIM) ncs-xml-init > $(TARGET_DIR)/ncs-cdb/netsim_init.xml
.PHONY: setup_netsim