blob: 0b6501fc9afec94ba6908e9efe9ae0d8e8d759fe [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 Landley57f93c82015-02-28 12:39:16 -060014# CFLAGS and OPTIMIZE are different so you can add extra CFLAGS without
15# disabling default optimizations
Rob Landley85ffccb2017-01-04 14:19:06 -060016[ -z "$CFLAGS" ] && CFLAGS="-Wall -Wundef -Wno-char-subscripts -Werror=implicit-function-declaration"
Rob Landley97abd4a2012-06-18 23:23:24 -050017# Required for our expected ABI. we're 8-bit clean thus "char" must be unsigned.
Rob Landley28964802008-01-19 17:08:39 -060018CFLAGS="$CFLAGS -funsigned-char"
Rob Landley35c92f12015-09-17 01:49:48 -050019[ -z "$OPTIMIZE" ] && OPTIMIZE="-Os -ffunction-sections -fdata-sections -fno-asynchronous-unwind-tables -fno-strict-aliasing"
Rob Landleyac84e852019-08-27 12:45:25 -050020# set ASAN=1 to enable "address sanitizer" and debuggable backtraces
Rob Landleyabddc3b2019-09-20 14:38:52 -050021[ -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 -050022
Rob Landley57f93c82015-02-28 12:39:16 -060023# We accept LDFLAGS, but by default don't have anything in it
Elliott Hughes360a2bf2018-11-30 13:47:05 -080024if [ "$(uname)" != "Darwin" ]
25then
26 [ -z "$LDOPTIMIZE" ] && LDOPTIMIZE="-Wl,--gc-sections"
27 LDASNEEDED="-Wl,--as-needed"
28fi
Rob Landley57f93c82015-02-28 12:39:16 -060029
Rob Landley12235782015-10-05 20:47:49 -050030# The makefile provides defaults for these, so this only gets used if
31# you call scripts/make.sh and friends directly.
32
Rob Landley57f93c82015-02-28 12:39:16 -060033[ -z "$CC" ] && CC=cc
Francesco Valla7335fe72018-06-04 08:25:56 +020034[ -z "$STRIP" ] && STRIP=strip
Rob Landley57f93c82015-02-28 12:39:16 -060035
36# If HOSTCC needs CFLAGS or LDFLAGS, just add them to the variable
37# ala HOSTCC="blah-cc --static"
Rob Landley12235782015-10-05 20:47:49 -050038[ -z "$HOSTCC" ] && HOSTCC=cc
Rob Landleyabddc3b2019-09-20 14:38:52 -050039
40[ -z "$GENERATED" ] && GENERATED=generated