Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build on windows #29

Merged
merged 4 commits into from
Sep 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions CLA-signed/CLA.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Contributor License Agreement

Version 1.0

Name: Gorazd Kovacic

E-Mail: gorazdko@gmail.com

Legal Jurisdiction: Wyoming, United States of America

Project: /~https://github.com/BlockchainCommons/bc-seedtool-cli

Date: 09-03-2020

## Purpose

This agreement gives Blockchain Commons, LLC the permission it needs in order to accept my contributions into its open software project and to manage the intellectual property in that project over time.

## License

I hereby license Blockchain Commons, LLC to:

1. do anything with my contributions that would otherwise infringe my copyright in them

2. do anything with my contributions that would otherwise infringe patents that I can or become able to license

3. sublicense these rights to others on any terms they like

## Reliability

I understand that Blockchain Commons will rely on this license. I may not revoke this license.

## Awareness

I promise that I am familiar with legal rules, like ["work made for hire" rules](http://worksmadeforhire.com), that can give employers and clients ownership of intellectual property in work that I do. I am also aware that legal agreements I might sign, like confidential information and invention assignment agreements, will usually give ownership of intellectual property in my work to employers, clients, and companies that I found. If someone else owns intellectual property in my work, I need their permission to license it.

## Copyright Guarantee

I promise not to offer contributions to the project that contain copyrighted work that I do not have legally binding permission to contribute under these terms. When I offer a contribution with permission, I promise to document in the contribution who owns copyright in what work, and how they gave permission to contribute it. If I later become aware that one of my contributions may have copyrighted work of others that I did not have permission to contribute, I will notify Blockchain Commons, in confidence, immediately.

## Patent Guarantee

I promise not to offer contributions to the project that I know infringe patents of others that I do not have permission to contribute under these terms.

## Open Source Guarantee

I promise not to offer contributions that contain or depend on the work of others, unless that work is available under a license that [Blue Oak Council rates bronze or better](https://blueoakconcil.org/list), such as the MIT License, two- or three-clause BSD License, the Apache License Version 2.0, or the Blue Oak Model License 1.0.0. When I offer a contribution containing or depending on others' work, I promise to document in the contribution who licenses that work, along with copies of their license terms.

## Disclaimers

***As far as the law allows, my contributions come as is, without any warranty or condition. Other than under [Copyright Guarantee](#copyright-guarantee), [Patent Guarantee](#patent-guarantee), or [Open Source Guarantee](#open-source-guarantee), I will not be liable to anyone for any damages related to my contributions or this contributor license agreement, under any kind of legal claim.***

---

To sign this Contributor License Agreement, fill in `$name`, `$email`, and `$date` above. Then sign using GPG using the following command `gpg --armor --clearsign --output CLA.YOURGITHUBNAME.YOURGPGFINGERPRINT.asc CLA.md`, then either submit your signed Contributor License Agreement to this repo as a GPG signed Pull Request or email it to [ChristopherA@BlockchainCommons.com](mailto:ChristopherA@BlockchainCommons.com).

8 changes: 8 additions & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
# Licensed under the "BSD-2-Clause Plus Patent License"
#

UNAME := $(shell uname)
ifeq ($(UNAME), Linux)
SHELL := /bin/bash
else ifeq ($(findstring MINGW64, $(UNAME)), MINGW64)
# on windows building with msys2/mingw64
SHELL := /bin/bash
endif

# Package-specific substitution variables
package = @PACKAGE_NAME@
version = @PACKAGE_VERSION@
Expand Down
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,39 @@ See [`MANUAL.md`](MANUAL.md) for details, many more examples, and version histor

These dependencies are automatically installed as submodules when you run the build script. This is the recommended way to install.

### MacOS

```bash
$ ./build.sh
$ sudo make install
```

### Linux

Make sure you have llvm/clang, libc++ and libc++abi installed. All of them with
a minimum recommended version 10.

#### Ubuntu and Debian

```bash
$ sudo apt-get install make

$ wget https://apt.llvm.org/llvm.sh
$ chmod +x llvm.sh
$ sudo ./llvm.sh 10 # version 10

$ sudo apt-get install libc++-10-dev libc++abi-10-dev
```

```bash
$ export CC="clang-10" && export CXX="clang++-10" && ./build.sh
$ sudo make install
```

### Windows

See [instructions here](Windows.md).

## Alternative Installation

This sequence does *not* install the dependencies from submodules; instead they must be installed in the usual places on the build system, otherwise the `./configure` step below will fail.
Expand All @@ -149,6 +177,7 @@ $ ./configure
$ make
$ sudo make install
```
*Note:* On Linux the first step is `./configure CC=clang-10 CXX=clang++-10`

## Incremental Builds

Expand Down
71 changes: 71 additions & 0 deletions Windows.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
## Seedtool on Windows

### Abstract

This document describes building `seedtool` with `MSYS2` and its usage on `Windows 10` 64-bit.

### Installing MSYS2 and Packages

* First, install `MSYS2` by downloading the installer and following the installation guide in [www.msys2.org](www.msys2.org).

* Run `MSYS2` and make sure the package database is updated:

```bash
# pacman -Syu
# pacman -Su
```

* Next, install the compiler and the required packages:

```bash
# pacman -S mingw-w64-x86_64-clang
# pacman -S patch
# pacman -S git
# pacman -S make
# pacman -S mingw-w64-x86_64-libc++
# pacman -S autoconf
# pacman -S automake1.8
```

### Compiling

First, clone `bc-seedtool-cli`, e.g. into `C:\msys64\home`, open `MSYS2 MinGW 64-bit` application and `cd` into `C:\msys64\home\bc-seedtool-cli`

* Now, run the build script with:

```bash
# export CC="clang" && export CXX="clang++" && ./build.sh
```

* and install:

```bash
# make install
```

You can now freely use `seedtool` inside `MSYS2 MinGW 64-bit` console.


### Running Seedtool as a Native Windows App

To be able to use `seedtool` as a native app on Windows outside `msys2/mingw64`, you have to expose 3 files to the system: `seedtool.exe`, `libc++.dll` and `libunwind.dll` which all reside in `C:\msys64\mingw64\bin`. So go ahead and add that folder to the `Windows PATH` by the following command in `Windows Cmd`:

```bash
set PATH=%PATH%;C:\msys64\mingw64\bin
```

That's it. Now you can use `seedtool` as a native Windows app in the Windows command line tool.


*Note:* If you want to pipe seedtool ouput into a QR code generator, you could use:

```bash
seedtool --ur | python -c "import sys; print(sys.stdin.readlines()[0].upper())" | qr > seedqrcode.png
```

For this you'll need `Python` and the following package:

```bash
pip install qrcode[pil]
```

14 changes: 0 additions & 14 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -3753,19 +3753,6 @@ LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bc_bytewords_bytewords_encode" >&5
$as_echo "$ac_cv_lib_bc_bytewords_bytewords_encode" >&6; }
if test "x$ac_cv_lib_bc_bytewords_bytewords_encode" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBBC_BYTEWORDS 1
_ACEOF

LIBS="-lbc-bytewords $LIBS"

else

echo "### Error! libbc-bytewords must be installed first."
exit -1

fi

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for argp_parse in -largp" >&5
$as_echo_n "checking for argp_parse in -largp... " >&6; }
Expand Down Expand Up @@ -5820,4 +5807,3 @@ if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
fi

4 changes: 0 additions & 4 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ AC_CHECK_LIB([bc-bip39], [bip39_mnemonic_from_word], [], [
echo "### Error! libbc-bip39 must be installed first."
exit -1
])
AC_CHECK_LIB([bc-bytewords], [bytewords_encode], [], [
echo "### Error! libbc-bytewords must be installed first."
exit -1
])
AC_CHECK_LIB([argp], [argp_parse], [], [
echo "### Error! argp must be installed first. Try 'brew install argp-standalone'."
exit -1
Expand Down
12 changes: 10 additions & 2 deletions src/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,15 @@ OBJS = \
randombytes.o \
hkdf.o

LDFLAGS += -lstdc++ -lbc-crypto-base -lbc-shamir -lbc-slip39 -lbc-bip39 -lbc-ur -largp
LDLIBS += -lbc-slip39 -lbc-shamir -lbc-crypto-base -lbc-bip39 -lbc-ur -largp

UNAME := $(shell uname)
ifeq ($(UNAME), Linux)
LDLIBS += -lm -lc++ -lc++abi -lgcc_s -lgcc
else ifeq ($(findstring MINGW64, $(UNAME)), MINGW64)
# on windows building with msys2/mingw64
LDLIBS += -lm -lc++ -lws2_32
endif

$(toolname): $(OBJS)

Expand All @@ -85,7 +93,7 @@ format-bytewords.o: format-bytewords.hpp format.hpp params.hpp random.hpp
format-bytewords-uri.o: format-bytewords-uri.hpp format.hpp params.hpp random.hpp
format-bytewords-minimal.o: format-bytewords-minimal.hpp format.hpp params.hpp random.hpp

bindir = $(DESTDIR)/$(prefix)/bin
bindir = $(DESTDIR)$(prefix)/bin

.PHONY: install
install: $(toolname)
Expand Down
1 change: 1 addition & 0 deletions src/hkdf.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ extern "C" {
// THE SOFTWARE.

#include <stdlib.h>
#include <stdint.h>

/**
* hkdf_sha256 - generate a derived key
Expand Down