blob: 06d7cbab85ae2920867a25fdd093400fcf3b149b [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 Landley97abd4a2012-06-18 23:23:24 -050023
Rob Landley57f93c82015-02-28 12:39:16 -060024# We accept LDFLAGS, but by default don't have anything in it
Elliott Hughes360a2bf2018-11-30 13:47:05 -080025if [ "$(uname)" != "Darwin" ]
26then
27 [ -z "$LDOPTIMIZE" ] && LDOPTIMIZE="-Wl,--gc-sections"
28 LDASNEEDED="-Wl,--as-needed"
29fi
Rob Landley57f93c82015-02-28 12:39:16 -060030
Rob Landley12235782015-10-05 20:47:49 -050031# The makefile provides defaults for these, so this only gets used if
32# you call scripts/make.sh and friends directly.
33
Rob Landley57f93c82015-02-28 12:39:16 -060034[ -z "$CC" ] && CC=cc
Francesco Valla7335fe72018-06-04 08:25:56 +020035[ -z "$STRIP" ] && STRIP=strip
Rob Landley57f93c82015-02-28 12:39:16 -060036
37# If HOSTCC needs CFLAGS or LDFLAGS, just add them to the variable
38# ala HOSTCC="blah-cc --static"
Rob Landley12235782015-10-05 20:47:49 -050039[ -z "$HOSTCC" ] && HOSTCC=cc