Skip to content

Commit abe584f

Browse files
committed
build - move closer to autotools style
1 parent 13ff0a1 commit abe584f

9 files changed

+231
-211
lines changed

.travis.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ script:
1111
- "./build-x86-64.sh"
1212
before_deploy:
1313
- mkdir -p $TRAVIS_BUILD_DIR/tls-scan/man/man1
14-
- cp $TRAVIS_BUILD_DIR/ts-build-root/bin/tls-scan $TRAVIS_BUILD_DIR/tls-scan/tls-scan
15-
- cp $TRAVIS_BUILD_DIR/ts-build-root/man/man1/tls-scan.1.gz $TRAVIS_BUILD_DIR/tls-scan/man/man1/tls-scan.1.gz
16-
- cp $TRAVIS_BUILD_DIR/ts-build-root/etc/tls-scan/ca-bundle.crt $TRAVIS_BUILD_DIR/tls-scan/ca-bundle.crt
14+
- cp $TRAVIS_BUILD_DIR/build-root/bin/tls-scan $TRAVIS_BUILD_DIR/tls-scan/tls-scan
15+
- cp $TRAVIS_BUILD_DIR/build-root/man/man1/tls-scan.1.gz $TRAVIS_BUILD_DIR/tls-scan/man/man1/tls-scan.1.gz
16+
- cp $TRAVIS_BUILD_DIR/build-root/etc/tls-scan/ca-bundle.crt $TRAVIS_BUILD_DIR/tls-scan/ca-bundle.crt
1717
- tar -zcvf tls-scan-${TRAVIS_OS_NAME}.tar.gz ./tls-scan/
1818
deploy:
1919
provider: releases

Makefile

-56
This file was deleted.

Makefile.am

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Build the library in the hand subdirectory first.
2+
3+
# Include hand's header when compiling this directory.
4+
#AM_CPPFLAGS = -I$(srcdir)/third-party/zlib/include
5+
6+
# link with the hand library.
7+
#arm_LDADD = hand/libhand.a
8+
9+
bin_PROGRAMS = tls-scan
10+
tls_scan_SOURCES = main.c common.c cert-parser.c gnutls13.c proto-adapters.c
11+
12+
#SUBDIRS = $(subdirs) $(subdirs_extra) openssl-1.0.2-chacha
13+
14+
15+
TS_VERSION = $(shell grep -m 1 Version $(top_srcdir)/CHANGELOG | awk '{print $$2}')
16+
TS_BUILD_DATE = $(shell date '+%Y-%m-%d')
17+
TS_OS = $(shell uname -s)
18+
AM_CPPFLAGS = -I$(top_srcdir)/include -I build-root/include -I build-root/include -Wall -Wundef -Wshadow -Wunreachable-code -Wswitch-default -Wcast-align -pedantic -g -std=c99 -D_GNU_SOURCE -DTS_VERSION=\"$(TS_VERSION)\" -DTS_BUILD_DATE=\"$(TS_BUILD_DATE)\" -DTS_OS=\"$(TS_OS)\"
19+
20+
LDADD = build-root/lib/libssl.a build-root/lib/libcrypto.a build-root/lib/libevent.a build-root/lib/libevent_openssl.a build-root/lib/libgnutls.a build-root/lib/libhogweed.a build-root/lib/libnettle.a -ldl
21+
22+
if LINUX
23+
LDADD += build-root/lib/libz.a -lrt
24+
endif
25+
26+
if DARWIN
27+
AM_LDFLAGS = -lz -framework Security -framework CoreFoundation
28+
endif
29+
#ifeq ($(TS_OS),Darwin)
30+
#AM_LDFLAGS += -lz -framework Security -framework CoreFoundation
31+
#end
32+
33+
34+
myconfdir = $(sysconfdir)/tls-scan
35+
myconf_DATA = ca-bundle.crt
36+
man1_MANS = man/tls-scan.1
37+
EXTRA_DIST = build-x86-64.sh
38+
39+

