1#! /bin/bash -ex
2
3CORE_CONFIG="$1"
4TARGET_DIR=$(dirname "$0")/include
5rm -rf "$TARGET_DIR"/arch
6mkdir -p "$TARGET_DIR/arch"
7
8if [ -d "$CORE_CONFIG" ] ; then
9  cp -a "$CORE_CONFIG/xtensa-elf/arch/include" "$TARGET_DIR/arch"
10else
11  CORE_DIR=$(tar -tf "$CORE_CONFIG" | head -n1 | cut -d '/' -f1-2)
12  tar -xf "$CORE_CONFIG" --strip-components=3 -C "$TARGET_DIR" "$CORE_DIR/xtensa-elf/arch/include"
13fi
14