Project

General

Profile

Statistics
| Branch: | Revision:

gdp-router-click / Makefile @ master

History | View | Annotate | Download (8.11 KB)

1
# 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
# For a gdp-router-click installation from the source: work in progress
9
#
10

    
11
GDP_BLD=			build/gdp
12
GDP_REPO=			https://repoman@repo.eecs.berkeley.edu/git-anon/projects/swarmlab/gdp.git
13

    
14
GDP_NET3_BRANCH=	net3-legacy
15

    
16
CLICK_BLD=			build/click
17
CLICK_REPO=			https://github.com/kohler/click.git
18
CLICK_M=			${CLICK_BLD}/Makefile
19

    
20
# major version
21
V=				2
22
VERHH=				version_gdp_v4_router.hh
23
S_VERHH=			src/${VERHH}
24

    
25
# userlevel workspace
26
CLICK_UL_M=			${CLICK_BLD}/userlevel/Makefile
27
UL_M_O=				ul_m_orig
28
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

    
32
# linuxmodule workspace
33
CLICK_LM_PATCH=		${CLICK_BLD}/click.git_apply_patch.linuxmodule_target
34
UNAME_R=			$(shell /bin/uname -r)
35
GDP_LM_PATCH=		adm/click.git_apply_patch.linuxmodule_target
36

    
37
# builds with the latest Click, unless the next line is uncommented and updated
38
#CLICK_COMMIT=	f40363bb492188d44ba2f1251d2fe5dc553b97c9
39

    
40
# 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
# default
51
all: gdp-router-click
52

    
53
# no target should survive recipe errors
54
.DELETE_ON_ERROR:
55

    
56
remove_gdp:
57
	@if [ -d "${GDP_BLD}" ]; \
58
	then \
59
		echo "Removing ${GDP_BLD}" ; \
60
		rm -rf ${GDP_BLD} ; \
61
	else \
62
		echo "${GDP_BLD} not found" ; \
63
	fi
64

    
65
remove_click:
66
	@if [ -d "${CLICK_BLD}" ]; \
67
	then \
68
		echo "Removing ${CLICK_BLD}" ; \
69
		rm -rf ${CLICK_BLD} ; \
70
	else \
71
		echo "${CLICK_BLD} not found" ; \
72
	fi
73

    
74
#
75
# (default) set up a userlevel workspace then build gdp-router-click
76
#
77

    
78
.PHONY: unconfigure_userlevel install install-gdp-router-click
79
.PHONY: stop start reinstall
80

    
81
configure_userlevel:
82
	@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
	if [ ! -d ${GDP_BLD} ]; \
87
	then \
88
		git clone ${GDP_REPO} ${GDP_BLD} ; \
89
	fi
90
	( cd ${GDP_BLD}/util && make )
91
	@if [ -d ${CLICK_BLD} ]; \
92
	then \
93
		echo "Error: pre-existing ${CLICK_BLD} (make remove_click)" ; \
94
		exit 1 ; \
95
	fi
96
	if [ -z "${CLICK_COMMIT}" ]; \
97
	then \
98
		git clone ${CLICK_REPO} ${CLICK_BLD} ; \
99
	else \
100
		git clone -n ${CLICK_REPO} ${CLICK_BLD} && \
101
				( cd ${CLICK_BLD} && git checkout ${CLICK_COMMIT} ) ; \
102
	fi
103
	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
	test -r ${CLICK_UL_M_O} || \
106
		( cd ${CLICK_BLD} ; \
107
		  ./configure --disable-linuxmodule --enable-local ; \
108
		  make elemlist ; \
109
		  sed -i.${UL_M_O} \
110
			-e '/^LIBS = /s/$$/ -lssl -lcrypto -lsystemd -lresolv /' \
111
			-e 's/CXXFLAGS = -g -O2 -W -Wall/CXXFLAGS = -g -O2 -W -Wall -fno-strict-aliasing/' \
112
				userlevel/Makefile )
113
	touch configure_userlevel
114

    
115
unconfigure_userlevel:
116
	@test ! -e configure_linuxmodule || \
117
		{ echo "WARN: detected linuxmodule config, command ignored."; exit 1; }
118
	@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
	@if [ -d ${CLICK_BLD} ]; \
126
	then \
127
		echo "Remove ${CLICK_BLD}..." ; \
128
		rm -rf ${CLICK_BLD} ; \
129
	else \
130
		echo "${CLICK_BLD} not found" ; \
131
	fi
