tce-load -wi compiletc autoconf automake libtool-dev gengetopt pkg-config help2man udev-lib-dev bash hidapi-dev json-c13-dev
# autoconf-archive
wget https://github.com/Yubico/libu2f-host/archive/libu2f-host-1.1.10.tar.gz
tar zxf libu2f-host-1.1.10.tar.gz
cd libu2f-host-libu2f-host-1.1.10
./autogen.sh
CC="gcc -flto -fuse-linker-plugin -mtune=generic -Os -pipe" CXX="g++ -flto -fuse-linker-plugin -mtune=generic -Os -pipe -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local -disable-static
find . -name Makefile -type f -exec sed -i 's/-g -O2//g' {} \;
make
mkdir -p /tmp/libu2f-host
sudo make DESTDIR=/tmp/libu2f-host install

# strip binaries
sudo strip /tmp/libu2f-host/usr/local/bin/*
sudo strip /tmp/libu2f-host/usr/local/lib/*

# remove man file
sudo rm -rf /tmp/libu2f-host/usr/local/share/man

# add copyright file
sudo mkdir -p /tmp/libu2f-host/usr/local/share/doc/libu2f-host
sudo cp COPYING* /tmp/libu2f-host/usr/local/share/doc/libu2f-host/

# move -dev files to dedicated dir
mkdir -p /tmp/libu2f-host-dev
cd /tmp/libu2f-host
tar cpf - usr/local/include/u2f-host | ( cd /tmp/libu2f-host-dev && sudo tar xvpf - )
sudo rm -rf usr/local/include
tar cpf - usr/local/lib/libu2f-host.la usr/local/lib/pkgconfig | ( cd /tmp/libu2f-host-dev && sudo tar xvpf - )
sudo rm -rf usr/local/lib/libu2f-host.la usr/local/lib/pkgconfig

# package
tce-load -wi squashfs-tools

cd /tmp
mksquashfs /tmp/libu2f-host /tmp/libu2f-host.tcz
md5sum libu2f-host.tcz > libu2f-host.tcz.md5.txt
cd /tmp/libu2f-host
find -type f -o -type l | sort | sed -e 's#^.##g' > /tmp/libu2f-host.tcz.list

cd /tmp
mksquashfs /tmp/libu2f-host-dev /tmp/libu2f-host-dev.tcz
md5sum libu2f-host-dev.tcz > libu2f-host-dev.tcz.md5.txt
cd /tmp/libu2f-host-dev
find -type f -o -type l | sort | sed -e 's#^.##g' > /tmp/libu2f-host-dev.tcz.list

# create .dep file
cd /tmp
vi libu2f-host.tcz.dep
- - - -
hidapi.tcz
udev-lib.tcz
json-c13.tcz
- - - -

vi libu2f-host-dev.tcz.dep
- - - -
hidapi-dev.tcz
udev-lib-dev.tcz
json-c13-dev.tcz
- - - -

# create .info file
cd /tmp
vi libu2f-host.tcz.info
- - - -
Title:          libu2f-host.tcz
Description:    Universal 2nd Factor (U2F) Host C Library
Version:        1.1.10
Author:         see list of sites below
Original-site:  https://github.com/Yubico/libu2f-host
Copying-policy: The library and command-line tool = LGPLv2+ license.
                Some other files are licensed under the GPLv3+ license.
Size:           48K
Extension_by:   Yoshihiro Sato
Tags:           libu2f
Comments:       C library and command-line tool that implements the host-side of the U2F protocol.
Change-log:     2020/09/18 initial commit
Current:        2020/09/18
- - - -

vi libu2f-host-dev.tcz.info
- - - -
Title:          libu2f-host-dev.tcz
Description:    libu2f-host devs
Version:        1.1.10
Author:         see list of sites below
Original-site:  https://github.com/Yubico/libu2f-host
Copying-policy: The library and command-line tool = LGPLv2+ license.
                Some other files are licensed under the GPLv3+ license.
Size:           4.0K
Extension_by:   Yoshihiro Sato
Tags:           libu2f dev
Comments:       C library and command-line tool that implements the host-side of the U2F protocol.
Change-log:     2020/09/18 initial commit
Current:        2020/09/18
- - - -

# create build-dep file
vi libu2f-host.tcz.build-dep
  (add this file's contents)

# QA
tce-load -wi submitqc

mkdir qc
cd qc
cp /tmp/libu2f-host.tcz* .
submitqc --libs
  (confirm "All extensions passed! Ready for submission." message)

# pack with tar.gz for submission
cd /tmp
tar zcvf /tmp/libu2f-host_11.x_x86_64.tgz libu2f-host.tcz*
tar zcvf /tmp/libu2f-host-dev_11.x_x86_64.tgz libu2f-host-dev.tcz*
