-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copy missing contrib/ports/unix dir from non-Espressif LWIP repo (#2)
- Loading branch information
Erik Corry
authored
Nov 15, 2021
1 parent
af4046e
commit 0263806
Showing
35 changed files
with
3,905 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# This file is indended to be included in end-user CMakeLists.txt | ||
# include(/path/to/Filelists.cmake) | ||
# It assumes the variable LWIP_CONTRIB_DIR is defined pointing to the | ||
# root path of lwIP/contrib sources. | ||
# | ||
# This file is NOT designed (on purpose) to be used as cmake | ||
# subdir via add_subdirectory() | ||
# The intention is to provide greater flexibility to users to | ||
# create their own targets using the *_SRCS variables. | ||
|
||
if(NOT ${CMAKE_VERSION} VERSION_LESS "3.10.0") | ||
include_guard(GLOBAL) | ||
endif() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
if(NOT ${CMAKE_VERSION} VERSION_LESS "3.10.0") | ||
include_guard(GLOBAL) | ||
endif() | ||
|
||
if(NOT CMAKE_BUILD_TYPE) | ||
message(STATUS "CMAKE_BUILD_TYPE not set - defaulting to Debug build.") | ||
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build, options are: ${CMAKE_CONFIGURATION_TYPES}." FORCE) | ||
endif() | ||
message (STATUS "Build type: ${CMAKE_BUILD_TYPE}") | ||
|
||
set(LWIP_CONTRIB_DIR ${LWIP_DIR}/contrib) | ||
|
||
# ARM mbedtls support https://tls.mbed.org/ | ||
if(NOT DEFINED LWIP_MBEDTLSDIR) | ||
set(LWIP_MBEDTLSDIR ${LWIP_DIR}/../mbedtls) | ||
message(STATUS "LWIP_MBEDTLSDIR not set - using default location ${LWIP_MBEDTLSDIR}") | ||
endif() | ||
if(EXISTS ${LWIP_MBEDTLSDIR}/CMakeLists.txt) | ||
set(LWIP_HAVE_MBEDTLS ON BOOL) | ||
|
||
# Prevent building MBEDTLS programs and tests | ||
set(ENABLE_PROGRAMS OFF CACHE BOOL "") | ||
set(ENABLE_TESTING OFF CACHE BOOL "") | ||
|
||
# mbedtls uses cmake. Sweet! | ||
add_subdirectory(${LWIP_MBEDTLSDIR} mbedtls) | ||
|
||
set (LWIP_MBEDTLS_DEFINITIONS | ||
LWIP_HAVE_MBEDTLS=1 | ||
) | ||
set (LWIP_MBEDTLS_INCLUDE_DIRS | ||
${LWIP_MBEDTLSDIR}/include | ||
) | ||
set (LWIP_MBEDTLS_LINK_LIBRARIES | ||
mbedtls | ||
mbedcrypto | ||
mbedx509 | ||
) | ||
endif() | ||
|
||
set(LWIP_COMPILER_FLAGS_GNU_CLANG | ||
$<$<CONFIG:Debug>:-Og> | ||
$<$<CONFIG:Debug>:-g> | ||
$<$<CONFIG:Release>:-O3> | ||
-Wall | ||
-pedantic | ||
-Werror | ||
-Wparentheses | ||
-Wsequence-point | ||
-Wswitch-default | ||
-Wextra | ||
-Wundef | ||
-Wshadow | ||
-Wpointer-arith | ||
-Wcast-qual | ||
-Wwrite-strings | ||
$<$<COMPILE_LANGUAGE:C>:-Wold-style-definition> | ||
-Wcast-align | ||
$<$<COMPILE_LANGUAGE:C>:-Wmissing-prototypes> | ||
$<$<COMPILE_LANGUAGE:C>:-Wnested-externs> | ||
-Wunreachable-code | ||
-Wuninitialized | ||
-Wmissing-prototypes | ||
-Waggregate-return | ||
-Wlogical-not-parentheses | ||
) | ||
|
||
if (NOT LWIP_HAVE_MBEDTLS) | ||
list(APPEND LWIP_COMPILER_FLAGS_GNU_CLANG | ||
-Wredundant-decls | ||
$<$<COMPILE_LANGUAGE:C>:-Wc++-compat> | ||
) | ||
endif() | ||
|
||
if(CMAKE_C_COMPILER_ID STREQUAL "GNU") | ||
list(APPEND LWIP_COMPILER_FLAGS_GNU_CLANG | ||
-Wlogical-op | ||
-Wtrampolines | ||
) | ||
|
||
if (NOT LWIP_HAVE_MBEDTLS) | ||
list(APPEND LWIP_COMPILER_FLAGS_GNU_CLANG | ||
$<$<COMPILE_LANGUAGE:C>:-Wc90-c99-compat> | ||
) | ||
endif() | ||
|
||
if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9) | ||
if(LWIP_USE_SANITIZERS) | ||
list(APPEND LWIP_COMPILER_FLAGS_GNU_CLANG | ||
-fsanitize=address | ||
-fsanitize=undefined | ||
-fno-sanitize=alignment | ||
-fstack-protector | ||
-fstack-check | ||
) | ||
set(LWIP_SANITIZER_LIBS asan ubsan) | ||
endif() | ||
endif() | ||
|
||
set(LWIP_COMPILER_FLAGS ${LWIP_COMPILER_FLAGS_GNU_CLANG}) | ||
endif() | ||
|
||
if(CMAKE_C_COMPILER_ID STREQUAL "Clang") | ||
list(APPEND LWIP_COMPILER_FLAGS_GNU_CLANG | ||
-Wdocumentation | ||
-Wno-documentation-deprecated-sync | ||
) | ||
|
||
if(LWIP_USE_SANITIZERS) | ||
list(APPEND LWIP_COMPILER_FLAGS_GNU_CLANG | ||
-fsanitize=address | ||
-fsanitize=undefined | ||
-fno-sanitize=alignment | ||
) | ||
set(LWIP_SANITIZER_LIBS asan ubsan) | ||
endif() | ||
|
||
set(LWIP_COMPILER_FLAGS ${LWIP_COMPILER_FLAGS_GNU_CLANG}) | ||
endif() | ||
|
||
if(CMAKE_C_COMPILER_ID STREQUAL "MSVC") | ||
set(LWIP_COMPILER_FLAGS | ||
$<$<CONFIG:Debug>:/Od> | ||
$<$<CONFIG:Release>:/Ox> | ||
/Wall | ||
/WX | ||
) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# | ||
# Copyright (c) 2001, 2002 Swedish Institute of Computer Science. | ||
# All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without modification, | ||
# are permitted provided that the following conditions are met: | ||
# | ||
# 1. Redistributions of source code must retain the above copyright notice, | ||
# this list of conditions and the following disclaimer. | ||
# 2. Redistributions in binary form must reproduce the above copyright notice, | ||
# this list of conditions and the following disclaimer in the documentation | ||
# and/or other materials provided with the distribution. | ||
# 3. The name of the author may not be used to endorse or promote products | ||
# derived from this software without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT | ||
# SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT | ||
# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY | ||
# OF SUCH DAMAGE. | ||
# | ||
# This file is part of the lwIP TCP/IP stack. | ||
# | ||
# Author: Adam Dunkels <[email protected]> | ||
# | ||
|
||
#CC=gcc | ||
#CC=clang | ||
CCDEP?=$(CC) | ||
|
||
CFLAGS+=-g -DLWIP_DEBUG -Wall -pedantic -Werror \ | ||
-Wparentheses -Wsequence-point -Wswitch-default \ | ||
-Wextra -Wundef -Wshadow -Wpointer-arith -Wcast-qual \ | ||
-Wc++-compat -Wwrite-strings -Wold-style-definition -Wcast-align \ | ||
-Wmissing-prototypes -Wredundant-decls -Wnested-externs \ | ||
-Wunreachable-code -Wuninitialized -Wmissing-prototypes \ | ||
-Wredundant-decls -Waggregate-return -Wlogical-not-parentheses | ||
# -Wconversion -Wsign-compare -Wmissing-include-dirs | ||
|
||
ifeq (,$(findstring clang,$(CC))) | ||
CFLAGS+= -Wlogical-op -Wc90-c99-compat -Wtrampolines | ||
# if GCC is newer than 4.8/4.9 you may use: | ||
#CFLAGS:=$(CFLAGS) -fsanitize=address -fstack-protector -fstack-check -fsanitize=undefined -fno-sanitize=alignment | ||
else | ||
# we cannot sanitize alignment on x86-64 targets because clang wants 64 bit alignment | ||
CFLAGS+= -fsanitize=address -fsanitize=undefined -fno-sanitize=alignment -Wdocumentation -Wno-documentation-deprecated-sync | ||
endif | ||
|
||
CONTRIBDIR?=../../.. | ||
ARFLAGS?=rs | ||
|
||
#Set this to where you have the lwip core module checked out from git | ||
#default assumes it's a dir above the contrib module | ||
LWIPDIR?=$(CONTRIBDIR)/.. | ||
|
||
CFLAGS+=-I. \ | ||
-I$(CONTRIBDIR) \ | ||
-I$(LWIPDIR)/include \ | ||
-I$(LWIPARCH)/include | ||
|
||
# Add include path and link to mbedTLS lib if available | ||
MBEDTLSDIR?=$(LWIPDIR)/../mbedtls | ||
ifneq (,$(wildcard $(MBEDTLSDIR)/include/mbedtls/*.h)) | ||
LDFLAGS+=-L$(MBEDTLSDIR)/library -lmbedtls -lmbedcrypto -lmbedx509 | ||
CFLAGS+=-I$(MBEDTLSDIR)/include -Wno-redundant-decls -DLWIP_HAVE_MBEDTLS=1 -Wno-c90-c99-compat | ||
endif | ||
|
||
include $(CONTRIBDIR)/Filelists.mk | ||
include $(LWIPDIR)/Filelists.mk | ||
|
||
# LWIPFILES: All the above. | ||
LWIPFILES=$(LWIPNOAPPSFILES) $(ARCHFILES) | ||
LWIPOBJS=$(notdir $(LWIPFILES:.c=.o)) | ||
|
||
LWIPLIBCOMMON=liblwipcommon.a | ||
$(LWIPLIBCOMMON): $(LWIPOBJS) | ||
$(AR) $(ARFLAGS) $(LWIPLIBCOMMON) $? | ||
|
||
APPFILES=$(CONTRIBAPPFILES) $(LWIPAPPFILES) | ||
APPLIB=liblwipapps.a | ||
APPOBJS=$(notdir $(APPFILES:.c=.o)) | ||
$(APPLIB): $(APPOBJS) | ||
$(AR) $(ARFLAGS) $(APPLIB) $? | ||
|
||
%.o: | ||
$(CC) $(CFLAGS) -c $< |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# | ||
# Copyright (c) 2001, 2002 Swedish Institute of Computer Science. | ||
# All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without modification, | ||
# are permitted provided that the following conditions are met: | ||
# | ||
# 1. Redistributions of source code must retain the above copyright notice, | ||
# this list of conditions and the following disclaimer. | ||
# 2. Redistributions in binary form must reproduce the above copyright notice, | ||
# this list of conditions and the following disclaimer in the documentation | ||
# and/or other materials provided with the distribution. | ||
# 3. The name of the author may not be used to endorse or promote products | ||
# derived from this software without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT | ||
# SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT | ||
# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY | ||
# OF SUCH DAMAGE. | ||
# | ||
# This file is part of the lwIP TCP/IP stack. | ||
# | ||
# Author: Adam Dunkels <[email protected]> | ||
# | ||
|
||
# Architecture specific files. | ||
LWIPARCH?=$(CONTRIBDIR)/ports/unix/port | ||
SYSARCH?=$(LWIPARCH)/sys_arch.c | ||
ARCHFILES=$(LWIPARCH)/perf.c \ | ||
$(SYSARCH) \ | ||
$(LWIPARCH)/netif/tapif.c \ | ||
$(LWIPARCH)/netif/list.c \ | ||
$(LWIPARCH)/netif/sio.c \ | ||
$(LWIPARCH)/netif/fifo.c | ||
|
||
UNIX_COMMON_MK_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) | ||
include $(UNIX_COMMON_MK_DIR)../Common.allports.mk | ||
|
||
LDFLAGS+=-lutil | ||
|
||
UNAME_S:= $(shell uname -s) | ||
ifneq ($(UNAME_S),Darwin) | ||
# Darwin doesn't have pthreads or POSIX real-time extensions libs | ||
LDFLAGS+=-pthread -lrt | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# This file is indended to be included in end-user CMakeLists.txt | ||
# include(/path/to/Filelists.cmake) | ||
# It assumes the variable LWIP_CONTRIB_DIR is defined pointing to the | ||
# root path of lwIP/contrib sources. | ||
# | ||
# This file is NOT designed (on purpose) to be used as cmake | ||
# subdir via add_subdirectory() | ||
# The intention is to provide greater flexibility to users to | ||
# create their own targets using the *_SRCS variables. | ||
|
||
if(NOT ${CMAKE_VERSION} VERSION_LESS "3.10.0") | ||
include_guard(GLOBAL) | ||
endif() | ||
|
||
set(lwipcontribportunix_SRCS | ||
${LWIP_CONTRIB_DIR}/ports/unix/port/sys_arch.c | ||
${LWIP_CONTRIB_DIR}/ports/unix/port/perf.c | ||
) | ||
|
||
set(lwipcontribportunixnetifs_SRCS | ||
${LWIP_CONTRIB_DIR}/ports/unix/port/netif/tapif.c | ||
${LWIP_CONTRIB_DIR}/ports/unix/port/netif/list.c | ||
${LWIP_CONTRIB_DIR}/ports/unix/port/netif/sio.c | ||
${LWIP_CONTRIB_DIR}/ports/unix/port/netif/fifo.c | ||
) | ||
|
||
add_library(lwipcontribportunix EXCLUDE_FROM_ALL ${lwipcontribportunix_SRCS} ${lwipcontribportunixnetifs_SRCS}) | ||
target_include_directories(lwipcontribportunix PRIVATE ${LWIP_INCLUDE_DIRS} ${LWIP_MBEDTLS_INCLUDE_DIRS}) | ||
target_compile_options(lwipcontribportunix PRIVATE ${LWIP_COMPILER_FLAGS}) | ||
target_compile_definitions(lwipcontribportunix PRIVATE ${LWIP_DEFINITIONS} ${LWIP_MBEDTLS_DEFINITIONS}) | ||
target_link_libraries(lwipcontribportunix PUBLIC ${LWIP_MBEDTLS_LINK_LIBRARIES}) | ||
|
||
if (CMAKE_SYSTEM_NAME STREQUAL "Linux") | ||
find_library(LIBUTIL util) | ||
find_library(LIBPTHREAD pthread) | ||
find_library(LIBRT rt) | ||
target_link_libraries(lwipcontribportunix PUBLIC ${LIBUTIL} ${LIBPTHREAD} ${LIBRT}) | ||
endif() | ||
|
||
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") | ||
# Darwin doesn't have pthreads or POSIX real-time extensions libs | ||
find_library(LIBUTIL util) | ||
target_link_libraries(lwipcontribportunix PUBLIC ${LIBUTIL}) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
This port contains infrastructure and examples for running lwIP on Unix-like | ||
operating systems (Linux, OpenBSD, cygwin). Much of this is targetted towards | ||
testing lwIP applications. | ||
|
||
* port/sys_arch.c, port/perf.c, port/include/arch/: Generic platform porting, | ||
for both states of NO_SYS. (Mapping debugging to printf, providing | ||
sys_now & co from the system time etc.) | ||
|
||
* check: Runs the unit tests shipped with main lwIP on the Unix port. | ||
|
||
* port/netif, port/include/netif: Various network interface implementations and | ||
their helpers, some explicitly for Unix infrastructure, some generic (but most | ||
useful on an easy to debug system): | ||
|
||
* fifo: Helper for sio | ||
|
||
* list: Helper for unixif | ||
|
||
* pcapif: Network interface that replays packages from a PCAP dump file, and | ||
discards packages sent out from it | ||
|
||
* sio: Mapping Unix character devices to lwIP's sio mechanisms | ||
|
||
* tapif: Network interface that is mapped to a tap interface (Unix user | ||
space layer 2 network device). Uses lwIP threads. |
Oops, something went wrong.