-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmicropython.mk
More file actions
75 lines (66 loc) · 3.07 KB
/
Copy pathmicropython.mk
File metadata and controls
75 lines (66 loc) · 3.07 KB
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
# MicroPython build glue for usdl2 (desktop SDL2 subset: unix + windows ports).
#
# Discovered via USER_C_MODULES pointing at the workspace directory that
# contains this repo (its parent), e.g. `make USER_C_MODULES=../../..`.
#
# Linux/unix: libsdl2-dev + pkg-config sdl2
# Windows (MinGW): SDL2 official MinGW development zip (not vendored in this repo).
# export SDL2_DEV=~/SDL2-2.x.x # unpacked zip root (x86_64-w64-mingw32/ inside)
# See usdl2/README.md. The release .pc files use wrong prefix paths; SDL2_DEV
# uses the unpacked directory layout directly.
USDL2_MOD_DIR := $(USERMOD_DIR)
PORT_DIR_ABS := $(abspath $(CURDIR))
IS_UNIX_PORT := $(findstring /ports/unix,$(PORT_DIR_ABS))
IS_WINDOWS_PORT := $(findstring /ports/windows,$(PORT_DIR_ABS))
ifneq ($(IS_UNIX_PORT)$(IS_WINDOWS_PORT),)
ifeq ($(IS_WINDOWS_PORT),)
# Unix: system SDL2 via pkg-config.
SDL2_CFLAGS ?= $(shell pkg-config --cflags sdl2 2>/dev/null)
SDL2_LIBS ?= $(shell pkg-config --libs sdl2 2>/dev/null)
else
# Windows: static SDL2 for a self-contained .exe (no SDL2.dll beside the binary).
ifdef SDL2_DEV
USDL2_SDL2_TRIPLET ?= x86_64-w64-mingw32
ifneq ($(findstring i686-w64-mingw32,$(CROSS_COMPILE)),)
USDL2_SDL2_TRIPLET := i686-w64-mingw32
endif
USDL2_SDL2_PREFIX := $(SDL2_DEV)/$(USDL2_SDL2_TRIPLET)
# Console app: no SDL2main / WinMain / -mwindows (micropython already has main()).
SDL2_CFLAGS := -I$(USDL2_SDL2_PREFIX)/include/SDL2
SDL2_LIBS := -L$(USDL2_SDL2_PREFIX)/lib \
$(USDL2_SDL2_PREFIX)/lib/libSDL2.a \
-lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 \
-lole32 -loleaut32 -lshell32 -lsetupapi -lversion -luuid
else
# Without SDL2_DEV, only a MinGW pkg-config is valid — never host Linux sdl2.pc
# (Debian's /usr/include/SDL2/SDL_config.h indirection breaks cross-compiles).
USDL2_MINGW_PKG_CONFIG :=
ifneq ($(findstring x86_64-w64-mingw32,$(CROSS_COMPILE)),)
ifneq ($(shell command -v x86_64-w64-mingw32-pkg-config 2>/dev/null),)
USDL2_MINGW_PKG_CONFIG := x86_64-w64-mingw32-pkg-config
endif
else ifneq ($(findstring i686-w64-mingw32,$(CROSS_COMPILE)),)
ifneq ($(shell command -v i686-w64-mingw32-pkg-config 2>/dev/null),)
USDL2_MINGW_PKG_CONFIG := i686-w64-mingw32-pkg-config
endif
endif
ifneq ($(USDL2_MINGW_PKG_CONFIG),)
SDL2_CFLAGS ?= $(shell $(USDL2_MINGW_PKG_CONFIG) --cflags sdl2 2>/dev/null)
SDL2_LIBS ?= $(shell $(USDL2_MINGW_PKG_CONFIG) --static --libs sdl2 2>/dev/null)
else
$(error usdl2 windows port requires SDL2_DEV=path to unpacked SDL2 MinGW development ZIP — see usdl2/README.md)
endif
endif
endif
ifeq ($(SDL2_CFLAGS),)
$(error usdl2 SDL2 not found — unix: install libsdl2-dev; windows: set SDL2_DEV to unpacked SDL2 MinGW dev zip (see usdl2/README.md))
endif
CFLAGS_USERMOD += $(SDL2_CFLAGS) -I$(USDL2_MOD_DIR)/src -Wno-sign-compare -Wno-unused-parameter -Wno-shadow
# MicroPython only appends LDFLAGS_USERMOD (see py/py.mk); do not use LIBS_USERMOD.
LDFLAGS_USERMOD += $(SDL2_LIBS)
ifeq ($(IS_WINDOWS_PORT),)
else
LDFLAGS_USERMOD += -static-libgcc
endif
SRC_USERMOD_C += $(USDL2_MOD_DIR)/src/usdl2_mp.c
endif