primecoin-sys_leveldb.patch 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. diff -Naur primecoin-0.1.2-linux.orig/src/bitcoin-qt.pro primecoin-0.1.2-linux/src/bitcoin-qt.pro
  2. --- primecoin-0.1.2-linux.orig/src/bitcoin-qt.pro 2013-08-05 08:37:14.000000000 -0400
  3. +++ primecoin-0.1.2-linux/src/bitcoin-qt.pro 2013-11-30 16:39:48.464770389 -0500
  4. @@ -4,7 +4,7 @@
  5. VERSION = 0.8.3
  6. INCLUDEPATH += src src/json src/qt
  7. QT += network
  8. -DEFINES += QT_GUI BOOST_THREAD_USE_LIB BOOST_SPIRIT_THREADSAFE
  9. +DEFINES += QT_GUI BOOST_THREAD_USE_LIB BOOST_SPIRIT_THREADSAFE LEVELDB_WITHOUT_MEMENV
  10. CONFIG += no_include_pwd
  11. CONFIG += thread
  12. @@ -98,25 +98,29 @@
  13. QTPLUGIN += qcncodecs qjpcodecs qtwcodecs qkrcodecs qtaccessiblewidgets
  14. }
  15. +contains(USE_SYSTEM_LEVELDB, 1) {
  16. + LIBS += -lleveldb
  17. +} else {
  18. INCLUDEPATH += src/leveldb/include src/leveldb/helpers
  19. -LIBS += $$PWD/src/leveldb/libleveldb.a $$PWD/src/leveldb/libmemenv.a
  20. +LIBS += $$PWD/src/leveldb/libleveldb.a
  21. !win32 {
  22. # we use QMAKE_CXXFLAGS_RELEASE even without RELEASE=1 because we use RELEASE to indicate linking preferences not -O preferences
  23. - genleveldb.commands = cd $$PWD/src/leveldb && CC=$$QMAKE_CC CXX=$$QMAKE_CXX $(MAKE) OPT=\"$$QMAKE_CXXFLAGS $$QMAKE_CXXFLAGS_RELEASE\" libleveldb.a libmemenv.a
  24. + genleveldb.commands = cd $$PWD/src/leveldb && CC=$$QMAKE_CC CXX=$$QMAKE_CXX $(MAKE) OPT=\"$$QMAKE_CXXFLAGS $$QMAKE_CXXFLAGS_RELEASE\" libleveldb.a
  25. } else {
  26. # make an educated guess about what the ranlib command is called
  27. isEmpty(QMAKE_RANLIB) {
  28. QMAKE_RANLIB = $$replace(QMAKE_STRIP, strip, ranlib)
  29. }
  30. LIBS += -lshlwapi
  31. - genleveldb.commands = cd $$PWD/src/leveldb && CC=$$QMAKE_CC CXX=$$QMAKE_CXX TARGET_OS=OS_WINDOWS_CROSSCOMPILE $(MAKE) OPT=\"$$QMAKE_CXXFLAGS $$QMAKE_CXXFLAGS_RELEASE\" libleveldb.a libmemenv.a && $$QMAKE_RANLIB $$PWD/src/leveldb/libleveldb.a && $$QMAKE_RANLIB $$PWD/src/leveldb/libmemenv.a
  32. + genleveldb.commands = cd $$PWD/src/leveldb && CC=$$QMAKE_CC CXX=$$QMAKE_CXX TARGET_OS=OS_WINDOWS_CROSSCOMPILE $(MAKE) OPT=\"$$QMAKE_CXXFLAGS $$QMAKE_CXXFLAGS_RELEASE\" libleveldb.a && $$QMAKE_RANLIB $$PWD/src/leveldb/libleveldb.a
  33. }
  34. genleveldb.target = $$PWD/src/leveldb/libleveldb.a
  35. genleveldb.depends = FORCE
  36. PRE_TARGETDEPS += $$PWD/src/leveldb/libleveldb.a
  37. QMAKE_EXTRA_TARGETS += genleveldb
  38. +}
  39. # Gross ugly hack that depends on qmake internals, unfortunately there is no other way to do it.
  40. -QMAKE_CLEAN += $$PWD/src/leveldb/libleveldb.a; cd $$PWD/src/leveldb ; $(MAKE) clean
  41. +QMAKE_CLEAN += $$PWD/src/leveldb/libleveldb.a; cd $$PWD/src/leveldb && $(MAKE) clean || true
  42. # regenerate src/build.h
  43. !win32|contains(USE_BUILD_INFO, 1) {
  44. diff -Naur primecoin-0.1.2-linux.orig/src/src/leveldb.cpp primecoin-0.1.2-linux/src/src/leveldb.cpp
  45. --- primecoin-0.1.2-linux.orig/src/src/leveldb.cpp 2013-08-05 08:37:20.000000000 -0400
  46. +++ primecoin-0.1.2-linux/src/src/leveldb.cpp 2013-11-30 16:41:25.632773774 -0500
  47. @@ -8,7 +8,9 @@
  48. #include <leveldb/env.h>
  49. #include <leveldb/cache.h>
  50. #include <leveldb/filter_policy.h>
  51. -#include <memenv/memenv.h>
  52. +#ifndef LEVELDB_WITHOUT_MEMENV
  53. +#include <memenv.h>
  54. +#endif
  55. #include <boost/filesystem.hpp>
  56. @@ -43,8 +45,12 @@
  57. options = GetOptions(nCacheSize);
  58. options.create_if_missing = true;
  59. if (fMemory) {
  60. +#ifndef LEVELDB_WITHOUT_MEMENV
  61. penv = leveldb::NewMemEnv(leveldb::Env::Default());
  62. options.env = penv;
  63. +#else
  64. + throw std::runtime_error("CLevelDB(): compiled without memenv support");
  65. +#endif
  66. } else {
  67. if (fWipe) {
  68. printf("Wiping LevelDB in %s\n", path.string().c_str());
  69. diff -Naur primecoin-0.1.2-linux.orig/src/src/makefile.unix primecoin-0.1.2-linux/src/src/makefile.unix
  70. --- primecoin-0.1.2-linux.orig/src/src/makefile.unix 2013-08-05 08:37:21.000000000 -0400
  71. +++ primecoin-0.1.2-linux/src/src/makefile.unix 2013-11-30 17:20:06.545854617 -0500
  72. @@ -111,8 +111,7 @@
  73. # adds some defaults in front. Unfortunately, LDFLAGS=... $(LDFLAGS) does not work.
  74. xLDFLAGS=$(LDHARDENING) $(LDFLAGS)
  75. -OBJS= \
  76. - leveldb/libleveldb.a \
  77. +BASEOBJS := \
  78. obj/alert.o \
  79. obj/version.o \
  80. obj/checkpoints.o \
  81. @@ -121,7 +120,6 @@
  82. obj/crypter.o \
  83. obj/key.o \
  84. obj/db.o \
  85. - obj/init.o \
  86. obj/keystore.o \
  87. obj/main.o \
  88. obj/net.o \
  89. @@ -141,25 +139,44 @@
  90. obj/hash.o \
  91. obj/bloom.o \
  92. obj/noui.o \
  93. - obj/leveldb.o \
  94. obj/txdb.o \
  95. obj/prime.o \
  96. obj/checkpointsync.o
  97. +OBJS := \
  98. + obj/leveldb.o \
  99. + obj/init.o \
  100. + $(BASEOBJS)
  101. +
  102. +TESTOBJS := \
  103. + obj-test/leveldb.o \
  104. + $(patsubst test/%.cpp,obj-test/%.o,$(wildcard test/*.cpp)) \
  105. + $(BASEOBJS)
  106. +
  107. all: primecoind
  108. test check: test_primecoin FORCE
  109. ./test_primecoin
  110. +ifdef USE_SYSTEM_LEVELDB
  111. + LIBS += -lleveldb
  112. + TESTLIBS += -lmemenv
  113. +else
  114. #
  115. # LevelDB support
  116. #
  117. MAKEOVERRIDES =
  118. -LIBS += $(CURDIR)/leveldb/libleveldb.a $(CURDIR)/leveldb/libmemenv.a
  119. +LIBS += $(CURDIR)/leveldb/libleveldb.a
  120. +TESTLIBS += $(CURDIR)/leveldb/libmemenv.a
  121. DEFS += $(addprefix -I,$(CURDIR)/leveldb/include)
  122. DEFS += $(addprefix -I,$(CURDIR)/leveldb/helpers)
  123. leveldb/libleveldb.a:
  124. - @echo "Building LevelDB ..." && cd leveldb && $(MAKE) CC=$(CC) CXX=$(CXX) OPT="$(xCXXFLAGS)" libleveldb.a libmemenv.a && cd ..
  125. + @echo "Building LevelDB ..." && cd leveldb && $(MAKE) CC=$(CC) CXX=$(CXX) OPT="$(xCXXFLAGS)" libleveldb.a && cd ..
  126. +leveldb/libmemenv.a:
  127. + @echo "Building LevelDB memenv ..." && cd leveldb && $(MAKE) CC=$(CC) CXX=$(CXX) OPT="$(xCXXFLAGS)" libmemenv.a && cd ..
  128. +OBJS += leveldb/libleveldb.a
  129. +TESTOBJS += leveldb/libmemenv.a
  130. +endif
  131. # auto-generated dependencies:
  132. -include obj/*.P
  133. @@ -170,24 +187,22 @@
  134. version.cpp: obj/build.h
  135. DEFS += -DHAVE_BUILD_INFO
  136. -obj/%.o: %.cpp
  137. - $(CXX) -c $(xCXXFLAGS) -MMD -MF $(@:%.o=%.d) -o $@ $<
  138. +P_TO_D = \
  139. @cp $(@:%.o=%.d) $(@:%.o=%.P); \
  140. - sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
  141. + sed -e 's/\#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
  142. -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
  143. rm -f $(@:%.o=%.d)
  144. -primecoind: $(OBJS:obj/%=obj/%)
  145. - $(LINK) $(xCXXFLAGS) -o $@ $^ $(xLDFLAGS) $(LIBS)
  146. +obj/%.o: %.cpp
  147. + $(CXX) -c $(xCXXFLAGS) -DLEVELDB_WITHOUT_MEMENV -MMD -MF $(@:%.o=%.d) -o $@ $<
  148. + $(P_TO_D)
  149. -TESTOBJS := $(patsubst test/%.cpp,obj-test/%.o,$(wildcard test/*.cpp))
  150. +primecoind: $(OBJS)
  151. + $(LINK) $(xCXXFLAGS) -o $@ $^ $(xLDFLAGS) $(LIBS)
  152. obj-test/%.o: test/%.cpp
  153. - $(CXX) -c $(TESTDEFS) $(xCXXFLAGS) -MMD -MF $(@:%.o=%.d) -o $@ $<
  154. - @cp $(@:%.o=%.d) $(@:%.o=%.P); \
  155. - sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
  156. - -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
  157. - rm -f $(@:%.o=%.d)
  158. + $(CXX) -c $(xCXXFLAGS) -DLEVELDB_WITHOUT_MEMENV -MMD -MF $(@:%.o=%.d) -o $@ $<
  159. + $(P_TO_D)
  160. test_primecoin: $(TESTOBJS) $(filter-out obj/init.o,$(OBJS:obj/%=obj/%))
  161. $(LINK) $(xCXXFLAGS) -o $@ $(LIBPATHS) $^ $(TESTLIBS) $(xLDFLAGS) $(LIBS)