Rob Landley | 29fb638 | 2018-02-04 20:07:12 -0600 | [diff] [blame] | 1 | #!/bin/bash |
Rob Landley | 2896480 | 2008-01-19 17:08:39 -0600 | [diff] [blame] | 2 | |
| 3 | # This sets environment variables used by scripts/make.sh |
| 4 | |
Rob Landley | 29fb638 | 2018-02-04 20:07:12 -0600 | [diff] [blame] | 5 | # People run ./configure out of habit, so do "defconfig" for them. |
| 6 | |
| 7 | if [ "$(basename "$0")" == configure ] |
| 8 | then |
| 9 | echo "Assuming you want 'make defconfig', but you should probably check the README." |
| 10 | make defconfig |
| 11 | exit $? |
| 12 | fi |
| 13 | |
Rob Landley | 2896480 | 2008-01-19 17:08:39 -0600 | [diff] [blame] | 14 | # A synonym. |
| 15 | [ -z "$CROSS_COMPILE" ] && CROSS_COMPILE="$CROSS" |
Rob Landley | 57f93c8 | 2015-02-28 12:39:16 -0600 | [diff] [blame] | 16 | |
| 17 | # CFLAGS and OPTIMIZE are different so you can add extra CFLAGS without |
| 18 | # disabling default optimizations |
Rob Landley | 85ffccb | 2017-01-04 14:19:06 -0600 | [diff] [blame] | 19 | [ -z "$CFLAGS" ] && CFLAGS="-Wall -Wundef -Wno-char-subscripts -Werror=implicit-function-declaration" |
Rob Landley | 97abd4a | 2012-06-18 23:23:24 -0500 | [diff] [blame] | 20 | # Required for our expected ABI. we're 8-bit clean thus "char" must be unsigned. |
Rob Landley | 2896480 | 2008-01-19 17:08:39 -0600 | [diff] [blame] | 21 | CFLAGS="$CFLAGS -funsigned-char" |
Rob Landley | 35c92f1 | 2015-09-17 01:49:48 -0500 | [diff] [blame] | 22 | [ -z "$OPTIMIZE" ] && OPTIMIZE="-Os -ffunction-sections -fdata-sections -fno-asynchronous-unwind-tables -fno-strict-aliasing" |
Rob Landley | ac84e85 | 2019-08-27 12:45:25 -0500 | [diff] [blame] | 23 | # set ASAN=1 to enable "address sanitizer" and debuggable backtraces |
Rob Landley | abddc3b | 2019-09-20 14:38:52 -0500 | [diff] [blame] | 24 | [ -z "$ASAN" ] || { CFLAGS="$CFLAGS -O1 -g -fno-omit-frame-pointer -fno-optimize-sibling-calls -fsanitize=address"; NOSTRIP=1; } |
Rob Landley | 97abd4a | 2012-06-18 23:23:24 -0500 | [diff] [blame] | 25 | |
Rob Landley | 57f93c8 | 2015-02-28 12:39:16 -0600 | [diff] [blame] | 26 | # We accept LDFLAGS, but by default don't have anything in it |
Elliott Hughes | 360a2bf | 2018-11-30 13:47:05 -0800 | [diff] [blame] | 27 | if [ "$(uname)" != "Darwin" ] |
| 28 | then |
| 29 | [ -z "$LDOPTIMIZE" ] && LDOPTIMIZE="-Wl,--gc-sections" |
| 30 | LDASNEEDED="-Wl,--as-needed" |
| 31 | fi |
Rob Landley | 57f93c8 | 2015-02-28 12:39:16 -0600 | [diff] [blame] | 32 | |
Rob Landley | 1223578 | 2015-10-05 20:47:49 -0500 | [diff] [blame] | 33 | # The makefile provides defaults for these, so this only gets used if |
| 34 | # you call scripts/make.sh and friends directly. |
| 35 | |
Rob Landley | 57f93c8 | 2015-02-28 12:39:16 -0600 | [diff] [blame] | 36 | [ -z "$CC" ] && CC=cc |
Francesco Valla | 7335fe7 | 2018-06-04 08:25:56 +0200 | [diff] [blame] | 37 | [ -z "$STRIP" ] && STRIP=strip |
Rob Landley | 57f93c8 | 2015-02-28 12:39:16 -0600 | [diff] [blame] | 38 | |
| 39 | # If HOSTCC needs CFLAGS or LDFLAGS, just add them to the variable |
| 40 | # ala HOSTCC="blah-cc --static" |
Rob Landley | 1223578 | 2015-10-05 20:47:49 -0500 | [diff] [blame] | 41 | [ -z "$HOSTCC" ] && HOSTCC=cc |
Rob Landley | abddc3b | 2019-09-20 14:38:52 -0500 | [diff] [blame] | 42 | |
| 43 | [ -z "$GENERATED" ] && GENERATED=generated |