[build] Add a Plan 9 port.

* mkfile: Build instructions.
* build/plan9/p9lib.h: Standard lib replacement.
* build/plan9/README: Docs.
This commit is contained in:
Yaroslav Kolomiiets 2026-04-22 13:01:21 +00:00 committed by Alexei Podtelezhnikov
parent ce4105f913
commit f2b3f96901
3 changed files with 188 additions and 0 deletions

34
builds/plan9/README Normal file
View file

@ -0,0 +1,34 @@
README for the builds/plan9 subdirectory.
Copyright (C) 2026 by Yaroslav Kolomiiets.
The mkfile is provided for Plan 9 from Bell Labs. To build, run:
cd ../.. # to the top FreeType directory
mk
It produces a library to link against as ../../libfreetype.a𝑂 archive.
To integrate with your code, add to your mkfile:
FTDIR=/your/path/to/freetype
LIB=$LIBDIR/libfreetype.a$O
LIBHFILES=$LIBDIR/builds/plan9/p9ftopt.h
HFILES=$HFILES $LIBHFILES
CFLAGS=$CFLAGS -p -I$LIBDIR/builds/plan9 -I$LIBDIR/include \
-D'FT_CONFIG_OPTIONS_H=<p9ftopt.h>' \
-D'FT_CONFIG_STANDARD_LIBRARY_H=<p9lib.h>' \
$LIB $LIBHFILES:
cd $FTDIR; mk install
This file is part of the FreeType project, and may only be used,
modified, and distributed under the terms of the FreeType project
license, LICENSE.TXT. By continuing to use, modify, or distribute
this file you indicate that you have read the license and understand
and accept it fully.

79
builds/plan9/p9lib.h Normal file
View file

@ -0,0 +1,79 @@
/****************************************************************************
*
* ftstdlib.h
*
* Plan 9-specific library and header configuration file
*
* Copyright (C) 2002-2026 by
* David Turner, Robert Wilhelm, Werner Lemberg and Yaroslav Kolomiiets.
*
* This file is part of the FreeType project, and may only be used,
* modified, and distributed under the terms of the FreeType project
* license, LICENSE.TXT. By continuing to use, modify, or distribute
* this file you indicate that you have read the license and
* understand and accept it fully.
*
*/
#ifndef FTSTDLIB_H_
#define FTSTDLIB_H_
#include <u.h>
#include <libc.h>
#include <ape/limits.h>
#include <stdio.h>
#define size_t ulong
#define ptrdiff_t int
#define ft_ptrdiff_t ptrdiff_t
#define FT_CHAR_BIT CHAR_BIT
#define FT_USHORT_MAX USHRT_MAX
#define FT_INT_MAX INT_MAX
#define FT_INT_MIN INT_MIN
#define FT_UINT_MAX UINT_MAX
#define FT_LONG_MIN LONG_MIN
#define FT_LONG_MAX LONG_MAX
#define FT_ULONG_MAX ULONG_MAX
#define FT_LLONG_MAX LLONG_MAX
#define FT_LLONG_MIN LLONG_MIN
#define FT_ULLONG_MAX ULLONG_MAX
#define ft_memchr memchr
#define ft_memcmp memcmp
#define ft_memcpy memcpy
#define ft_memmove memmove
#define ft_memset memset
#define ft_strcat strcat
#define ft_strcmp strcmp
#define ft_strcpy strcpy
#define ft_strlen strlen
#define ft_strncmp strncmp
#define ft_strncpy strncpy
#define ft_strrchr strrchr
#define ft_strstr strstr
#define FT_FILE FILE
#define ft_fclose fclose
#define ft_fopen fopen
#define ft_fread fread
#define ft_fseek fseek
#define ft_ftell ftell
#define ft_snprintf snprintf
#define ft_qsort qsort
#define ft_scalloc calloc
#define ft_sfree free
#define ft_smalloc malloc
#define ft_srealloc realloc
#define ft_strtol strtol
#define ft_getenv getenv
#define ft_jmp_buf jmp_buf
#define ft_longjmp longjmp
#define ft_setjmp( b ) setjmp( *(ft_jmp_buf*) &(b) )
#endif /* FTSTDLIB_H_ */

75
mkfile Normal file
View file

@ -0,0 +1,75 @@
# mkfile for Plan 9 from Bell Labs
#
# See builds/plan9/README for usage.
#
# Copyright (C) 2026 by Yaroslav Kolomiiets.
#
# This file is part of the FreeType project, and may only be used,
# modified, and distributed under the terms of the FreeType project
# license, LICENSE.TXT. By continuing to use, modify, or distribute
# this file you indicate that you have read the license and understand
# and accept it fully.
#
</$objtype/mkfile
LIB=libfreetype.a$O
OFILES=\
src/base/ftbase.$O \
ftsystem.$O \
ftinit.$O \
ftdebug.$O \
ftbitmap.$O \
ftglyph.$O \
ftmm.$O \
src/autofit/autofit.$O \
src/bdf/bdf.$O \
src/cache/ftcache.$O \
src/cff/cff.$O \
src/cid/type1cid.$O \
src/gzip/ftgzip.$O \
src/hvf/hvf.$O \
src/lzw/ftlzw.$O \
src/pcf/pcf.$O \
src/pfr/pfr.$O \
src/psaux/psaux.$O \
src/pshinter/pshinter.$O \
src/psnames/psnames.$O \
src/raster/raster.$O \
src/sdf/sdf.$O \
src/sfnt/sfnt.$O \
src/smooth/smooth.$O \
src/svg/svg.$O \
src/truetype/truetype.$O \
src/type1/type1.$O \
src/type42/type42.$O \
src/winfonts/winfnt.$O \
HFILES=\
builds/plan9/p9ftopt.h \
builds/plan9/p9lib.h \
CFLAGS=-p -Ibuilds/plan9 -Iinclude \
-D'FT_CONFIG_OPTIONS_H=<p9ftopt.h>' \
-D'FT_CONFIG_STANDARD_LIBRARY_H=<p9lib.h>' \
-DFT2_BUILD_LIBRARY \
</sys/src/cmd/mklib
%.$O: %.c
$CC $CFLAGS -o $stem.$O $stem.c
%.$O: src/base/%.c
$CC $CFLAGS src/base/$stem.c
builds/plan9/p9ftopt.h:D: include/freetype/config/ftoption.h
sed '
/#define FT_CONFIG_OPTION_USE_LZW/ s!^!// !
/#define FT_CONFIG_OPTION_USE_ZLIB/ s!^!// !
' $prereq > $target
clean:V:
rm -f *.[$OS] src/*/*.[$OS] $CLEANFILES
nuke:V:
rm -f *.[$OS] src/*/*.[$OS] $CLEANFILES
rm -f libfreetype.a[$OS] builds/plan9/p9ftopt.h