README.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Linux and OSX: [https://github.com/prbinu/tls-scan/releases/latest](https://gith
3232

3333
### Build From Source
3434

35-
All you need is [`build-x86-64.sh`](https://github.com/prbinu/tls-scan/blob/master/build-x86-64.sh). This script pulls `tls-scan`, its dependent packages - PeterMosmans [`openssl`](https://github.com/PeterMosmans/openssl), [`libevent`](https://github.com/libevent/libevent) and [GnuTLS](https://gitlab.com/gnutls/gnutls/), and build those from the scratch. Since the openssl we use is different from stock openssl, it is linked statically to tls-scan program. The build can take approximately twenty minutes to complete.
35+
All you need is [`build-x86-64.sh`](https://github.com/prbinu/tls-scan/blob/master/build-x86-64.sh). This script pulls dependent packages - PeterMosmans [`openssl`](https://github.com/PeterMosmans/openssl), [`libevent`](https://github.com/libevent/libevent) and [GnuTLS](https://gitlab.com/gnutls/gnutls/), and build those from the scratch. Since the openssl we use is different from stock openssl, it is linked statically to tls-scan program. The build can take approximately twenty minutes to complete.
3636

3737
*Build Pre-requisites* :
3838

@@ -47,15 +47,17 @@ All you need is [`build-x86-64.sh`](https://github.com/prbinu/tls-scan/blob/mast
4747
*Build* :
4848

4949
```sh
50+
% git clone https://github.com/prbinu/tls-scan.git
51+
% cd tls-scan
5052
% ./build-x86-64.sh
5153
```
5254

53-
The newly built tls-scan binary can be found at `./ts-build-root/bin`
55+
The newly built tls-scan binary can be found at `./build-root/bin`. build-x86-64.sh is a wrapper script that calls `./bootstrap.sh` to build all dependent packages. bootstrap.sh also executes the `autoreconf -i` command to generate `configure` file. Subsequently it calles the standard `./configure`, `make && make install`.
5456

5557
*Test* :
5658

5759
```sh
58-
% cd ts-build-root/bin
60+
% cd build-root/bin
5961
% ./tls-scan --connect=yahoo.com --cacert=../etc/tls-scan/ca-bundle.crt --pretty
6062
```
6163

@@ -68,10 +70,12 @@ If you do not have the pre-requisite packages, you can easily install those pack
6870
*Build* :
6971

7072
```sh
73+
% git clone https://github.com/prbinu/tls-scan.git
74+
% cd tls-scan
7175
% ./build-x86-64.sh
7276
```
7377

74-
The tls-scan binary can be found at `./ts-build-root/bin`. Another (easy) option is to use our Docker image to build and run `tls-scan` on OSX.
78+
The tls-scan binary can be found at `./build-root/bin`. Another (easy) option is to use our Docker image to build and run `tls-scan` on OSX.
7579

7680
### Docker
7781

bootstrap.sh

+140
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
#!/bin/bash
2+
# Environment variables
3+
# TS_BUILDROOT : Build root directory. Default to current working directory
4+
# TS_INSTALLDIR : Installation directory. Default to ${TS_BUILDROOT}
5+
#
6+
echo " "
7+
echo " IMPORTANT NOTICE"
8+
echo " Build Pre-requisites :"
9+
echo " "
10+
echo " gcc"
11+
echo " autoconf"
12+
echo " automake"
13+
echo " libtool"
14+
echo " pkg-config"
15+
echo "Make sure you have these packages installed before you proceed with tls-scan build"
16+
echo "continue in a moment ..."
17+
sleep 10
18+
19+
set -e
20+
CD=`pwd`
21+
OS=`uname`
22+
23+
if [ "${OS}" != "Darwin" ] && [ "${OS}" != "Linux" ]; then
24+
echo "Error: ${OS} is not a currently supported platform."
25+
exit 1
26+
fi
27+
28+
[[ -z "${TS_BUILDROOT}" ]] && BUILDDIR="${CD}" || BUILDDIR="${TS_BUILDROOT}"
29+
30+
echo ">>> Build DIR: ${BUILDDIR}"
31+
BUILDDIR=${BUILDDIR}/build-root
32+
33+
# remove build dirs
34+
test -d ${BUILDDIR}/build && rm -rf ${BUILDDIR}/build/*
35+
36+
37+
test -z ${BUILDDIR} || /bin/mkdir -p ${BUILDDIR}
38+
test -z ${BUILDDIR}/downloads || /bin/mkdir -p ${BUILDDIR}/downloads
39+
test -z ${BUILDDIR}/build || /bin/mkdir -p ${BUILDDIR}/build
40+
41+
[[ -z "${TS_INSTALLDIR}" ]] && OUTDIR="${BUILDDIR}" || OUTDIR="${TS_INSTALLDIR}"
42+
43+
echo ">>> Install DIR: ${OUTDIR}"
44+
export PKG_CONFIG_PATH=${OUTDIR}/lib/pkgconfig
45+
46+
OPENSSL_VERSION="1.0.2-chacha"
47+
LIBEVENT_VERSION="2.1.8-stable"
48+
ZLIB_VERSION="zlib-1.2.11"
49+
50+
FILE="${BUILDDIR}/downloads/${OPENSSL_VERSION}.zip"
51+
if [ ! -f $FILE ]; then
52+
echo "Downloading $FILE.."
53+
cd ${BUILDDIR}/downloads
54+
curl -OL https://github.com/PeterMosmans/openssl/archive/${OPENSSL_VERSION}.zip
55+
fi
56+
57+
cd ${BUILDDIR}/build
58+
unzip ${BUILDDIR}/downloads/${OPENSSL_VERSION}.zip
59+
mv openssl-${OPENSSL_VERSION} openssl-x86_64
60+
61+
cd openssl-x86_64
62+
63+
if [ "${OS}" == "Darwin" ]; then
64+
./Configure darwin64-x86_64-cc enable-static-engine enable-ec_nistp_64_gcc_128 enable-gost enable-idea enable-md2 enable-rc2 enable-rc5 enable-rfc3779 enable-ssl-trace enable-ssl2 enable-ssl3 enable-zlib experimental-jpake --prefix=${OUTDIR} --openssldir=${OUTDIR}/ssl
65+
else
66+
cd ${BUILDDIR}/downloads
67+
curl -OL http://www.zlib.net/${ZLIB_VERSION}.tar.gz
68+
69+
cd ${BUILDDIR}/build
70+
tar -zxvf ${BUILDDIR}/downloads/${ZLIB_VERSION}.tar.gz
71+
mv ${ZLIB_VERSION} zlib-x86_64
72+
cd zlib-x86_64
73+
74+
./configure --prefix=${OUTDIR} --static -64
75+
make
76+
make install
77+
78+
echo ">>> ZLIB complete"
79+
cd ${BUILDDIR}/build/openssl-x86_64
80+
./config enable-static-engine enable-ec_nistp_64_gcc_128 enable-gost enable-idea enable-md2 enable-rc2 enable-rc5 enable-rfc3779 enable-ssl-trace enable-ssl2 enable-ssl3 enable-zlib experimental-jpake --prefix=${OUTDIR} --openssldir=${OUTDIR}/ssl -I${OUTDIR}/include -L${OUTDIR}/lib --with-zlib-lib=${OUTDIR}/lib --with-zlib-include=${OUTDIR}/include
81+
fi
82+
83+
make
84+
make install prefix=${OUTDIR}
85+
86+
FILE="${BUILDDIR}/downloads/libevent-${LIBEVENT_VERSION}.tar.gz"
87+
if [ ! -f $FILE ]; then
88+
echo "Downloading $FILE.."
89+
cd ${BUILDDIR}/downloads
90+
curl -OL https://github.com/libevent/libevent/releases/download/release-${LIBEVENT_VERSION}/libevent-${LIBEVENT_VERSION}.tar.gz
91+
fi
92+
93+
cd ${BUILDDIR}/build
94+
tar -zxvf ${BUILDDIR}/downloads/libevent-${LIBEVENT_VERSION}.tar.gz
95+
mv libevent-${LIBEVENT_VERSION} libevent-x86_64
96+
97+
cd libevent-x86_64
98+
./autogen.sh
99+
100+
if [ "${OS}" == "Darwin" ]; then
101+
./configure --enable-shared=no --enable-static CFLAGS="-I${OUTDIR}/include -arch x86_64" LIBS="-L${OUTDIR}/lib -lssl -L${OUTDIR}/lib -lcrypto -ldl -L${OUTDIR}/lib -lz"
102+
else
103+
./configure --enable-shared=no OPENSSL_CFLAGS=-I${OUTDIR}/include OPENSSL_LIBS="-L${OUTDIR}/lib -lssl -L${OUTDIR}/lib -lcrypto" CFLAGS="-I${OUTDIR}/include" LIBS="-L${OUTDIR}/lib -ldl -lz"
104+
fi
105+
106+
make
107+
make install prefix=${OUTDIR}
108+
109+
echo "Downloading nettle_3.5.1."
110+
cd ${BUILDDIR}/downloads
111+
curl -OL https://git.lysator.liu.se/nettle/nettle/-/archive/nettle_3.5.1_release_20190627/nettle-nettle_3.5.1_release_20190627.tar.gz
112+
113+
cd ${BUILDDIR}/build
114+
tar -zxvf ${BUILDDIR}/downloads/nettle-nettle_3.5.1_release_20190627.tar.gz
115+
cd nettle-nettle_3.5.1_release_20190627
116+
./.bootstrap
117+
./configure --enable-static --enable-mini-gmp --disable-openssl --disable-shared --disable-documentation LDFLAGS="-L${OUTDIR}/lib"
118+
make && make install prefix=${OUTDIR}
119+
120+
echo "Downloading gnutls_3.6.10."
121+
cd ${BUILDDIR}/downloads
122+
curl -OL https://www.gnupg.org/ftp/gcrypt/gnutls/v3.6/gnutls-3.6.10.tar.xz
123+
124+
cd ${BUILDDIR}/build
125+
tar -xvf ${BUILDDIR}/downloads/gnutls-3.6.10.tar.xz
126+
cd gnutls-3.6.10
127+
128+
if [ "${OS}" == "Darwin" ]; then
129+
./configure --enable-static --disable-openssl-compatibility --disable-libdane --without-p11-kit --without-tpm --without-idn --disable-tests --disable-doc --disable-full-test-suite --disable-libdane --disable-nls --enable-shared=no --with-included-libtasn1 --with-included-unistring --with-nettle-mini --enable-guile=no --prefix=$OUTDIR PKG_CONFIG_PATH=${OUTDIR}/lib/pkgconfig LDFLAGS="-L${OUTDIR}/lib" NETTLE_CFLAGS="-I${OUTDIR}/include -arch x86_64" NETTLE_LIBS="-L${OUTDIR}/lib -lnettle" HOGWEED_CFLAGS="-I${OUTDIR}/include -arch x86_64 " HOGWEED_LIBS="-L${OUTDIR}/lib -lhogweed"
130+
else
131+
./configure --enable-static --disable-openssl-compatibility --disable-libdane --without-p11-kit --without-tpm --without-idn --disable-tests --disable-doc --disable-full-test-suite --disable-libdane --disable-nls --enable-shared=no --with-included-libtasn1 --with-included-unistring --with-nettle-mini --enable-guile=no --prefix=$OUTDIR LDFLAGS="-L${OUTDIR}/lib" NETTLE_CFLAGS="-I${OUTDIR}/include" NETTLE_LIBS="-L${OUTDIR}/lib -lnettle" HOGWEED_CFLAGS="-I${OUTDIR}/include" HOGWEED_LIBS="-L${OUTDIR}/lib -lhogweed" LIBS="${OUTDIR}/lib/libhogweed.a ${OUTDIR}/lib/libnettle.a"
132+
fi
133+
134+
make && make install prefix=${OUTDIR}
135+
136+
echo ">>> Running autoreconf -i"
137+
cd ${CD}
138+
autoreconf -i
139+
140+
echo ">>> Bootstrap complete"

0 commit comments

Comments
 (0)