10f66f451Sopenharmony_ci#!/bin/bash
20f66f451Sopenharmony_ci
30f66f451Sopenharmony_ci# This sets environment variables used by scripts/make.sh
40f66f451Sopenharmony_ci
50f66f451Sopenharmony_ci# People run ./configure out of habit, so do "defconfig" for them.
60f66f451Sopenharmony_ci
70f66f451Sopenharmony_ciif [ "$(basename "$0")" == configure ]
80f66f451Sopenharmony_cithen
90f66f451Sopenharmony_ci  echo "Assuming you want 'make defconfig', but you should probably check the README."
100f66f451Sopenharmony_ci  make defconfig
110f66f451Sopenharmony_ci  exit $?
120f66f451Sopenharmony_cifi
130f66f451Sopenharmony_ci
140f66f451Sopenharmony_ci# A synonym.
150f66f451Sopenharmony_ci[ -z "$CROSS_COMPILE" ] && CROSS_COMPILE="$CROSS"
160f66f451Sopenharmony_ci
170f66f451Sopenharmony_ci# CFLAGS and OPTIMIZE are different so you can add extra CFLAGS without
180f66f451Sopenharmony_ci# disabling default optimizations
190f66f451Sopenharmony_ci[ -z "$CFLAGS" ] && CFLAGS="-Wall -Wundef -Wno-char-subscripts -Werror=implicit-function-declaration"
200f66f451Sopenharmony_ci# Required for our expected ABI. we're 8-bit clean thus "char" must be unsigned.
210f66f451Sopenharmony_ciCFLAGS="$CFLAGS -funsigned-char"
220f66f451Sopenharmony_ci[ -z "$OPTIMIZE" ] && OPTIMIZE="-Os -ffunction-sections -fdata-sections -fno-asynchronous-unwind-tables -fno-strict-aliasing"
230f66f451Sopenharmony_ci# set ASAN=1 to enable "address sanitizer" and debuggable backtraces
240f66f451Sopenharmony_ci[ -z "$ASAN" ] || { CFLAGS="$CFLAGS -O1 -g -fno-omit-frame-pointer -fno-optimize-sibling-calls -fsanitize=address"; NOSTRIP=1; }
250f66f451Sopenharmony_ci
260f66f451Sopenharmony_ci# We accept LDFLAGS, but by default don't have anything in it
270f66f451Sopenharmony_ciif [ "$(uname)" != "Darwin" ]
280f66f451Sopenharmony_cithen
290f66f451Sopenharmony_ci  [ -z "$LDOPTIMIZE" ] && LDOPTIMIZE="-Wl,--gc-sections"
300f66f451Sopenharmony_ci  LDASNEEDED="-Wl,--as-needed"
310f66f451Sopenharmony_cifi
320f66f451Sopenharmony_ci
330f66f451Sopenharmony_ci# The makefile provides defaults for these, so this only gets used if
340f66f451Sopenharmony_ci# you call scripts/make.sh and friends directly.
350f66f451Sopenharmony_ci
360f66f451Sopenharmony_ci[ -z "$CC" ] && CC=cc
370f66f451Sopenharmony_ci[ -z "$STRIP" ] && STRIP=strip
380f66f451Sopenharmony_ci
390f66f451Sopenharmony_ci# If HOSTCC needs CFLAGS or LDFLAGS, just add them to the variable
400f66f451Sopenharmony_ci# ala HOSTCC="blah-cc --static"
410f66f451Sopenharmony_ci[ -z "$HOSTCC" ] && HOSTCC=cc
420f66f451Sopenharmony_ci
430f66f451Sopenharmony_ci[ -z "$GENERATED" ] && GENERATED=generated
44