1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
|
#!/bin/sh
LANG=C
export LANG
(
(
echo "CC?=cc"
echo "CFLAGS+=-W -Wall -Os -fPIC -fwrapv -Icryptoint"
echo "LDFLAGS?="
echo "CPPFLAGS?="
echo
echo "DESTDIR?="
echo "PREFIX?=/usr/local"
echo
echo "INSTALL?=install"
echo
links='tinysshd-makekey tinysshd-printkey tinysshnoneauthd'
autoheaders=''
binaries=''
testcryptobinaries=''
objlib=''
objall=''
outfiles=''
for file in `ls -1`; do
ofile=`echo ${file} | sed 's/\.c$/.o/'`
hfile=`echo ${file} | sed 's/\.c$/.h/'`
case "${file}" in
randombytes\.c)
objall="${objall} ${ofile}"
;;
has*\.c)
autoheaders="${autoheaders} `echo ${file} | sed 's/\.c/.h/'`"
;;
test-*\.sh)
outfiles="${outfiles} `echo ${file} | sed 's/\.sh/.out/'`"
;;
test-crypto.c)
if grep '^int main(' "${file}" >/dev/null; then
testcryptobinaries="${testcryptobinaries} `echo ${file} | sed 's/\.c$//'`"
fi
objall="${objall} ${ofile}"
;;
*\.c)
if grep '^int main(' "${file}" >/dev/null; then
binaries="${binaries} `echo ${file} | sed 's/\.c$//'`"
else
objlib="${objlib} ${ofile}"
fi
objall="${objall} ${ofile}"
;;
*)
;;
esac
done
echo "LINKS=${links}"
echo
echo "`echo BINARIES=${binaries} | fold -s | sed 's/^/ /' | sed 's/^ BINARIES= /BINARIES=/' | sed 's/ $/ \\\\/'`"
echo
echo "`echo TESTCRYPTOBINARIES=${testcryptobinaries} | fold -s | sed 's/^/ /' | sed 's/^ TESTCRYPTOBINARIES= /TESTCRYPTOBINARIES=/' | sed 's/ $/ \\\\/'`"
echo
echo "`echo OBJLIB=${objlib} | fold -s | sed 's/^/ /' | sed 's/^ OBJLIB= /OBJLIB=/' | sed 's/ $/ \\\\/'`"
echo
echo "`echo OBJALL=${objall} | fold -s | sed 's/^/ /' | sed 's/^ OBJALL= /OBJALL=/' | sed 's/ $/ \\\\/'`"
echo
echo "`echo AUTOHEADERS=${autoheaders} | fold -s | sed 's/^/ /' | sed 's/^ AUTOHEADERS= /AUTOHEADERS=/' | sed 's/ $/ \\\\/'`"
echo
echo "`echo TESTOUT=${outfiles} | fold -s | sed 's/^/ /' | sed 's/^ TESTOUT= /TESTOUT=/' | sed 's/ $/ \\\\/'`"
echo
echo "all: \$(AUTOHEADERS) \$(BINARIES) \$(LINKS)"
echo
touch ${autoheaders}
for ofile in ${objall}; do
(
cfile=`echo ${ofile} | sed 's/\.o/.c/'`
gcc -MM -Icryptoint "${cfile}"
echo " \$(CC) \$(CFLAGS) \$(CPPFLAGS) -c ${cfile}"
echo
)
done
rm -f ${autoheaders}
for file in ${binaries}; do
ofile="${file}.o"
echo "${file}: ${ofile} \$(OBJLIB) randombytes.o libs"
echo " \$(CC) \$(CFLAGS) \$(CPPFLAGS) -o ${file} ${ofile} \\"
echo " \$(OBJLIB) \$(LDFLAGS) \`cat libs\`" randombytes.o
echo
done
echo
for file in ${testcryptobinaries}; do
ofile="${file}.o"
echo "${file}: ${ofile} \$(OBJLIB) libs"
echo " \$(CC) \$(CFLAGS) \$(CPPFLAGS) -o ${file} ${ofile} \\"
echo " \$(OBJLIB) \$(LDFLAGS) \`cat libs\`"
echo
done
echo
for hfile in ${autoheaders}; do
cfile=`echo ${hfile} | sed 's/\.h/.c/'`
lfile=`echo ${cfile} | sed 's/\.c/.log/'`
touch "${hfile}"
echo "${hfile}: tryfeature.sh ${cfile} libs"
echo " env CC=\"\$(CC)\" CFLAGS=\"\$(CFLAGS)\" LDFLAGS=\"\$(LDFLAGS) \`cat libs\`\" \\"
echo " ./tryfeature.sh ${cfile} >${hfile} 2>${lfile}"
echo " cat ${hfile}"
echo
done
for outfile in ${outfiles}; do
expfile=`echo ${outfile} | sed 's/\.out/.exp/'`
shfile=`echo ${outfile} | sed 's/\.out/.sh/'`
echo "${outfile}: \$(BINARIES) \$(TESTCRYPTOBINARIES) \$(LINKS) runtest.sh ${shfile} ${expfile}"
echo " sh runtest.sh ${shfile} ${outfile} ${expfile}"
echo
done
echo "test: \$(TESTOUT)"
echo
echo "libs: trylibs.sh"
echo " env CC=\"\$(CC)\" ./trylibs.sh -lsocket -lnsl -lutil -lrandombytes -l25519 -l1305 -lntruprime >libs 2>libs.log"
echo " cat libs"
echo
echo "tinysshd-makekey: tinysshd"
echo " rm -f tinysshd-makekey"
echo " ln -s tinysshd tinysshd-makekey"
echo
echo "tinysshd-printkey: tinysshd"
echo " rm -f tinysshd-printkey"
echo " ln -s tinysshd tinysshd-printkey"
echo
echo "tinysshnoneauthd: tinysshd"
echo " rm -f tinysshnoneauthd"
echo " ln -s tinysshd tinysshnoneauthd"
echo
echo "install: \$(BINARIES) \$(LINKS)"
echo " mkdir -p \$(DESTDIR)\$(PREFIX)/sbin"
echo " mkdir -p \$(DESTDIR)\$(PREFIX)/share/man/man8"
echo " \$(INSTALL) -m 0755 tinysshd \$(DESTDIR)\$(PREFIX)/sbin/tinysshd"
echo " \$(INSTALL) -m 0755 tinysshd-makekey \$(DESTDIR)\$(PREFIX)/sbin/tinysshd-makekey"
echo " \$(INSTALL) -m 0755 tinysshd-printkey \$(DESTDIR)\$(PREFIX)/sbin/tinysshd-printkey"
echo " \$(INSTALL) -m 0755 tinysshnoneauthd \$(DESTDIR)\$(PREFIX)/sbin/tinysshnoneauthd"
echo " \$(INSTALL) -m 0644 man/tinysshd.8 \$(DESTDIR)\$(PREFIX)/share/man/man8/tinysshd.8"
echo " \$(INSTALL) -m 0644 man/tinysshd-makekey.8 \$(DESTDIR)\$(PREFIX)/share/man/man8/tinysshd-makekey.8"
echo " \$(INSTALL) -m 0644 man/tinysshd-printkey.8 \$(DESTDIR)\$(PREFIX)/share/man/man8/tinysshd-printkey.8"
echo " \$(INSTALL) -m 0644 man/tinysshnoneauthd.8 \$(DESTDIR)\$(PREFIX)/share/man/man8/tinysshnoneauthd.8"
echo
echo "clean:"
echo " rm -f *.log libs \$(OBJLIB) \$(OBJALL) \$(BINARIES) \$(TESTCRYPTOBINARIES) \$(LINKS) \$(AUTOHEADERS) \$(TESTOUT)"
echo
) > Makefile
)
|