8000 extmod: Factor out makefile rules from py.mk to new extmod.mk file. · shazz/micropython@cd6b115 · GitHub
[go: up one dir, main page]

Skip to content

Commit cd6b115

Browse files
committed
extmod: Factor out makefile rules from py.mk to new extmod.mk file.
To logically separate extmod related rules out, and prevent py.mk from growing too large.
1 parent 7cf26ca commit cd6b115

File tree

2 files changed

+124
-110
lines changed

2 files changed

+124
-110
lines changed

extmod/extmod.mk

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# This makefile fragment provides rules to build 3rd-party components for extmod modules
2+
3+
# this sets the config file for FatFs
4+
CFLAGS_MOD += -DFFCONF_H=\"lib/oofatfs/ffconf.h\"
5+
6+
################################################################################
7+
# ussl
8+
9+
ifeq ($(MICROPY_PY_USSL),1)
10+
CFLAGS_MOD += -DMICROPY_PY_USSL=1
11+
ifeq ($(MICROPY_SSL_AXTLS),1)
12+
CFLAGS_MOD += -DMICROPY_SSL_AXTLS=1 -I$(TOP)/lib/axtls/ssl -I$(TOP)/lib/axtls/crypto -I$(TOP)/extmod/axtls-include
13+
AXTLS_DIR = lib/axtls
14+
$(BUILD)/$(AXTLS_DIR)/%.o: CFLAGS += -Wno-all -Wno-unused-parameter -Wno-uninitialized -Wno-sign-compare -Wno-old-style-definition $(AXTLS_DEFS_EXTRA)
15+
SRC_MOD += $(addprefix $(AXTLS_DIR)/,\
16+
ssl/asn1.c \
17+
ssl/loader.c \
18+
ssl/tls1.c \
19+
ssl/tls1_svr.c \
20+
ssl/tls1_clnt.c \
21+
ssl/x509.c \
22+
crypto/aes.c \
23+
crypto/bigint.c \
24+
crypto/crypto_misc.c \
25+
crypto/hmac.c \
26+
crypto/md5.c \
27+
crypto/rsa.c \
28+
crypto/sha1.c \
29+
)
30+
else ifeq ($(MICROPY_SSL_MBEDTLS),1)
31+
# Can be overridden by ports which have "builtin" mbedTLS
32+
MICROPY_SSL_MBEDTLS_INCLUDE ?= $(TOP)/lib/mbedtls/include
33+
CFLAGS_MOD += -DMICROPY_SSL_MBEDTLS=1 -I$(MICROPY_SSL_MBEDTLS_INCLUDE)
34+
LDFLAGS_MOD += -L$(TOP)/lib/mbedtls/library -lmbedx509 -lmbedtls -lmbedcrypto
35+
endif
36+
endif
37+
38+
################################################################################
39+
# lwip
40+
41+
ifeq ($(MICROPY_PY_LWIP),1)
42+
# A port should add an include path where lwipopts.h can be found (eg extmod/lwip-include)
43+
LWIP_DIR = lib/lwip/src
44+
INC += -I$(TOP)/$(LWIP_DIR)/include
45+
CFLAGS_MOD += -DMICROPY_PY_LWIP=1
46+
$(BUILD)/$(LWIP_DIR)/core/ipv4/dhcp.o: CFLAGS_MOD += -Wno-address
47+
SRC_MOD += extmod/modlwip.c lib/netutils/netutils.c
48+
SRC_MOD += $(addprefix $(LWIP_DIR)/,\
49+
core/def.c \
50+
core/dns.c \
51+
core/inet_chksum.c \
52+
core/init.c \
53+
core/ip.c \
54+
core/mem.c \
55+
core/memp.c \
56+
core/netif.c \
57+
core/pbuf.c \
58+
core/raw.c \
59+
core/stats.c \
60+
core/sys.c \
61+
core/tcp.c \
62+
core/tcp_in.c \
63+
core/tcp_out.c \
64+
core/timeouts.c \
65+
core/udp.c \
66+
core/ipv4/autoip.c \
67+
core/ipv4/dhcp.c \
68+
core/ipv4/etharp.c \
69+
core/ipv4/icmp.c \
70+
core/ipv4/igmp.c \
71+
core/ipv4/ip4_addr.c \
72+
core/ipv4/ip4.c \
73+
core/ipv4/ip4_frag.c \
74+
core/ipv6/dhcp6.c \
75+
core/ipv6/ethip6.c \
76+
core/ipv6/icmp6.c \
77+
core/ipv6/inet6.c \
78+
core/ipv6/ip6_addr.c \
79+
core/ipv6/ip6.c \
80+
core/ipv6/ip6_frag.c \
81+
core/ipv6/mld6.c \
82+
core/ipv6/nd6.c \
83+
netif/ethernet.c \
84+
)
85+
ifeq ($(MICROPY_PY_LWIP_SLIP),1)
86+
CFLAGS_MOD += -DMICROPY_PY_LWIP_SLIP=1
87+
SRC_MOD += $(LWIP_DIR)/netif/slipif.c
88+
endif
89+
endif
90+
91+
################################################################################
92+
# btree
93+
94+
ifeq ($(MICROPY_PY_BTREE),1)
95+
BTREE_DIR = lib/berkeley-db-1.xx
96+
BTREE_DEFS = -D__DBINTERFACE_PRIVATE=1 -Dmpool_error=printf -Dabort=abort_ "-Dvirt_fd_t=void*" $(BTREE_DEFS_EXTRA)
97+
INC += -I$(TOP)/$(BTREE_DIR)/PORT/include
98+
SRC_MOD += extmod/modbtree.c
99+
SRC_MOD += $(addprefix $(BTREE_DIR)/,\
100+
btree/bt_close.c \
101+
btree/bt_conv.c \
102+
btree/bt_debug.c \
103+
btree/bt_delete.c \
104+
btree/bt_get.c \
105+
btree/bt_open.c \
106+
btree/bt_overflow.c \
107+
btree/bt_page.c \
108+
btree/bt_put.c \
109+
btree/bt_search.c \
110+
btree/bt_seq.c \
111+
btree/bt_split.c \
112+
btree/bt_utils.c \
113+
mpool/mpool.c \
114+
)
115+
CFLAGS_MOD += -DMICROPY_PY_BTREE=1
116+
# we need to suppress certain warnings to get berkeley-db to compile cleanly
117+
# and we have separate BTREE_DEFS so the definitions don't interfere with other source code
118+
$(BUILD)/$(BTREE_DIR)/%.o: CFLAGS += -Wno-old-style-definition -Wno-sign-compare -Wno-unused-parameter $(BTREE_DEFS)
119+
$(BUILD)/extmod/modbtree.o: CFLAGS += $(BTREE_DEFS)
120+
endif
121+

