-
Notifications
You must be signed in to change notification settings - Fork 8
/
Target.linux.x86_64.mk
351 lines (301 loc) · 11.5 KB
/
Target.linux.x86_64.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
###########################################################################
#
# Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
# All rights reserved.
# Copyright (c) 2013-2017, NEC Europe Ltd., NEC Corporation.
# 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]>
# Simon Kuenzer <[email protected]>
#
###########################################################################
ifndef LWIP_ROOT
$(error "Please define LWIP_ROOT")
endif
ifeq ($(CONFIG_OSVAPP),y)
ifndef OSV_ROOT
$(error "Please define OSV_ROOT")
endif
BUILDSO=y
CONFIG_OSVNET=y
CONFIG_OSVBLK=y
CONFIG_PTH_THREADS=n
CINCLUDES+=-I$(OSV_ROOT)/arch/x64 -I$(OSV_ROOT) -I$(OSV_ROOT)/include
CINCLUDES+=-isystem $(OSV_ROOT)/include/glibc-compat
glibcbase = $(OSV_ROOT)/external/x64/glibc.bin
gccbase = $(OSV_ROOT)/external/x64/gcc.bin
miscbase = $(OSV_ROOT)/external/x64/misc.bin
gcc-inc-base = $(dir $(shell find $(gccbase)/ -name vector | grep -v -e debug/vector$$ -e profile/vector$$))
gcc-inc-base2 = $(dir $(shell find $(gccbase)/ -name unwind.h))
gcc-inc-base3 = $(dir $(shell dirname `find $(gccbase)/ -name c++config.h | grep -v /32/`))
CINCLUDES+=-isystem $(gcc-inc-base) \
-isystem $(gcc-inc-base3)
CINCLUDES+=-isystem $(OSV_ROOT)/external/x64/acpica/source/include \
-isystem $(OSV_ROOT)/external/x64/misc.bin/usr/include \
-isystem $(OSV_ROOT)/include/api \
-isystem $(OSV_ROOT)/include/api/x64
# must be after include/api, since it includes some libc-style headers:
CINCLUDES+=-isystem $(gcc-inc-base2) \
-isystem gen/include \
$(post-includes-bsd)
OSV_BUILD_MODE=${mode}
CINCLUDES+=-I$(OSV_ROOT)/build/$(OSV_BUILD_MODE)/gen/include/
post-includes-bsd += -isystem $(OSV_ROOT)/bsd/sys
# For acessing machine/ in cpp xen drivers
post-includes-bsd += -isystem $(OSV_ROOT)/bsd/
post-includes-bsd += -isystem $(OSV_ROOT)/bsd/x64
#autodepend = -MD -MT $@ -MP
common+=-nostdinc -D__BSD_VISIBLE=1 -D_KERNEL -g \
-include $(OSV_ROOT)/compiler/include/intrinsics.hh -Wformat=0 \
-Wno-format-security-DNDEBUG -DCONF_debug_memory=0 \
-D__OSV__
ifndef CONFIG_BUILD_OPTIMISATION
common += -O3
else
common += $(CONFIG_BUILD_OPTIMISATION)
endif
CFLAGS+=$(common)
CXXFLAGS+=-std=gnu++11 $(common)
LDFLAGS+=$(autodepend)
else
CONFIG_PTH_THREADS?=n
CONFIG_SHELL?=n
CONFIG_NETMAP?=y
CONFIG_SHFS_CACHE_READAHEAD ?= 8
CONFIG_SHFS_CACHE_POOL_NB_BUFFERS ?= 8192
CONFIG_SHFS_CACHE_GROW = n
endif
ifeq ($(CONFIG_SHELL),y)
ifneq ($(CONFIG_PTH_THREADS),y)
$(warning "Shell is not available without threads support")
CONFIG_SHELL:=n
endif
endif
ifeq ($(CONFIG_NETMAP),y)
ifndef NETMAP_INCLUDES
$(error "Please define NETMAP_INCLUDES")
endif
endif
###########################################################################
CONFIG_CTLDIR = n # ctldir is not supported on linuxapp
CONFIG_SHFS_STATS = n # no stats
CONFIG_TESTSUITE = n # no testuite
CONFIG_MINICACHE_MINDER_PRINT ?= n
CONFIG_LWIP_CHECKSUM_NOCHECK ?= y
CONFIG_LWIP_CHECKSUM_NOGEN ?= n
ifeq ($(CONFIG_LWIP_NUM_TCPCON),)
CONFIG_LWIP_NUM_TCPCON=512
endif
CFLAGS+= -DCONFIG_LWIP_NUM_TCPCON=$(CONFIG_LWIP_NUM_TCPCON)
CFLAGS-$(CONFIG_LWIP_CHECKSUM_NOCHECK)+=-DCONFIG_LWIP_CHECKSUM_NOCHECK
CFLAGS-$(CONFIG_LWIP_CHECKSUM_NOGEN)+=-DCONFIG_LWIP_CHECKSUM_NOGEN
CFLAGS-$(CONFIG_DEBUG_LWIP)+=-DCONFIG_DEBUG_LWIP
CFLAGS-$(CONFIG_DEBUG_LWIP_MAINLOOP)+=-DLWIP_MAINLOOP_DEBUG
CFLAGS-$(CONFIG_DEBUG_LWIP_IF)+=-DLWIP_IF_DEBUG
CFLAGS-$(CONFIG_DEBUG_LWIP_IP)+=-DLWIP_IP_DEBUG
CFLAGS-$(CONFIG_DEBUG_LWIP_UDP)+=-DLWIP_UDP_DEBUG
CFLAGS-$(CONFIG_DEBUG_LWIP_TCP)+=-DLWIP_TCP_DEBUG
CFLAGS-$(CONFIG_DEBUG_LWIP_SYS)+=-DLWIP_SYS_DEBUG
CFLAGS-$(CONFIG_DEBUG_LWIP_API)+=-DLWIP_API_DEBUG
CFLAGS-$(CONFIG_DEBUG_LWIP_SERVICE)+=-DLWIP_SERVICE_DEBUG
CFLAGS+= -DCONFIG_LWIP_NOTHREADS
CFLAGS+= -DHAVE_LWIP
include Minicache.mk
#################################
LN = ln -sf
MKDIR = mkdir -p
MV = mv -f
RM = rm -f
RMDIR = rm -rf
TOUCH = touch
CCDEP=gcc
CC=gcc
CXX=g++
LD=$(CC)
CFLAGS+=-g -D$(TARGET) $(MCCFLAGS) \
-Wparentheses -Wsequence-point -Wswitch-default \
-Wundef -Wpointer-arith -Wbad-function-cast \
-Wwrite-strings -Wold-style-definition \
-Wmissing-prototypes -Wredundant-decls -Wno-address
# -Wextra -Wnested-externs -Wall -Wshadow
# -pedantic \
# not used for now but interesting:
# -Wpacked
# -Wunreachable-code
# -ansi
# -std=c89
LDFLAGS+=-pthread #-lutil
ARFLAGS=rs
ifeq ($(CONFIG_PTH_THREADS),y)
LDFLAGS+=-lpth
CFLAGS+=-DCONFIG_PTH_THREADS
endif
ifeq ($(BUILDSO),y)
CFLAGS+=-fPIC -DLWIP_DNS_API_DECLARE_H_ERRNO=0
CXXFLAGS+=-fPIC -DLWIP_DNS_API_DECLARE_H_ERRNO=0
endif
CONTRIBDIR = ../lwip-contrib
LWIPDIR ?= $(LWIP_ROOT)/src
MINICACHE_ROOT ?= $(realpath .)
LWIPARCH = $(MINICACHE_ROOT)/target/$(TARGET)
BUILDDIR ?= $(MINICACHE_ROOT)/build
ifneq ($(BUILDSO),y)
MINICACHE_OUT ?= minicache_$(ARCH)
else
MINICACHE_OUT ?= minicache_$(ARCH).so
endif
CINCLUDES+=-I. \
-Itarget/$(TARGET)/include \
-I$(LWIPDIR)/include \
-I$(LWIPARCH) \
-I$(LWIPARCH)/include \
-I$(LWIPDIR)
CFLAGS+=$(CINCLUDES)
CXXFLAGS+=$(CINCLUDES)
# COREFILES, CORE4FILES: The minimum set of files needed for lwIP.
COREDIRS=$(LWIPDIR)/core
COREFILES=$(LWIPDIR)/core/def.c $(LWIPDIR)/core/dhcp.c $(LWIPDIR)/core/dns.c \
$(LWIPDIR)/core/inet_chksum.c $(LWIPDIR)/core/init.c $(LWIPDIR)/core/mem.c \
$(LWIPDIR)/core/memp.c $(LWIPDIR)/core/netif.c $(LWIPDIR)/core/pbuf.c \
$(LWIPDIR)/core/raw.c $(LWIPDIR)/core/stats.c $(LWIPDIR)/core/sys.c \
$(LWIPDIR)/core/tcp.c $(LWIPDIR)/core/tcp_in.c $(LWIPDIR)/core/tcp_in.c \
$(LWIPDIR)/core/tcp_out.c $(LWIPDIR)/core/timers.c $(LWIPDIR)/core/udp.c
CORE4DIRS=$(LWIPDIR)/core/ipv4
CORE4FILES=$(LWIPDIR)/core/ipv4/autoip.c $(LWIPDIR)/core/ipv4/icmp.c \
$(LWIPDIR)/core/ipv4/igmp.c $(LWIPDIR)/core/ipv4/ip_frag.c \
$(LWIPDIR)/core/ipv4/ip4.c $(LWIPDIR)/core/ipv4/ip4_addr.c
CORE6DIRS=$(LWIPDIR)/core/ipv6
CORE6FILES=$(LWIPDIR)/core/ipv6/dhcp6.c $(LWIPDIR)/core/ipv6/ethip6.c \
$(LWIPDIR)/core/ipv6/icmp6.c $(LWIPDIR)/core/ipv6/ip6.c \
$(LWIPDIR)/core/ipv6/ip6_addr.c $(LWIPDIR)/core/ipv6/ip6_frag.c \
$(LWIPDIR)/core/ipv6/mld6.c $(LWIPDIR)/core/ipv6/nd6.c
# APIFILES: The files which implement the sequential and socket APIs.
APIDIRS=$(LWIPDIR)/api
APIFILES=$(LWIPDIR)/api/api_lib.c $(LWIPDIR)/api/api_msg.c $(LWIPDIR)/api/err.c \
$(LWIPDIR)/api/netbuf.c $(LWIPDIR)/api/netdb.c $(LWIPDIR)/api/netifapi.c \
$(LWIPDIR)/api/sockets.c $(LWIPDIR)/api/tcpip.c
# NETIFFILES: Files implementing various generic network interface functions.'
NETIFDIRS=$(LWIPDIR)/netif
NETIFFILES=$(LWIPDIR)/netif/etharp.c
# NETIFFILES: Add SLIP netif
NETIFFILES+=$(LWIPDIR)/netif/slipif.c
# SNMPFILES: Extra SNMPv1 agent
SNMPFILES=$(LWIPDIR)/core/snmp/asn1_dec.c $(LWIPDIR)/core/snmp/asn1_enc.c \
$(LWIPDIR)/core/snmp/mib2.c $(LWIPDIR)/core/snmp/mib_structs.c \
$(LWIPDIR)/core/snmp/msg_in.c $(LWIPDIR)/core/snmp/msg_out.c \
$(LWIPARCH)/lwip_prvmib.c
SNMPDIRS=$(LWIPDIR)/core/snmp
ARCHDIRS=$(LWIPARCH)/netif
#ARCHFILES=$(wildcard $(LWIPARCH)/*.c) # $(LWIPARCH)/netif/sio.c $(LWIPARCH)/netif/fifo.c)
# lwIP device driver
ifeq ($(CONFIG_PCAPIF),y)
ARCHFILES+=$(wildcard $(LWIPARCH)/netif/pcapif.c)
CFLAGS+=-DCONFIG_PCAPIF
LDFLAGS+=-lpcap
else
ifeq ($(CONFIG_OSVNET),y)
ARCHFILES+=$(wildcard $(LWIPARCH)/netif/osv-net.c)
ARCHFILESXX+=$(wildcard $(LWIPARCH)/netif/osv-net-io.cc)
CFLAGS+=-DCONFIG_OSVNET
else
ifeq ($(CONFIG_NETMAP),y)
ARCHFILES+=$(wildcard $(LWIPARCH)/netif/netmapif.c)
CFLAGS+=-DCONFIG_NETMAP -I$(NETMAP_INCLUDES)
else
ARCHFILES+=$(wildcard $(LWIPARCH)/netif/tapif.c)
CFLAGS+=-DCONFIG_TAPIF
endif
endif
endif
APPDIRS=target/$(TARGET)/blkdev
ifeq ($(CONFIG_OSVBLK),y)
APPFILES+=target/$(TARGET)/blkdev/osv-blk.c
APPFILESXX+=target/$(TARGET)/blkdev/osv-blk-bio.cc
CFLAGS+=-DCONFIG_OSVBLK
else
APPFILES+=target/$(TARGET)/blkdev/paio-blk.c
LDFLAGS+=-lrt
endif
# APPFILES: Applications.
APPDIRS+=:.:target/$(TARGET)
APPFILES+=$(MCOBJS)
APPFILESXX+=$(MCOBJSXX)
APPFILESW =$(addprefix $(BUILDDIR)/,$(notdir $(APPFILES)))
APPFILESWXX=$(addprefix $(BUILDDIR)/,$(notdir $(APPFILESXX)))
APPOBJS =$(addprefix $(BUILDDIR)/,$(notdir $(APPFILESW:.c=.o)))
APPOBJS+=$(addprefix $(BUILDDIR)/,$(notdir $(APPFILESWXX:.cc=.o)))
# LWIPFILES: All the above.
LWIPFILES =$(COREFILES) $(CORE4FILES) $(CORE6FILES) $(SNMPFILES) $(APIFILES) $(NETIFFILES) $(ARCHFILES) target/$(TARGET)/sys_arch.c
LWIPFILESXX=$(COREFILESXX) $(CORE4FILESXX) $(CORE6FILESXX) $(SNMPFILESXX) $(APIFILESXX) $(NETIFFILESXX) $(ARCHFILESXX)
LWIPFILESW=$(wildcard $(LWIPFILES))
LWIPFILESWXX=$(wildcard $(LWIPFILESXX))
LWIPOBJS =$(addprefix $(BUILDDIR)/,$(notdir $(LWIPFILES:.c=.o)))
LWIPOBJS+=$(addprefix $(BUILDDIR)/,$(notdir $(LWIPFILESXX:.cc=.o)))
ifneq ($(BUILDSO),y)
LWIPLIB=$(BUILDDIR)/liblwip.a
APPLIB=$(BUILDDIR)/minicache.a
else
LWIPLIB=$(BUILDDIR)/liblwip.so
endif
CFLAGS+=$(CFLAGS-y)
# set source search path
VPATH=$(BUILDDIR):$(LWIPARCH):$(COREDIRS):$(CORE4DIRS):$(CORE6DIRS):$(SNMPDIRS):$(APIDIRS):$(NETIFDIRS):$(ARCHDIRS):$(APPDIRS)
include $(BUILDDIR)/.depend
.PHONY: clean
clean:
$(RM) $(BUILDDIR)/*.o $(BUILDDIR)/$(LWIPLIB) $(BUILDDIR)/$(APPLIB) $(BUILDDIR)/$(MINICACHE_OUT) $(BUILDDIR)/*.s $(BUILDDIR)/.depend* $(BUILDDIR)/*.core $(BUILDDIR)/core
.PHONY: distclean
distclean:
$(RMDIR) $(BUILDDIR)
.PHONY: all
all: $(BUILDDIR)/$(MINICACHE_OUT)
.PHONY: build
build: $(BUILDDIR) $(BUILDDIR)/.depend $(BUILDDIR)/$(MINICACHE_OUT)
$(BUILDDIR):
$(MKDIR) $@
$(BUILDDIR)/.depend: $(BUILDDIR) $(LWIPFILES) $(APPFILES) | $(BUILDDIR)
$(CCDEP) $(CFLAGS) -MM $^ > $(BUILDDIR)/.depend || $(RM) $(BUILDDIR)/.depend
$(BUILDDIR)/%.o: %.cc | $(BUILDDIR)
$(CXX) $(CXXFLAGS) -c -o $@ $<
$(BUILDDIR)/%.o: %.c | $(BUILDDIR)
$(CC) $(CFLAGS) -c -o $@ $<
$(BUILDDIR)/%.a: %.o
$(AR) $(ARFLAGS) -o $@ $^
.PHONY: $(BUILDDIR)/$(MINICACHE_OUT)
ifneq ($(BUILDSO),y)
$(LWIPLIB): $(LWIPOBJS)
$(AR) $(ARFLAGS) $(LWIPLIB) $?
$(APPLIB): $(APPOBJS)
$(AR) $(ARFLAGS) $(APPLIB) $?
$(BUILDDIR)/$(MINICACHE_OUT): $(BUILDDIR)/.depend $(LWIPLIB) $(APPLIB) $(APPFILES)
$(LD) $(APPLIB) $(LWIPLIB) $(LDFLAGS) -o $(BUILDDIR)/$(MINICACHE_OUT)
else
$(LWIPLIB): $(LWIPOBJS)
$(LD) $(LDFLAGS) $? -shared -o $(LWIPLIB)
$(BUILDDIR)/$(MINICACHE_OUT): $(BUILDDIR)/.depend $(LWIPLIB) $(APPOBJS) $(APPFILES)
$(LD) $(APPOBJS) $(LDFLAGS) -l:$(LWIPLIB) -shared -o $(BUILDDIR)/$(MINICACHE_OUT)
endif