diff --git a/src/leveldb/build_detect_platform b/src/leveldb/build_detect_platform old mode 100644 new mode 100755 diff --git a/src/makefile.osx b/src/makefile.osx index 90712b5..bba72d0 100644 --- a/src/makefile.osx +++ b/src/makefile.osx @@ -6,39 +6,61 @@ # Mac OS X makefile for photon # Originally by Laszlo Hanyecz (solar@heliacal.net) +# choose c and c++ libraries +CC=clang CXX=llvm-g++ -DEPSDIR=/opt/local + +# standard library dirs brew and opt +BREW_DEP_DIR = /usr/local/Cellar +OPT_DEP_DIR = /usr/local/opt + +# You can configure these and point them to where ever your dependencies are. +OPENSSL_DIR = $(BREW_DEP_DIR)/openssl/1.0.2j +BOOST_DIR = $(OPT_DEP_DIR)/boost@1.55 +MINIUPNPC_DIR = $(BREW_DEP_DIR)/miniupnpc +BERKELEY_DIR = $(BREW_DEP_DIR)/berkeley-db@4/4.8.30 + INCLUDEPATHS= \ -I"$(CURDIR)" \ -I"$(CURDIR)"/obj \ - -I"$(DEPSDIR)/include" \ - -I"$(DEPSDIR)/include/db48" + -I"$(OPENSSL_DIR)"/include \ + -I"$(BERKELEY_DIR)"/include \ + -I"$(MINIUPNPC_DIR)"/include \ + -I"$(BOOST_DIR)"/include LIBPATHS= \ - -L"$(DEPSDIR)/lib" \ - -L"$(DEPSDIR)/lib/db48" + -L"$(OPENSSL_DIR)"/lib \ + -L"$(BERKELEY_DIR)"/lib \ + -L"$(MINIUPNPC_DIR)"/lib \ + -L"$(BOOST_DIR)"/lib + USE_UPNP:=1 USE_IPV6:=1 +#set this before compiling +STATIC = true + LIBS= -dead_strip TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data) ifdef STATIC -# Build STATIC if you are redistributing the photond binary +# Build STATIC if you are redistributing the photond binary. +# if not all the libraries must be in the same DIR as photond TESTLIBS += \ - $(DEPSDIR)/lib/libboost_unit_test_framework-mt.a + $(BOOST_DIR)/lib/libboost_unit_test_framework-mt.a LIBS += \ - $(DEPSDIR)/lib/db48/libdb_cxx-4.8.a \ - $(DEPSDIR)/lib/libboost_system-mt.a \ - $(DEPSDIR)/lib/libboost_filesystem-mt.a \ - $(DEPSDIR)/lib/libboost_program_options-mt.a \ - $(DEPSDIR)/lib/libboost_thread-mt.a \ - $(DEPSDIR)/lib/libboost_chrono-mt.a \ - $(DEPSDIR)/lib/libssl.a \ - $(DEPSDIR)/lib/libcrypto.a \ + $(BERKELEY_DIR)/lib/libdb_cxx-4.8.a \ + $(BOOST_DIR)/lib/libboost_system-mt.a \ + $(BOOST_DIR)/lib/libboost_filesystem-mt.a \ + $(BOOST_DIR)/lib/libboost_program_options-mt.a \ + $(BOOST_DIR)/lib/libboost_thread-mt.a \ + $(BOOST_DIR)/lib/libboost_chrono-mt.a \ + $(OPENSSL_DIR)/lib/libssl.a \ + $(OPENSSL_DIR)/lib/libcrypto.a \ + $(MINIUPNPC_DIR)/lib/libminiupnpc.a \ -lz else TESTLIBS += \ @@ -62,13 +84,17 @@ ifdef RELEASE # Compile for maximum compatibility and smallest size. # This requires that dependencies are compiled # the same way. -CFLAGS = -mmacosx-version-min=10.5 -arch i386 -O3 +CFLAGS = -mmacosx-version-min=10.12 -O3 +CXXFLAGS = -mmacosx-version-min=10.12 -O3 else DEBUGFLAGS = -g endif # ppc doesn't work because we don't support big-endian -CFLAGS += -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter \ +CFLAGS += -Wall \ + $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS) + +CXXFLAGS += -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter \ $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS) OBJS= \ @@ -112,7 +138,7 @@ endif ifneq (${USE_UPNP}, -) DEFS += -DUSE_UPNP=$(USE_UPNP) ifdef STATIC - LIBS += $(DEPSDIR)/lib/libminiupnpc.a + LIBS += $(MINIUPNPC_DIR)/lib/libminiupnpc.a else LIBS += -lminiupnpc endif @@ -146,33 +172,33 @@ version.cpp: obj/build.h DEFS += -DHAVE_BUILD_INFO obj/%.o: %.cpp - $(CXX) -c $(CFLAGS) -MMD -MF $(@:%.o=%.d) -o $@ $< + $(CXX) -c $(CXXFLAGS) -MMD -MF $(@:%.o=%.d) -o $@ $< @cp $(@:%.o=%.d) $(@:%.o=%.P); \ sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \ rm -f $(@:%.o=%.d) obj/%.o: %.c - $(CXX) -c $(CFLAGS) -fpermissive -MMD -MF $(@:%.o=%.d) -o $@ $< + $(CC) -c $(CFLAGS) -fpermissive -MMD -MF $(@:%.o=%.d) -o $@ $< @cp $(@:%.o=%.d) $(@:%.o=%.P); \ sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \ rm -f $(@:%.o=%.d) photond: $(OBJS:obj/%=obj/%) - $(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) + $(CXX) $(CXXFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) TESTOBJS := $(patsubst test/%.cpp,obj-test/%.o,$(wildcard test/*.cpp)) obj-test/%.o: test/%.cpp - $(CXX) -c $(TESTDEFS) $(CFLAGS) -MMD -MF $(@:%.o=%.d) -o $@ $< + $(CXX) -c $(TESTDEFS) $(CXXFLAGS) -MMD -MF $(@:%.o=%.d) -o $@ $< @cp $(@:%.o=%.d) $(@:%.o=%.P); \ sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \ rm -f $(@:%.o=%.d) test_photon: $(TESTOBJS) $(filter-out obj/init.o,$(OBJS:obj/%=obj/%)) - $(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) $(TESTLIBS) + $(CXX) $(CXXFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) $(TESTLIBS) clean: -rm -f photond test_photon diff --git a/src/obj/.gitignore b/src/obj/.gitignore deleted file mode 100644 index d6b7ef3..0000000 --- a/src/obj/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/src/serialize.h b/src/serialize.h index e3d9939..78db9ea 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -895,18 +895,18 @@ class CDataStream 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); } - void insert(iterator it, const_iterator first, const_iterator last) - { - assert(last - first >= 0); - if (it == vch.begin() + nReadPos && (unsigned int)(last - first) <= nReadPos) - { - // special case for inserting at the front when there's room - nReadPos -= (last - first); - memcpy(&vch[nReadPos], &first[0], last - first); - } - else - vch.insert(it, first, last); - } +// void insert(iterator it, const_iterator first, const_iterator last) +// { +// assert(last - first >= 0); +// if (it == vch.begin() + nReadPos && (unsigned int)(last - first) <= nReadPos) +// { +// // special case for inserting at the front when there's room +/// nReadPos -= (last - first); +// memcpy(&vch[nReadPos], &first[0], last - first); +// } +// else +// vch.insert(it, first, last); +// } void insert(iterator it, std::vector::const_iterator first, std::vector::const_iterator last) {