#!/bin/bash folders=("engine/src" "lib/raylib/include" "lib/tiny/inc" "lib/luajit/inc") names=("enginend" "raylib" "tiny" "luajit") outdir="include" types=("h" "hpp") mkdir -p "$outdir" create_symlinks() { local src="$1" local outnam="$2" local currout="$outdir/$outnam" mkdir -p "$currout" find "$src" -mindepth 1 -print0 | while IFS= read -r -d '' item; do rl="${item#$src/}" outpath="$currout/$rl" mkdir -p "$(dirname "$outpath")" if [ -f "$item" ]; then nam=$(basename "$item") ftype="${nam##*.}" skip=true for type in "${types[@]}"; do if [ "$ftype" = "$type" ]; then skip=false break fi done if [ "$skip" = false ]; then ln -sf "$(realpath --relative-to="$(dirname "$outpath")" "$item")" "$outpath" fi elif [ -d "$item" ]; then mkdir -p "$outpath" fi done } for i in "${!folders[@]}"; do if [ $i -lt ${#names[@]} ]; then src="${folders[$i]}" outnam="${names[$i]}" if [ -d "$src" ]; then create_symlinks "$src" "$outnam" echo else echo "'$src' not exist" fi fi done