Skip to content
This repository has been archived by the owner on Jul 2, 2021. It is now read-only.

Commit

Permalink
Merge pull request #366 from mstuehlinger/dllsupport
Browse files Browse the repository at this point in the history
Windows 64bit shared library build
  • Loading branch information
braydonf committed Jul 21, 2017
2 parents 343057f + a6037de commit d5c5393
Show file tree
Hide file tree
Showing 14 changed files with 226 additions and 152 deletions.
20 changes: 20 additions & 0 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,26 @@ Configure command for libstorj-c:
PKG_CONFIG_LIBDIR="$(pwd)/depends/build/x86_64-w64-mingw32/lib/pkgconfig" CFLAGS="-DCURL_STATICLIB -I$(pwd)/depends/build/x86_64-w64-mingw32/include -L$(pwd)/depends/build/x86_64-w64-mingw32/lib -static" ./configure --host=x86_64-w64-mingw32 --enable-static --disable-shared --prefix=$(pwd)/depends/build/x86_64-w64-mingw32
```

**Windows Shared Library (DLL)**

Supported hosts include:
- x86_64-w64-mingw32

Dependencies:
```
apt-get install gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64
```

```
cd ./depends
make HOST="x86_64-w64-mingw32" BUILD_DLL=1
```

Configure command for libstorj-c:
```
PKG_CONFIG_LIBDIR="$(pwd)/depends/build/x86_64-w64-mingw32/lib/pkgconfig" CFLAGS="-I$(pwd)/depends/build/x86_64-w64-mingw32/include -L$(pwd)/depends/build/x86_64-w64-mingw32/lib -DSTORJDLL" ./configure --host=x86_64-w64-mingw32 --prefix=$(pwd)/depends/build/x86_64-w64-mingw32
```

**ARM GNU/Linux**

Supported hosts include:
Expand Down
5 changes: 3 additions & 2 deletions configure.ac
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ AC_INIT([libstorj],[1.0.1])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([build-aux/m4])
AM_INIT_AUTOMAKE([foreign])
LT_INIT
LT_INIT([win32-dll])

AC_PATH_PROG(HEXDUMP,hexdump)

Expand All @@ -20,7 +20,6 @@ AC_CHECK_HEADERS([curl/curl.h], [libcurl_found_headers=yes; break;])
AS_IF([test "x$libcurl_found_headers" != "xyes"],
[AC_MSG_ERROR([Unable to find libcurl headers.])])


PKG_CHECK_MODULES([NETTLE], [nettle >= 3.1],, [AC_MSG_ERROR([nettle 3.1 or greater was not found.
You can get it from https://www.lysator.liu.se/~nisse/nettle/])])

Expand Down Expand Up @@ -48,6 +47,8 @@ AC_CONFIG_FILES([libstorj.pc:libstorj.pc.in])

AC_CHECK_FUNCS([aligned_alloc posix_memalign posix_fallocate])

AM_CONDITIONAL([BUILD_STORJ_DLL], [test "x${CFLAGS/"STORJDLL"}" != x"$CFLAGS"])

AC_ARG_ENABLE([debug],
[AS_HELP_STRING([--enable-debug],
[use debug compiler flags and macros (default is no)])],
Expand Down
13 changes: 11 additions & 2 deletions depends/Makefile
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ ifeq ($(host_os),)
host_os=$(full_host_os)
endif

config_lib_type=--enable-static --disable-shared

# mingw dll build
ifeq ($(HOST), x86_64-w64-mingw32)
ifeq ($(BUILD_DLL), 1)
config_lib_type=
endif
endif

# mac build
DARWIN_SDK_PATH ?= "$(CURDIR)/MacOSX10.11.sdk"
DARWIN_CFLAGS = "-target $(HOST) -isysroot $(DARWIN_SDK_PATH) -mmacosx-version-min=10.8 -mlinker-version=253.9 -pipe -I$(PREFIX_DIR)include"
Expand Down Expand Up @@ -77,13 +86,13 @@ define build_source
echo "curdir: $(CURDIR)" && \
echo "build_env: $(build_env)" && \
echo "config_env: $($(1)_config_env)" && \
echo "config_opts: $($(1)_config_opts)" && \
echo "config_opts: $($(1)_config_opts) $(config_lib_type)" && \
echo "host: $(HOST)" && \
echo "prefix: $(PREFIX_DIR)" && \
echo "====================================\n\n" && \
export PATH="$(TOOLCHAIN_BUILD_DIR)bin:${PATH}" && \
if test -f "./autogen.sh"; then ./autogen.sh; fi && \
$(build_env) $($(1)_config_env) ./configure --host="$(HOST)" $($(1)_config_opts) --enable-static --disable-shared --prefix=$(PREFIX_DIR) || exit && \
$(build_env) $($(1)_config_env) ./configure --host="$(HOST)" $($(1)_config_opts) $(config_lib_type) --prefix=$(PREFIX_DIR) || exit && \
make || exit && \
make install || exit && \
cd "$(CURDIR)"
Expand Down
5 changes: 5 additions & 0 deletions depends/packages/gmp.mk
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ $(package)_sha256_hash=5275bb04f4863a13516b2f39392ac5e272f5e1bb8057b18aec1c9b79d
$(package)_config_env_default=
$(package)_config_opts_default=

#mingw dll specific settings
ifeq ($(BUILD_DLL), 1)
$(package)_config_opts_x86_64-w64-mingw32=--disable-static --enable-shared
endif

# arm specific settings
$(package)_config_opts_arm=--disable-assembly
$(package)_config_opts_aarch64-linux-gnu=$($(package)_config_opts_arm)
Expand Down
5 changes: 5 additions & 0 deletions depends/packages/gnutls.mk
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ $(package)_config_env_x86_64-apple-darwin11=$($(package)_config_env_darwin)
# 32 bit linux settings
$(package)_config_env_i686-pc-linux-gnu=NETTLE_CFLAGS="-static" GMP_CFLAGS="-static" PKG_CONFIG_LIBDIR="$(PREFIX_DIR)/lib/pkgconfig" CFLAGS="-I$(PREFIX_DIR)include -L$(PREFIX_DIR)lib -static -m32" CXXFLAGS="-m32" LDFLAGS="-m32"

# mingw dll specific settings
ifeq ($(BUILD_DLL), 1)
$(package)_config_env_x86_64-w64-mingw32=PKG_CONFIG_LIBDIR="$(PREFIX_DIR)/lib/pkgconfig" CFLAGS="-I$(PREFIX_DIR)include -L$(PREFIX_DIR)lib"
endif

# set settings based on host
$(package)_config_env = $(if $($(package)_config_env_$(HOST)), $($(package)_config_env_$(HOST)), $($(package)_config_env_default))
$(package)_config_opts = $(if $($(package)_config_opts_$(HOST)), $($(package)_config_opts_$(HOST)), $($(package)_config_opts_default))
5 changes: 5 additions & 0 deletions depends/packages/libcurl.mk
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ $(package)_config_env_i686-w64-mingw32=$($(package)_config_env_mingw32)
$(package)_config_opts_x86_64-w64-mingw32=$($(package)_config_opts_mingw32)
$(package)_config_opts_i686-w64-mingw32=$($(package)_config_opts_mingw32)

#mingw dll specific settings
ifeq ($(BUILD_DLL), 1)
$(package)_config_env_x86_64-w64-mingw32=LIBS="-lcrypt32 -lnettle -lhogweed -lgmp" LD_LIBRARY_PATH="$(PREFIX_DIR)lib" PKG_CONFIG_LIBDIR="$(PREFIX_DIR)lib/pkgconfig" CPPFLAGS="-I$(PREFIX_DIR)include" LDFLAGS="-L$(PREFIX_DIR)lib"
endif

# 32-bit linux specific settings
$(package)_config_env_i686-pc-linux-gnu=LIBS="-lnettle -lhogweed -lgmp" LD_LIBRARY_PATH="$(PREFIX_DIR)lib" PKG_CONFIG_LIBDIR="$(PREFIX_DIR)lib/pkgconfig" CPPFLAGS="-I$(PREFIX_DIR)include -m32" LDFLAGS="-L$(PREFIX_DIR)lib -m32"
$(package)_config_opts_i686-pc-linux-gnu=--disable-ftp --disable-file --disable-ldap --disable-ldaps --disable-rtsp --disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smb --disable-smtp --disable-gopher --enable-proxy --without-ssl --with-gnutls="$(PREFIX_DIR)" --disable-telnet --enable-threaded-resolver
Expand Down
7 changes: 6 additions & 1 deletion depends/packages/nettle.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@ $(package)_config_env_default=PKG_CONFIG_LIBDIR="$(PREFIX_DIR)/lib/pkgconfig" CF
$(package)_config_opts_default=

# mingw specific settings
$(package)_config_env_mingw32=PKG_CONFIG_LIBDIR="$(PREFIX_DIR)/lib/pkgconfig" CFLAGS="-I$(PREFIX_DIR)include -L$(PREFIX_DIR)lib -static"
$(package)_config_env_mingw32=PKG_CONFIG_LIBDIR="$(PREFIX_DIR)/lib/pkgconfig" CFLAGS="-I$(PREFIX_DIR)include -L$(PREFIX_DIR)lib" -static
$(package)_config_env_x86_64-w64-mingw32=$($(package)_config_env_mingw32)
$(package)_config_env_i686-w64-mingw32=$($(package)_config_env_mingw32)

# mingw dll specific settings
ifeq ($(BUILD_DLL), 1)
$(package)_config_env_x86_64-w64-mingw32=PKG_CONFIG_LIBDIR="$(PREFIX_DIR)/lib/pkgconfig" CFLAGS="-I$(PREFIX_DIR)include -L$(PREFIX_DIR)lib"
endif

# darwin specific settings
$(package)_config_env_darwin=PKG_CONFIG_LIBDIR="$(PREFIX_DIR)/lib/pkgconfig"
$(package)_config_env_x86_64-apple-darwin11=$($(package)_config_env_darwin)
Expand Down
7 changes: 7 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@ lib_LTLIBRARIES = libstorj.la
libstorj_la_SOURCES = storj.c utils.c utils.h http.c http.h uploader.c uploader.h downloader.c downloader.h bip39.c bip39.h bip39_english.h crypto.c crypto.h rs.c rs.h
libstorj_la_LIBADD = -lcurl -lnettle -ljson-c -luv -lm
libstorj_la_LDFLAGS = -Wall
if BUILD_STORJ_DLL
libstorj_la_LDFLAGS += -no-undefined
endif
include_HEADERS = storj.h

bin_PROGRAMS = storj
storj_SOURCES = cli.c storj.h
storj_LDADD = libstorj.la
if BUILD_STORJ_DLL
storj_LDFLAGS = -Wall
else
storj_LDFLAGS = -Wall -static
endif
4 changes: 2 additions & 2 deletions src/downloader.c
Original file line number Diff line number Diff line change
Expand Up @@ -1844,7 +1844,7 @@ static void queue_next_work(storj_download_state_t *state)

}

int storj_bridge_resolve_file_cancel(storj_download_state_t *state)
STORJ_API int storj_bridge_resolve_file_cancel(storj_download_state_t *state)
{
if (state->canceled) {
return 0;
Expand All @@ -1866,7 +1866,7 @@ int storj_bridge_resolve_file_cancel(storj_download_state_t *state)
return 0;
}

int storj_bridge_resolve_file(storj_env_t *env,
STORJ_API int storj_bridge_resolve_file(storj_env_t *env,
storj_download_state_t *state,
const char *bucket_id,
const char *file_id,
Expand Down
Loading

0 comments on commit d5c5393

Please sign in to comment.