Project

General

Profile

Statistics
| Branch: | Revision:

gdp-router-click / Makefile @ master

History | View | Annotate | Download (8.11 KB)

1 239fe014 Rick Pratt
# For a gdp-router-click installation from the source:
2
#
3
#   invoke "adm/install-gdp-router-click.sh", which will leverage this
4
#   Makefile to git the correct version of click, configure userlevel
5
#   click, compile, install, and set up gdp-router-click service on
6
#   the current host.
7
#
8 d9ef385a Eric Allman
# For a gdp-router-click installation from the source: work in progress
9 239fe014 Rick Pratt
#
10 bdacc134 Nitesh Mor
11 537fe96d Rick Pratt
GDP_BLD=			build/gdp
12 870f095e Rick Pratt
GDP_REPO=			https://repoman@repo.eecs.berkeley.edu/git-anon/projects/swarmlab/gdp.git
13 cc06285b Rick Pratt
14
GDP_NET3_BRANCH=	net3-legacy
15
16 537fe96d Rick Pratt
CLICK_BLD=			build/click
17 239fe014 Rick Pratt
CLICK_REPO=			https://github.com/kohler/click.git
18 537fe96d Rick Pratt
CLICK_M=			${CLICK_BLD}/Makefile
19 239fe014 Rick Pratt
20 d672d917 Rick Pratt
# major version
21 d9ef385a Eric Allman
V=				2
22 31c2a8d8 Rick Pratt
VERHH=				version_gdp_v4_router.hh
23 d672d917 Rick Pratt
S_VERHH=			src/${VERHH}
24
25 e2404776 Rick Pratt
# userlevel workspace
26 537fe96d Rick Pratt
CLICK_UL_M=			${CLICK_BLD}/userlevel/Makefile
27 239fe014 Rick Pratt
UL_M_O=				ul_m_orig
28 537fe96d Rick Pratt
CLICK_UL_M_O=		${CLICK_BLD}/userlevel/Makefile.$(UL_M_O)
29
CLICK_UL_BINARY=	$(CLICK_BLD)/userlevel/click
30
CLICK_ELEMS_LOCAL=	${CLICK_BLD}/elements/local
31 239fe014 Rick Pratt
32 e2404776 Rick Pratt
# linuxmodule workspace
33 537fe96d Rick Pratt
CLICK_LM_PATCH=		${CLICK_BLD}/click.git_apply_patch.linuxmodule_target
34 e2404776 Rick Pratt
UNAME_R=			$(shell /bin/uname -r)
35 00b517f3 Rick Pratt
GDP_LM_PATCH=		adm/click.git_apply_patch.linuxmodule_target
36 e2404776 Rick Pratt
37 239fe014 Rick Pratt
# builds with the latest Click, unless the next line is uncommented and updated
38
#CLICK_COMMIT=	f40363bb492188d44ba2f1251d2fe5dc553b97c9
39
40 d9ef385a Eric Allman
# to allow changes on the command line
41
DESTDIR=
42
LOCALROOT=	/usr
43
44
# generally shouldn't need changing
45
INSTALLROOT=	${DESTDIR}${LOCALROOT}
46
BINDIR=		${INSTALLROOT}/bin
47
SBINDIR=	${INSTALLROOT}/sbin
48
49
50 e2404776 Rick Pratt
# default
51 d9ef385a Eric Allman
all: gdp-router-click
52 bdacc134 Nitesh Mor
53 00b517f3 Rick Pratt
# no target should survive recipe errors
54
.DELETE_ON_ERROR:
55
56 cc06285b Rick Pratt
remove_gdp:
57 537fe96d Rick Pratt
	@if [ -d "${GDP_BLD}" ]; \
58 cc06285b Rick Pratt
	then \
59 537fe96d Rick Pratt
		echo "Removing ${GDP_BLD}" ; \
60
		rm -rf ${GDP_BLD} ; \
61 cc06285b Rick Pratt
	else \
62 537fe96d Rick Pratt
		echo "${GDP_BLD} not found" ; \
63 cc06285b Rick Pratt
	fi
64
65
remove_click:
66 537fe96d Rick Pratt
	@if [ -d "${CLICK_BLD}" ]; \
67 239fe014 Rick Pratt
	then \
68 537fe96d Rick Pratt
		echo "Removing ${CLICK_BLD}" ; \
69
		rm -rf ${CLICK_BLD} ; \
70 239fe014 Rick Pratt
	else \
71 537fe96d Rick Pratt
		echo "${CLICK_BLD} not found" ; \
72 239fe014 Rick Pratt
	fi
