xref: /freebsd/contrib/libfido2/.actions/build-linux-openssl3-i686-w64-mingw32-gcc (revision 60a517b66a69b8c011b04063ef63a938738719bd)
1*60a517b6SEd Maste#!/bin/sh -eux
2*60a517b6SEd Maste
3*60a517b6SEd Maste# Copyright (c) 2022-2023 Yubico AB. All rights reserved.
4*60a517b6SEd Maste# Use of this source code is governed by a BSD-style
5*60a517b6SEd Maste# license that can be found in the LICENSE file.
6*60a517b6SEd Maste# SPDX-License-Identifier: BSD-2-Clause
7*60a517b6SEd Maste
8*60a517b6SEd Maste# XXX defining CC and cross-compiling confuses OpenSSL's build.
9*60a517b6SEd Masteunset CC
10*60a517b6SEd Maste
11*60a517b6SEd Mastesudo mkdir /fakeroot
12*60a517b6SEd Mastesudo chmod 755 /fakeroot
13*60a517b6SEd Maste
14*60a517b6SEd Mastecat << EOF > /tmp/mingw.cmake
15*60a517b6SEd MasteSET(CMAKE_SYSTEM_NAME Windows)
16*60a517b6SEd MasteSET(CMAKE_C_COMPILER i686-w64-mingw32-gcc)
17*60a517b6SEd MasteSET(CMAKE_CXX_COMPILER i686-w64-mingw32-g++)
18*60a517b6SEd MasteSET(CMAKE_RC_COMPILER i686-w64-mingw32-windres)
19*60a517b6SEd MasteSET(CMAKE_FIND_ROOT_PATH /fakeroot)
20*60a517b6SEd MasteSET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
21*60a517b6SEd MasteSET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
22*60a517b6SEd MasteSET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
23*60a517b6SEd MasteEOF
24*60a517b6SEd Maste
25*60a517b6SEd Maste# Build and install libcbor.
26*60a517b6SEd Mastegit clone --depth=1 https://github.com/pjk/libcbor -b v0.10.1
27*60a517b6SEd Mastecd libcbor
28*60a517b6SEd Mastemkdir build
29*60a517b6SEd Maste(cd build && cmake -DCMAKE_TOOLCHAIN_FILE=/tmp/mingw.cmake \
30*60a517b6SEd Maste	-DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=/fakeroot ..)
31*60a517b6SEd Mastemake -j"$(nproc)" -C build
32*60a517b6SEd Mastesudo make -C build install
33*60a517b6SEd Mastecd ..
34*60a517b6SEd Maste
35*60a517b6SEd Maste# Build and install OpenSSL 3.0.11.
36*60a517b6SEd Mastegit clone --branch openssl-3.0.12 \
37*60a517b6SEd Maste	--depth=1 https://github.com/openssl/openssl
38*60a517b6SEd Mastecd openssl
39*60a517b6SEd Maste./Configure mingw --prefix=/fakeroot --openssldir=/fakeroot/openssl \
40*60a517b6SEd Maste	--cross-compile-prefix=i686-w64-mingw32- --libdir=lib
41*60a517b6SEd Mastemake -j"$(nproc)"
42*60a517b6SEd Mastesudo make install_sw
43*60a517b6SEd Mastecd ..
44*60a517b6SEd Maste
45*60a517b6SEd Maste# Build and install zlib.
46*60a517b6SEd Mastegit clone --depth=1 https://github.com/madler/zlib -b v1.3
47*60a517b6SEd Mastecd zlib
48*60a517b6SEd Mastemake -fwin32/Makefile.gcc PREFIX=i686-w64-mingw32-
49*60a517b6SEd Mastesudo make -fwin32/Makefile.gcc PREFIX=i686-w64-mingw32- DESTDIR=/fakeroot \
50*60a517b6SEd Maste	INCLUDE_PATH=/include LIBRARY_PATH=/lib BINARY_PATH=/bin install
51*60a517b6SEd Mastecd ..
52*60a517b6SEd Maste
53*60a517b6SEd Maste# Build and install libfido2.
54*60a517b6SEd Masteexport PKG_CONFIG_PATH=/fakeroot/lib/pkgconfig
55*60a517b6SEd Mastemkdir build
56*60a517b6SEd Maste(cd build && cmake -DCMAKE_TOOLCHAIN_FILE=/tmp/mingw.cmake \
57*60a517b6SEd Maste	-DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/fakeroot ..)
58*60a517b6SEd Mastemake -C build 2>&1
59*60a517b6SEd Mastesudo make -C build install
60