• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1From 777db45e3ae9c17abf397daf79a129ad5ed1e0cf Mon Sep 17 00:00:00 2001
2From: peanut_huang <huangliming5@huawei.com>
3Date: Mon, 30 Nov 2020 06:53:46 +0000
4Subject: [PATCH] add makefile
5
6Signed-off-by: peanut_huang <huangliming5@huawei.com>
7---
8 src/Makefile                | 60 ++++++++++++++++++++++++++++
9 src/api/dir.mk              |  3 ++
10 src/core/dir.mk             |  6 +++
11 src/include/arch/cc.h       |  7 ++++
12 src/include/arch/sys_arch.h |  7 ++++
13 src/include/lwipopts.h      | 80 +++++++++++++++++++++++++++++++++++++
14 src/netif/dir.mk            |  3 ++
15 7 files changed, 166 insertions(+)
16 create mode 100644 src/Makefile
17 create mode 100644 src/api/dir.mk
18 create mode 100644 src/core/dir.mk
19 create mode 100644 src/include/arch/cc.h
20 create mode 100644 src/include/arch/sys_arch.h
21 create mode 100644 src/include/lwipopts.h
22 create mode 100644 src/netif/dir.mk
23
24diff --git a/src/Makefile b/src/Makefile
25new file mode 100644
26index 0000000..3ecf8d2
27--- /dev/null
28+++ b/src/Makefile
29@@ -0,0 +1,60 @@
30+LWIP_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
31+ROOT_DIR := $(dir $(abspath $(LWIP_DIR)))
32+
33+LWIP_INC = $(LWIP_DIR)/include
34+#DPDK_INCLUDE_FILE ?= /usr/include/dpdk
35+
36+SEC_FLAGS = -fstack-protector-strong -Werror -Wall -Wl,-z,relro,-z,now -Wl,-z,noexecstack -Wtrampolines -fPIC
37+
38+CC = gcc
39+AR = ar
40+OPTIMIZATION = -O3
41+INC = -I$(LWIP_DIR) \
42+      -I$(LWIP_INC)
43+
44+CFLAGS = -g $(OPTIMIZATION) $(INC) $(SEC_FLAGS)
45+ARFLAGS = crDP
46+
47+ifeq ($(shell $(CC) -dumpmachine | cut -d"-" -f1), x86_64)
48+    CFLAGS += -mssse3
49+endif
50+
51+SRCS =
52+DIRS = api core netif
53+
54+define register_dir
55+SRCS += $(patsubst %, $(1)/%, $(2))
56+endef
57+
58+include $(patsubst %, %/dir.mk, $(DIRS))
59+
60+OBJS = $(subst .c,.o,$(SRCS))
61+TMPS := $(subst .c,.s,$(SRCS))
62+TMPS += $(subst .c,.i,$(SRCS))
63+
64+LWIP_LIB = liblwip.a
65+
66+INSTALL_LIB = $(DESTDIR)/usr/lib64
67+INSTALL_INC = $(DESTDIR)/usr/include/lwip
68+
69+.PHONY: all
70+all: $(LWIP_LIB)
71+
72+.depend: $(SRCS)
73+	rm -f ./.depend
74+	$(foreach SRC,$(SRCS),$(CC) $(CFLAGS) -MM -MT $(SRC:.c=.o) $(SRC) >> .depend;)
75+
76+-include .depend
77+
78+$(LWIP_LIB): $(OBJS)
79+	$(AR) $(ARFLAGS) $@ $(OBJS)
80+
81+.PHONY: install
82+install:
83+	install -dp $(INSTALL_LIB) $(INSTALL_INC)
84+	install -Dp $(LWIP_DIR)/$(LWIP_LIB) $(INSTALL_LIB)
85+	cp -pr $(LWIP_INC)/* $(INSTALL_INC)/
86+
87+.PHONY: clean
88+clean:
89+	$(RM) $(LWIP_LIB) $(OBJS) $(TMPS) .depend
90diff --git a/src/api/dir.mk b/src/api/dir.mk
91new file mode 100644
92index 0000000..72142ab
93--- /dev/null
94+++ b/src/api/dir.mk
95@@ -0,0 +1,3 @@
96+SRC = api_lib.c api_msg.c err.c netbuf.c netdb.c netifapi.c sockets.c tcpip.c
97+
98+$(eval $(call register_dir, api, $(SRC)))
99diff --git a/src/core/dir.mk b/src/core/dir.mk
100new file mode 100644
101index 0000000..e5a055b
102--- /dev/null
103+++ b/src/core/dir.mk
104@@ -0,0 +1,6 @@
105+SRC = inet_chksum.c init.c ip.c mem.c memp.c netif.c pbuf.c \
106+	raw.c stats.c tcp.c tcp_in.c tcp_out.c timeouts.c udp.c \
107+	ipv4/etharp.c ipv4/icmp.c ipv4/ip4_addr.c ipv4/ip4.c \
108+	ipv4/ip4_frag.c
109+
110+$(eval $(call register_dir, core, $(SRC)))
111diff --git a/src/include/arch/cc.h b/src/include/arch/cc.h
112new file mode 100644
113index 0000000..52b76f9
114--- /dev/null
115+++ b/src/include/arch/cc.h
116@@ -0,0 +1,7 @@
117+#ifndef LWIP_CC_H
118+#define LWIP_CC_H
119+
120+
121+
122+#endif /* LWIP_CC_H */
123+
124diff --git a/src/include/arch/sys_arch.h b/src/include/arch/sys_arch.h
125new file mode 100644
126index 0000000..3f555ee
127--- /dev/null
128+++ b/src/include/arch/sys_arch.h
129@@ -0,0 +1,7 @@
130+#ifndef LWIP_SYS_ARCH_H
131+#define LWIP_SYS_ARCH_H
132+
133+
134+
135+#endif /* LWIP_SYS_ARCH_H */
136+
137diff --git a/src/include/lwipopts.h b/src/include/lwipopts.h
138new file mode 100644
139index 0000000..4ab26f2
140--- /dev/null
141+++ b/src/include/lwipopts.h
142@@ -0,0 +1,80 @@
143+/*
144+ * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
145+ * All rights reserved.
146+ *
147+ * Redistribution and use in source and binary forms, with or without modification,
148+ * are permitted provided that the following conditions are met:
149+ *
150+ * 1. Redistributions of source code must retain the above copyright notice,
151+ *    this list of conditions and the following disclaimer.
152+ * 2. Redistributions in binary form must reproduce the above copyright notice,
153+ *    this list of conditions and the following disclaimer in the documentation
154+ *    and/or other materials provided with the distribution.
155+ * 3. The name of the author may not be used to endorse or promote products
156+ *    derived from this software without specific prior written permission.
157+ *
158+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
159+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
160+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
161+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
162+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
163+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
164+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
165+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
166+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
167+ * OF SUCH DAMAGE.
168+ *
169+ * This file is part of the lwIP TCP/IP stack.
170+ *
171+ * Author: Simon Goldschmidt
172+ *
173+ */
174+#ifndef LWIP_HDR_LWIPOPTS_H__
175+#define LWIP_HDR_LWIPOPTS_H__
176+
177+/* Prevent having to link sys_arch.c (we don't test the API layers in unit tests) */
178+#define NO_SYS                          1
179+#define LWIP_NETCONN                    0
180+#define LWIP_SOCKET                     0
181+#define SYS_LIGHTWEIGHT_PROT            0
182+
183+#define LWIP_IPV6                       1
184+#define IPV6_FRAG_COPYHEADER            1
185+#define LWIP_IPV6_DUP_DETECT_ATTEMPTS   0
186+
187+/* Enable some protocols to test them */
188+#define LWIP_DHCP                       1
189+#define LWIP_AUTOIP                     1
190+
191+#define LWIP_IGMP                       1
192+#define LWIP_DNS                        1
193+
194+#define LWIP_ALTCP                      1
195+
196+/* Turn off checksum verification of fuzzed data */
197+#define CHECKSUM_CHECK_IP               0
198+#define CHECKSUM_CHECK_UDP              0
199+#define CHECKSUM_CHECK_TCP              0
200+#define CHECKSUM_CHECK_ICMP             0
201+#define CHECKSUM_CHECK_ICMP6            0
202+
203+/* Minimal changes to opt.h required for tcp unit tests: */
204+#define MEM_SIZE                        16000
205+#define TCP_SND_QUEUELEN                40
206+#define MEMP_NUM_TCP_SEG                TCP_SND_QUEUELEN
207+#define TCP_OVERSIZE                    1
208+#define TCP_SND_BUF                     (12 * TCP_MSS)
209+#define TCP_WND                         (10 * TCP_MSS)
210+#define LWIP_WND_SCALE                  1
211+#define TCP_RCV_SCALE                   2
212+#define PBUF_POOL_SIZE                  400 /* pbuf tests need ~200KByte */
213+
214+/* Minimal changes to opt.h required for etharp unit tests: */
215+#define ETHARP_SUPPORT_STATIC_ENTRIES   1
216+
217+#define LWIP_NUM_NETIF_CLIENT_DATA      1
218+#define LWIP_SNMP                       1
219+#define MIB2_STATS                      1
220+#define LWIP_MDNS_RESPONDER             1
221+
222+#endif /* LWIP_HDR_LWIPOPTS_H__ */
223diff --git a/src/netif/dir.mk b/src/netif/dir.mk
224new file mode 100644
225index 0000000..233c79a
226--- /dev/null
227+++ b/src/netif/dir.mk
228@@ -0,0 +1,3 @@
229+SRC = ethernet.c
230+
231+$(eval $(call register_dir, netif, $(SRC)))
232--
2332.23.0
234
235