@@ -30,6 +30,13 @@ LIBS := -lnx
3030# include and lib
3131# ---------------------------------------------------------------------------------
3232
33+ # Use gnu-sed if it is macos
34+ ifeq ($(UNAME_S ) ,Darwin)
35+ SED := gsed
36+ else
37+ SED := sed
38+ endif
39+
3340PYCONFIG_DIR := ../python_config
3441
3542LIBDIRS := $(PORTLIBS ) $(LIBNX )
@@ -42,7 +49,7 @@ ifndef PYVERS
4249 PYVERS := 3.5.3
4350endif
4451
45- ANAME := libpython$(shell echo $(PYVERS ) | sed 's/\([0-9]* \.\([0-9]* \) \).*/\1/').a
52+ ANAME := libpython$(shell echo $(PYVERS ) | $( SED ) 's/\([0-9]* \.\([0-9]* \) \).*/\1/').a
4653
4754OUTDIR := nxpy$(PYVERS )
4855
@@ -54,6 +61,8 @@ _NXVERS := 5baa28b0ce6ab2c8390fd85cfc36e1086f2cede9
5461NXFILE := nx.zip
5562NXVERS := e0fb67e90e945c6f214f16a804ae1ca7fa211d95
5663
64+
65+
5766.PHONY : all clean
5867
5968all : distfPY
@@ -67,7 +76,7 @@ distfPY: linkPY
6776 cp $(PYDIR ) /Include/* $(OUTDIR ) /include/nxpy
6877 cp $(PYDIR ) /pyconfig.h $(OUTDIR ) /include/nxpy/
6978 cp $(PYDIR ) /Lib/socket.py $(PYDIR ) /Lib/socket.pyX
70- cat $(PYDIR ) /Lib/socket.pyX | sed ' s/' " '" ' getpeername' " '" ' , //g' > $(PYDIR ) /Lib/socket.py
79+ cat $(PYDIR ) /Lib/socket.pyX | $( SED ) ' s/' " '" ' getpeername' " '" ' , //g' > $(PYDIR ) /Lib/socket.py
7180 rm $(PYDIR ) /Lib/socket.pyX
7281 cd $(PYDIR ) /Lib && ls * .py -1 | xargs zip ../../$(OUTDIR ) /python.zip && find json/ encodings/ html/ http/ test/ urllib/ collections/ email/ sqlite3/ logging/ xml/ importlib/ asyncio/ -type f | xargs zip ../../$(OUTDIR ) /python.zip
7382
@@ -91,28 +100,28 @@ soospatchPY: compilePY
91100 cp $(PYCONFIG_DIR ) /fileutils.c $(PYDIR ) /Python/
92101 cp $(PYCONFIG_DIR ) /getaddrinfo.c $(PYDIR ) /Modules/
93102 cp $(PYDIR ) /Modules/posixmodule.c $(PYDIR ) /Modules/posixmodule.c_old
94- cat $(PYDIR ) /Modules/posixmodule.c_old | sed ' s/return utime(path, time)/errno=ENOENT; return -1/g' | sed ' s/define LSTAT lstat/define LSTAT stat/' | sed ' 1s/^/#include <sys\/socket.h>/' | sed ' s/access(path->narrow, mode)/1/' | sed ' s/\(^[^rt]*time_t atime, mtime;.*\)/return NULL; \1/' | sed ' s/\(^[^ri]*int i = (int)umask(mask);.*\)/int i=0; return NULL;/' | sed ' s/^\([^#][^#]*#undef HAVE_FSTATVFS.*\)/\#undef HAVE_FSTATVFS \1/' | sed ' s/#define HAVE_\(EXECV\|FORK\|GETEGID\|GETEUID\|GETGID\|GETPPID\|GETUID\|KILL\|PIPE\|POPEN\|SYSTEM\|TTYNAME\|SYMLINK\|UTIME_H\|FDATASYNC\).*/#undef HAVE_\1/g' | sed ' s/^#define HAVE_\(STATVFS\|SYS_STATVFS_H\|FDATASYNC\|FTIME\|SYMLINK\|EXECV\|FORK\|GETEGID\|GETEUID\|GETGID\|GETPPID\|GETUID\|KILL\|PIPE\|POPEN\|SYSTEM\|TTYNAME\|SYMLINK\|UTIME_H\|FDATASYNC\).*/#undef HAVE_\1/' > $(PYDIR ) /Modules/posixmodule.c
103+ cat $(PYDIR ) /Modules/posixmodule.c_old | $( SED ) ' s/return utime(path, time)/errno=ENOENT; return -1/g' | $( SED ) ' s/define LSTAT lstat/define LSTAT stat/' | $( SED ) ' 1s/^/#include <sys\/socket.h>/' | $( SED ) ' s/access(path->narrow, mode)/1/' | $( SED ) ' s/\(^[^rt]*time_t atime, mtime;.*\)/return NULL; \1/' | $( SED ) ' s/\(^[^ri]*int i = (int)umask(mask);.*\)/int i=0; return NULL;/' | $( SED ) ' s/^\([^#][^#]*#undef HAVE_FSTATVFS.*\)/\#undef HAVE_FSTATVFS \1/' | $( SED ) ' s/#define HAVE_\(EXECV\|FORK\|GETEGID\|GETEUID\|GETGID\|GETPPID\|GETUID\|KILL\|PIPE\|POPEN\|SYSTEM\|TTYNAME\|SYMLINK\|UTIME_H\|FDATASYNC\).*/#undef HAVE_\1/g' | $( SED ) ' s/^#define HAVE_\(STATVFS\|SYS_STATVFS_H\|FDATASYNC\|FTIME\|SYMLINK\|EXECV\|FORK\|GETEGID\|GETEUID\|GETGID\|GETPPID\|GETUID\|KILL\|PIPE\|POPEN\|SYSTEM\|TTYNAME\|SYMLINK\|UTIME_H\|FDATASYNC\).*/#undef HAVE_\1/' > $(PYDIR ) /Modules/posixmodule.c
95104 cp $(PYDIR ) /Modules/socketmodule.c $(PYDIR ) /Modules/socketmodule.c_old
96- cat $(PYDIR ) /Modules/socketmodule.c_old | sed ' s/send(s->sock_fd, buf, len, flags);/send(s->sock_fd, buf, len<4096?len:4096, flags);/g' | sed ' s/ sizeof(addr->sa_data)/ 28/g' > $(PYDIR ) /Modules/socketmodule.c
105+ cat $(PYDIR ) /Modules/socketmodule.c_old | $( SED ) ' s/send(s->sock_fd, buf, len, flags);/send(s->sock_fd, buf, len<4096?len:4096, flags);/g' | $( SED ) ' s/ sizeof(addr->sa_data)/ 28/g' > $(PYDIR ) /Modules/socketmodule.c
97106 cp $(PYDIR ) /Objects/exceptions.c $(PYDIR ) /Objects/exceptions.c_old
98- cat $(PYDIR ) /Objects/exceptions.c_old | sed ' s/ESHUTDOWN/EPIPE/g' > $(PYDIR ) /Objects/exceptions.c
107+ cat $(PYDIR ) /Objects/exceptions.c_old | $( SED ) ' s/ESHUTDOWN/EPIPE/g' > $(PYDIR ) /Objects/exceptions.c
99108 cp $(PYDIR ) /Python/pytime.c $(PYDIR ) /Python/pytime.c_old
100- cat $(PYDIR ) /Python/pytime.c_old | sed ' s/CLOCK_MONOTONIC/(clockid_t)4/g' > $(PYDIR ) /Python/pytime.c
109+ cat $(PYDIR ) /Python/pytime.c_old | $( SED ) ' s/CLOCK_MONOTONIC/(clockid_t)4/g' > $(PYDIR ) /Python/pytime.c
101110 cp $(PYDIR ) /Makefile $(PYDIR ) /Makefile_old
102- cat $(PYDIR ) /Makefile_old | sed ' s/-Werror=declaration-after-statement//' | sed ' s/Python\/$$(DYNLOADFILE) \\/\\/' > $(PYDIR ) /Makefile
111+ cat $(PYDIR ) /Makefile_old | $( SED ) ' s/-Werror=declaration-after-statement//' | $( SED ) ' s/Python\/$$(DYNLOADFILE) \\/\\/' > $(PYDIR ) /Makefile
103112 touch soospatchPY
104113
105114compilePY : extractedPY patchPY
106115 cd $(PYDIR ) && ./configure CC=" $( CC) " CXX=" $( CXX) " AS=" $( AS) " AR=" $( AR) " OBJCOPY=" $( OBJCOPY) " STRIP=" $( STRIP) " NM=" $( NM) " RANLIB=" $( RANLIB) " CFLAGS=" $( CFLAGS) " CXXFLAGS=" $( CXXFLAGS) " ASFLAGS=" $( ASFLAGS) " LDFLAGS=" $( LDFLAGS) " CONFIG_SITE=" config.site" --disable-shared --without-threads --without-signal-module --disable-ipv6 --host=aarch64-none-elf --build=` ./config.guess` && cd .. && touch compilePY
107116
108117patchPY : cloneNX
109118 cp $(PYDIR ) /configure $(PYDIR ) /configure_old
110- cat $(PYDIR ) /configure_old | sed ' s/ \*\-\*\-linux\*)/ \*\-\*\-linux\*\|aarch64\-none\-elf)/g' > $(PYDIR ) /configure
119+ cat $(PYDIR ) /configure_old | $( SED ) ' s/ \*\-\*\-linux\*)/ \*\-\*\-linux\*\|aarch64\-none\-elf)/g' > $(PYDIR ) /configure
111120 echo ac_cv_file__dev_ptmx=no > $(PYDIR ) /config.site
112121 echo ac_cv_file__dev_ptc=no >> $(PYDIR ) /config.site
113122 echo ac_cv_lib_dl_dlopen=no >> $(PYDIR ) /config.site
114123 cp $(PYDIR ) /Modules/Setup.dist $(PYDIR ) /Modules/Setup.dist_old
115- cat $(PYDIR ) /Modules/Setup.dist_old | sed -e ' $$a_nx -I$$(srcdir)/Modules/_nx _nx/_nxmodule.c' | sed ' s/^\([^#].* pwdmodule\.c.*\)/#\1/' | sed ' s/^#\(array\|cmath\|math\|_struct\|operator\|_random\|_collections\|itertools\|signal\|strop\|unicodedata\|_io\|_csv\|_md5\|_sha\|_sha256\|_sha512\|binascii\|select\|cStringIO\|time\|_functools\|_socket\|datetime\|_bisect\)\(.*\)/\1\2/' | sed " s#\\ (zlib[^\$ $]*\\ )\$ $( prefix) \\ ([^\$ $]*\\ )\$ $( exec_prefix) \\ (.*\\ )#\1$( DEVKITPRO) /portlibs/switch\2$( DEVKITPRO) /portlibs/switch\3#" > $(PYDIR ) /Modules/Setup.dist
124+ cat $(PYDIR ) /Modules/Setup.dist_old | $( SED ) -e ' $$a_nx -I$$(srcdir)/Modules/_nx _nx/_nxmodule.c' | $( SED ) ' s/^\([^#].* pwdmodule\.c.*\)/#\1/' | $( SED ) ' s/^#\(array\|cmath\|math\|_struct\|operator\|_random\|_collections\|itertools\|signal\|strop\|unicodedata\|_io\|_csv\|_md5\|_sha\|_sha256\|_sha512\|binascii\|select\|cStringIO\|time\|_functools\|_socket\|datetime\|_bisect\)\(.*\)/\1\2/' | $( SED ) " s#\\ (zlib[^\$ $]*\\ )\$ $( prefix) \\ ([^\$ $]*\\ )\$ $( exec_prefix) \\ (.*\\ )#\1$( DEVKITPRO) /portlibs/switch\2$( DEVKITPRO) /portlibs/switch\3#" > $(PYDIR ) /Modules/Setup.dist
116125 cp -r _nx-* /_nx $(PYDIR ) /Modules/
117126
118127 touch patchPY
0 commit comments