- Move nacl-prepare-sources to nacl.

- Alter nacl-prepare-sources to do some of what nacl-jni-prep did.
- Commit nacl.h and sources.mk created by nacl-prepare-sources for
  nacl-20110221. This lets you build the Android version out of the
  box. The native version can still be built after 'do' script is
  run (necessary to build the libraries and create includes).
This commit is contained in:
Daniel O'Connor 2012-02-25 13:15:19 +10:30
parent 14a3560786
commit 6102dc0ccb
6 changed files with 3 additions and 246 deletions

View File

@ -1,47 +0,0 @@
# Fetch latest version of source as recommended by nacl installation page
[ -e nacl-source.tar.bz2 ] || \
`wget -q -O - http://nacl.cr.yp.to/install.html | grep wget | sed -e 's/^ *//g' -e 's/^wget /wget -O nacl-source.tar.bz2 /'`
# Extract tarball
bzip2 -d nacl-source.tar.bz2
mkdir nacl-source
cd nacl-source
tar xvf ../nacl-source.tar
nacldir=`echo *`
cd ${nacldir}
# Now build the actual compilable sources using our
# hacked version of NaCl's 'do' script
cp ../../nacl-prepare-sources .
chmod 755 nacl-prepare-sources
./nacl-prepare-sources
cd nacl-source
ls -1 *.h | grep -v mphlr.h | sed -e 's,^,#include ",' -e 's,$,",' > nacl.h
ls -1 *.h >../../../nacl-sources.list
mv *.h ../../../
cd ../../../
rm nacl-source/*/nacl-source/*/measure.c
echo `ls -1 nacl-source/*/nacl-source/*/*.c` >>nacl-sources.list
# Now build Android.mk with the extra .c files listed
sources=`echo nacl-source/*/nacl-source/*/*.c`
echo sed -e 's,LOCAL_SRC_FILES:= \\,LOCAL_SRC_FILES:= '"${sources}"' \\,'
cat Android-without-NaCl.mk | sed -e 's,LOCAL_SRC_FILES:= \\,LOCAL_SRC_FILES:= '"${sources}"' \\,' > Android.mk
if [ ! -e libsqlite.so ]; then
# Copy libsqlite.so from /system/lib/ on an android phone.
phonecount=`adb devices | wc -l`
if [ ${phonecount} -lt 3 ]; then
echo "ERROR: You MUST connect and Android phone with USB debugging enabled"
echo " so that I can copy /system/lib/libsqlite.so to link against."
exit 3
fi
dev=`adb devices | awk '($1>"") { n=$1;} END { print n;}'`
echo "Copying /system/lib/libsqlite.so from device $dev"
adb -s $dev pull /system/lib/libsqlite.so
fi

View File

