Makefile 3.13 KB
Newer Older
1 2 3 4 5 6
PREFIX = /usr/local
EXEC_PREFIX = ${PREFIX}
LIBDIR = ${PREFIX}/lib
INCLUDEDIR = ${PREFIX}/include

LIBRESSL_VERSION = 1.0
7 8
LIBTLS_SOVERSION = 1
LIBTLS_FULLVERSION = 1.0.0
9 10 11 12 13 14

OPENSSL_CFLAGS = $(shell pkgconf openssl --cflags)
OPENSSL_LIBS = $(shell pkgconf openssl --libs)

CFLAGS = -Wall -Wno-pointer-sign -fPIC -DPIC -shared -include tls_compat.h -isystem ${LIBRESSL_SRCDIR}/include/compat ${OPENSSL_CFLAGS} -I ${LIBRESSL_SRCDIR}/include \
	-D__BEGIN_HIDDEN_DECLS= -D__END_HIDDEN_DECLS=
15
LDFLAGS = -fPIC -DPIC -shared -Wl,-soname,libtls-standalone.so.${LIBTLS_SOVERSION} ${OPENSSL_LIBS}
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37

SOURCES = \
	tls_compat.c				\
	${LIBRESSL_SRCDIR}/tls/tls.c		\
	${LIBRESSL_SRCDIR}/tls/tls_bio_cb.c	\
	${LIBRESSL_SRCDIR}/tls/tls_client.c	\
	${LIBRESSL_SRCDIR}/tls/tls_config.c	\
	${LIBRESSL_SRCDIR}/tls/tls_conninfo.c	\
	${LIBRESSL_SRCDIR}/tls/tls_keypair.c	\
	${LIBRESSL_SRCDIR}/tls/tls_ocsp.c	\
	${LIBRESSL_SRCDIR}/tls/tls_peer.c	\
	${LIBRESSL_SRCDIR}/tls/tls_server.c	\
	${LIBRESSL_SRCDIR}/tls/tls_util.c	\
	${LIBRESSL_SRCDIR}/tls/tls_verify.c	\
	${LIBRESSL_SRCDIR}/crypto/compat/arc4random.c		\
	${LIBRESSL_SRCDIR}/crypto/compat/arc4random_uniform.c	\
	${LIBRESSL_SRCDIR}/crypto/compat/freezero.c		\
	${LIBRESSL_SRCDIR}/crypto/compat/reallocarray.c		\
	${LIBRESSL_SRCDIR}/crypto/compat/timingsafe_memcmp.c

OBJECTS = ${SOURCES:.c=.o}

38
all: dumpconfig libtls-standalone.so.${LIBTLS_FULLVERSION} libtls-standalone.so.${LIBTLS_SOVERSION} libtls-standalone.pc
39 40 41 42 43 44 45 46 47 48

dumpconfig:
	@echo "Building with:"
	@echo "  LIBRESSL_SRCDIR = ${LIBRESSL_SRCDIR}"
	@echo "  OPENSSL_CFLAGS  = ${OPENSSL_CFLAGS}"
	@echo "  OPENSSL_LIBS    = ${OPENSSL_LIBS}"

.c.o:
	${CC} ${CFLAGS} -o $@ -c $<

49
libtls-standalone.so.${LIBTLS_SOVERSION}: libtls-standalone.so.${LIBTLS_FULLVERSION}
50 51
	ln -s $< $@

52
libtls-standalone.so.${LIBTLS_FULLVERSION}: ${OBJECTS}
53 54 55
	${CC} ${CFLAGS} ${LDFLAGS} -o $@ ${OBJECTS} ${OPENSSL_LIBS}

check: test_program
56
	LD_LIBRARY_PATH=$$PWD ./test_program
57 58

test_program: test_program.c
59
	${CC} -I${LIBRESSL_SRCDIR}/include -o $@ test_program.c ./libtls-standalone.so.${LIBTLS_FULLVERSION}
60 61 62

clean:
	rm -f ${OBJECTS}
63
	rm -f libtls-standalone.so.${LIBTLS_FULLVERSION} libtls-standalone.so.${LIBTLS_SOVERSION}
64 65 66
	rm -f test_program

install:
67 68 69
	install -D -m755 libtls-standalone.so.${LIBTLS_FULLVERSION} ${DESTDIR}${PREFIX}/lib/libtls-standalone.so.${LIBTLS_FULLVERSION}
	ln -sf libtls-standalone.so.${LIBTLS_FULLVERSION} ${DESTDIR}${PREFIX}/lib/libtls-standalone.so.${LIBTLS_SOVERSION}
	ln -sf libtls-standalone.so.${LIBTLS_FULLVERSION} ${DESTDIR}${PREFIX}/lib/libtls-standalone.so
70

71
	install -D -m644 ${LIBRESSL_SRCDIR}/include/tls.h ${DESTDIR}${PREFIX}/include/libtls-standalone/tls.h
72

73
	install -D -m644 libtls-standalone.pc ${DESTDIR}${PREFIX}/lib/pkgconfig/libtls-standalone.pc
74

75
libtls-standalone.pc: ${LIBRESSL_SRCDIR}/libtls.pc.in
76 77 78
	sed -e s:@prefix@:${PREFIX}:g \
	    -e s:@exec_prefix@:${EXEC_PREFIX}:g \
	    -e s:@libdir@:${LIBDIR}:g \
79 80
	    -e s:@includedir@:${INCLUDEDIR}/libtls-standalone:g \
	    -e s:@LIBS@:-ltls-standalone:g \
81 82
	    -e s:@PLATFORM_LDADD@::g \
	    -e s:@VERSION@:${LIBRESSL_VERSION}:g \
83 84
	    -e /^Libs:/s:-ltls:-ltls-standalone:g \
	    $< > libtls-standalone.pc
85 86

.DUMMY: check dumpconfig clean install