annotate sources/sections/ccwrap.sh @ 1085:2e03f846b21e

Build ccwrap static unless BUILD_STATIC=none or we're doing the simple cross compiler.
author Rob Landley <rob@landley.net>
date Sun, 16 May 2010 18:36:07 -0500
parents c6b3d648ead6
children affef1edbdba
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
905
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
1 # build and install gcc wrapper script.
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
2
1085
2e03f846b21e Build ccwrap static unless BUILD_STATIC=none or we're doing the simple cross compiler.
Rob Landley <rob@landley.net>
parents: 981
diff changeset
3 # Which compiler do we build the wrapper with, and should it be static?
905
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
4
1085
2e03f846b21e Build ccwrap static unless BUILD_STATIC=none or we're doing the simple cross compiler.
Rob Landley <rob@landley.net>
parents: 981
diff changeset
5 if [ -z "$FROM_ARCH" ] || [ "$BUILD_STATIC" == none ]
2e03f846b21e Build ccwrap static unless BUILD_STATIC=none or we're doing the simple cross compiler.
Rob Landley <rob@landley.net>
parents: 981
diff changeset
6 then
2e03f846b21e Build ccwrap static unless BUILD_STATIC=none or we're doing the simple cross compiler.
Rob Landley <rob@landley.net>
parents: 981
diff changeset
7 TEMP="$CC"
2e03f846b21e Build ccwrap static unless BUILD_STATIC=none or we're doing the simple cross compiler.
Rob Landley <rob@landley.net>
parents: 981
diff changeset
8 STATIC_FLAGS=
2e03f846b21e Build ccwrap static unless BUILD_STATIC=none or we're doing the simple cross compiler.
Rob Landley <rob@landley.net>
parents: 981
diff changeset
9 else
2e03f846b21e Build ccwrap static unless BUILD_STATIC=none or we're doing the simple cross compiler.
Rob Landley <rob@landley.net>
parents: 981
diff changeset
10 TEMP="${FROM_ARCH}-cc"
2e03f846b21e Build ccwrap static unless BUILD_STATIC=none or we're doing the simple cross compiler.
Rob Landley <rob@landley.net>
parents: 981
diff changeset
11 STATIC_FLAGS=--static
2e03f846b21e Build ccwrap static unless BUILD_STATIC=none or we're doing the simple cross compiler.
Rob Landley <rob@landley.net>
parents: 981
diff changeset
12 fi
905
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
13
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
14 # Copy compiler binaries (if not already present)
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
15
937
f2b4d7297c9d Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents: 920
diff changeset
16 if false
905
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
17 then
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
18 # Populate the wrapper directories (unfinished)
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
19
981
c6b3d648ead6 Cleanups and comments.
Rob Landley <rob@landley.net>
parents: 943
diff changeset
20 # The purpose of this is to wrap an existing cross compiler by populating
c6b3d648ead6 Cleanups and comments.
Rob Landley <rob@landley.net>
parents: 943
diff changeset
21 # a directory of symlinks in the layout ccwrap expects. This requires
c6b3d648ead6 Cleanups and comments.
Rob Landley <rob@landley.net>
parents: 943
diff changeset
22 # querying the existing compiler to find 1) system header dirs,
c6b3d648ead6 Cleanups and comments.
Rob Landley <rob@landley.net>
parents: 943
diff changeset
23 # 2) compiler header dirs, 3) system library dirs, 4) compiler library dirs,
c6b3d648ead6 Cleanups and comments.
Rob Landley <rob@landley.net>
parents: 943
diff changeset
24 # 5) binary search path for cpp and ld and such.
c6b3d648ead6 Cleanups and comments.
Rob Landley <rob@landley.net>
parents: 943
diff changeset
25
905
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
26 mkdir -p "$STAGE_DIR"/{tools,include,lib,cc/{include,lib}} &&
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
27
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
28 # Setup bin directory
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
29
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
30 mkdir -p "$STAGE_DIR/bin" || dienow
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
31 path_search "$PATH" "${PROGRAM_PREFIX}*" \
937
f2b4d7297c9d Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents: 920
diff changeset
32 'cp "$DIR/$FILE" "$STAGE_DIR/bin/$FILE"' | dotprogress
905
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
33
937
f2b4d7297c9d Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents: 920
diff changeset
34 mv "$STAGE_DIR/"{bin/"${PROGRAM_PREFIX}"cc,tools/bin/cc} ||
f2b4d7297c9d Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents: 920
diff changeset
35 mv "$STAGE_DIR/"{bin/"${PROGRAM_PREFIX}"gcc,tools/bin/cc} || dienow
905
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
36 ln -sf "${PROGRAM_PREFIX}cc" "$STAGE_DIR/bin/${PROGRAM_PREFIX}gcc" || dienow
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
37
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
38 # populate include
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
39
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
40 SYSINC_PATH="$(echo '#include <stdio.h>' | "$ARCH-cc" -E - | \
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
41 sed -n 's@.*"\(.*\)/stdio\.h".*@\1@p;T;q')"
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
42
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
43 # populate lib
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
44
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
45 # Need both /lib and /usr/lib. What if libc.so linker script points to
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
46 # other directory? --print-search-dirs, perhaps?
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
47
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
48 # populate cc/include
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
49
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
50 # This is the trick uClibc build uses.
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
51
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
52 CCINC_PATH="$(gcc --print-file-name=include)"
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
53
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
54 # populate cc/lib
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
55
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
56 CCLIB_PATH="$(gcc --print-file-name=crtbegin.o | sed 's@crtbegin.o$@@')"
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
57 # or maybe --print-search-dirs "libraries"?
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
58
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
59 # Populate tools
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
60 fi
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
61
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
62 # Build wrapper binary
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
diff changeset
63
920
a69213462fbe If "$CCWRAP" is quoted it gets passed in as a blank argument when empty, confusing the compiler.
Rob Landley <rob@landley.net>
parents: 918
diff changeset
64 "$TEMP" "$SOURCES/toys/ccwrap.c" -Os $CFLAGS \
943
7f2e6bdfcdcb Remove the old GIMME_AN_S logic, instead make ccwrap autodetect presence of libgcc_s.so. Also fix a typo causing a nasty bug with the two dash version of --static.
Rob Landley <rob@landley.net>
parents: 937
diff changeset
65 -o "$STAGE_DIR/bin/${PROGRAM_PREFIX}cc" $STATIC_FLAGS || dienow