[Toybox] [PATCH] scripts/genconfig: Define LINUX, ANDROID and OSX symbols in Config.probed

Georgi Chorbadzhiyski gf at unixsol.org
Thu Mar 15 02:57:13 PDT 2012


This would allow disabling of toys using kconfig dependancies.
---
 scripts/genconfig.sh |   37 +++++++++++++++++++++++++++++++++++++
 1 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/scripts/genconfig.sh b/scripts/genconfig.sh
index f677954..0761c26 100755
--- a/scripts/genconfig.sh
+++ b/scripts/genconfig.sh
@@ -19,7 +19,44 @@ probeconfig()
 EOF
   [ $? -eq 0 ] && DEFAULT=y || DEFAULT=n
   echo -e "\tdefault $DEFAULT\n" || return 1
+
+  # Probe if we are building for Linux
+
+  echo -e "config LINUX\n\tbool" || return 1
+  ${CROSS_COMPILE}${CC} -c -xc -o /dev/null - 2>/dev/null << EOF
+#if defined(__linux__)
+#error YES
+#endif
+int main(void) { return 0; }
+EOF
+  [ $? -eq 0 ] && DEFAULT=n || DEFAULT=y
+  echo -e "\tdefault $DEFAULT\n" || return 1
+
+  # Probe if we are building for Android
+
+  echo -e "config ANDROID\n\tbool" || return 1
+  ${CROSS_COMPILE}${CC} -c -xc -o /dev/null - 2>/dev/null << EOF
+#if defined(__ANDROID__)
+#error YES
+#endif
+int main(void) { return 0; }
+EOF
+  [ $? -eq 0 ] && DEFAULT=n || DEFAULT=y
+  echo -e "\tdefault $DEFAULT\n" || return 1
+
+  # Probe if we are building for OS X
+
+  echo -e "config OSX\n\tbool" || return 1
+  ${CROSS_COMPILE}${CC} -c -xc -o /dev/null - 2>/dev/null << EOF
+#if defined(__APPLE__)
+#error YES
+#endif
+int main(void) { return 0; }
+EOF
+  [ $? -eq 0 ] && DEFAULT=n || DEFAULT=y
+  echo -e "\tdefault $DEFAULT\n" || return 1
 }
+
 genconfig()
 {
   # extract config stanzas from each command source file, in alphabetical order
-- 
1.7.5.1


 1331805433.0


More information about the Toybox mailing list