shithub: puzzles

Download patch

ref: 7a66855947c043e502d00fa41cd7b7c06127adf9
parent: 2e48ce132e011e83517a9fc4905edcc8f9a5ef58
author: Ben Harris <bjh21@bjh21.me.uk>
date: Wed Apr 5 20:00:07 EDT 2023

KaiOS: include extra copyright notices in manual

The KaiOS build includes compiled versions of various Emscripten library
files.  These are generally under the MIT licence like Puzzles itself.
The MIT licence requires that the licence, and the copyright notice, be
"included in all copies or substantial portions of the Software."

Since each KaiOS package includes the full manual, which already
contains the licence for Puzzles itself, adding the copyright notices
there seems like the best approach.  I've done this by providing an
additional input file that contains the licences for source files used
by a current Emscripten build.  More automation might be nice, but the
set of copyright notices is unlikely to change very much.  There are
basically one for Emscripten, one for musl, and a few for odd bits of
third-party code embedded in musl.

--- a/Buildscr
+++ b/Buildscr
@@ -146,10 +146,10 @@
 # have the right dependencies installed for Emscripten, I do this by a
 # delegation.
 ifneq "$(NOJS)" yes then
-  # The Emscripten delegate doesn't have Halibut, so provide the HTML
-  # docs for the KaiOS apps to use.
+  # The Emscripten delegate doesn't have Halibut, so build a set of
+  # HTML docs for the KaiOS apps to use.
   in puzzles do mkdir -p build-kaios/help/en
