gnuk/src/configure

198 lines
5.0 KiB
Plaintext
Raw Normal View History

2011-01-06 08:27:14 +00:00
#! /bin/bash
2010-10-14 08:08:09 +00:00
#
# This file is *NOT* generated by GNU Autoconf, but written by NIIBE Yutaka
#
2011-01-07 07:18:47 +00:00
# Copyright (C) 2010, 2011 Free Software Initiative of Japan
2010-10-14 08:08:09 +00:00
#
# This file is a part of Gnuk, a GnuPG USB Token implementation.
# Gnuk is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Gnuk is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
# License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Default settings
help=no
target=OLIMEX_STM32_H103
verbose=no
2010-10-20 01:14:03 +00:00
with_dfu=default
2011-01-07 07:18:47 +00:00
with_fixed_serial=no
2010-10-14 08:08:09 +00:00
debug=no
2010-12-15 01:24:39 +00:00
pinpad=no
2010-10-14 08:08:09 +00:00
2010-10-20 04:34:04 +00:00
# check /dev/random
if test ! -e /dev/random; then
echo "/dev/random is required." >&2
exit 1
fi
2010-10-14 08:08:09 +00:00
# Process each option
for option; do
case $option in
*=*) optarg=`expr "X$option" : '[^=]*=\(.*\)'` ;;
*) optarg=yes ;;
esac
case $option in
-h | --help)
help=yes ;;
--target=*)
target=$optarg ;;
-v | --verbose)
verbose=yes ;;
--enable-debug)
2011-01-06 08:27:14 +00:00
debug=yes ;;
2010-10-14 08:08:09 +00:00
--disable-debug)
2011-01-06 08:27:14 +00:00
debug=no ;;
2010-12-15 01:24:39 +00:00
--enable-pinpad)
2011-01-06 08:27:14 +00:00
pinpad=yes ;;
--enable-pinpad=*)
pinpad=$optarg ;;
2010-12-15 01:24:39 +00:00
--disable-pinpad)
2011-01-06 08:27:14 +00:00
pinpad=no ;;
2010-10-14 08:08:09 +00:00
--with-dfu)
with_dfu=yes ;;
--without-dfu)
with_dfu=no ;;
2011-01-07 07:18:47 +00:00
--with-fixed-serial)
with_fixed_serial=yes ;;
--without-fixed-serial)
with_fixed_serial=no ;;
2010-10-14 08:08:09 +00:00
*)
echo "Unrecognized option \`$option'" >&2
echo "Try \`$0 --help' for more information." >&2
exit 1
;;
esac
done
if test "$help" = "yes"; then
cat <<EOF
Usage: $0 [OPTION]...
Defaults for the options are specified in brackets.
Configuration:
-h, --help display this help and exit [no]
--target=TARGET specify target [OLIMEX_STM32_H103]
supported targes are:
OLIMEX_STM32_H103
STM32_PRIMER2
2010-10-20 01:14:03 +00:00
CQ_STARM
2010-10-22 03:56:40 +00:00
STBEE_MINI
2010-10-14 08:08:09 +00:00
--enable-debug debug with virtual COM port [no]
2011-01-06 08:27:14 +00:00
--enable-pinpad={cir,dial}
PIN input device support [no]
2010-10-20 01:00:37 +00:00
--with-dfu build image for DFU [<target specific>]
2011-01-07 07:18:47 +00:00
--with-fixed-serial Use fixed serial number [no: chip unique ID]
2010-10-14 08:08:09 +00:00
EOF
exit 0
fi
BOARD_MAKEFILE=../boards/$target/board.mk
if test -f $BOARD_MAKEFILE; then
echo "Configured for target: $target"
else
echo "Unsupported target \`$target'" >&2
exit 1
fi
2010-12-15 01:24:39 +00:00
# Flash page size in byte
FLASH_PAGE_SIZE=1024
# Flash memory size in KB
FLASH_SIZE=128
# Settings for TARGET
2010-10-20 01:14:03 +00:00
case $target in
2010-10-22 03:56:40 +00:00
CQ_STARM|STBEE_MINI)
2010-10-20 01:14:03 +00:00
if test "$with_dfu" = "default"; then
with_dfu=yes;
fi ;;
2010-12-15 01:24:39 +00:00
STM32_PRIMER2)
FLASH_PAGE_SIZE=2048
;;
STM8S_DISCOVERY)
FLASH_SIZE=64
;;
2010-10-20 01:14:03 +00:00
*)
2010-12-15 01:24:39 +00:00
;;
2010-10-20 01:14:03 +00:00
esac
2011-01-07 07:18:47 +00:00
# --with-fixed-serial option
if test "$with_fixed_serial" = "no"; then
echo "Using chip unique ID for card AID"
SERIAL_DEFINE="#undef SERIAL_NUMBER_IN_AID"
2010-10-20 04:34:04 +00:00
else
2011-01-07 07:18:47 +00:00
echo "Using fixed serial number (at compile time) for card AID"
2010-10-20 04:34:04 +00:00
if test "x$MAIL" = "x"; then
2010-10-22 03:56:40 +00:00
echo "ERROR: Please set MAIL shell variable to select FSIJ serial number" >&2
2010-10-20 04:34:04 +00:00
exit 1
fi
2011-01-07 07:18:47 +00:00
SERIAL=`sed -n -e "/^$MAIL/s/^.* \(..\):\(..\):\(..\):\(..\)/0x\1, 0x\2, 0x\3, 0x\4/p" ../FSIJ_SERIAL_NUMBER`
SERIAL_DEFINE="#define SERIAL_NUMBER_IN_AID $SERIAL"
2010-10-20 04:34:04 +00:00
fi
2010-12-15 01:24:39 +00:00
# --enable-debug option
2010-10-14 08:08:09 +00:00
if test "$debug" = "yes"; then
DEBUG_MAKE_OPTION="ENABLE_DEBUG=1"
DEBUG_DEFINE="#define DEBUG 1"
2010-12-07 05:34:25 +00:00
echo "Debug option enabled"
2010-10-14 08:08:09 +00:00
else
DEBUG_MAKE_OPTION="# ENABLE_DEBUG=1"
DEBUG_DEFINE="#undef DEBUG"
2010-12-07 05:34:25 +00:00
echo "Debug option disabled"
2010-10-14 08:08:09 +00:00
fi
2010-12-15 01:24:39 +00:00
# --with-dfu option
2010-10-14 08:08:09 +00:00
if test "$with_dfu" = "yes"; then
echo "Configured for DFU"
ORIGIN=0x08003000
2010-12-15 01:24:39 +00:00
FLASH_SIZE=`expr $FLASH_SIZE - 12`
2010-10-14 08:08:09 +00:00
DFU_DEFINE="#define DFU_SUPPORT 1"
else
echo "Configured for bare system (no-DFU)"
ORIGIN=0x08000000
DFU_DEFINE="#undef DFU_SUPPORT"
fi
2010-12-15 01:24:39 +00:00
# --enable-pinpad option
2011-01-06 08:27:14 +00:00
if test "$pinpad" = "no"; then
PINPAD_MAKE_OPTION="# ENABLE_PINPAD="
2010-12-15 01:24:39 +00:00
PINPAD_DEFINE="#undef PINPAD_SUPPORT"
2011-01-06 08:27:14 +00:00
PINPAD_MORE_DEFINE=""
2010-12-15 01:24:39 +00:00
echo "PIN pad option disabled"
2011-01-06 08:27:14 +00:00
elif test "$pinpad" = "yes"; then
PINPAD_MAKE_OPTION="ENABLE_PINPAD=cir"
PINPAD_DEFINE="#define PINPAD_SUPPORT 1"
PINPAD_MORE_DEFINE="#define PINPAD_CIR_SUPPORT 1"
echo "PIN pad option enabled (cir)"
else
PINPAD_MAKE_OPTION="ENABLE_PINPAD=$pinpad"
PINPAD_DEFINE="#define PINPAD_SUPPORT 1"
PINPAD_MORE_DEFINE="#define PINPAD_${pinpad^^[a-z]}_SUPPORT 1"
echo "PIN pad option enabled ($pinpad)"
2010-12-14 08:42:38 +00:00
fi
2010-10-14 08:08:09 +00:00
sed -e "s%@BOARD_MAKEFILE@%$BOARD_MAKEFILE%" \
-e "s%@DEBUG_MAKE_OPTION@%$DEBUG_MAKE_OPTION%" \
2010-12-15 01:24:39 +00:00
-e "s%@PINPAD_MAKE_OPTION@%$PINPAD_MAKE_OPTION%" \
2010-10-14 08:08:09 +00:00
< Makefile.in > Makefile
sed -e "s/@ORIGIN@/$ORIGIN/" -e "s/@FLASH_SIZE@/$FLASH_SIZE/" \
2010-11-30 05:32:56 +00:00
-e "s/@FLASH_PAGE_SIZE@/$FLASH_PAGE_SIZE/" \
2010-10-14 08:08:09 +00:00
< gnuk.ld.in > gnuk.ld
sed -e "s/@DEBUG_DEFINE@/$DEBUG_DEFINE/" \
2010-12-15 01:24:39 +00:00
-e "s/@PINPAD_DEFINE@/$PINPAD_DEFINE/" \
2011-01-06 08:27:14 +00:00
-e "s/@PINPAD_MORE_DEFINE@/$PINPAD_MORE_DEFINE/" \
2010-10-14 08:08:09 +00:00
-e "s/@DFU_DEFINE@/$DFU_DEFINE/" \
2011-01-07 07:18:47 +00:00
-e "s/@SERIAL_DEFINE@/$SERIAL_DEFINE/" \
2010-10-14 08:08:09 +00:00
< config.h.in > config.h
exit 0