@ -1,150 +0,0 @@
#!/bin/sh
# Prepare NaCl source files and include files for compilation with Serval DNA,
# possibly using the Android NDK to produce a JNI compatible library.
# Android and JNI complicate matters substantially, and prevent us just building
# the .a the way that NaCl was intended. The cross compilation environment
# will play havoc for a start.
# Derived from:
# nacl/do
# D. J. Bernstein
# Public domain.
version=`cat version`
project=nacl
work=nacl-source
# and work around bug in GNU sort
LANG=C
export LANG
rm -rf "$work"
mkdir -p "$work"
# PGS - Create a couple of missing files needed
cp randombytes/devurandom.h ${work}/randombytes.h
cat <<EOF > ${work}/crypto_uint32.h
#ifndef CRYPTO_UINT32
#define CRYPTO_UINT32
typedef unsigned int crypto_uint32;
#endif
EOF
# loop over operations
cat OPERATIONS \
| while read o
do
[ -d "$o" ] || continue
selected=''
[ -f "$o/selected" ] && selected=`cat "$o/selected"`
# for each operation, loop over primitives
ls "$o" \
| sort \
| while read p
do
[ -d "$o/$p" ] || continue
expectedchecksum=''
[ -f "$o/$p/checksum" ] && expectedchecksum=`cat "$o/$p/checksum"`
op="${o}_${p}"
startdate=`date +%Y%m%d`
# for each operation primitive abi, loop over implementations
find "$o/$p" -follow -name "api.h" \
| grep /ref/ \
| sort \
| while read doth
do
implementationdir=`dirname $doth`
opi=`echo "$implementationdir" | tr ./- ___`
echo "=== `date` === $abi $implementationdir"
cfiles=`ls "$implementationdir" | grep '\.c$' || :`
sfiles=`ls "$implementationdir" | grep '\.[sS]$' || :`
cppfiles=`ls "$o" | grep '\.cpp$' || :`
mkdir -p "${work}/${opi}"
cp -p "$o"/*.c "$work/${opi}"
cp -pr "$implementationdir"/* "$work/${opi}"
rm ${work}/${opi}/measure.c
rm ${work}/${opi}/try.c
cp -p MACROS "$work/MACROS"
cp -p PROTOTYPES.c "$work/PROTOTYPES.c"
cp -p PROTOTYPES.cpp "$work/PROTOTYPES.cpp"
cp $implementationdir/api.h "$work"
(
cd "$work"
(
echo "#ifndef ${o}_H"
echo "#define ${o}_H"
echo ""
echo "#include \"${op}.h\""
echo ""
egrep "${o}"'$|'"${o}"'\(|'"${o}"'_' < MACROS \
| sed "s/$o/$op/" | while read mop
do
echo "#define ${mop} ${mop}" | sed "s/$op/$o/"
echo "/* CHEESEBURGER ${mop} */"
done
echo "#define ${o}_PRIMITIVE \"${p}\""
echo "#define ${o}_IMPLEMENTATION ${op}_IMPLEMENTATION"
echo "#define ${o}_VERSION ${op}_VERSION"
echo ""
echo "#endif"
) > "${opi}/$o.h"
(
echo "#ifndef ${op}_H"
echo "#define ${op}_H"
echo ""
sed 's/[ ]CRYPTO_/ '"${opi}"'_/g' < api.h
echo '#ifdef __cplusplus'
echo '#include <string>'
egrep "${o}"'$|'"${o}"'\(|'"${o}"'_' < PROTOTYPES.cpp \
| sed "s/$o/$opi/"
echo 'extern "C" {'
echo '#endif'
egrep "${o}"'$|'"${o}"'\(|'"${o}"'_' < PROTOTYPES.c \
| sed "s/$o/$opi/"
echo '#ifdef __cplusplus'
echo '}'
echo '#endif'
echo ""
egrep "${o}"'$|'"${o}"'\(|'"${o}"'_' < MACROS \
| sed "s/$o/$opi/" | while read mopi
do
echo "#define ${mopi} ${mopi}" | sed "s/$opi/$op/"
echo "/* POTATO ${mopi} $opi $op */"
done
echo "#define ${op}_IMPLEMENTATION \"${implementationdir}\""
echo "#ifndef ${opi}_VERSION"
echo "#define ${opi}_VERSION \"-\""
echo "#endif"
echo "#define ${op}_VERSION ${opi}_VERSION"
echo ""
echo "#endif"
) > "$op.h"
cd ..
)
done
echo "=== `date` === $abi $o/$p measuring"
done
done
# PGS - Remove testing files that we don't care about.
rm ${work}/measure.c ${work}/try.c
echo "=== `date` === finishing"

Binary file not shown.

View File

