summaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorP. J. McDermott <pjm@nac.net>2013-05-18 12:25:16 (EDT)
committer P. J. McDermott <pjm@nac.net>2013-05-18 12:25:16 (EDT)
commit275c6d69c9e7e3e1d4f7ad18354d2471f16458f1 (patch)
tree4668216ed40bb32c3b3992937439d3ba2b654a15 /config
parentda6571d75ad299cfbe3984930c86cecf3be29401 (diff)
Make gcc and g++ target-specific.
Diffstat (limited to 'config')
-rwxr-xr-xconfig59
1 files changed, 59 insertions, 0 deletions
diff --git a/config b/config
new file mode 100755
index 0000000..a33c2f2
--- /dev/null
+++ b/config
@@ -0,0 +1,59 @@
+#! /bin/sh
+
+set -e
+
+TPL_PKGS='gcc g++'
+
+main()
+{
+ case "${1}" in
+ clean)
+ clean
+ ;;
+ *)
+ if [ -z "${PKG_TARGETS}" ]; then
+ PKG_TARGETS="$(cat targets.in)"
+ fi
+ for arch in ${PKG_TARGETS}; do
+ PKG_TARGET_ARCH="${arch}" configure_build
+ printf '%s\n' "${arch}" >>targets
+ done
+ ;;
+ esac
+}
+
+msg()
+{
+ printf 'gcc-defaults config: '
+ printf "${@}"
+ printf '\n'
+}
+
+configure_build()
+{
+ # Generate a sed script to edit files.
+ _ss=
+ for _name in TARGET_ARCH; do
+ _ss="${_ss}s&@PKG_${_name}@&$(eval echo \$\{PKG_${_name}\})&;"
+ done
+
+ # Write metadata for <pkgbase>-<target> packages.
+ for _pkg in ${TPL_PKGS}; do
+ mkdir -p "${_pkg}-${PKG_TARGET_ARCH}.pkg"
+ sed "${_ss}" "${_pkg}.pkg.in/control" \
+ >"${_pkg}-${PKG_TARGET_ARCH}.pkg/control"
+ cp "${_pkg}.pkg.in/files" "${_pkg}-${PKG_TARGET_ARCH}.pkg/files"
+ msg 'Metadata for package "%s" generated.' \
+ "${_pkg}-${PKG_TARGET_ARCH}"
+ done
+}
+
+clean()
+{
+ # Remove generated metadata for <pkgbase>-<target> packages.
+ for _pkg in ${TPL_PKGS}; do
+ rm -Rf "${_pkg}"-*-*-*.pkg/
+ done
+}
+
+main "${@}"