• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3# This sets environment variables used by scripts/make.sh
4
5# 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
14# A synonym.
15[ -z "$CROSS_COMPILE" ] && CROSS_COMPILE="$CROSS"
16
17# CFLAGS and OPTIMIZE are different so you can add extra CFLAGS without
18# disabling default optimizations
19[ -z "$CFLAGS" ] && CFLAGS="-Wall -Wundef -Wno-char-subscripts -Werror=implicit-function-declaration"
20# Required for our expected ABI. we're 8-bit clean thus "char" must be unsigned.
21CFLAGS="$CFLAGS -funsigned-char"
22[ -z "$OPTIMIZE" ] && OPTIMIZE="-Os -ffunction-sections -fdata-sections -fno-asynchronous-unwind-tables -fno-strict-aliasing"
23# set ASAN=1 to enable "address sanitizer" and debuggable backtraces
24[ -z "$ASAN" ] || { CFLAGS="$CFLAGS -O1 -g -fno-omit-frame-pointer -fno-optimize-sibling-calls -fsanitize=address"; NOSTRIP=1; }
25
26# We accept LDFLAGS, but by default don't have anything in it
27if [ "$(uname)" != "Darwin" ]
28then
29  [ -z "$LDOPTIMIZE" ] && LDOPTIMIZE="-Wl,--gc-sections"
30  LDASNEEDED="-Wl,--as-needed"
31fi
32
33# The makefile provides defaults for these, so this only gets used if
34# you call scripts/make.sh and friends directly.
35
36[ -z "$CC" ] && CC=cc
37[ -z "$STRIP" ] && STRIP=strip
38
39# If HOSTCC needs CFLAGS or LDFLAGS, just add them to the variable
40# ala HOSTCC="blah-cc --static"
41[ -z "$HOSTCC" ] && HOSTCC=cc
42
43[ -z "$GENERATED" ] && GENERATED=generated
44