view scripts/genconfig.sh @ 484:4099d3026e56

Set HOSTCC only if it isn't already set as an environment variable.
author Rob Landley <rob@landley.net>
date Sun, 19 Feb 2012 22:21:45 -0600
parents 8f5780dd6da4
children f0247cfc37f2
line wrap: on
line source

#!/bin/bash

# This has to be a separate file from scripts/make.sh so it can be called
# before menuconfig.  (It's called again from scripts/make.sh just to be sure.)

mkdir -p generated
OUTFILE=generated/Config.in

source configure

genconfig()
{
  # Probe for container support on target

  echo -e "# container support\nconfig TOYBOX_CONTAINER\n\tbool" || return 1
  $CC -c -xc -o /dev/null - << EOF
    #include <sched.h>
    int x=CLONE_NEWNS|CLONE_NEWUTS|CLONE_NEWIPC|CLONE_NEWNET;
EOF
  [ $? -eq 0 ] && DEFAULT=y || DEFAULT=n
  echo -e "\tdefault $DEFAULT\n" || return 1

  # extract config stanzas from each command source file, in alphabetical order

  for i in $(ls -1 toys/*.c)
  do
    # Grab the config block for Config.in
    echo "# $i"
    sed -n '/^\*\//q;/^config [A-Z]/,$p' $i || return 1
    echo
  done
}

genconfig > generated/Config.in || rm "$OUTFILE"