diff options
| author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-10-07 17:06:26 +0000 |
|---|---|---|
| committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-10-07 17:06:26 +0000 |
| commit | f545be083d3e9758b70edf16aa532528cd7ce108 (patch) | |
| tree | 136f8792a5217e6558a29aee33eef199e338f652 /scripts/trylink | |
| parent | def88985966a9351911844d42e06b735977bcb72 (diff) | |
| download | busybox-w32-f545be083d3e9758b70edf16aa532528cd7ce108.tar.gz busybox-w32-f545be083d3e9758b70edf16aa532528cd7ce108.tar.bz2 busybox-w32-f545be083d3e9758b70edf16aa532528cd7ce108.zip | |
reviving libbusybox, adding CONFIG_INDIVIDUAL part 4
Diffstat (limited to 'scripts/trylink')
| -rwxr-xr-x | scripts/trylink | 69 |
1 files changed, 68 insertions, 1 deletions
diff --git a/scripts/trylink b/scripts/trylink index de60a2cf7..a87d67225 100755 --- a/scripts/trylink +++ b/scripts/trylink | |||
| @@ -137,7 +137,7 @@ if test "$CONFIG_FEATURE_SHARED_BUSYBOX" = y; then | |||
| 137 | -o $EXE -Wl,-Map -Wl,$EXE.map \ | 137 | -o $EXE -Wl,-Map -Wl,$EXE.map \ |
| 138 | -Wl,--warn-common -Wl,--sort-common -Wl,--gc-sections \ | 138 | -Wl,--warn-common -Wl,--sort-common -Wl,--gc-sections \ |
| 139 | -Wl,--start-group $O_FILES -Wl,--end-group \ | 139 | -Wl,--start-group $O_FILES -Wl,--end-group \ |
| 140 | $l_list -Wl,--verbose \ | 140 | -Wl,--verbose \ |
| 141 | -L"$sharedlib_dir" -lbusybox \ | 141 | -L"$sharedlib_dir" -lbusybox \ |
| 142 | >/dev/null \ | 142 | >/dev/null \ |
| 143 | || { | 143 | || { |
| @@ -148,3 +148,70 @@ if test "$CONFIG_FEATURE_SHARED_BUSYBOX" = y; then | |||
| 148 | strip -s --remove-section=.note --remove-section=.comment $EXE -o "$sharedlib_dir/busybox" | 148 | strip -s --remove-section=.note --remove-section=.comment $EXE -o "$sharedlib_dir/busybox" |
| 149 | echo "busybox linked against libbusybox: $sharedlib_dir/busybox" | 149 | echo "busybox linked against libbusybox: $sharedlib_dir/busybox" |
| 150 | fi | 150 | fi |
| 151 | |||
| 152 | if test "$CONFIG_FEATURE_INDIVIDUAL" = y; then | ||
| 153 | gcc -DNAME_MAIN_CNAME -E -include include/autoconf.h include/applets.h \ | ||
| 154 | | grep -v "^#" \ | ||
| 155 | | grep -v "^$" \ | ||
| 156 | > applet.lst | ||
| 157 | while read name main cname; do | ||
| 158 | |||
| 159 | test x"$cname" = "x[" && cname=test | ||
| 160 | test x"$cname" = "x[[" && cname=test | ||
| 161 | |||
| 162 | echo "\ | ||
| 163 | #include <errno.h> | ||
| 164 | #include <unistd.h> | ||
| 165 | #include <stdlib.h> | ||
| 166 | #include <stdio.h> | ||
| 167 | #include \"../include/autoconf.h\" | ||
| 168 | #include \"../include/usage.h\" | ||
| 169 | |||
| 170 | #ifdef __GLIBC__ | ||
| 171 | /* Make it reside in R/W memory: */ | ||
| 172 | int *const bb_errno __attribute__ ((section (\".data\"))); | ||
| 173 | #endif | ||
| 174 | |||
| 175 | const char *applet_name = \"$name\"; | ||
| 176 | |||
| 177 | void bb_show_usage(void) | ||
| 178 | { | ||
| 179 | fprintf(stderr, \"Usage: $name \" | ||
| 180 | #ifdef ${cname}_trivial_usage | ||
| 181 | ${cname}_trivial_usage | ||
| 182 | #endif | ||
| 183 | #ifdef ${cname}_full_usage | ||
| 184 | \"\\n\\n\" ${cname}_full_usage | ||
| 185 | #endif | ||
| 186 | \"\\n\\n\"); | ||
| 187 | exit(1); | ||
| 188 | } | ||
| 189 | |||
| 190 | int $main(int argc, char **argv); | ||
| 191 | |||
| 192 | int main(int argc, char **argv) | ||
| 193 | { | ||
| 194 | #ifdef __GLIBC__ | ||
| 195 | (*(int **)&bb_errno) = __errno_location(); | ||
| 196 | #endif | ||
| 197 | return $main(argc, argv); | ||
| 198 | } | ||
| 199 | " >"$sharedlib_dir/applet.c" | ||
| 200 | |||
| 201 | EXE="$sharedlib_dir/$name" | ||
| 202 | try $CC $LDFLAGS "$sharedlib_dir/applet.c" \ | ||
| 203 | -o $EXE \ | ||
| 204 | -Wl,--warn-common -Wl,--sort-common -Wl,--gc-sections \ | ||
| 205 | -L"$sharedlib_dir" -lbusybox \ | ||
| 206 | >/dev/null \ | ||
| 207 | || { | ||
| 208 | echo "Linking $EXE failed" | ||
| 209 | cat -- $EXE.out | ||
| 210 | exit 1 | ||
| 211 | } | ||
| 212 | rm -- "$sharedlib_dir/applet.c" $EXE.out | ||
| 213 | strip -s --remove-section=.note --remove-section=.comment $EXE | ||
| 214 | echo "applet linked against libbusybox: $EXE" | ||
| 215 | |||
| 216 | done <applet.lst | ||
| 217 | fi | ||
