randomconfig fixes
[oweals/busybox.git] / applets / busybox.mkll
index fa1bff209b11c9a27adb494fca3937c5d0e9569b..68dbf216262a6cd6a6f64d24a4cbe1c94b62108b 100755 (executable)
@@ -1,19 +1,24 @@
 #!/bin/sh
 # Make busybox links list file.
 
-DF="busybox.def.h"
-MF="busybox.c"
+# input $1: full path to Config.h
+# input $2: full path to applets.h
+# output (stdout): list of pathnames that should be linked to busybox
 
-LIST="$(sed -n '/^#define/{s/^#define BB_FEATURE_.*//g;s/^#define //p;}' $DF)"
+# Maintainer: Larry Doolittle <ldoolitt@recycle.lbl.gov>
 
-for def in ${LIST}; do
-       i=`sed -n '/^#ifdef \<'$def'\>.*/,/^#endif/{ s/.*\"\(.*\)\".*\(_BB_DIR_[A-Z_]*\).*$/\2\/\1/gp; }' $MF`
-       for j in $i; do 
-               if [ -z $j ] ; then 
-                       continue;
-               fi;
-               echo $j | sed -e 's/_BB_DIR_ROOT//g;s/_BB_DIR_BIN/\/bin/g;' \
-                   -e 's/_BB_DIR_SBIN/\/sbin/g;s/_BB_DIR_USR_BIN/\/usr\/bin/g;' \
-                   -e 's/_BB_DIR_USR_SBIN/\/usr\/sbin/g;'
-       done;
-done
+export LC_ALL=POSIX
+export LC_CTYPE=POSIX
+
+CONFIG_H=${1:-include/autoconf.h}
+APPLETS_H=${2:-include/applets.h}
+$HOSTCC -E -DMAKE_LINKS -include $CONFIG_H $APPLETS_H |
+  awk '/^[ \t]*LINK/{
+       dir=substr($2,7)
+       gsub("_","/",dir)
+       if(dir=="/ROOT") dir=""
+       file=$3
+       gsub("\"","",file)
+       if (file=="busybox") next
+       print tolower(dir) "/" file
+  }'