summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md32
-rwxr-xr-xios/cmake-ios-lagrange.sh13
-rwxr-xr-xios/cmake-ios-tf.sh11
-rw-r--r--ios/cross-mac-arm64-ios-arm64.ini27
-rwxr-xr-xios/deps.sh81
-rw-r--r--ios/iconfigure-osminver.patch18
6 files changed, 174 insertions, 8 deletions
diff --git a/README.md b/README.md
index a70d27bf..82ac77d8 100644
--- a/README.md
+++ b/README.md
@@ -41,7 +41,7 @@ The required tools are a C11 compiler (e.g., Clang or GCC), CMake and `pkg-confi
414. Create a build directory. 414. Create a build directory.
425. In your empty build directory, run CMake: ```cmake {path_of_lagrange_sources} -DCMAKE_BUILD_TYPE=Release``` 425. In your empty build directory, run CMake: ```cmake {path_of_lagrange_sources} -DCMAKE_BUILD_TYPE=Release```
436. Build it: ```cmake --build .``` 436. Build it: ```cmake --build .```
447. Now you can run `lagrange`, `lagrange.exe`, or `Lagrange.app`. 447. Now you can run *lagrange*, *lagrange.exe*, or *Lagrange.app*.
45 45
46### Unicode text rendering 46### Unicode text rendering
47 47
@@ -113,18 +113,17 @@ You should use a version of the SDL 2 library that is compiled for native Window
113 Libs: ${libdir}/SDL2.dll -mwindows 113 Libs: ${libdir}/SDL2.dll -mwindows
114 Cflags: -I${incdir} 114 Cflags: -I${incdir}
115 115
116The *-mwindows* option is particularly important as that specifies the target is a GUI application. Also note that you are linking directly against the Windows DLL — do not use any prebuilt .lib files if available, as those as specific to MSVC. 116The `-mwindows` option is particularly important as that specifies the target is a GUI application. Also note that you are linking directly against the Windows DLL — do not use any prebuilt .lib files if available, as those as specific to MSVC.
117 117
118`pkg-config` will find your .pc file if it is on `PKG_CONFIG_PATH` or you place it in a system-wide pkgconfig directory. 118`pkg-config` will find your .pc file if it is on `PKG_CONFIG_PATH` or you place it in a system-wide pkgconfig directory.
119 119
120Once you have compiled a working binary under MSYS2, there is still an additional step required to allow running it directly from the Windows shell: the shared libraries from MSYS2 must be found either via `PATH` or by copying them to the same directory where `lagrange.exe` is located. 120Once you have compiled a working binary under MSYS2, there is still an additional step required to allow running it directly from the Windows shell: the shared libraries from MSYS2 must be found either via `PATH` or by copying them to the same directory where _lagrange.exe_ is located.
121 121
122### Compiling on Raspberry Pi 122### Compiling on Raspberry Pi
123 123
124On Raspberry Pi 4/400, you can compile and run Lagrange just like on a regular desktop PC. Accelerated OpenGL graphics should work fine under X11. 124On Raspberry Pi 4/400, you can compile and run Lagrange just like on a regular desktop PC. Accelerated OpenGL graphics should work fine under X11.
125 125
126On Raspberry Pi 3 or earlier, you should use a version of SDL that is compiled to take advantage of the Broadcom VideoCore OpenGL ES hardware. This provides the best performance when running Lagrange in a console. OpenGL under X11 on Raspberry Pi 2/3 is quite 126On Raspberry Pi 3 or earlier, you should use a version of SDL that is compiled to take advantage of the Broadcom VideoCore OpenGL ES hardware. This provides the best performance when running Lagrange in a console. OpenGL under X11 on Raspberry Pi 2/3 is quite slow/experimental. When running under X11, software rendering is the best choice and the SDL from Raspbian etc. is sufficient.
127slow/experimental. When running under X11, software rendering is the best choice and the SDL from Raspbian etc. is sufficient.
128 127
129The following build options are recommended on Raspberry Pi 2/3: 128The following build options are recommended on Raspberry Pi 2/3:
130 129
@@ -135,13 +134,30 @@ The following build options are recommended on Raspberry Pi 2/3:
135[rel]: https://git.skyjake.fi/gemini/lagrange/releases 134[rel]: https://git.skyjake.fi/gemini/lagrange/releases
136[tf]: https://git.skyjake.fi/skyjake/the_Foundation 135[tf]: https://git.skyjake.fi/skyjake/the_Foundation
137 136
137### Compiling on iOS
138
139Compiling Lagrange on iOS is moderately difficult.
140
141As a prerequisite, you will need to have an [iOS toolchain configuration for CMake](https://github.com/leetal/ios-cmake). CMake is required for Lagrange itself and for the\_Foundation. You will also need [Autotools helpers for iOS](https://github.com/szanni/ios-autotools.git) because HarfBuzz, libiconv, libunistring, and libpcre use Automake. Meson and Ninja are used for GNU FriBidi. The _iconfigure_ script in the Autotools helpers needs to be [patched](ios/iconfigure-osminver.patch).
142
143After these utilities are available, the scripts in _ios/_ can be used as a basis for the build. Unfortunately there is no ready-made high-level script for performing all these steps, so you'll need to adapt them individually to your needs.
144
1451. Meson cross-compilation is controlled with _ios/cross-mac-arm64-ios-arm64.ini_. Modify it to be compatible with your build system and target device.
1462. _ios/deps.sh_ compiles most of the dependencies using Meson, Ninja, and _iconfigure_. Note that the simulator build has not been set up in these scripts, only the `os` build.
1473. Clone [OpenSSL for iPhone](https://github.com/x2on/OpenSSL-for-iPhone.git) and build it with iOS 9.0 as the minimum version. Deploy the static libraries in *$HOME/SDK/ios/$arch/*, or wherever you've set `IOS_DIR` to be.
1484. Create an empty build directory for the\_Foundation and run _ios/cmake-ios-tf.sh_ from there. You may need to adjust the source directory path in the script depending on where you place your build directory.
1495. Now you can `make install` to build and deploy the_Foundation to `IOS_DIR`.
1506. Finally, you can run CMake like in _ios/cmake-ios-lagrange.sh_ to generate an Xcode project that builds the app.
151
152If FriBidi and HarfBuzz are not used (disabling RTL and complex text rendering), the first step can be skipped and the corresponding build steps in _ios/deps.sh_ can be removed. In this case, Meson and Ninja are not needed at all.
153
138## User files 154## User files
139 155
140On Windows, user files are stored in `%HOMEPATH%/AppData/Roaming/fi.skyjake.Lagrange/`, unless one is using the portable distribution and there is a `userdata` subdirectory present in the executable directory. 156On Windows, user files are stored in *%HOMEPATH%/AppData/Roaming/fi.skyjake.Lagrange/*, unless one is using the portable distribution and there is a *userdata/* subdirectory present in the executable directory.
141 157
142On macOS, user files are stored in `~/Library/Application Support/fi.skyjake.Lagrange/`. 158On macOS, user files are stored in *~/Library/Application Support/fi.skyjake.Lagrange/*.
143 159
144On Linux/*BSD/other operating systems, user files stored in `~/.config/lagrange` unless you have customized the XDG directories, in which case the `XDG_CONFIG_HOME` environment variable is used to determine where user files saved. 160On Linux/*BSD/other operating systems, user files stored in _~/.config/lagrange/_ unless you have customized the XDG directories, in which case the `XDG_CONFIG_HOME` environment variable is used to determine where user files saved.
145 161
146The usage and contents of the user files are described in the Help document. You can delete one or more of the files while Lagrange is not running to reset the corresponding data to the default/empty state. 162The usage and contents of the user files are described in the Help document. You can delete one or more of the files while Lagrange is not running to reset the corresponding data to the default/empty state.
147 163
diff --git a/ios/cmake-ios-lagrange.sh b/ios/cmake-ios-lagrange.sh
new file mode 100755
index 00000000..598d89a5
--- /dev/null
+++ b/ios/cmake-ios-lagrange.sh
@@ -0,0 +1,13 @@
1#!/bin/sh
2IOS_DIR="$HOME/SDK/ios/arm64"
3cmake ../lagrange \
4 -G Xcode \
5 -DCMAKE_TOOLCHAIN_FILE=$HOME/src/libs/ios-cmake/ios.toolchain.cmake \
6 -DPLATFORM=OS64 \
7 -DENABLE_BITCODE=0 \
8 -DDEPLOYMENT_TARGET=9.0 \
9 -DIOS_DIR=$IOS_DIR \
10 -Dthe_Foundation_DIR=$IOS_DIR/lib/cmake/the_Foundation \
11 -DXCODE_DEVELOPMENT_TEAM=XXXXXXXXXX \
12 -DENABLE_BINCAT_SH=YES \
13 -DENABLE_DOWNLOAD_EDIT=NO
diff --git a/ios/cmake-ios-tf.sh b/ios/cmake-ios-tf.sh
new file mode 100755
index 00000000..89d3bd14
--- /dev/null
+++ b/ios/cmake-ios-tf.sh
@@ -0,0 +1,11 @@
1#!/bin/sh
2cmake ../the_Foundation \
3 -DCMAKE_TOOLCHAIN_FILE=$HOME/src/libs/ios-cmake/ios.toolchain.cmake \
4 -DCMAKE_BUILD_TYPE=RelWithDebInfo \
5 -DPLATFORM=OS64 \
6 -DENABLE_BITCODE=0 \
7 -DTFDN_STATIC_LIBRARY=YES \
8 -DTFDN_ENABLE_TESTS=NO \
9 -DTFDN_ENABLE_WEBREQUEST=NO \
10 -DIOS_DIR=$HOME/SDK/ios/arm64 \
11 -DCMAKE_INSTALL_PREFIX=$HOME/SDK/ios/arm64
diff --git a/ios/cross-mac-arm64-ios-arm64.ini b/ios/cross-mac-arm64-ios-arm64.ini
new file mode 100644
index 00000000..aa759cf2
--- /dev/null
+++ b/ios/cross-mac-arm64-ios-arm64.ini
@@ -0,0 +1,27 @@
1[constants]
2xcode = '/Applications/Xcode.app/Contents/Developer'
3platform = xcode + '/Platforms/iPhoneOS.platform'
4sdk = platform + '/Developer/SDKs/iPhoneOS.sdk'
5osminver = '9.0'
6
7common_flags = ['-arch', 'arm64', '-isysroot', sdk, '-miphoneos-version-min=' + osminver]
8
9[properties]
10sizeof_int = 4
11sizeof_wchar_t = 4
12sizeof_void* = 8
13c_args = common_flags + ['-fobjc-abi-version=2', '-ffast-math']
14cpp_args = common_flags + ['-fobjc-abi-version=2', '-ffast-math', '-fvisibility-inlines-hidden']
15c_link_args = common_flags
16
17[binaries]
18c = xcode + '/usr/bin/gcc'
19cpp = xcode + '/usr/bin/g++'
20c_ld = xcode + '/usr/bin/ld'
21strip = xcode + '/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip'
22
23[host_machine]
24system = 'darwin'
25cpu_family = 'aarc64'
26cpu = 'arm64'
27endian = 'little'
diff --git a/ios/deps.sh b/ios/deps.sh
new file mode 100755
index 00000000..9970087d
--- /dev/null
+++ b/ios/deps.sh
@@ -0,0 +1,81 @@
1#!/bin/sh
2KIND=iphone$1
3if [ -z "$1" ]; then
4 echo "Usage: ios-deps.sh os|simulator"
5 exit 0
6fi
7if [ "$KIND" = "iphoneos" ]; then
8 PREFIX=$HOME/SDK/ios
9else
10 PREFIX=$HOME/SDK/ios-sim
11fi
12DIR_FRIBIDI=$HOME/src/libs/fribidi
13DIR_HARFBUZZ=$HOME/src/libs/harfbuzz
14DIR_ICONV=$HOME/src/libs/libiconv-1.16
15DIR_UNISTRING=$HOME/src/libs/libunistring-0.9.10
16DIR_PCRE=$HOME/src/libs/pcre-8.44
17
18echo "Prefix: ${PREFIX}"
19read -p "--- Press Enter to begin ---"
20
21ICONF=$HOME/src/libs/ios-autotools/iconfigure
22# Note: There's a small modification to the `iconfigure` script.
23export OSMINVER=9.0
24export SDK=$KIND
25
26function build_arch() {
27 arch=$1
28
29 cd $DIR_FRIBIDI
30 rm -rf ios-build
31 mkdir ios-build
32 cd ios-build
33 meson .. \
34 --cross-file $HOME/cross-mac-arm64-ios-arm64.ini \
35 -Dbuildtype=release \
36 -Ddefault_library=static \
37 -Dtests=false \
38 -Ddocs=false \
39 -Dbin=false \
40 -Ddocs=false \
41 --prefix ${PREFIX}/arm64
42 ninja install
43
44 cd $DIR_HARFBUZZ
45 make clean
46 PREFIX=$PREFIX/$arch $ICONF $arch --with-cairo=no --with-glib=no --with-freetype=no --with-gobject=no --with-chafa=no --with-graphite2=no --with-coretext=no
47 make install
48
49 cd $DIR_ICONV
50 make clean
51 PREFIX=$PREFIX/$arch $ICONF $arch
52 make install
53
54 cd $DIR_UNISTRING
55 make clean
56 PREFIX=$PREFIX/$arch $ICONF $arch --disable-namespacing --with-libiconv-prefix=$PREFIX/$arch
57 make install
58
59 cd $DIR_PCRE
60 make clean
61 PREFIX=$PREFIX/$arch $ICONF $arch --enable-unicode-properties
62 make install
63}
64
65function fat_archive() {
66 lipo \
67 -arch x86_64 $PREFIX/x86_64/lib/$1 \
68 -arch arm64 $PREFIX/arm64/lib/$1 \
69 -output $PREFIX/fat/lib/$1 -create
70}
71
72#build_arch x86_64
73build_arch arm64
74
75#fat_archive libiconv.a
76#fat_archive libunistring.a
77#fat_archive libpcre.a
78
79#mkdir -p $PREFIX/fat/include
80#cp -r $PREFIX/arm64/include/* $PREFIX/fat/include
81
diff --git a/ios/iconfigure-osminver.patch b/ios/iconfigure-osminver.patch
new file mode 100644
index 00000000..2ef0076d
--- /dev/null
+++ b/ios/iconfigure-osminver.patch
@@ -0,0 +1,18 @@
1diff --git a/iconfigure b/iconfigure
2index 734bb47..e31c6cf 100755
3--- a/iconfigure
4+++ b/iconfigure
5@@ -93,10 +93,10 @@ export CXX=$(xcrun --sdk $SDK --find g++)
6 export LD=$(xcrun --sdk $SDK --find ld)
7
8 # Flags
9-export CFLAGS="$CFLAGS -arch $ARCH -isysroot $SDKROOT -I$PREFIX/include -miphoneos-version-min=$SDKVERSION"
10-export CPPFLAGS="$CPPFLAGS -arch $ARCH -isysroot $SDKROOT -I$PREFIX/include -miphoneos-version-min=$SDKVERSION"
11+export CFLAGS="$CFLAGS -arch $ARCH -isysroot $SDKROOT -I$PREFIX/include -miphoneos-version-min=$OSMINVER"
12+export CPPFLAGS="$CPPFLAGS -arch $ARCH -isysroot $SDKROOT -I$PREFIX/include -miphoneos-version-min=$OSMINVER"
13 export CXXFLAGS="$CXXFLAGS -arch $ARCH -isysroot $SDKROOT -I$PREFIX/include"
14-export LDFLAGS="$LDFLAGS -arch $ARCH -isysroot $SDKROOT -L$PREFIX/lib"
15+export LDFLAGS="$LDFLAGS -arch $ARCH -isysroot $SDKROOT -L$PREFIX/lib -miphoneos-version-min=$OSMINVER"
16 export PKG_CONFIG_PATH="$PKG_CONFIG_PATH":"$SDKROOT/usr/lib/pkgconfig":"$PREFIX/lib/pkgconfig"
17
18 # Remove script parameters