Skip to content

Conversation

randolf
Copy link
Contributor

@randolf randolf commented Jan 9, 2018

This change makes it possible to build/compile Bitcoin on NetBSD (specifically, NetBSD 7.0, and very likely other recent versions too). One .m4 file has one minor change so that ./configure can find Berkeley DB 4.8, and one .md file was created that provides instructions for NetBSD users.

Thank you to the many helpful people in the #netbsd and #bitcoin-core-dev channels on irc.freenode.net for your help with this.

Added "db4_cxx" as this is the name used in NetBSD for the Berkeley DB library.  Without this additional base filename alternative, the "configure" script will fail to find this library and compilation will not succeed.
Added a test for the "__NetBSD__" definition (because testing for "OS_NETBSD" fails in NetBSD 7).
Fixed formatting, and added -DOS_NETBSD to ./configure's CPPFLAGS so ensure gmake's success.
Minor improvement to some of the instructions, and added "autogen.sh" to the steps.
Copy link
Contributor

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@theuni may want to take a look.

With wallet:
```
./autogen.sh
./configure CPPFLAGS="-I/usr/pkg/include -DOS_NETBSD" LDFLAGS="-L/usr/pkg/lib" BOOST_CPPFLAGS="-I/usr/pkg/include" BOOST_LDFLAGS="-L/usr/pkg/lib"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like we should be able to auto-detect /usr/pkg/*, then, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there's a way to include this in the Makefile (or whatever's most appropriate), then I certainly welcome such a change, especially if it simplifies the usage of "./configure" to something like this: ./configure CPPFLAGS="-DOS_NETBSD"

The "/usr/pkg/" path is the default where pkgsrc and pkgin place package sources, binaries, libraries, configuration files, etc., and most (if not all) NetBSD installations have this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, adding those flags seems unnecessary. Further, DOS_NETBSD can and should be set by configure.

Copy link
Contributor Author

@randolf randolf Jan 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fantastic. Eliminating the need for any flags with "./configure" is something I agree with, and placing it in the "configure.ac" file after the "openbsd" entry seems reasonable to me (if, in the future, this list becomes longer, then at that point there may be a need to organize it in alphabetical order for easier maintenance, but for now it's short so I'm not suggesting this).

P.S.: I added this change in on my test system, and it seemed to work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TheBlueMatt This is from the irc.freenode.net#netbsd channel regarding your question about auto-detecting the "/usr/pkg/" directory...

-----BEGIN-----
[22:07:50] Randolf: Hmm... Re your bitcoin pull request: software should not look in /usr/pkg by default. Anything built by pkgsrc will automatically add -I/usr/pkg/include -- or -I${PREFIX}/include, when PREFIX may not actually be /usr/pkg.
[22:08:39] Part of the point of /usr/pkg is that nothing else uses it by default, unlike /usr/local which has all sorts of variegated cultural associations and random behaviour.
-----END-----

So, perhaps it would be better to not attempt to automatically detect NetBSD's pkgsrc/pkgin systems, but instead either leave the the ./configure parameters as documented with CPPFLAGS, etc., or provide an alternative such as a special parameter called PKG_PATH="/usr/pkg" that helps to make it all work automatically behind-the-scenes (assuming this is even possible).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to not hardcode /usr/pkg, as this prefix is configurable and people use diverse ones, like /opt, ~/pkg/ etc.

@theuni
Copy link
Member

theuni commented Jan 10, 2018

This should take care of the define for leveldb:

diff --git a/configure.ac b/configure.ac
index f7de4c9..2690477 100644
--- a/configure.ac
+++ b/configure.ac
@@ -449,6 +449,8 @@ case $host in
    *openbsd*)
      LEVELDB_TARGET_FLAGS="-DOS_OPENBSD"
      ;;
+    *netbsd*)
+     LEVELDB_TARGET_FLAGS="-DOS_NETBSD"
    *)
      OTHER_OS=`echo ${host_os} | awk '{print toupper($0)}'`
      AC_MSG_WARN([Guessing LevelDB OS as OS_${OTHER_OS}, please check whether this is correct, if not add an entry to configure.ac.])

I'm confused about /usr/pkg, though. Is the system compiler not configured to check there by default?

@riastradh
Copy link

NetBSD/pkgsrc developer here. If you simply allow standard CPPFLAGS and LDFLAGS in ./configure, then when this is built by pkgsrc to be linked against the library packages it depends on, pkgsrc will furnish the necessary -I and -L and -R flags for /usr/pkg, or for wherever pkgsrc is built to install into.

The system compiler intentionally doesn't automatically add /usr/pkg to the paths because /usr/pkg is the domain of packages, not of the compiler; pkgsrc can be built for any other location, e.g. /usr/pkg-20xxQy for a quarterly release or /home/alice/pkg for unprivileged installations; and what's in it may change as you install or remove packages, but pkgsrc has no record of things outside /usr/pkg that might be broken by that.

The best way to link against libraries installed in /usr/pkg or elsewhere by pkgsrc is just to package up bitcoin in pkgsrc (currently there's an old version in pkgsrc-wip -- patches welcome!); otherwise, software built outside pkgsrc is expected to pass the necessary -I/-L/-R flags as if for any custom library installation prefix.

@fanquake
Copy link
Member

@randolf What's required to move this forward?

At a minimum, please update 0dccc26 with a better commit title, rather than the GitHub default.
i.e "[build] Add db4_cxx to bitcoin_find_bdb48.m4".

Please also squash d3e58d2 through 30062f8 into a single commit. "[doc] Create build-netbsd.md" etc.

@fanquake fanquake changed the title Fix NetBSD compilation [Docs] Create NetBSD build instructions and fix compilation. Jan 22, 2018
@randolf
Copy link
Contributor Author

randolf commented Jan 22, 2018

@fanquake Thanks; I'm new to GitHub.com and so I appreciate any assistance from you and anyone else. I did originally name this because I prefer this over default names, and at present I'm trying to figure out how to make changes to this Pull Request. I would love to move this forward, but I think I'm just stuck with a GitHub learning curve at present, so I certainly welcome all pointers and suggestions.

(None of the instructions for Squashing that I've tried seem to work because the various options instructed simply don't appear for me anywhere on the GitHub web site or within the GitHub Desktop software. If there are some reliable instructions to follow to Squash this, I'll gladly try it.)

@maflcko
Copy link
Member

maflcko commented Jan 22, 2018

It is not possible to squash on GitHub web. I am not familiar with GitHub desktop, but there are some notes in https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#squashing-commits

@randolf
Copy link
Contributor Author

randolf commented Jan 22, 2018

@MarcoFalke I can "clone" on Unix but "checkout" always fails to find the .git file. "Allow edits from maintainers" is enabled, in case that's helpful.

I want to get Squash working (I'm assuming that I must be missing something), but if there's a time-constraint then I also don't want to cause any delays for the Bitcoin project overall.

@maflcko
Copy link
Member

maflcko commented Jan 23, 2018

No, there is no pressure and squashing makes the review easier, I presume.

I can "clone" on Unix but "checkout" always fails to find the .git file.

It probably said something like "cloning into bitcoin", so you'd first cd ./bitcoin/ and then git log -1 etc.

@randolf
Copy link
Contributor Author

randolf commented Jan 23, 2018

Thanks @MarcoFalke. I couldn't find the "Squash" feature 14 days ago (see my first comment on this Pull Request where I indicated that I'd like to do this), and I'm not finding it now. I looked into this for a while but didn't make any progress. If there's a guide you (or anyone) can point me to that will help me to get this Pull Request "squashed," I'd be happy to give it a try.

@ryanofsky
Copy link
Contributor

If there's a guide you (or anyone) can point me to that will help me to get this Pull Request "squashed," I'd be happy to give it a try.

I don't know of a guide offhand, but if you google git rebase squash you can find some tutorials. Basic idea is to run a command like git rebase -i $(git merge-base HEAD origin/master) which will open up your text editor and let you change the branch history. If you change the history from "pick pick pick..." to "pick squash squash..." this will combine separate commits into one commit.

@jcvernaleo
Copy link

@randolf I wrote these instructions for how to rebase and squash for a different cryptocurrency which might be of help https://gist.github.com/jcvernaleo/aa3f6c216f3df1f9c6b62d7f59a2a469#rebasing-one-of-your-existing-pull-requests

@randolf
Copy link
Contributor Author

randolf commented Jan 24, 2018

Thank you @ryanofsky -- I will look into that.

@randolf
Copy link
Contributor Author

randolf commented Jan 24, 2018

@jcvernaleo Okay, your instructions seem to be helpful, and I think I've made some progress on this now despite the fun with using "vi" to change "noop" to "s" (hopefully I can configure git to use a different editor, but I'll leave this for later). I was also prompted by the "git push" command for username and password, and then it all finished with "Everything is up-to-date."

I don't see any indication of changes on the GitHub.com web site though, but perhaps my upload is queued somewhere and I just have to wait? I'll check back later.

Thanks for your help!

@maflcko
Copy link
Member

maflcko commented Jan 24, 2018

noop will appear when you run git rebase --interactive HEAD

You should replace HEAD with HEAD~6 or 0dccc26~

@jcvernaleo
Copy link

@randolf git uses whatever default editor you have set as $EDITOR (or vi if that isn't set). So you can either set $EDITOR in your shell or set it just for gti like:

git config --global core.editor emacs

or whatever editor you prefer.

@randolf
Copy link
Contributor Author

randolf commented Jan 27, 2018

@jcvernaleo That worked very well, thank you.

@randolf
Copy link
Contributor Author

randolf commented Jan 27, 2018

@MarcoFalke So I saw 6 items in the list, each with "pick" as the first word. The "git push" command (which I had to login for, as expected), then reported the following:

* [new branch] HEAD -> bitcoin

On the GitHub.com web site, the "Compare" function still shows 6 changes, so if it's not Squashed yet I'm probably looking in the wrong place. There's so much to learn about using git (it seems to be a pretty extensive system), and I appreciate all the help from you and everyone else thus far.

@flack
Copy link
Contributor

flack commented Jan 27, 2018

@randolf you need to mark the commits as squash in the editor, see http://push.cwcon.org/learn/squashing-commits.html

@fanquake
Copy link
Member

@randolf Thanks for your work so far. I've created a new PR, squashing and updating the commit messages of your commits. All of your changes are still attributed to you. I'll close this PR, any further review can happen in #12294.

@fanquake fanquake closed this Jan 29, 2018
@randolf
Copy link
Contributor Author

randolf commented Jan 29, 2018

@fanquake Thanks for taking care of the Squashing for me. I'm still new to GitHub and so this is helpful to get things moving along. I appreciate it.

laanwj added a commit that referenced this pull request Jan 30, 2018
…tion

11c5827 [build] Add NETBSD leveldb target to configure.ac (fanquake)
1944fa3 [doc] Create build-netbsd.md (Randolf Richardson)
336685e [build] Add db4_cxx to bitcoin_find_bdb48.m4 (Randolf Richardson)

Pull request description:

  Replaces #12125.

Tree-SHA512: 411d082ffff7198bcc1b2b6fcdf86c378baf228d8f4fee0e6c9f0688efe9c6b6dcfd5c1ab9c1dfd0c4637723b8584dbbb614634ace0e1a417b59e88a6c736dc0
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 26, 2021
…compilation

11c5827 [build] Add NETBSD leveldb target to configure.ac (fanquake)
1944fa3 [doc] Create build-netbsd.md (Randolf Richardson)
336685e [build] Add db4_cxx to bitcoin_find_bdb48.m4 (Randolf Richardson)

Pull request description:

  Replaces bitcoin#12125.

Tree-SHA512: 411d082ffff7198bcc1b2b6fcdf86c378baf228d8f4fee0e6c9f0688efe9c6b6dcfd5c1ab9c1dfd0c4637723b8584dbbb614634ace0e1a417b59e88a6c736dc0
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants