Mercurial > hg > qcc
comparison make/make.sh @ 590:18ffc34ebf5d
Replace old "DEBUG=echo" with "VERBOSE=1", which shows the command lines
(properly escaped so you can cut and paste to re-run them) while also executing
each one. For the old "just show the commands, don't execute them" use
"VERBOSE=debug".
author | Rob Landley <rob@landley.net> |
---|---|
date | Sun, 06 Apr 2008 17:02:18 -0500 |
parents | 29c7cb849479 |
children | 18192dd26583 |
comparison
equal
deleted
inserted
replaced
589:49d3fc246344 | 590:18ffc34ebf5d |
---|---|
11 | 11 |
12 TINYCC_VERSION=1.0.0-pre3 | 12 TINYCC_VERSION=1.0.0-pre3 |
13 | 13 |
14 DOLOCAL="-B. -I./include -I." | 14 DOLOCAL="-B. -I./include -I." |
15 | 15 |
16 # Add a compiler define to the cc argument list, set to a string containing | |
17 # the value of the environment variable of the same name. | |
18 function DEF() | |
19 { | |
20 if [ -z "$DEBUG" ] | |
21 then | |
22 # Add a -DSYMBOL="STRING" argument. The shell eats some of the characters | |
23 # but this gives the compiler the right arguments. | |
24 echo -D$1=\"\$$1\" | |
25 else | |
26 # Add an extra layer of quotes so that even after the shell eats one, | |
27 # "echo" produces something that works if we cut and paste it. | |
28 echo -D$1=\\\"\$$1\\\" | |
29 fi | |
30 } | |
31 | |
16 # Invoke the compiler with all the appropriate arguments | 32 # Invoke the compiler with all the appropriate arguments |
17 | 33 |
18 function compile_tinycc() | 34 function compile_tinycc() |
19 { | 35 { |
20 OUTFILE=$1 | 36 OUTFILE=$1 |
21 shift | 37 shift |
38 TINYCC_TARGET="$ARCH" | |
22 $DEBUG $CC $@ -o $OUTFILE $CFLAGS $LIBS \ | 39 $DEBUG $CC $@ -o $OUTFILE $CFLAGS $LIBS \ |
23 -DTINYCC_TARGET_$(echo $ARCH | tr a-z A-Z) \ | 40 -DTINYCC_TARGET_$(echo $ARCH | tr a-z A-Z) \ |
24 -DTINYCC_TARGET='"'$ARCH'"' \ | 41 $(DEF TINYCC_TARGET) $(DEF TINYCC_VERSION) $(DEF TINYCC_INSTALLDIR) \ |
25 -DTINYCC_VERSION='"'$TINYCC_VERSION'"' \ | 42 $(DEF CC_CRTDIR) $(DEF CC_LIBPATH) $(DEF CC_HEADERPATH) \ |
26 -DTINYCC_INSTALLDIR='"'$TINYCC_INSTALLDIR'"' \ | 43 $(DEF CC_DYNAMIC_LINKER) |
27 -DCC_CRTDIR='"'$CC_CRTDIR'"' \ | |
28 -DCC_LIBPATH='"'$CC_LIBPATH'"' \ | |
29 -DCC_HEADERPATH='"'$CC_HEADERPATH'"' \ | |
30 -DCC_DYNAMIC_LINKER='"'$CC_DYNAMIC_LINKER'"' | |
31 } | 44 } |
32 | 45 |
46 # Show command line before running it. | |
47 function show_verbose() | |
48 { | |
49 SHOWIT=echo | |
50 [ "$1" == "compile_tinycc" ] && SHOWIT="" | |
51 [ ! -z "$VERBOSE" ] && DEBUG=echo $SHOWIT "$@" | |
52 [ "$VERBOSE" != "debug" ] && "$@" || return 0 | |
53 } | |
33 | 54 |
34 function build() | 55 function build() |
35 { | 56 { |
36 # The path at which the new compiler should search for system libraries is, | 57 # The path at which the new compiler should search for system libraries is, |
37 # alas, target dependent. | 58 # alas, target dependent. |
45 L="$CC_LIBPATH" | 66 L="$CC_LIBPATH" |
46 fi | 67 fi |
47 | 68 |
48 # Build tinycc with a specific architecture and search paths. | 69 # Build tinycc with a specific architecture and search paths. |
49 | 70 |
50 ARCH=$1 CC_LIBPATH="$L" compile_tinycc $1-tinycc_unstripped tcc.c options.c && | 71 ARCH=$1 CC_LIBPATH="$L" show_verbose compile_tinycc $1-tinycc_unstripped \ |
51 $DEBUG $STRIP $1-tinycc_unstripped -o $1-tinycc | 72 tcc.c options.c && |
73 show_verbose $STRIP $1-tinycc_unstripped -o $1-tinycc | |
52 | 74 |
53 [ $? -ne 0 ] && exit 1 | 75 [ $? -ne 0 ] && exit 1 |
54 | 76 |
55 # If the compiler we just built works as a native compiler for this host, | 77 # If the compiler we just built works as a native compiler for this host, |
56 # create a "tinycc" symlink pointing to it | 78 # create a "tinycc" symlink pointing to it |
57 | 79 |
58 if [ "$1" == "$HOST" ] | 80 if [ "$1" == "$HOST" ] |
59 then | 81 then |
60 $DEBUG rm -f tinycc | 82 show_verbose rm -f tinycc |
61 $DEBUG ln -s $1-tinycc tinycc || exit 1 | 83 show_verbose ln -s $1-tinycc tinycc || exit 1 |
62 fi | 84 fi |
63 | 85 |
64 # Compile tinycc engine as a shared library. | 86 # Compile tinycc engine as a shared library. |
65 | 87 |
66 ARCH=$1 compile_tinycc libtinycc-$1.so -shared -fPIC -DLIBTCC tcc.c && | 88 ARCH=$1 show_verbose compile_tinycc libtinycc-$1.so -shared -fPIC -DLIBTCC \ |
89 tcc.c && | |
67 | 90 |
68 # If we're building a tinycc binary we can't run, build one we _can_ run | 91 # If we're building a tinycc binary we can't run, build one we _can_ run |
69 # that outputs binaries for the same target. We need it to build a target | 92 # that outputs binaries for the same target. We need it to build a target |
70 # version of the runtime library (libtinyccrt) with. | 93 # version of the runtime library (libtinyccrt) with. |
71 | 94 |
72 if [ "$CC" != "$HOSTCC" ] | 95 if [ "$CC" != "$HOSTCC" ] |
73 then | 96 then |
74 LIBCC=host-$1-tinycc | 97 LIBCC=host-$1-tinycc |
75 ARCH=$1 CC="$HOSTCC" CC_LIBPATH="$L" compile_tinycc $LIBCC tcc.c options.c | 98 ARCH=$1 CC="$HOSTCC" CC_LIBPATH="$L" show_verbose compile_tinycc $LIBCC \ |
99 tcc.c options.c | |
76 else | 100 else |
77 LIBCC=$1-tinycc | 101 LIBCC=$1-tinycc |
78 fi | 102 fi |
79 | 103 |
80 # Build libtinyccrt-$ARCH.a (which compiled programs link against). This | 104 # Build libtinyccrt-$ARCH.a (which compiled programs link against). This |
83 | 107 |
84 # XXX build this on all platforms | 108 # XXX build this on all platforms |
85 | 109 |
86 if [ -f $1/alloca.S ] | 110 if [ -f $1/alloca.S ] |
87 then | 111 then |
88 $DEBUG mkdir -p lib/$1 | 112 show_verbose mkdir -p lib/$1 |
89 $DEBUG ./$LIBCC $DOLOCAL -o libtinycc1-$1.o -c libtinycc1.c && | 113 show_verbose ./$LIBCC $DOLOCAL -o libtinycc1-$1.o -c libtinycc1.c && |
90 $DEBUG ./$LIBCC $DOLOCAL -o alloca-$1.o -c $1/alloca.S && | 114 show_verbose ./$LIBCC $DOLOCAL -o alloca-$1.o -c $1/alloca.S && |
91 $DEBUG ./$LIBCC $DOLOCAL -o bound-alloca-$1.o -c $1/bound-alloca.S && | 115 show_verbose ./$LIBCC $DOLOCAL -o bound-alloca-$1.o -c $1/bound-alloca.S && |
92 $DEBUG $AR rcs libtinyccrt-$1.a {libtinycc1,alloca,bound-alloca}-$1.o | 116 show_verbose $AR rcs libtinyccrt-$1.a {libtinycc1,alloca,bound-alloca}-$1.o |
93 fi | 117 fi |
94 } | 118 } |
95 | 119 |
96 # Figure out what target(s) to build for. | 120 # Figure out what target(s) to build for. |
97 | 121 |