xref: /freebsd/contrib/libfido2/.actions/build-linux-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 1.1.1w.
36*60a517b6SEd Mastegit clone --depth=1 https://github.com/openssl/openssl -b OpenSSL_1_1_1w
37*60a517b6SEd Mastecd openssl
38*60a517b6SEd Maste./Configure mingw --prefix=/fakeroot --openssldir=/fakeroot/openssl \
39*60a517b6SEd Maste	--cross-compile-prefix=i686-w64-mingw32-
40*60a517b6SEd Mastemake -j"$(nproc)"
41*60a517b6SEd Mastesudo make install_sw
42*60a517b6SEd Mastecd ..
43*60a517b6SEd Maste
44*60a517b6SEd Maste# Build and install zlib.
45*60a517b6SEd Mastegit clone --depth=1 https://github.com/madler/zlib -b v1.3
46*60a517b6SEd Mastecd zlib
47*60a517b6SEd Mastemake -fwin32/Makefile.gcc PREFIX=i686-w64-mingw32-
48*60a517b6SEd Mastesudo make -fwin32/Makefile.gcc PREFIX=i686-w64-mingw32- DESTDIR=/fakeroot \
49*60a517b6SEd Maste	INCLUDE_PATH=/include LIBRARY_PATH=/lib BINARY_PATH=/bin install
50*60a517b6SEd Mastecd ..
51*60a517b6SEd Maste
52*60a517b6SEd Maste# Build and install libfido2.
53*60a517b6SEd Masteexport PKG_CONFIG_PATH=/fakeroot/lib/pkgconfig
54*60a517b6SEd Mastemkdir build
55*60a517b6SEd Maste(cd build && cmake -DCMAKE_TOOLCHAIN_FILE=/tmp/mingw.cmake \
56*60a517b6SEd Maste	-DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/fakeroot ..)
57*60a517b6SEd Mastemake -j"$(nproc)" -C build
58*60a517b6SEd Mastesudo make -C build install
59