@ -1,69 +1,24 @@
#include <api.h> #include <api.h>
#include <crypto_auth_hmacsha256.h> #include <crypto_auth_hmacsha256.h>
#include <crypto_auth_hmacsha256_ref/api.h>
#include <crypto_auth_hmacsha256_ref/crypto_auth.h>
#include <crypto_auth_hmacsha512256.h> #include <crypto_auth_hmacsha512256.h>
#include <crypto_auth_hmacsha512256_ref/api.h>
#include <crypto_auth_hmacsha512256_ref/crypto_auth.h>
#include <crypto_box_curve25519xsalsa20poly1305.h> #include <crypto_box_curve25519xsalsa20poly1305.h>
#include <crypto_box_curve25519xsalsa20poly1305_ref/api.h>
#include <crypto_box_curve25519xsalsa20poly1305_ref/crypto_box.h>
#include <crypto_core_hsalsa20.h> #include <crypto_core_hsalsa20.h>
#include <crypto_core_hsalsa20_ref/api.h>
#include <crypto_core_hsalsa20_ref/crypto_core.h>
#include <crypto_core_salsa20.h> #include <crypto_core_salsa20.h>
#include <crypto_core_salsa2012.h> #include <crypto_core_salsa2012.h>
#include <crypto_core_salsa2012_ref/api.h>
#include <crypto_core_salsa2012_ref/crypto_core.h>
#include <crypto_core_salsa208.h> #include <crypto_core_salsa208.h>
#include <crypto_core_salsa208_ref/api.h>
#include <crypto_core_salsa208_ref/crypto_core.h>
#include <crypto_core_salsa20_ref/api.h>
#include <crypto_core_salsa20_ref/crypto_core.h>
#include <crypto_hash_sha256.h> #include <crypto_hash_sha256.h>
#include <crypto_hash_sha256_ref/api.h>
#include <crypto_hash_sha256_ref/crypto_hash.h>
#include <crypto_hash_sha512.h> #include <crypto_hash_sha512.h>
#include <crypto_hash_sha512_ref/api.h>
#include <crypto_hash_sha512_ref/crypto_hash.h>
#include <crypto_hashblocks_sha256.h> #include <crypto_hashblocks_sha256.h>
#include <crypto_hashblocks_sha256_ref/api.h>
#include <crypto_hashblocks_sha256_ref/crypto_hashblocks.h>
#include <crypto_hashblocks_sha512.h> #include <crypto_hashblocks_sha512.h>
#include <crypto_hashblocks_sha512_ref/api.h>
#include <crypto_hashblocks_sha512_ref/crypto_hashblocks.h>
#include <crypto_onetimeauth_poly1305.h> #include <crypto_onetimeauth_poly1305.h>
#include <crypto_onetimeauth_poly1305_ref/api.h>
#include <crypto_onetimeauth_poly1305_ref/crypto_onetimeauth.h>
#include <crypto_scalarmult_curve25519.h> #include <crypto_scalarmult_curve25519.h>
#include <crypto_scalarmult_curve25519_ref/api.h>
#include <crypto_scalarmult_curve25519_ref/crypto_scalarmult.h>
#include <crypto_secretbox_xsalsa20poly1305.h> #include <crypto_secretbox_xsalsa20poly1305.h>
#include <crypto_secretbox_xsalsa20poly1305_ref/api.h>
#include <crypto_secretbox_xsalsa20poly1305_ref/crypto_secretbox.h>
#include <crypto_sign_edwards25519sha512batch.h> #include <crypto_sign_edwards25519sha512batch.h>
#include <crypto_sign_edwards25519sha512batch_ref/api.h>
#include <crypto_sign_edwards25519sha512batch_ref/crypto_sign.h>
#include <crypto_sign_edwards25519sha512batch_ref/fe25519.h>
#include <crypto_sign_edwards25519sha512batch_ref/ge25519.h>
#include <crypto_sign_edwards25519sha512batch_ref/sc25519.h>
#include <crypto_stream_salsa20.h> #include <crypto_stream_salsa20.h>
#include <crypto_stream_salsa2012.h> #include <crypto_stream_salsa2012.h>
#include <crypto_stream_salsa2012_ref/api.h>
#include <crypto_stream_salsa2012_ref/crypto_stream.h>
#include <crypto_stream_salsa208.h> #include <crypto_stream_salsa208.h>
#include <crypto_stream_salsa208_ref/api.h>
#include <crypto_stream_salsa208_ref/crypto_stream.h>
#include <crypto_stream_salsa20_ref/api.h>
#include <crypto_stream_salsa20_ref/crypto_stream.h>
#include <crypto_stream_xsalsa20.h> #include <crypto_stream_xsalsa20.h>
#include <crypto_stream_xsalsa20_ref/api.h>
#include <crypto_stream_xsalsa20_ref/crypto_stream.h>
#include <crypto_uint32.h> #include <crypto_uint32.h>
#include <crypto_verify_16.h> #include <crypto_verify_16.h>
#include <crypto_verify_16_ref/api.h>
#include <crypto_verify_16_ref/crypto_verify.h>
#include <crypto_verify_32.h> #include <crypto_verify_32.h>
#include <crypto_verify_32_ref/api.h>
#include <crypto_verify_32_ref/crypto_verify.h>
#include <randombytes.h> #include <randombytes.h>

