aboutsummaryrefslogblamecommitdiff
path: root/GNUmakefile
blob: aed7b4af02aed491be05d866d343b745b27b4db9 (plain) (tree)


















































































                                                                                                          
# Cryptech project makefile for Cryptlib.  This is a work in progress.

# The one thing that must be configured here is which Hardware
# Adaption Layer ("HAL") to build into Cryptlib.  Due to the need to
# support different Cryptech configurations on different boards, it's
# not really possible to provide a single HAL which supports all
# Cryptech configurations in a sane way, so you have to pick one.
# This makefile provides a default, but you can override it by
# providing a value for the CRYPTECH_HAL makefile variable on the
# command line, or by setting the CRYPTECH_HAL environment variable
# (explicit argument overrides environment variable, see GNU make
# documentation for details).

ifndef CRYPTECH_HAL
  CRYPTECH_HAL := src/cryptech_novena_i2c_simple.c
endif

# Notes on the option settings we use when building cryptlib:
#
# - Python extension modules need to be position-independent code.  We
#   could handle this by building cryptlib as a shared library, but
#   for the moment it's simpler to force even the static library to
#   use position independent code.  Works with gcc and clang, anyway,
#   which are the only compilers we care about at the moment.
#
# - Point of the exercise is a hardware device, and we want the full
#   set of SHA-2 digests.
#
# - See config.h for other options we might want to add here.  In
#   particular, USE_ECDH, USE_ECDSA, and USE_GCM all touch on subjects
#   that came up during the early Cryptech design discussions.

################################################################

# From here down is not intended to be user-servicable.  Tinker to
# your heart's content, but don't complain if it breaks.

LIB = build/libcl.a

PYTHONPATH = $(firstword $(wildcard build/bindings/build/lib.*))

all: build/makefile.ready
	cd build; ${MAKE}
	@${MAKE} python-bindings

clean:
	rm -rf build

build/makefile.ready: GNUmakefile dist/cl342.zip
	rm -rf build
	mkdir build
	cd build; unzip -a ../dist/cl342.zip
	sed <build/makefile >build/makefile.cryptech \
		-e 's=device/hw_dummy=../$(basename ${CRYPTECH_HAL})=g' \
		-e 's=hw_dummy=$(notdir $(basename ${CRYPTECH_HAL}))=g' \
		-e '/^CFLAGS/s=$$= -fPIC -DUSE_SHA2_EXT -DUSE_HARDWARE -DUSE_DEVICES='
	mv build/makefile.cryptech build/makefile
	touch $@

ifeq (,${PYTHONPATH})

  python-bindings:
	cd build/bindings; python setup.py build

else

  python-bindings: ${PYTHONPATH}/cryptlib_py.so

  ${PYTHONPATH}/cryptlib_py.so: ${LIB}
	cd build/bindings; python setup.py build --force

endif

test: all
	@${MAKE} run-tests

run-tests:
	for script in tests/*.py; do echo Running $$script; PYTHONPATH=${PYTHONPATH} python $$script; done

tags: TAGS

TAGS: build/makefile.ready
	find src build -type f -name '*.[ch]' | etags -