-  in puzzles do cp -Rv doc/* build-kaios/help/en
+  in puzzles/build-kaios/help/en do halibut --html -Chtml-template-fragment:%k ../../../puzzles.but ../../../emcccopy.but
   delegate emscripten
     in puzzles do emcmake cmake -B build-emscripten $(web_unfinished_option) .
     in puzzles/build-emscripten do make -j$(nproc) VERBOSE=1
--- a/cmake/platforms/emscripten.cmake
+++ b/cmake/platforms/emscripten.cmake
@@ -73,9 +73,11 @@
     add_custom_command(OUTPUT ${help_dir}/en/index.html
       COMMAND ${HALIBUT} --html -Chtml-template-fragment:%k
         ${CMAKE_CURRENT_SOURCE_DIR}/puzzles.but
+        ${CMAKE_CURRENT_SOURCE_DIR}/emcccopy.but
       DEPENDS
       ${help_dir}/en
       ${CMAKE_CURRENT_SOURCE_DIR}/puzzles.but
+      ${CMAKE_CURRENT_SOURCE_DIR}/emcccopy.but
       WORKING_DIRECTORY ${help_dir}/en)
     add_custom_target(kaios_help ALL
       DEPENDS ${help_dir}/en/index.html)
--- /dev/null
+++ b/emcccopy.but
@@ -1,0 +1,128 @@
+\A{thirdparty} Third-party software licences
+
+\# This file should contain the copyright notices for third-party code
+included in the Emscripten builds of Puzzles.  To get a list of
+relevant source files, you can build Puzzles with "-gsource-map" and
+then do something like:
+
+\# jq -r '.sources[]' *.map | sort -u
+
+\# This file is based on a build of Git commit
+2e48ce132e011e83517a9fc4905edcc8f9a5ef58 using Emscripten 3.1.35
+
+\# system/lib/compiler-rt/lib/builtins/*
+\# upstream/lib/clang/17/include/tgmath.h
+
+\# These are under the Apache Licence v2.0 with LLVM Exceptions.  The
+LLVM Exceptions allow us not to mention them in binary distributions.
+
+\# system/lib/dlmalloc.c
+
+\# dlmalloc is in the public domain and so needs no acknowledgement.
+
+The JavaScript and KaiOS versions of Puzzles incorporate some third
+party software.  Most of it is licensed under the \i{MIT licence} (see
+\k{licence}) and requires the following \i{copyright} notices:
+
+\quote{
+
+\# system/lib/libc/emscripten_get_heap_size.c
+\# system/lib/libc/emscripten_memcpy.c
+\# system/lib/libc/emscripten_syscall_stubs.c
+\# system/lib/libc/wasi-helpers.c
+\# system/lib/pthread/library_pthread_stub.c
+\# system/lib/pthread/pthread_self_stub.c
+\# system/lib/sbrk.c
+
+\# These are parts of Emscripten and either refer explicitly to the
+Emscripten LICENSE file or make no mention of a licence.  LICENSE
+allows use under the MIT licence and specifies this copyright notice:
+
+Copyright (c) 2010-2014 Emscripten authors, see AUTHORS file.
+
+\# cache/sysroot/include/math.h
+\# system/lib/libc/musl/src/ctype/*
+\# system/lib/libc/musl/src/env/*
+\# system/lib/libc/musl/src/errno/*
+\# system/lib/libc/musl/src/internal/atomic.h
+\# system/lib/libc/musl/src/internal/floatscan.c
+\# system/lib/libc/musl/src/internal/intscan.c
+\# system/lib/libc/musl/src/internal/shgetc.c
+\# system/lib/libc/musl/src/math/copysignl.c
+\# system/lib/libc/musl/src/math/fabs.c
+\# system/lib/libc/musl/src/math/fabsl.c
+\# system/lib/libc/musl/src/math/floor.c
+\# system/lib/libc/musl/src/math/fmodl.c
+\# system/lib/libc/musl/src/math/__fpclassifyl.c
+\# system/lib/libc/musl/src/math/frexp.c
+\# system/lib/libc/musl/src/math/scalbn.c
+\# system/lib/libc/musl/src/math/scalbnl.c
+\# system/lib/libc/musl/src/math/sqrtf.c
+\# system/lib/libc/musl/src/multibyte/*
+\# system/lib/libc/musl/src/stdio/*
+\# system/lib/libc/musl/src/stdlib/abs.c
+\# system/lib/libc/musl/src/stdlib/atof.c
+\# system/lib/libc/musl/src/stdlib/atoi.c
+\# system/lib/libc/musl/src/stdlib/atol.c
+\# system/lib/libc/musl/src/stdlib/labs.c
+\# system/lib/libc/musl/src/stdlib/qsort_nr.c
+\# system/lib/libc/musl/src/stdlib/strtod.c
+\# system/lib/libc/musl/src/stdlib/strtol.c
+\# system/lib/libc/musl/src/string/*
+\# system/lib/libc/musl/src/unistd/getpid.c
+
+\# These are parts of musl, which is licensed "as a whole" under the
+MIT licence.  These parts don't carry any licence notice themselves.
+This is the copyright notice from musl's COPYRIGHT file, modified to
+allow for non-Unicode targets:
+
+Copyright \u00A9{(C)} 2005-2020 Rich Felker, et al.
+
+\# system/lib/libc/musl/src/stdlib/qsort.c
+
+\# This is part of musl, but has its own copyright notice and MIT
+licence in its source file.
+
+Copyright (C) 2011 by Valentin Ochs
+
+}
+
+Other incorporated software requires these notices:
+
+\quote{
+
+\# system/lib/libc/musl/src/math/acosf.c
+\# system/lib/libc/musl/src/math/atan.c
+\# system/lib/libc/musl/src/math/cos.c
+\# system/lib/libc/musl/src/math/__cosdf.c
+\# system/lib/libc/musl/src/math/cosf.c
+\# system/lib/libc/musl/src/math/__rem_pio2f.c
+\# system/lib/libc/musl/src/math/sin.c
+\# system/lib/libc/musl/src/math/__sindf.c
+\# system/lib/libc/musl/src/math/sinf.c
+
+\# These are parts of musl with a SunPro copyright notice and licence.
+
+Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+
+Developed at SunPro, a Sun Microsystems, Inc. business.
+Permission to use, copy, modify, and distribute this
+software is freely granted, provided that this notice
+is preserved.
+
+\# system/lib/libc/musl/src/math/atan2.c
+\# system/lib/libc/musl/src/math/__cos.c
+\# system/lib/libc/musl/src/math/__rem_pio2.c
+\# system/lib/libc/musl/src/math/__rem_pio2_large.c
+\# system/lib/libc/musl/src/math/__sin.c
+
+\# These are parts of musl with a SunSoft copyright notice and licence.
+
+Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+
+Developed at SunSoft, a Sun Microsystems, Inc. business.
+Permission to use, copy, modify, and distribute this
+software is freely granted, provided that this notice
+is preserved.
+
+}
\ No newline at end of file