73 bdacc134 Nitesh Mor
74 e2404776 Rick Pratt
#
75 91aeb581 Rick Pratt
# (default) set up a userlevel workspace then build gdp-router-click
76 e2404776 Rick Pratt
#
77 bdacc134 Nitesh Mor
78 d9ef385a Eric Allman
.PHONY: unconfigure_userlevel install install-gdp-router-click
79
.PHONY: stop start reinstall
80 239fe014 Rick Pratt
81 cc06285b Rick Pratt
configure_userlevel:
82 62a58ed2 Rick Pratt
	@test ! -e configure_userlevel || \
83
		{ echo "WARN: detected userlevel config, command ignored."; exit 1; }
84
	@test ! -e configure_linuxmodule || \
85
		{ echo "WARN: detected linuxmodule config, command ignored."; exit 1; }
86 5105e14d Eric Allman
	if [ ! -d ${GDP_BLD} ]; \
87 1e57c114 Rick Pratt
	then \
88
		git clone ${GDP_REPO} ${GDP_BLD} ; \
89
	fi
90 5105e14d Eric Allman
	( cd ${GDP_BLD}/util && make )
91 537fe96d Rick Pratt
	@if [ -d ${CLICK_BLD} ]; \
92 e2a8d6d7 Rick Pratt
	then \
93 537fe96d Rick Pratt
		echo "Error: pre-existing ${CLICK_BLD} (make remove_click)" ; \
94 e2a8d6d7 Rick Pratt
		exit 1 ; \
95
	fi
96 5105e14d Eric Allman
	if [ -z "${CLICK_COMMIT}" ]; \
97 e2a8d6d7 Rick Pratt
	then \
98 5105e14d Eric Allman
		git clone ${CLICK_REPO} ${CLICK_BLD} ; \
99 e2a8d6d7 Rick Pratt
	else \
100 537fe96d Rick Pratt
		git clone -n ${CLICK_REPO} ${CLICK_BLD} && \
101
				( cd ${CLICK_BLD} && git checkout ${CLICK_COMMIT} ) ; \
102 e2a8d6d7 Rick Pratt
	fi
103 5dbdffae Rick Pratt
	ln src/gdp_v4_router.hh ${CLICK_ELEMS_LOCAL}/gdp_v4_router.hh
104
	ln src/gdp_v4_router.cc ${CLICK_ELEMS_LOCAL}/gdp_v4_router.cc
105 5105e14d Eric Allman
	test -r ${CLICK_UL_M_O} || \
106 537fe96d Rick Pratt
		( cd ${CLICK_BLD} ; \
107 62a58ed2 Rick Pratt
		  ./configure --disable-linuxmodule --enable-local ; \
108
		  make elemlist ; \
109
		  sed -i.${UL_M_O} \
110 0a4d4011 Rick Pratt
			-e '/^LIBS = /s/$$/ -lssl -lcrypto -lsystemd -lresolv /' \
111 870f095e Rick Pratt
			-e 's/CXXFLAGS = -g -O2 -W -Wall/CXXFLAGS = -g -O2 -W -Wall -fno-strict-aliasing/' \
112 62a58ed2 Rick Pratt
				userlevel/Makefile )
113 d9ef385a Eric Allman
	touch configure_userlevel
114 62a58ed2 Rick Pratt
115 d9ef385a Eric Allman
unconfigure_userlevel:
116 62a58ed2 Rick Pratt
	@test ! -e configure_linuxmodule || \
117
		{ echo "WARN: detected linuxmodule config, command ignored."; exit 1; }
118 1e57c114 Rick Pratt
	@if [ -d ${GDP_BLD} ]; \
119
	then \
120
		echo "Remove ${GDP_BLD}..." ; \
121
		rm -rf ${GDP_BLD} ; \
122
	else \
123
		echo "${GDP_BLD} not found" ; \
124
	fi
125 537fe96d Rick Pratt
	@if [ -d ${CLICK_BLD} ]; \
126 e2a8d6d7 Rick Pratt
	then \
127 537fe96d Rick Pratt
		echo "Remove ${CLICK_BLD}..." ; \
128
		rm -rf ${CLICK_BLD} ; \
129 e2a8d6d7 Rick Pratt
	else \
130 537fe96d Rick Pratt
		echo "${CLICK_BLD} not found" ; \
131 e2a8d6d7 Rick Pratt
	fi
132 d9ef385a Eric Allman
	@rm -f configure_userlevel
133 62a58ed2 Rick Pratt
134 d9ef385a Eric Allman
gdp-router-click: configure_userlevel src/*.hh src/*.cc
135 62a58ed2 Rick Pratt
	@test ! -e configure_linuxmodule || \
136
		{ echo "WARN: detected linuxmodule config, command ignored."; exit 1; }
137 537fe96d Rick Pratt
	@echo "Refresh source hardlinks in ${CLICK_BLD} (required post git pull)"
138 5dbdffae Rick Pratt
	@ln -f src/gdp_v4_router.hh ${CLICK_ELEMS_LOCAL}/gdp_v4_router.hh
139
	@ln -f src/gdp_v4_router.cc ${CLICK_ELEMS_LOCAL}/gdp_v4_router.cc
140 d9ef385a Eric Allman
	@echo "/* autogenerated for gdp-router-click - do not edit */" > ${S_VERHH}
141 d672d917 Rick Pratt
	@echo "#define STRINGIFY(_vs_) # _vs_" >> ${S_VERHH}
142 d9ef385a Eric Allman
	@echo "const char *ver_major = { STRINGIFY($V) };" >> ${S_VERHH}
143
	@echo $V
144 d672d917 Rick Pratt
	@echo -n "const char *git_branch = {\n\t STRINGIFY(" >> ${S_VERHH}
145
	@git rev-parse --abbrev-ref HEAD >> ${S_VERHH}
146
	@echo -n ")};\nconst char *git_hash = {\n\t STRINGIFY(" >> ${S_VERHH}
147
	@git log -n 1 --oneline --pretty=format:'%H%n' >> ${S_VERHH}
148
	@echo ")};" >> ${S_VERHH}
149
	@ln -f ${S_VERHH} ${CLICK_ELEMS_LOCAL}/${VERHH}
150 537fe96d Rick Pratt
	@( cd $(CLICK_BLD) && make )
151 62a58ed2 Rick Pratt
	@cp ${CLICK_UL_BINARY} $@
152
153 d9ef385a Eric Allman
install: gdp-router-click
154 91aeb581 Rick Pratt
	@test ! -e configure_linuxmodule || \
155 534c81a9 Rick Pratt
		{ echo "WARN: detected linuxmodule config, command ignored."; exit 1; }
156 d9ef385a Eric Allman
	cp -p ./gdp-router-click ${SBINDIR}/gdp-router-click
157
	chmod 755 ${SBINDIR}/gdp-router-click
158
	chown gdp:gdp ${SBINDIR}/gdp-router-click
159 91aeb581 Rick Pratt
160 d9ef385a Eric Allman
install-gdp-router-click: gdp-router-click
161 65f704ba Rick Pratt
	@test ! -e configure_linuxmodule || \
162
		{ echo "WARN: detected linuxmodule config, command ignored."; exit 1; }
163 d9ef385a Eric Allman
	./adm/setup-gdp-router-click.sh
164
	cp -p ./gdp-router-click /usr/sbin/gdp-router-click
165
	chmod 755 /usr/sbin/gdp-router-click
166
	chown gdp:gdp /usr/sbin/gdp-router-click
167 cb04269b Rick Pratt
168 d9ef385a Eric Allman
docker: gdp-router-click
169
	@cp -p ./gdp-router-click ./docker.gdp_router_click/
170
	@( cd ./docker.gdp_router_click/ && docker build -t gdp_router_click . )
171 f687a636 Rick Pratt
172 d9ef385a Eric Allman
stop:
173 534c81a9 Rick Pratt
	@test ! -e configure_linuxmodule || \
174
		{ echo "WARN: detected linuxmodule config, command ignored."; exit 1; }
175 d9ef385a Eric Allman
	systemctl stop gdplogd
176
	systemctl stop gdp-router-click
177 91aeb581 Rick Pratt
178 d9ef385a Eric Allman
start:
179 534c81a9 Rick Pratt
	@test ! -e configure_linuxmodule || \
180
		{ echo "WARN: detected linuxmodule config, command ignored."; exit 1; }
181 d9ef385a Eric Allman
	systemctl start gdp-router-click
182
	systemctl start gdplogd
183 91aeb581 Rick Pratt
184 d9ef385a Eric Allman
reinstall: gdp-router-click
185 91aeb581 Rick Pratt
	@test ! -e configure_linuxmodule || \
186 534c81a9 Rick Pratt
		{ echo "WARN: detected linuxmodule config, command ignored."; exit 1; }
187 65f704ba Rick Pratt
	systemctl stop gdplogd2
188 d9ef385a Eric Allman
	systemctl stop gdp-router-click
189
	cp -p ./gdp-router-click /usr/sbin/gdp-router-click
190
	chmod 755 /usr/sbin/gdp-router-click
191
	chown gdp:gdp /usr/sbin/gdp-router-click
192
	systemctl start gdp-router-click
193 65f704ba Rick Pratt
	systemctl start gdplogd2
194 91aeb581 Rick Pratt
195 d9ef385a Eric Allman
clean: unconfigure_userlevel
196
	@test ! -r ${CLICK_M} || ( cd $(CLICK_BLD) && make clean )
197
	@rm -f ${CLICK_UL_BINARY} gdp-router-click gdp-router-click*.deb README.html
198
199 62a58ed2 Rick Pratt
#
200 e2404776 Rick Pratt
# (non-default) set up a linuxmodule workspace
201
#
202
203 00b517f3 Rick Pratt
.PHONY: unconfigure_linuxmodule lm_install lm_clean
204 e2404776 Rick Pratt
205
/usr/src/linux-headers-${UNAME_R}:
206
	@echo "Installing linux-headers-${UNAME_R}"
207 65f704ba Rick Pratt
	@apt install linux-headers-${UNAME_R}
208 e2404776 Rick Pratt
209
${CLICK_LM_PATCH}: ${GDP_LM_PATCH}
210
	@echo "Applying ${GDP_LM_PATCH}"
211
	@cp -pf ${GDP_LM_PATCH} ${CLICK_LM_PATCH}
212 537fe96d Rick Pratt
	@( cd ${CLICK_BLD} ; git apply ${CLICK_LM_PATCH} )
213 e2404776 Rick Pratt
214 537fe96d Rick Pratt
configure_linuxmodule: ${CLICK_BLD} \
215 e2404776 Rick Pratt
						/usr/src/linux-headers-${UNAME_R} \
216
						${CLICK_LM_PATCH}
217
	@test ! -e configure_userlevel || \
218
		{ echo "WARN: detected userlevel config, command ignored."; exit 1; }
219
	@echo "Configuring linuxmodule workspace"
220 537fe96d Rick Pratt
	@( cd ${CLICK_BLD} ; \
221 65f704ba Rick Pratt
		  ./configure --disable-userlevel \
222 e2404776 Rick Pratt
				--enable-linuxmodule --enable-multithread \
223
				--with-linux=/usr/src/linux-headers-${UNAME_R} \
224
				--with-linux-map=/boot/System.map-${UNAME_R} ; \
225 65f704ba Rick Pratt
		  make elemlist ; )
226 e2404776 Rick Pratt
	@touch configure_linuxmodule
227
228
unconfigure_linuxmodule: lm_clean
229
	@test ! -e configure_userlevel || \
230
		{ echo "WARN: detected userlevel config, command ignored."; exit 1; }
231
	@echo "Unconfiguring linuxmodule workspace"
232
	@test ! -r ${CLICK_LM_PATCH} || \
233 537fe96d Rick Pratt
		( cd ${CLICK_BLD} && git apply --reverse ${CLICK_LM_PATCH} )
234 65f704ba Rick Pratt
	@rm -f ${CLICK_LM_PATCH}
235
	@test ! -r ${CLICK_M} || rm -f ${CLICK_M}
236 e2404776 Rick Pratt
	@rm -f configure_linuxmodule
237
238 00b517f3 Rick Pratt
lm: configure_linuxmodule src/*.hh src/*.cc
239 e2404776 Rick Pratt
	@test ! -e configure_userlevel || \
240
		{ echo "WARN: detected userlevel config, command ignored."; exit 1; }
241
	@echo "Updating Click kernel loadable modules"
242 537fe96d Rick Pratt
	@( cd $(CLICK_BLD) && make )
243 00b517f3 Rick Pratt
	@touch lm
244 e2404776 Rick Pratt
245
lm_install: lm
246
	@test ! -e configure_userlevel || \
247
		{ echo "WARN: detected userlevel config, command ignored."; exit 1; }
248 537fe96d Rick Pratt
	@( cd $(CLICK_BLD) && make install )
249 e2404776 Rick Pratt
250
lm_clean:
251
	@test ! -e configure_userlevel || \
252
		{ echo "WARN: detected userlevel config, command ignored."; exit 1; }
253 537fe96d Rick Pratt
	@test ! -r ${CLICK_M} || ( cd $(CLICK_BLD) && make clean )
254 00b517f3 Rick Pratt
	@rm -f lm
255 e2404776 Rick Pratt
256
#
257
# manual targets
258
#
259
260
# if desired, run manually after ensuring pandoc is available
261 239fe014 Rick Pratt
README.html: README.md
262
	pandoc -sS -o $@ $<