Skip to content

Commit

Permalink
Merge pull request #16 from gl3nda85/compile-fix-osx
Browse files Browse the repository at this point in the history
make file fixed for OSX
  • Loading branch information
BlueDragon747 committed May 19, 2018
2 parents 94c1add + 069de10 commit a88d3c9
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 37 deletions.
Empty file modified src/leveldb/build_detect_platform 100644 → 100755
Empty file.
72 changes: 49 additions & 23 deletions src/makefile.osx
Expand Up @@ -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 += \
Expand All @@ -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= \
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions src/obj/.gitignore

This file was deleted.

24 changes: 12 additions & 12 deletions src/serialize.h
Expand Up @@ -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<char>::const_iterator first, std::vector<char>::const_iterator last)
{
Expand Down

0 comments on commit a88d3c9

Please sign in to comment.