ncurses-emscripten
ncurses-emscripten copied to clipboard
ncurses for Emscripten (WASM)
ncurses for Emscripten (WASM)
Introduction
Here you’ll find the installation instructions and patch required to compile ncurses 6.1+ for Emscripten.
Please take note of the following considerations:
- Before using this patched version of ncurses it's important that code linking or compiling from this repository use -s ASSERTIONS=1 as further debugging of this library is required.
- The patch contains a redeclaration of getenv() from stdlib.h which solves the problem described in issue #6778.
- There is no Makefile patching done to the make process itself and since the build requires several native applications to be compiled the make process is not as straightforward as other libraries or applications. Creating a companion make process for both the native and Emscripten elements would be ideal but now for we are just changing the make process manually. Instructions to modifying the relevant Makefiles are below.
Lastly, a large part of this work can be credited to ilyaigpetrov found in his repository (ilyaigpetrov/ncurses-for-emscripten).
Also, it’s worth noting that there are several other projects of a curses nature out there and if you’re looking at the most optimal solution for curses for Emscripten each of them have their merits.
- https://github.com/sabotage-linux/netbsd-curses
- https://github.com/wmcbrine/PDCurses
- https://github.com/rhaberkorn/emcurses
Installation
It's recommended to create a separate directory to build this project in. For example ncurses-emscripten/.
Downloading and patching ncurses
~$ wget https://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.1.tar.gz
~$ wget https://raw.githubusercontent.com/jamesbiv/ncurses-emscripten/master/ncurses-6.1_emscripten.patch
~$ tar -xzvf ncurses-6.1.tar.gz
Note: Because this is a source tree level patch make sure the patch is in the directory before the installed directory. For example, if the directory for ncurses is /home/user/ncurses-6.1 then make sure the patch is located at /home/user/ncurses-6.1_emscripten.patch.
~$ patch -p0~$ cd ncurses-6.1Configure and make the native components
Note: Using --prefix defines the installation path for ncurses. Feel free to change --prefix to anything you wish, just make sure you specify the same directory below when calling emconfigure. Further, it’s recommended to use --prefix because you really don't want this to be a global library either way.
~$ ./configure --prefix=`pwd`/build~$ make && make installConfigure and make the Emscripten components
Note: Using --prefix defines the installation path for ncurses. Make sure you use the same path you've described above.
~$ emconfigure ./configure --prefix=`pwd`/buildModifying the Makefiles for Emscripten
~$ nano -w ./MakefileComment out the following lines of code using # to reflect the following:
Line 113 #cd man && ${MAKE} ${TOP_MFLAGS} $@ Line 116 #cd progs && ${MAKE} ${TOP_MFLAGS} $@ Line 120 #cd test && ${MAKE} ${TOP_MFLAGS} $@ Line 121 #cd misc && ${MAKE} ${TOP_MFLAGS} $@ Line 122 #cd c++ && ${MAKE} ${TOP_MFLAGS} $@Save and exit nano
~$ nano -w ./ncurses/MakefileComment out the following lines of code using # to reflect the following:
From line 233
#make_keys$(BUILD_EXEEXT) : \ # $(tinfo)/make_keys.c \ # names.c # $(BUILD_CC) -o $@ $(BUILD_CPPFLAGS) $(BUILD_CCFLAGS) $(tinfo)/make_keys.c $(BUILD_LDFLAGS) $(BUILD_LIBS) #make_hash$(BUILD_EXEEXT) : \ # $(tinfo)/make_hash.c \ # ../include/hashsize.h # $(BUILD_CC) -o $@ $(BUILD_CPPFLAGS) $(BUILD_CCFLAGS) $(tinfo)/make_hash.c $(BUILD_LDFLAGS) $(BUILD_LIBS) #report_offsets$(BUILD_EXEEXT) : \ # $(srcdir)/report_offsets.c # $(BUILD_CC) -o $@ $(BUILD_CPPFLAGS) $(BUILD_CCFLAGS) $(srcdir)/report_offsets.c $(BUILD_LDFLAGS) $(BUILD_LIBS)Comment out the following lines of code in the same Makefile using # to reflect the following:
From line 283
# -rm -f make_keys$(BUILD_EXEEXT) # -rm -f make_hash$(BUILD_EXEEXT) # -rm -f report_offsets$(BUILD_EXEEXT)Save and exit nano
Compiling and installing for Emscripten
Note: Ideally make clean should be committed before the emconfigure but because we are preserving parts of the native build we commit the make clean after the Makefile modifications.
~$ make clean~$ emmake make && emmake make install~$ cd build (or whatever directory you've asked it to install too)