blob: 4735a7e9c18b6fa2e8db1d72d8f6823bb041aafa [file] [log] [blame]
Rob Landley29fb6382018-02-04 20:07:12 -06001#!/bin/bash
Rob Landley28964802008-01-19 17:08:39 -06002
3# This sets environment variables used by scripts/make.sh
4
Rob Landley29fb6382018-02-04 20:07:12 -06005# People run ./configure out of habit, so do "defconfig" for them.
6
7if [ "$(basename "$0")" == configure ]
8then
9 echo "Assuming you want 'make defconfig', but you should probably check the README."
10 make defconfig
11 exit $?
12fi
13
Rob Landley28964802008-01-19 17:08:39 -060014# A synonym.
15[ -z "$CROSS_COMPILE" ] && CROSS_COMPILE="$CROSS"
Rob Landley57f93c82015-02-28 12:39:16 -060016
17# CFLAGS and OPTIMIZE are different so you can add extra CFLAGS without
18# disabling default optimizations
Rob Landley85ffccb2017-01-04 14:19:06 -060019[ -z "$CFLAGS" ] && CFLAGS="-Wall -Wundef -Wno-char-subscripts -Werror=implicit-function-declaration"
Rob Landley97abd4a2012-06-18 23:23:24 -050020# Required for our expected ABI. we're 8-bit clean thus "char" must be unsigned.
Rob Landley28964802008-01-19 17:08:39 -060021CFLAGS="$CFLAGS -funsigned-char"
Rob Landley35c92f12015-09-17 01:49:48 -050022[ -z "$OPTIMIZE" ] && OPTIMIZE="-Os -ffunction-sections -fdata-sections -fno-asynchronous-unwind-tables -fno-strict-aliasing"
Rob Landleyac84e852019-08-27 12:45:25 -050023# set ASAN=1 to enable "address sanitizer" and debuggable backtraces
Rob Landleyabddc3b2019-09-20 14:38:52 -050024[ -z "$ASAN" ] || { CFLAGS="$CFLAGS -O1 -g -fno-omit-frame-pointer -fno-optimize-sibling-calls -fsanitize=address"; NOSTRIP=1; }
Rob Landley97abd4a2012-06-18 23:23:24 -050025
Rob Landley57f93c82015-02-28 12:39:16 -060026# We accept LDFLAGS, but by default don't have anything in it
Elliott Hughes360a2bf2018-11-30 13:47:05 -080027if [ "$(uname)" != "Darwin" ]
28then
29 [ -z "$LDOPTIMIZE" ] && LDOPTIMIZE="-Wl,--gc-sections"
30 LDASNEEDED="-Wl,--as-needed"
31fi
Rob Landley57f93c82015-02-28 12:39:16 -060032
Rob Landley12235782015-10-05 20:47:49 -050033# The makefile provides defaults for these, so this only gets used if
34# you call scripts/make.sh and friends directly.
35
Rob Landley57f93c82015-02-28 12:39:16 -060036[ -z "$CC" ] && CC=cc
Francesco Valla7335fe72018-06-04 08:25:56 +020037[ -z "$STRIP" ] && STRIP=strip
Rob Landley57f93c82015-02-28 12:39:16 -060038
39# If HOSTCC needs CFLAGS or LDFLAGS, just add them to the variable
40# ala HOSTCC="blah-cc --static"
Rob Landley12235782015-10-05 20:47:49 -050041[ -z "$HOSTCC" ] && HOSTCC=cc
Rob Landleyabddc3b2019-09-20 14:38:52 -050042
43[ -z "$GENERATED" ] && GENERATED=generated