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

Georgi Chorbadzhiyski gf at unixsol.org
Tue Apr 24 02:20:50 PDT 2012


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

diff --git a/scripts/genconfig.sh b/scripts/genconfig.sh
index 2334d8a..968ce3e 100755
--- a/scripts/genconfig.sh
+++ b/scripts/genconfig.sh
@@ -22,6 +22,42 @@ EOF
   [ $? -eq 0 ] && DEFAULT=y || DEFAULT=n
   rm a.out 2>/dev/null
   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()
diff --git a/scripts/make.sh b/scripts/make.sh
index 52380ec..3e2cedf 100755
--- a/scripts/make.sh
+++ b/scripts/make.sh
@@ -110,7 +110,7 @@ sed -n \
 # 4) Remove toybox itself from the list (as that indicates global symbols).
 # 5) Add "toys/" prefix and ".c" suffix.
 
-TOYFILES=$(cat .config | sed -nre 's/^CONFIG_(.*)=y/\1/;t skip;b;:skip;s/_.*//;p' | sort -u | tr A-Z a-z | grep -v '^toybox$' | sed 's@\(.*\)@toys/\1.c@' )
+TOYFILES=$(cat .config | sed -nre 's/^CONFIG_(.*)=y/\1/;t skip;b;:skip;s/_.*//;p' | sort -u | tr A-Z a-z | grep -vE '^(toybox|linux|android|osx)$' | sed 's@\(.*\)@toys/\1.c@' )
 
 echo "Compile toybox..."
 
-- 
1.7.5.1



More information about the Toybox mailing list