View File

@ -1,2 +1,2 @@
NACL_SOURCES := \ NACL_SOURCES := \
${NACL_BASE}/crypto_auth_hmacsha256_ref/hmac.c ${NACL_BASE}/crypto_auth_hmacsha256_ref/verify.c ${NACL_BASE}/crypto_auth_hmacsha512256_ref/hmac.c ${NACL_BASE}/crypto_auth_hmacsha512256_ref/verify.c ${NACL_BASE}/crypto_box_curve25519xsalsa20poly1305_ref/after.c ${NACL_BASE}/crypto_box_curve25519xsalsa20poly1305_ref/before.c ${NACL_BASE}/crypto_box_curve25519xsalsa20poly1305_ref/box.c ${NACL_BASE}/crypto_box_curve25519xsalsa20poly1305_ref/keypair.c ${NACL_BASE}/crypto_core_hsalsa20_ref/core.c ${NACL_BASE}/crypto_core_salsa2012_ref/core.c ${NACL_BASE}/crypto_core_salsa208_ref/core.c ${NACL_BASE}/crypto_core_salsa20_ref/core.c ${NACL_BASE}/crypto_hash_sha256_ref/hash.c ${NACL_BASE}/crypto_hash_sha512_ref/hash.c ${NACL_BASE}/crypto_hashblocks_sha256_ref/blocks.c ${NACL_BASE}/crypto_hashblocks_sha512_ref/blocks.c ${NACL_BASE}/crypto_onetimeauth_poly1305_ref/auth.c ${NACL_BASE}/crypto_onetimeauth_poly1305_ref/verify.c ${NACL_BASE}/crypto_scalarmult_curve25519_ref/base.c ${NACL_BASE}/crypto_scalarmult_curve25519_ref/smult.c ${NACL_BASE}/crypto_secretbox_xsalsa20poly1305_ref/box.c ${NACL_BASE}/crypto_sign_edwards25519sha512batch_ref/fe25519.c ${NACL_BASE}/crypto_sign_edwards25519sha512batch_ref/ge25519.c ${NACL_BASE}/crypto_sign_edwards25519sha512batch_ref/sc25519.c ${NACL_BASE}/crypto_sign_edwards25519sha512batch_ref/sign.c ${NACL_BASE}/crypto_stream_salsa2012_ref/stream.c ${NACL_BASE}/crypto_stream_salsa2012_ref/xor.c ${NACL_BASE}/crypto_stream_salsa208_ref/stream.c ${NACL_BASE}/crypto_stream_salsa208_ref/xor.c ${NACL_BASE}/crypto_stream_salsa20_ref/stream.c ${NACL_BASE}/crypto_stream_salsa20_ref/xor.c ${NACL_BASE}/crypto_stream_xsalsa20_ref/stream.c ${NACL_BASE}/crypto_stream_xsalsa20_ref/xor.c ${NACL_BASE}/crypto_verify_16_ref/verify.c ${NACL_BASE}/crypto_verify_32_ref/verify.c $(NACL_BASE)/crypto_auth_hmacsha256_ref/hmac.c $(NACL_BASE)/crypto_auth_hmacsha256_ref/verify.c $(NACL_BASE)/crypto_auth_hmacsha512256_ref/hmac.c $(NACL_BASE)/crypto_auth_hmacsha512256_ref/verify.c $(NACL_BASE)/crypto_box_curve25519xsalsa20poly1305_ref/after.c $(NACL_BASE)/crypto_box_curve25519xsalsa20poly1305_ref/before.c $(NACL_BASE)/crypto_box_curve25519xsalsa20poly1305_ref/box.c $(NACL_BASE)/crypto_box_curve25519xsalsa20poly1305_ref/keypair.c $(NACL_BASE)/crypto_core_hsalsa20_ref/core.c $(NACL_BASE)/crypto_core_salsa2012_ref/core.c $(NACL_BASE)/crypto_core_salsa208_ref/core.c $(NACL_BASE)/crypto_core_salsa20_ref/core.c $(NACL_BASE)/crypto_hash_sha256_ref/hash.c $(NACL_BASE)/crypto_hash_sha512_ref/hash.c $(NACL_BASE)/crypto_hashblocks_sha256_ref/blocks.c $(NACL_BASE)/crypto_hashblocks_sha512_ref/blocks.c $(NACL_BASE)/crypto_onetimeauth_poly1305_ref/auth.c $(NACL_BASE)/crypto_onetimeauth_poly1305_ref/verify.c $(NACL_BASE)/crypto_scalarmult_curve25519_ref/base.c $(NACL_BASE)/crypto_scalarmult_curve25519_ref/smult.c $(NACL_BASE)/crypto_secretbox_xsalsa20poly1305_ref/box.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/fe25519.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/ge25519.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/sc25519.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/sign.c $(NACL_BASE)/crypto_stream_salsa2012_ref/stream.c $(NACL_BASE)/crypto_stream_salsa2012_ref/xor.c $(NACL_BASE)/crypto_stream_salsa208_ref/stream.c $(NACL_BASE)/crypto_stream_salsa208_ref/xor.c $(NACL_BASE)/crypto_stream_salsa20_ref/stream.c $(NACL_BASE)/crypto_stream_salsa20_ref/xor.c $(NACL_BASE)/crypto_stream_xsalsa20_ref/stream.c $(NACL_BASE)/crypto_stream_xsalsa20_ref/xor.c $(NACL_BASE)/crypto_verify_16_ref/verify.c $(NACL_BASE)/crypto_verify_32_ref/verify.c

View File

@ -152,10 +152,9 @@ do
rm -f ${work}/measure.c ${work}/try.c rm -f ${work}/measure.c ${work}/try.c
# DOC - Create nacl.h for lazy programmers # DOC - Create nacl.h for lazy programmers
(cd ${work} ; find . -name \*.h -a \! -name mphlr.h -a \! -name nacl.h | sed -Ee 's,\./(.*),#include <\1>,') >${work}/nacl.h (cd ${work} ; find . -maxdepth 1 -name \*.h -a \! -name mphlr.h -a \! -name nacl.h | sed -Ee 's,\./(.*),#include <\1>,') >${work}/nacl.h
# DOC - Create source list suitable for inclusion into a makefile # DOC - Create source list suitable for inclusion into a makefile
echo "NACL_SOURCES := \\" >${work}/sources.mk echo "NACL_SOURCES := \\" >${work}/sources.mk
(cd ${work} ; find . -mindepth 2 -name \*.c | sed -Ee 's,\./(.*),${NACL_BASE}/\1,' | sort | xargs echo) >>${work}/sources.mk (cd ${work} ; find . -mindepth 2 -name \*.c | sed -Ee 's,\./(.*),$(NACL_BASE)/\1,' | sort | xargs echo ) >>${work}/sources.mk
echo "=== `date` === finishing" echo "=== `date` === finishing"