Skip to content

Instantly share code, notes, and snippets.

@sogaiu
Created May 31, 2020 02:25
Show Gist options
  • Save sogaiu/44fa0f5f056f4d823cc3c29fad8f03de to your computer and use it in GitHub Desktop.
Save sogaiu/44fa0f5f056f4d823cc3c29fad8f03de to your computer and use it in GitHub Desktop.
draft xterm for hermes
(use ../prelude)
(import ../core)
(use ./fontconfig)
(use ./freetype2)
(use ./libpng)
(use ./ncurses)
(use ./patchelf)
(use ./util-linux)
(use ./xorg)
(use ./zlib)
(defsrc xterm-src
:url
"ftp://ftp.invisible-island.net/xterm/xterm-356.tgz"
:hash
"sha256:38c5182fc4108390b21b54d2b84b7c92444221f39bb35129913149c4bf9629c7")
(defpkg xterm
:builder
(fn []
(os/setenv "PKG_CONFIG_PATH"
(string (join-pkg-paths ":" "/lib/pkgconfig"
[fontconfig
freetype2
libpng
libpthread-stubs
libxcb
libICE
libSM
libX11
libXau
libXaw
libXext
libXft
libXmu
libXpm
libXt
ncurses
util-linux
zlib
])
":"
(join-pkg-paths ":" "/share/pkgconfig"
[util-macros
xorgproto])))
(os/setenv "PATH"
(join-pkg-paths ":" "/bin"
[core/awk
core/coreutils
core/diffutils
core/gcc
core/grep
core/make
core/patch
patchelf
core/pkgconf
core/sed]))
# XXX: uuid/uuid.h wasn't being found appropriately
(os/setenv "CPPFLAGS"
(string
"-I" (util-linux :path) "/include"
" "
(sh/$<_ pkg-config --cflags-only-I
freetype2
libpng
ncurses
# XXX: isn't working?
uuid
x11
xaw6
xaw7
xext
xmu
xpm
xt
zlib)))
(os/setenv "CFLAGS"
(string *default-cflags*
" "
(sh/$<_ pkg-config --cflags-only-other
freetype2
libpng
ncurses
uuid
x11
xaw6
xaw7
xext
xmu
xpm
xt
zlib
)))
(os/setenv "LDFLAGS"
(string *default-ldflags*
" "
# use RUNPATH
"-Wl,--enable-new-dtags"
" "
(string/join (map
|(string "-Wl,-rpath-link="
($ :path) "/lib"
" ")
[fontconfig
freetype2
libpng
libpthread-stubs
libpng
libxcb
libICE
libSM
libX11
libXau
libXaw
libXext
libXft
libXmu
libXpm
libXrender
libXt
ncurses
util-linux
zlib]))))
# placate configure
(os/setenv "LD_LIBRARY_PATH"
(join-pkg-paths ":" "/lib"
[freetype2
libpng
libpthread-stubs
libxcb
libICE
libSM
libX11
libXau
libXaw
libXext
libXft
libXmu
libXpm
libXt
ncurses
util-linux
zlib]))
(unpack-src xterm-src)
(core/link-/bin/sh)
# XXX: without this the xterm window won't show up and there is error
# output
(sh/$ patch < ``
--- main.c 2016-03-09 15:30:51.191053881 +0100
+++ main.c.new 2016-03-09 15:31:17.961635229 +0100
@@ -2654,7 +2654,7 @@ get_pty(int *pty, char *from GCC_UNUSED)
close(opened_tty);
opened_tty = -1;
}
-#elif defined(HAVE_POSIX_OPENPT) && defined(HAVE_PTSNAME) && defined(HAVE_GRANTPT_PTY_ISATTY)
+#elif defined(HAVE_POSIX_OPENPT) && defined(HAVE_PTSNAME)
if ((*pty = posix_openpt(O_RDWR)) >= 0) {
char *name = ptsname(*pty);
if (name != 0) {
@@ -3735,7 +3735,7 @@ spawnXTerm(XtermWidget xw)
/*
* now in child process
*/
-#if defined(_POSIX_SOURCE) || defined(SVR4) || defined(__convex__) || defined(__SCO__) || defined(__QNX__)
+#if defined(_POSIX_VERSION) || defined(SVR4) || defined(__convex__) || defined(__SCO__) || defined(__QNX__)
int pgrp = setsid(); /* variable may not be used... */
#else
int pgrp = getpid();
``)
(sh/$ ./configure
--prefix= ^ (dyn :pkg-out)
--disable-regex)
# XXX: didn't figure out a way to get this in otherwise...
(rewrite "Makefile"
|(string/replace "LIBS\t\t="
(string "LIBS\t\t="
" "
"-L" (ncurses :path) "/lib"
" "
"-lncurses"
" ")
$))
# XXX: pliink.sh seemed to be pruning stuff we needed to keep
(rewrite "Makefile"
|(string/replace-all "\t$(SHELL) $(srcdir)/plink.sh "
"\t"
$))
#
(sh/$ make
-j (dyn :parallelism))
(sh/$ make install)
# XXX: this is not the only binary to patch
(sh/$ patchelf --set-rpath
(join-pkg-paths ":" "/lib"
[libICE
libSM
libX11
libXaw
libXmu
libXt
ncurses])
(string (dyn :pkg-out) "/bin/xterm"))
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment