amiga-sha/configure

218 lines
4.5 KiB
Bash
Executable File

#!/bin/sh
#
# Copyright (c) 2015 Carsten Larsen
# Copyright (c) 2014 Poul-Henning Kamp
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
set -e
#################################################
HDRS='
compiler.h
platform.h
sha1.h
sha256.h
sha384.h
sha512.h
'
SRCS='
sha.c
sha1.c
sha1_amiga.c
sha256.c
sha256_amiga.c
sha384.c
sha384_amiga.c
sha512.c
sha512_amiga.c
sha_amiga.c
sha_io.c
shatest.c
'
#################################################
SRCS1='
sha.c
sha1.c
sha256.c
sha384.c
sha512.c
sha_amiga.c
sha_io.c
'
SRCS2='
sha1.c
sha256.c
sha384.c
sha512.c
sha_io.c
shatest.c
'
SRCSS1='
sha1.c
sha1_amiga.c
sha_io.c
'
SRCSS256='
sha256.c
sha256_amiga.c
sha_io.c
'
SRCSS384='
sha384.c
sha384_amiga.c
sha_io.c
'
SRCSS512='
sha512.c
sha512_amiga.c
sha_io.c
'
#################################################
if [ -n "$1" ] && [ $1 = "help" ] ; then
echo "Usage: sh configure [AMIGA|AROS] [flags]"
echo "Example: sh configure AMIGA -mc68020"
exit
fi
if make -v 2>&1 | grep GNU > /dev/null 2>&1 ; then
echo "make is GNU make."
VALID=true
fi
if $VALID ; then
(
echo '# Portable Makefile generated by configure'
echo ''
echo 'all: sha sha1 sha256 sha384 sha512 test'
echo ''
if [ -n "$2" ] ; then
ARCH="$2 "
else
ARCH=""
fi
if [ -n "$1" ] && [ $1 = "AMIGA" ] ; then
echo 'CC = m68k-amigaos-gcc'
echo "CFLAGS = -O2 ${ARCH}-DAOS3 -noixemul -I. -Wall -Werror"
elif [ -n "$1" ] && [ $1 = "AROS" ] ; then
echo 'CC = gcc'
echo "CFLAGS = -O2 ${ARCH}-DAROS -I. -Wall -Werror"
else
echo "CFLAGS = -O2 ${ARCH}-Wall -Werror"
fi
echo ''
#################################################
for f in ${HDRS}
do
b=`basename $f .h`
i=`sed -n -e '/#include.*"/{
s/"$//
s/.*"//
p
}' $f | sort -u`
if [ "x${i}" != "x" ] ; then
echo "${b}.h: " ${i}
echo " touch ${b}.h"
echo
fi
done
l=""
for f in ${SRCS}
do
b=`basename $f .c`
i=`sed -n -e '/#include.*"/{
s/"$//
s/.*"//
p
}' $f | sort -u`
echo "${b}.o: ${b}.c" ${i}
echo
l="${l} ${b}.o"
done
#################################################
BIN1=""
for f in ${SRCS1}
do
BIN1="${BIN1} `basename $f .c`.o"
done
BIN2=""
for f in ${SRCS2}
do
BIN2="${BIN2} `basename $f .c`.o"
done
#################################################
BINS1=""
for f in ${SRCSS1}
do
BINS1="${BINS1} `basename $f .c`.o"
done
BINS256=""
for f in ${SRCSS256}
do
BINS256="${BINS256} `basename $f .c`.o"
done
BINS384=""
for f in ${SRCSS384}
do
BINS384="${BINS384} `basename $f .c`.o"
done
BINS512=""
for f in ${SRCSS512}
do
BINS512="${BINS512} `basename $f .c`.o"
done
#################################################
echo
echo "sha: ${BIN1}"
echo " \${CC} \${CFLAGS} -o sha ${BIN1}"
echo
echo "sha1: ${BINS1}"
echo " \${CC} \${CFLAGS} -o sha1 ${BINS1}"
echo
echo "sha256: ${BINS256}"
echo " \${CC} \${CFLAGS} -o sha256 ${BINS256}"
echo
echo "sha384: ${BINS384}"
echo " \${CC} \${CFLAGS} -o sha384 ${BINS384}"
echo
echo "sha512: ${BINS512}"
echo " \${CC} \${CFLAGS} -o sha512 ${BINS512}"
echo
echo "test: ${BIN2}"
echo " \${CC} \${CFLAGS} -o shatest ${BIN2}"
echo
echo "clean:"
echo " rm -f ${l} sha shatest sha1 sha256 sha384 sha512"
echo
echo "depend:"
echo " @echo Dependencies already done"
) > Makefile
echo "Makefile generated"
fi