Skip to content

Instantly share code, notes, and snippets.

@kjmkznr
Created May 14, 2016 08:55
Show Gist options
  • Select an option

  • Save kjmkznr/a22c20394bfa623e4ee482435f05f548 to your computer and use it in GitHub Desktop.

Select an option

Save kjmkznr/a22c20394bfa623e4ee482435f05f548 to your computer and use it in GitHub Desktop.
#!/bin/sh
CC="gcc"
OPT="-march=native"
NATIVE=$(echo | ${CC} -E -v ${OPT} - 2>&1 | grep cc1)
NOARCH=$(echo | ${CC} -E -v - 2>&1 | grep cc1)
for native in ${NATIVE} ; do
FOUND=0
for noarch in ${NOARCH} ; do
if [ "${native}" = "${noarch}" -a "${native}" != "${OPT}" ] ; then
FOUND=1
break
fi
done
if [ ${FOUND} -eq 0 ] ; then
echo -n "${native} "
fi
done
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment