zephyr/samples/net/echo_server/Makefile.ipstack

107 lines
3.2 KiB
Makefile

# Makefile - IP network stack Makefile for nano and micro kernel
#
# Copyright (c) 2015 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
PIPE_BASE=/tmp/ip-stack
ifeq ($(MAKECMDGOALS),server)
QEMU_NUM=server
endif
ifeq ($(MAKECMDGOALS),client)
QEMU_NUM=client
endif
ifdef QEMU_NUM
QEMU_EXTRA_FLAGS += -serial none -serial pipe:${PIPE_BASE}-${QEMU_NUM} -pidfile qemu-${QEMU_NUM}.pid
else
QEMU_EXTRA_FLAGS = -serial none -serial unix:/tmp/slip.sock
endif
PIPE_SERVER_IN=${PIPE_BASE}-server.in
PIPE_SERVER_OUT=${PIPE_BASE}-server.out
PIPE_CLIENT_IN=${PIPE_BASE}-client.in
PIPE_CLIENT_OUT=${PIPE_BASE}-client.out
.PHONY: remove_pipes
remove_pipes:
rm -f ${PIPE_SERVER_IN} ${PIPE_SERVER_OUT} ${PIPE_CLIENT_IN} \
${PIPE_CLIENT_OUT}
${PIPE_SERVER_IN}:
mkfifo $@
${PIPE_SERVER_OUT}:
mkfifo $@
${PIPE_CLIENT_IN}:
mkfifo $@
${PIPE_CLIENT_OUT}:
mkfifo $@
.PHONY: PIPE_CLIENT_IN_LINK
PIPE_CLIENT_IN_LINK: ${PIPE_SERVER_IN}
-ln ${PIPE_SERVER_IN} ${PIPE_CLIENT_OUT}
.PHONY: PIPE_CLIENT_OUT_LINK
PIPE_CLIENT_OUT_LINK: ${PIPE_SERVER_OUT}
-ln ${PIPE_SERVER_OUT} ${PIPE_CLIENT_IN}
# Setup the dual qemu test case with pcap support (two qemus passing data
# between them and saving data to pcap via help of monitor applicaiton)
.PHONY: setup_pipes_dual_monitor
setup_pipes_dual_monitor: ${PIPE_SERVER_IN} ${PIPE_SERVER_OUT} ${PIPE_CLIENT_IN} ${PIPE_CLIENT_OUT}
CONFIG_OPTIONS_1="CONFIG_NETWORKING_WITH_15_4=y"
CONFIG_OPTIONS_2="CONFIG_NETWORKING_WITH_15_4_LOOPBACK_UART=y"
CONFIG_OPTIONS_3="CONFIG_NETWORKING_WITH_6LOWPAN=y"
CONFIG_OPTIONS_4="CONFIG_NETWORKING_STATISTICS=y"
.PHONY: set_options
set_options:
# Network uart must be turned off as that will prevent communication
cp -f ${DOTCONFIG} ${DOTCONFIG}.orig ; true
grep -v CONFIG_NETWORKING_UART=y ${DOTCONFIG}.orig > ${DOTCONFIG}
echo "${CONFIG_OPTIONS_1}" >> ${DOTCONFIG}
echo "${CONFIG_OPTIONS_2}" >> ${DOTCONFIG}
echo "${CONFIG_OPTIONS_3}" >> ${DOTCONFIG}
echo "${CONFIG_OPTIONS_4}" >> ${DOTCONFIG}
export QEMU_NUM
export QEMU_EXTRA_FLAGS
PID_FILE=/tmp/monitor_15_4.pid
hosttoolsmake = @$(MAKE) -C $(ZEPHYR_BASE)/net/ip/tools $1
${ZEPHYR_BASE}/net/ip/tools/monitor_15_4:
$(Q)$(call hosttoolsmake,monitor_15_4)
.PHONY: start_monitor
start_monitor: ${ZEPHYR_BASE}/net/ip/tools/monitor_15_4
${ZEPHYR_BASE}/net/ip/tools/monitor_15_4 \
server-client-monitor.pcap \
${PIPE_BASE}-server ${PIPE_BASE}-client > /dev/null & \
echo "$$!" > ${PID_FILE}
server: remove_pipes setup_pipes_dual_monitor $(DOTCONFIG) set_options start_monitor
$(Q)$(call zephyrmake,$(O),qemu); true
$(Q)kill `cat ${PID_FILE}`
$(Q)rm -f ${PID_FILE}
-@killall monitor_15_4 > /dev/null 2>&1 ; true
$(Q)stty sane
client: setup_pipes_dual_monitor $(DOTCONFIG) set_options
$(Q)$(call zephyrmake,$(O),qemu); true
$(Q)stty sane