#!/bin/sh
-#Make busybox links list file
+# Make busybox links list file.
-DF="busybox.def.h"
-MF="busybox.c"
-
-LIST="$(sed -n '/^#define/{s/^#define //p;}' $DF)"
-
-for def in ${LIST}; do
- i=`sed -n 's/^#ifdef \<'$def'\>.*\/\/\(.*$\)/\/\1\//gp' $MF`
- j=`sed -n '/^#ifdef '$def'[ ].*/,/^#endif/{ s/.*\"\(.*\)\".*/\1/gp; }' $MF`
- for k in $j; do
- echo $i$k
- done
-done
+CONFIG_H=${1:-Config.h}
+APPLETS_H=${2:-applets.h}
+gcc -E -DMAKE_LINKS -include $CONFIG_H $APPLETS_H |
+ awk '/^[ \t]*LINK/{
+ match($2,"_BB_DIR[A-Z_]*")
+ dir=substr($2,RSTART+7,RLENGTH-7)
+ gsub("_","/",dir)
+ if(dir=="/ROOT") dir=""
+ file=$3
+ gsub("\"","",file)
+ if (file=="busybox") next
+ print tolower(dir) "/" file
+ }'