How NetSurf 3.11 was brought to ZETA - notes for anyone who wants to continue
==========================================================================

Why this is not a normal build
  ZETA's compiler is gcc 2.95 (2.9-beos-000224). NetSurf 3.x and its libraries need
  C99 (for-loop declarations, designated initialisers, inline, stdint/stdbool, ...) and
  cannot be built with it. But the BeAPI C++ ABI is the gcc2 one, so the front end
  (frontends/beos/*.cpp, which uses BWindow, BView, ...) must be compiled by ZETA's gcc.

  Solution: split the build.
    * All C code (NetSurf core, libcss, libdom, libhubbub, libparserutils, libwapcaplet,
      libnsgif, libnsbmp, libnsutils, libnspsl, utf8proc, expat, zlib, libpng, libjpeg,
      mbedTLS, curl) is cross-compiled on a Mac with clang (--target=i386-unknown-elf)
      using ZETA's own headers. The resulting ELF objects are linked on ZETA by ZETA's
      gcc/ld together with the gcc2-compiled front end.
    * The C++ front end is compiled natively on ZETA.
  The i386 C ABI is the same for both compilers (struct returns in memory, cdecl).

Things that bit us (all fixed in source/tools)
  1. Position independent code is mandatory. ZETA's ld builds ebx-relative PLT stubs.
     Non-PIC clang code crashes at the first lazy PLT call (eip = 0 in calloc()).
     Build with -fPIC and -Xclang -mrelax-relocations=no (ZETA's ld does not know
     R_386_GOT32X).
  2. ZETA's headers use GNU89 "extern inline"; clang defaults to C99 semantics and emits
     duplicate strtod/strtol/... definitions. Use -fgnu89-inline.
  3. wchar_t is 16 bit on BeOS: -fshort-wchar.
  4. BeOS stdint.h/inttypes.h are incomplete (no intptr_t, PRIu32, ...): see
     tools/hdr-overlay.
  5. BeOS be_prim.h typedefs 'bool' as unsigned char, which clashes with C99 stdbool:
     guard it with __bool_true_false_are_defined (the BeOS header copy is not
     redistributed - patch your own copy).
  6. The Mac file system is case-insensitive: be/support/byteorder.h (a 31 byte stub)
     overwrote ByteOrder.h. Keep the BeOS headers on a case-sensitive volume.
  7. BONE: no poll(), getaddrinfo is unreliable -> curl is configured with select() and
     gethostbyname(); sockets use setsockopt(SO_NONBLOCK). See tools/compat/curl_config.h.
  8. libroot lacks strtof() and scandir(): tools/compat/zns_compat.c.
  9. mbedTLS needs a clock and an entropy source: gmtime_r/ms_time shims in
     tools/compat/zns_mbedtls_glue.c; entropy comes from /dev/urandom.
 10. libzeta.so must be linked (find_directory_r lives there, not in libbe).
 11. Haiku-only pieces of the front end were replaced: BPathFinder (fixed
     /boot/apps/netsurf/res path), BAboutWindow (BAlert), the cookie manager
     (BColumnListView/BGroupLayout: stubbed), BCursorID cursors (classic 16x16
     cursors), vector icons (BIconUtils: text buttons), BWindowStack.
     BView::DrawBitmap(NULL) crashes on R5/ZETA (Haiku tolerates it).
 12. There is no 'rc' resource compiler: tools/compat/mkrsrc.cpp builds the .rsrc
     (data resources, app signature, file types, icons) with BResources and xres
     attaches it.
 13. Shutdown: after the core had shut down cleanly, exit() hung with all threads
     waiting on the malloc lock. The front end now calls _exit(0) once netsurf_exit()
     has returned (Alt+Q), Alt+W was unaffected.
 14. TLS needs a valid system clock (see README).

Debug aids still in the binary
  * A SIGSEGV/SIGILL/SIGFPE handler writes registers and code-looking stack words to
    /tmp/ns-crash.log. Resolve addresses with "nm -n NetSurf" (text base 0x80000000).
  * Set NS_STAGE_LOG=1 in the environment to log start-up / shutdown stages to
    /tmp/ns-stage.log.
  * There is no gdb on ZETA, that is why these exist.

Ideas / not done
  * JavaScript (Duktape + nsgenbind), SVG (libsvgtiny), WebP.
  * A proper cookie manager window for BeOS, toolbar icons as bitmaps.
  * Letting the network stack's resolver time out faster; replacing the 2023 CA bundle
    with a periodically refreshed one.