py/py.mk

Lines changed: 3 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -19,116 +19,6 @@ QSTR_GLOBAL_DEPENDENCIES += $(PY_SRC)/mpconfig.h mpconfigport.h
1919
# some code is performance bottleneck and compiled with other optimization options
2020
CSUPEROPT = -O3
2121

22-
# this sets the config file for FatFs
23-
CFLAGS_MOD += -DFFCONF_H=\"lib/oofatfs/ffconf.h\"
24-
25-
ifeq ($(MICROPY_PY_USSL),1)
26-
CFLAGS_MOD += -DMICROPY_PY_USSL=1
27-
ifeq ($(MICROPY_SSL_AXTLS),1)
28-
CFLAGS_MOD += -DMICROPY_SSL_AXTLS=1 -I$(TOP)/lib/axtls/ssl -I$(TOP)/lib/axtls/crypto -I$(TOP)/extmod/axtls-include
29-
AXTLS_DIR = lib/axtls
30-
$(BUILD)/$(AXTLS_DIR)/%.o: CFLAGS += -Wno-all -Wno-unused-parameter -Wno-uninitialized -Wno-sign-compare -Wno-old-style-definition $(AXTLS_DEFS_EXTRA)
31-
SRC_MOD += $(addprefix $(AXTLS_DIR)/,\
32-
ssl/asn1.c \
33-
ssl/loader.c \
34-
ssl/tls1.c \
35-
ssl/tls1_svr.c \
36-
ssl/tls1_clnt.c \
37-
ssl/x509.c \
38-
crypto/aes.c \
39-
crypto/bigint.c \
40-
crypto/crypto_misc.c \
41-
crypto/hmac.c \
42-
crypto/md5.c \
43-
crypto/rsa.c \
44-
crypto/sha1.c \
45-
)
46-
else ifeq ($(MICROPY_SSL_MBEDTLS),1)
47-
# Can be overridden by ports which have "builtin" mbedTLS
48-
MICROPY_SSL_MBEDTLS_INCLUDE ?= $(TOP)/lib/mbedtls/include
49-
CFLAGS_MOD += -DMICROPY_SSL_MBEDTLS=1 -I$(MICROPY_SSL_MBEDTLS_INCLUDE)
50-
LDFLAGS_MOD += -L$(TOP)/lib/mbedtls/library -lmbedx509 -lmbedtls -lmbedcrypto
51-
endif
52-
endif
53-
54-
ifeq ($(MICROPY_PY_LWIP),1)
55-
# A port should add an include path where lwipopts.h can be found (eg extmod/lwip-include)
56-
LWIP_DIR = lib/lwip/src
57-
INC += -I$(TOP)/$(LWIP_DIR)/include
58-
CFLAGS_MOD += -DMICROPY_PY_LWIP=1
59-
$(BUILD)/$(LWIP_DIR)/core/ipv4/dhcp.o: CFLAGS_MOD += -Wno-address
60-
SRC_MOD += extmod/modlwip.c lib/netutils/netutils.c
61-
SRC_MOD += $(addprefix $(LWIP_DIR)/,\
62-
core/def.c \
63-
core/dns.c \
64-
core/inet_chksum.c \
65-
core/init.c \
66-
core/ip.c \
67-
core/mem.c \
68-
core/memp.c \
69-
core/netif.c \
70-
core/pbuf.c \
71-
core/raw.c \
72-
core/stats.c \
73-
core/sys.c \
74-
core/tcp.c \
75-
core/tcp_in.c \
76-
core/tcp_out.c \
77-
core/timeouts.c \
78-
core/udp.c \
79-
core/ipv4/autoip.c \
80-
core/ipv4/dhcp.c \
81-
core/ipv4/etharp.c \
82-
core/ipv4/icmp.c \
83-
core/ipv4/igmp.c \
84-
core/ipv4/ip4_addr.c \
85-
core/ipv4/ip4.c \
86-
core/ipv4/ip4_frag.c \
87-
core/ipv6/dhcp6.c \
88-
core/ipv6/ethip6.c \
89-
core/ipv6/icmp6.c \
90-
core/ipv6/inet6.c \
91-
core/ipv6/ip6_addr.c \
92-
core/ipv6/ip6.c \
93-
core/ipv6/ip6_frag.c \
94-
core/ipv6/mld6.c \
95-
core/ipv6/nd6.c \
96-
netif/ethernet.c \
97-
)
98-
ifeq ($(MICROPY_PY_LWIP_SLIP),1)
99-
CFLAGS_MOD += -DMICROPY_PY_LWIP_SLIP=1
100-
SRC_MOD += $(LWIP_DIR)/netif/slipif.c
101-
endif
102-
endif
103-
104-
ifeq ($(MICROPY_PY_BTREE),1)
105-
BTREE_DIR = lib/berkeley-db-1.xx
106-
BTREE_DEFS = -D__DBINTERFACE_PRIVATE=1 -Dmpool_error=printf -Dabort=abort_ "-Dvirt_fd_t=void*" $(BTREE_DEFS_EXTRA)
107-
INC += -I$(TOP)/$(BTREE_DIR)/PORT/include
108-
SRC_MOD += extmod/modbtree.c
109-
SRC_MOD += $(addprefix $(BTREE_DIR)/,\
110-
btree/bt_close.c \
111-
btree/bt_conv.c \
112-
btree/bt_debug.c \
113-
btree/bt_delete.c \
114-
btree/bt_get.c \
115-
btree/bt_open.c \
116-
btree/bt_overflow.c \
117-
btree/bt_page.c \
118-
btree/bt_put.c \
119-
btree/bt_search.c \
120-
btree/bt_seq.c \
121-
btree/bt_split.c \
122-
btree/bt_utils.c \
123-
mpool/mpool.c \
124-
)
125-
CFLAGS_MOD += -DMICROPY_PY_BTREE=1
126-
# we need to suppress certain warnings to get berkeley-db to compile cleanly
127-
# and we have separate BTREE_DEFS so the definitions don't interfere with other source code
128-
$(BUILD)/$(BTREE_DIR)/%.o: CFLAGS += -Wno-old-style-definition -Wno-sign-compare -Wno-unused-parameter $(BTREE_DEFS)
129-
$(BUILD)/extmod/modbtree.o: CFLAGS += $(BTREE_DEFS)
130-
endif
131-
13222
# External modules written in C.
13323
ifneq ($(USER_C_MODULES),)
13424
# pre-define USERMOD variables as expanded so that variables are immediate
@@ -365,3 +255,6 @@ $(PY_BUILD)/vm.o: CFLAGS += $(CSUPEROPT)
365255
# http://hg.python.org/cpython/file/b127046831e2/Python/ceval.c#l828
366256
# http://www.emulators.com/docs/nx25_nostradamus.htm
367257
#-fno-crossjumping
258+
259+
# Include rules for extmod related code
260+
include $(TOP)/extmod/extmod.mk

0 commit comments

Comments
 (0)
0