132
	@rm -f configure_userlevel
133

    
134
gdp-router-click: configure_userlevel src/*.hh src/*.cc
135
	@test ! -e configure_linuxmodule || \
136
		{ echo "WARN: detected linuxmodule config, command ignored."; exit 1; }
137
	@echo "Refresh source hardlinks in ${CLICK_BLD} (required post git pull)"
138
	@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
	@echo "/* autogenerated for gdp-router-click - do not edit */" > ${S_VERHH}
141
	@echo "#define STRINGIFY(_vs_) # _vs_" >> ${S_VERHH}
142
	@echo "const char *ver_major = { STRINGIFY($V) };" >> ${S_VERHH}
143
	@echo $V
144
	@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
	@( cd $(CLICK_BLD) && make )
151
	@cp ${CLICK_UL_BINARY} $@
152

    
153
install: gdp-router-click
154
	@test ! -e configure_linuxmodule || \
155
		{ echo "WARN: detected linuxmodule config, command ignored."; exit 1; }
156
	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

    
160
install-gdp-router-click: gdp-router-click
161
	@test ! -e configure_linuxmodule || \
162
		{ echo "WARN: detected linuxmodule config, command ignored."; exit 1; }
163
	./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

    
168
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

    
172
stop:
173
	@test ! -e configure_linuxmodule || \
174
		{ echo "WARN: detected linuxmodule config, command ignored."; exit 1; }
175
	systemctl stop gdplogd
176
	systemctl stop gdp-router-click
177

    
178
start:
179
	@test ! -e configure_linuxmodule || \
180
		{ echo "WARN: detected linuxmodule config, command ignored."; exit 1; }
181
	systemctl start gdp-router-click
182
	systemctl start gdplogd
183

    
184
reinstall: gdp-router-click
185
	@test ! -e configure_linuxmodule || \
186
		{ echo "WARN: detected linuxmodule config, command ignored."; exit 1; }
187
	systemctl stop gdplogd2
188
	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
	systemctl start gdplogd2
194

    
195
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
#
200
# (non-default) set up a linuxmodule workspace
201
#
202

    
203
.PHONY: unconfigure_linuxmodule lm_install lm_clean
204

    
205
/usr/src/linux-headers-${UNAME_R}:
206
	@echo "Installing linux-headers-${UNAME_R}"
207
	@apt install linux-headers-${UNAME_R}
208

    
209
${CLICK_LM_PATCH}: ${GDP_LM_PATCH}
210
	@echo "Applying ${GDP_LM_PATCH}"
211
	@cp -pf ${GDP_LM_PATCH} ${CLICK_LM_PATCH}
212
	@( cd ${CLICK_BLD} ; git apply ${CLICK_LM_PATCH} )
213

    
214
configure_linuxmodule: ${CLICK_BLD} \
215
						/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
	@( cd ${CLICK_BLD} ; \
221
		  ./configure --disable-userlevel \
222
				--enable-linuxmodule --enable-multithread \
223
				--with-linux=/usr/src/linux-headers-${UNAME_R} \
224
				--with-linux-map=/boot/System.map-${UNAME_R} ; \
225
		  make elemlist ; )
226
	@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
		( cd ${CLICK_BLD} && git apply --reverse ${CLICK_LM_PATCH} )
234
	@rm -f ${CLICK_LM_PATCH}
235
	@test ! -r ${CLICK_M} || rm -f ${CLICK_M}
236
	@rm -f configure_linuxmodule
237

    
238
lm: configure_linuxmodule src/*.hh src/*.cc
239
	@test ! -e configure_userlevel || \
240
		{ echo "WARN: detected userlevel config, command ignored."; exit 1; }
241
	@echo "Updating Click kernel loadable modules"
242
	@( cd $(CLICK_BLD) && make )
243
	@touch lm
244

    
245
lm_install: lm
246
	@test ! -e configure_userlevel || \
247
		{ echo "WARN: detected userlevel config, command ignored."; exit 1; }
248
	@( cd $(CLICK_BLD) && make install )
249

    
250
lm_clean:
251
	@test ! -e configure_userlevel || \
252
		{ echo "WARN: detected userlevel config, command ignored."; exit 1; }
253
	@test ! -r ${CLICK_M} || ( cd $(CLICK_BLD) && make clean )
254
	@rm -f lm
255

    
256
#
257
# manual targets
258
#
259

    
260
# if desired, run manually after ensuring pandoc is available
261
README.html: README.md
262
	pandoc -sS -o $@ $<