#!/bin/bash

U=$(readlink -n -f ./usr/)

pushd ./leafpad-src/
 export LD=mold
 export CCLD=mold
 export CC="mold -run clang-21"
 export CFLAGS="-fbasic-block-address-map -funique-internal-linkage-names -flto -ffast-math -O3 -fPIE -fomit-frame-pointer -funroll-loops -fforce-addr -falign-functions=4 -msse4a"
 export CXXFLAGS="-fbasic-block-address-map -funique-internal-linkage-names -flto -ffast-math -O3 -fPIE -fomit-frame-pointer -funroll-loops -fforce-addr -falign-functions=4 -msse4a"
 autoconf
 ./configure --prefix=/usr
pushd ./src/
 make
popd
 mv ./src/leafpad $U/bin/
 cp -r ./d/* $U/share/
 make clean
 rm -r -f autom4te.cache
popd
find $U -type d -exec chmod =00755 '{}' \;