-
Notifications
You must be signed in to change notification settings - Fork 177
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
Minimal changes to get building on OS X with clang and Homebrew #136
Changes from all commits
21f0fc2
80848d1
88ee4b6
89f1c86
2418c7b
1f4a78a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
CXX=g++ | ||
|
||
DEFS=-D_MT -DNOPCH -DFOURWAYSSE2 -DUSE_SSL -DMAC_OSX=1 -DCRYPTOPP_DISABLE_ASM=1 -DUSE_UPNP=1 | ||
|
||
# Detect MinGW | ||
MINGW=$(shell uname -s|grep -i mingw32) | ||
|
||
# Link boost statically | ||
DEFS += -DBOOST_THREAD_USE_LIB | ||
|
||
# TODO: add instructions on how to install specific versions of these via homebrew | ||
INCLUDEPATHS= \ | ||
-I/usr/local/opt/openssl/include \ | ||
-I/usr/local/opt/boost/include \ | ||
-I/usr/local/opt/miniupnpc/include/miniupnpc \ | ||
-I/usr/local/opt/berkeley-db4/include | ||
|
||
LIBPATHS= \ | ||
-L/usr/local/opt/openssl/lib \ | ||
-L/usr/local/opt/boost/lib \ | ||
-L/usr/local/opt/miniupnpc/lib \ | ||
-L/usr/local/opt/miniupnpc/lib \ | ||
-L/usr/local/opt/berkeley-db4/lib \ | ||
-L/usr/local/lib | ||
|
||
LIBBOOST_SUFFIX=-mt | ||
|
||
LIBS= \ | ||
-lboost_system$(LIBBOOST_SUFFIX) \ | ||
-lboost_filesystem$(LIBBOOST_SUFFIX) \ | ||
-lboost_program_options$(LIBBOOST_SUFFIX) \ | ||
-lboost_thread$(LIBBOOST_SUFFIX) \ | ||
-lboost_chrono$(LIBBOOST_SUFFIX) \ | ||
-ldb_cxx -lminiupnpc -lssl -lcrypto \ | ||
-Wl,-dynamic \ | ||
-lz \ | ||
-ldl \ | ||
-lpthread | ||
|
||
# -lgthread-2.0 # doesn't seem necessary? | ||
|
||
CXXFLAGS=-O2 -Wno-invalid-offsetof -Wformat $(DEFS) $(INCLUDEPATHS) | ||
|
||
HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h \ | ||
script.h allocators.h db.h walletdb.h crypter.h net.h irc.h keystore.h main.h wallet.h bitcoinrpc.h uibase.h ui.h noui.h init.h auxpow.h | ||
|
||
OBJS= \ | ||
obj/auxpow.o \ | ||
obj/util.o \ | ||
obj/key.o \ | ||
obj/script.o \ | ||
obj/db.o \ | ||
obj/walletdb.o \ | ||
obj/crypter.o \ | ||
obj/net.o \ | ||
obj/irc.o \ | ||
obj/keystore.o \ | ||
obj/main.o \ | ||
obj/wallet.o \ | ||
obj/bitcoinrpc.o \ | ||
obj/init.o \ | ||
cryptopp/obj/sha.o \ | ||
cryptopp/obj/cpu.o | ||
|
||
all: namecoind | ||
|
||
|
||
obj/%.o: %.cpp $(HEADERS) | ||
$(CXX) -c $(CXXFLAGS) -DGUI -o $@ $< | ||
|
||
cryptopp/obj/%.o: cryptopp/%.cpp | ||
$(CXX) -c $(CXXFLAGS) -O3 -o $@ $< | ||
|
||
obj/nogui/%.o: %.cpp $(HEADERS) | ||
$(CXX) -c $(CXXFLAGS) -o $@ $< | ||
|
||
obj/test/%.o: test/%.cpp $(HEADERS) | ||
$(CXX) -c $(CFLAGS) -o $@ $< | ||
|
||
obj/nogui/namecoin.o: namecoin.h | ||
|
||
namecoind: $(OBJS:obj/%=obj/nogui/%) obj/nogui/namecoin.o | ||
$(CXX) $(CXXFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) | ||
|
||
clean: | ||
-rm -f namecoin namecoind | ||
-rm -f obj/*.o | ||
-rm -f obj/nogui/*.o | ||
-rm -f obj/test/*.o | ||
-rm -f cryptopp/obj/*.o | ||
-rm -f headers.h.gch |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -554,15 +554,15 @@ GetBitvectorWordCount (unsigned n) | |
template<typename A> | ||
unsigned int | ||
GetSerializeSize (const std::vector<bool, A>& v, | ||
int nType, int nVersion = VERSION) | ||
int nType, int nVersion) | ||
{ | ||
return GetSizeOfCompactSize (v.size ()) + GetBitvectorWordCount (v.size ()); | ||
} | ||
|
||
template<typename Stream, typename A> | ||
void | ||
Serialize (Stream& os, const std::vector<bool, A>& v, | ||
int nType, int nVersion = VERSION) | ||
int nType, int nVersion) | ||
{ | ||
WriteCompactSize (os, v.size ()); | ||
|
||
|
@@ -582,7 +582,7 @@ template<typename Stream, typename A> | |
template<typename Stream, typename A> | ||
void | ||
Unserialize (Stream& is, std::vector<bool, A>& v, | ||
int nType, int nVersion = VERSION) | ||
int nType, int nVersion) | ||
{ | ||
const unsigned size = ReadCompactSize (is); | ||
std::vector<unsigned char> words(GetBitvectorWordCount (size)); | ||
|
@@ -926,7 +926,7 @@ class CDataStream | |
void clear() { vch.clear(); nReadPos = 0; } | ||
iterator insert(iterator it, const char& x=char()) { return vch.insert(it, x); } | ||
void insert(iterator it, size_type n, const char& x) { vch.insert(it, n, x); } | ||
|
||
#ifdef __APPLE__ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change effectively removes the first insert method from the class on non-Apple platforms. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On OS X, the compiler errors because of multiple definitions. I can put the guard around the parameter definition if you'd prefer (as that's the only difference) and delete the duplicate body. Maybe there's a way to define the parameters correctly for all platforms, but again, I have no interest in figuring that out, I just made a few small changes to get it to compile on OS X. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no need for a guard. Just remove the correct duplicate and it should work with any compiler on any OS.
Then why bother at all if you only want a quick and dirty hack?! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alternatively, it might also work to simply show the second definition on all platforms except There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Removing one will break compilation on one of the platforms (regardless of which you remove), if I remember correctly. Feel free to send your own PR on top of this one if you'd like.
...I wanted "minimal changes" to get it to work on OS X. I got them. |
||
void insert(iterator it, const_iterator first, const_iterator last) | ||
{ | ||
if (it == vch.begin() + nReadPos && last - first <= nReadPos) | ||
|
@@ -938,7 +938,7 @@ class CDataStream | |
else | ||
vch.insert(it, first, last); | ||
} | ||
|
||
#else | ||
void insert(iterator it, std::vector<char>::const_iterator first, std::vector<char>::const_iterator last) | ||
{ | ||
if (it == vch.begin() + nReadPos && last - first <= nReadPos) | ||
|
@@ -950,7 +950,7 @@ class CDataStream | |
else | ||
vch.insert(it, first, last); | ||
} | ||
|
||
#endif | ||
#if !defined(_MSC_VER) || _MSC_VER >= 1300 | ||
void insert(iterator it, const char* first, const char* last) | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just use autotools?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a PR that uses that I think: #135
The title of this PR explains why I stuck with Make.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any explanation in the title. Unless you mean "minimal".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I mean minimal. PR #135 is roughly 60x larger, and nobody seems inclined to audit it.