aboutsummaryrefslogtreecommitdiff
path: root/binary/static-gcc
diff options
context:
space:
mode:
Diffstat (limited to 'binary/static-gcc')
-rwxr-xr-xbinary/static-gcc25
1 files changed, 19 insertions, 6 deletions
diff --git a/binary/static-gcc b/binary/static-gcc
index a4d865d5..c08f24b2 100755
--- a/binary/static-gcc
+++ b/binary/static-gcc
@@ -1,5 +1,10 @@
1#!/usr/bin/env bash 1#!/usr/bin/env bash
2 2
3STATIC_GCC_AR=${STATIC_GCC_AR:-ar}
4STATIC_GCC_RANLIB=${STATIC_GCC_RANLIB:-ranlib}
5STATIC_GCC_CC=${STATIC_GCC_CC:-gcc}
6STATIC_GCC_LIBDIR=${STATIC_GCC_LIBDIR:-/usr/lib}
7
3DIR="$( cd "$( dirname "$0" )" && pwd )" 8DIR="$( cd "$( dirname "$0" )" && pwd )"
4 9
5function log() { echo -- "$@" >> $DIR/log.txt; } 10function log() { echo -- "$@" >> $DIR/log.txt; }
@@ -13,7 +18,7 @@ allargs=()
13sources=() 18sources=()
14objects=() 19objects=()
15etc=() 20etc=()
16libdirs=("/usr/lib") 21libdirs=("$STATIC_GCC_LIBDIR")
17incdirs=() 22incdirs=()
18 23
19linking=0 24linking=0
@@ -94,15 +99,22 @@ done
94staticlibs=() 99staticlibs=()
95for lib in "${libs[@]}" 100for lib in "${libs[@]}"
96do 101do
102 found=0
97 for libdir in "${libdirs[@]}" 103 for libdir in "${libdirs[@]}"
98 do 104 do
99 staticlib="$libdir/lib$lib.a" 105 staticlib="$libdir/lib$lib.a"
100 if [ -e "$staticlib" ] 106 if [ -e "$staticlib" ]
101 then 107 then
102 staticlibs+=("$staticlib") 108 staticlibs+=("$staticlib")
109 found=1
103 break 110 break
104 fi 111 fi
105 done 112 done
113 if [ "$found" = 0 ]
114 then
115 log "STATICLIB not found for $lib"
116 runlog exit 1
117 fi
106done 118done
107 119
108oflag=() 120oflag=()
@@ -119,7 +131,7 @@ then
119 for source in "${sources[@]}" 131 for source in "${sources[@]}"
120 do 132 do
121 object="${source%.c}.o" 133 object="${source%.c}.o"
122 runlog gcc "${incdirs[@]}" "${etc[@]}" -c -o "$object" "$source" 134 runlog $STATIC_GCC_CC "${incdirs[@]}" "${etc[@]}" -c -o "$object" "$source"
123 [ "$?" = 0 ] || runlog exit $? 135 [ "$?" = 0 ] || runlog exit $?
124 objects+=("$object") 136 objects+=("$object")
125 done 137 done
@@ -137,22 +149,23 @@ then
137 done 149 done
138 echo "SAVE" >> ar.script 150 echo "SAVE" >> ar.script
139 echo "END" >> ar.script 151 echo "END" >> ar.script
140 cat ar.script | ar -M 152 cat ar.script >> "$DIR/log.txt"
153 cat ar.script | $STATIC_GCC_AR -M
141 [ "$?" = 0 ] || runlog exit $? 154 [ "$?" = 0 ] || runlog exit $?
142 155
143 [ -e "$output" ] || { 156 [ -e "$output" ] || {
144 exit 1 157 exit 1
145 } 158 }
146 159
147 runlog ranlib "$output" 160 runlog $STATIC_GCC_RANLIB "$output"
148 runlog exit $? 161 runlog exit $?
149elif [ "$object" = 1 ] 162elif [ "$object" = 1 ]
150then 163then
151 log OBJECT 164 log OBJECT
152 runlog gcc "${oflag[@]}" "${incdirs[@]}" "${etc[@]}" "${sources[@]}" 165 runlog $STATIC_GCC_CC "${oflag[@]}" "${incdirs[@]}" "${etc[@]}" "${sources[@]}"
153 runlog exit $? 166 runlog exit $?
154else 167else
155 log EXECUTABLE 168 log EXECUTABLE
156 runlog gcc "${allargs[@]}" 169 runlog $STATIC_GCC_CC "${allargs[@]}"
157 runlog exit $? 170 runlog exit $?
158fi 171fi