Skip to content

Commit

Permalink
build cryptoconditions as static (incl Windows)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmjatlanta committed Nov 9, 2021
1 parent 62ae1c2 commit a73398b
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 42 deletions.
11 changes: 5 additions & 6 deletions depends/hosts/mingw32.mk
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
mingw32_CC=x86_64-w64-mingw32-gcc-posix
mingw32_CXX=x86_64-w64-mingw32-g++-posix
mingw32_CFLAGS=-pipe -std=c11
mingw32_CXXFLAGS=$(mingw32_CFLAGS) -std=c++11
mingw32_CXXFLAGS=-pipe -std=c++11

mingw32_release_CFLAGS=-O1
mingw32_release_CXXFLAGS=$(mingw32_release_CFLAGS)

mingw32_debug_CFLAGS=-O1
mingw32_debug_CXXFLAGS=$(mingw32_debug_CFLAGS)
mingw32_release_CFLAGS=-O3
mingw32_release_CXXFLAGS=$(mingw32_CXXFLAGS) $(mingw32_release_CFLAGS)

mingw32_debug_CFLAGS=-g -O0
mingw32_debug_CPPFLAGS=-D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC
mingw32_debug_CXXFLAGS=$(mingw32_CXXFLAGS) $(mingw32_debug_CFLAGS)
2 changes: 1 addition & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DIST_SUBDIRS = secp256k1 univalue cryptoconditions
DIST_SUBDIRS = secp256k1 univalue
SUBDIRS = cryptoconditions
AM_LDFLAGS = $(PTHREAD_CFLAGS) $(LIBTOOL_LDFLAGS) $(SAN_LDFLAGS) $(HARDENED_LDFLAGS)
AM_CXXFLAGS = $(SAN_CXXFLAGS) $(HARDENED_CXXFLAGS) $(ERROR_CXXFLAGS)
Expand Down
12 changes: 2 additions & 10 deletions src/cryptoconditions/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
lib_LTLIBRARIES=libcryptoconditions.la
noinst_LTLIBRARIES=$(CRYPTOCONDITIONS_CORE)
noinst_LIBRARIES=libcryptoconditions_core.a
SUBDIRS = src/include/secp256k1

include_HEADERS = include/cryptoconditions.h

# Have a separate build target for cryptoconditions that does not contain secp256k1

libcryptoconditions_la_SOURCES = include/cryptoconditions.h
libcryptoconditions_la_LIBADD = $(CRYPTOCONDITIONS_CORE) $(LIBSECP256K1)

AM_CFLAGS = -I$(top_srcdir)/src/asn -I$(top_srcdir)/include -I$(top_srcdir)/src/include \
-Wall -Wno-pointer-sign -Wno-discarded-qualifiers

LIBSECP256K1=src/include/secp256k1/libsecp256k1.la

$(LIBSECP256K1): $(wildcard src/secp256k1/*)
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F) -march:x86-64 -g

CRYPTOCONDITIONS_CORE=libcryptoconditions_core.a

libcryptoconditions_core_a_SOURCES = \
src/cryptoconditions.c \
src/utils.c \
Expand Down Expand Up @@ -74,6 +65,7 @@ libcryptoconditions_core_a_SOURCES = \
src/asn/per_decoder.c \
src/asn/per_encoder.c \
src/asn/per_opentype.c
libcryptoconditions_core_a_CPPFLAGS=-I. -I./src/include -I./src/asn

test:
bash -c '[ -d .env ] || virtualenv .env -p python3'
Expand Down
25 changes: 13 additions & 12 deletions zcutil/build-win-dtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,24 @@
export HOST=x86_64-w64-mingw32
CXX=x86_64-w64-mingw32-g++-posix
CC=x86_64-w64-mingw32-gcc-posix
PREFIX="$(pwd)/depends/$HOST"

set -eu -o pipefail

set -x
cd "$(dirname "$(readlink -f "$0")")/.."

cd depends/ && make HOST=$HOST V=1 NO_QT=1
cd ../
WD=$PWD
cd src/cc
echo $PWD
./makecustom
cd $WD
UTIL_DIR="$(dirname "$(readlink -f "$0")")"
BASE_DIR="$(dirname "$(readlink -f "$UTIL_DIR")")"
PREFIX="$BASE_DIR/depends/$HOST"

cd $BASE_DIR/depends
make HOST=$HOST NO_QT=1 "$@"
cd $BASE_DIR

./autogen.sh
CONFIG_SITE=$PWD/depends/x86_64-w64-mingw32/share/config.site CXXFLAGS="-DPTW32_STATIC_LIB -DCURL_STATICLIB -DCURVE_ALT_BN128 -fopenmp -pthread" CPPFLAGS=-DTESTMODE ./configure --prefix="${PREFIX}" --host=x86_64-w64-mingw32 --enable-static --disable-shared
sed -i 's/-lboost_system-mt /-lboost_system-mt-s /' configure
cd src/
CC="${CC} -g " CXX="${CXX} -g " make V=1 komodod.exe komodo-cli.exe komodo-tx.exe

cd $BASE_DIR/src/cryptoconditions
CC="${CC} -g " CXX="${CXX} -g " make V=1
cd $BASE_DIR

CC="${CC} -g " CXX="${CXX} -g " make V=1 src/komodod.exe src/komodo-cli.exe src/komodo-tx.exe
22 changes: 9 additions & 13 deletions zcutil/build-win.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,19 @@
export HOST=x86_64-w64-mingw32
CXX=x86_64-w64-mingw32-g++-posix
CC=x86_64-w64-mingw32-gcc-posix
PREFIX="$(pwd)/depends/$HOST"

set -eu -o pipefail

set -x
cd "$(dirname "$(readlink -f "$0")")/.."
UTIL_DIR="$(dirname "$(readlink -f "$0")")"
BASE_DIR="$(dirname "$(readlink -f "$UTIL_DIR")")"
PREFIX="$BASE_DIR/depends/$HOST"

cd depends/ && make HOST=$HOST V=1 NO_QT=1
cd ../
WD=$PWD
cd src/cc
echo $PWD
./makecustom
cd $WD
cd $BASE_DIR/depends
make HOST=$HOST NO_QT=1 "$@"
cd $BASE_DIR

./autogen.sh
CONFIG_SITE=$PWD/depends/x86_64-w64-mingw32/share/config.site CXXFLAGS="-DPTW32_STATIC_LIB -DCURL_STATICLIB -DCURVE_ALT_BN128 -fopenmp -pthread" ./configure --prefix="${PREFIX}" --host=x86_64-w64-mingw32 --enable-static --disable-shared
CONFIG_SITE=$BASE_DIR/depends/$HOST/share/config.site CXXFLAGS="-DPTW32_STATIC_LIB -DCURL_STATICLIB -DCURVE_ALT_BN128 -fopenmp -pthread" ./configure --prefix=$PREFIX --host=$HOST --enable-static --disable-shared
sed -i 's/-lboost_system-mt /-lboost_system-mt-s /' configure
cd src/
CC="${CC} -g " CXX="${CXX} -g " make V=1 komodod.exe komodo-cli.exe komodo-tx.exe

make "$@"

0 comments on commit a73398b

Please sign in to comment.