You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

222 lines
6.7 KiB

define LICENSE
Copyright (c) 2014-2019, The Monero Project
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Parts of the project are originally copyright (c) 2012-2013 The Cryptonote
developers.
endef
6 years ago
TARGET = monero-pool
TYPE = debug
5 years ago
ifeq ($(MAKECMDGOALS),release)
TYPE = release
endif
MONERO_BUILD_ROOT = ${MONERO_ROOT}/build/$(shell echo `uname | \
sed -e 's|[:/\\ \(\)]|_|g'`/`\
git -C ${MONERO_ROOT} branch | grep '\* ' | cut -f2- -d' '| \
sed -e 's|[:/\\ \(\)]|_|g'`)/release
MONERO_INC = ${MONERO_ROOT}/src \
${MONERO_ROOT}/external/easylogging++ \
${MONERO_ROOT}/contrib/epee/include
MONERO_LIBS = \
${MONERO_BUILD_ROOT}/src/cryptonote_basic/libcryptonote_basic.a \
${MONERO_BUILD_ROOT}/src/cryptonote_core/libcryptonote_core.a \
${MONERO_BUILD_ROOT}/src/crypto/libcncrypto.a \
${MONERO_BUILD_ROOT}/src/common/libcommon.a \
${MONERO_BUILD_ROOT}/src/ringct/libringct.a \
${MONERO_BUILD_ROOT}/src/ringct/libringct_basic.a \
${MONERO_BUILD_ROOT}/src/device/libdevice.a \
${MONERO_BUILD_ROOT}/src/blockchain_db/libblockchain_db.a \
${MONERO_BUILD_ROOT}/contrib/epee/src/libepee.a \
${MONERO_BUILD_ROOT}/external/easylogging++/libeasylogging.a
DIRS = src data rxi/log/src
6 years ago
OS := $(shell uname -s)
CPPDEFS = _GNU_SOURCE AUTO_INITIALIZE_EASYLOGGINGPP LOG_USE_COLOR
CCPARAM = -Wall $(CFLAGS) -maes -fPIC
6 years ago
CXXFLAGS = -std=c++11
ifeq ($(OS), Darwin)
CXXFLAGS += -stdlib=libc++
CPPDEFS += HAVE_MEMSET_S
endif
ifeq ($(OS),Darwin)
LDPARAM =
6 years ago
else
5 years ago
LDPARAM = -Wl,-warn-unresolved-symbols -fPIC -pie
6 years ago
endif
ifeq ($(TYPE),debug)
CCPARAM += -g
CPPDEFS += DEBUG
endif
ifeq ($(TYPE), release)
CCPARAM += -O3 -Wno-unused-variable
ifneq ($(OS), Darwin)
5 years ago
LDPARAM = -Wl,--unresolved-symbols=ignore-in-object-files
6 years ago
endif
endif
LDPARAM += $(LDFLAGS)
LIBS := lmdb pthread microhttpd unbound
6 years ago
ifeq ($(OS), Darwin)
LIBS += c++ boost_system-mt boost_date_time-mt boost_chrono-mt \
boost_filesystem-mt boost_thread-mt boost_regex-mt
6 years ago
else
LIBS += dl boost_system boost_date_time boost_chrono boost_filesystem \
boost_thread boost_regex uuid
6 years ago
endif
PKG_LIBS := $(shell pkg-config \
"libevent >= 2.1" \
6 years ago
json-c \
openssl \
libsodium \
6 years ago
--libs)
STATIC_LIBS =
DLIBS =
INCPATH := $(DIRS) ${MONERO_INC} /opt/local/include /usr/local/include
6 years ago
PKG_INC := $(shell pkg-config \
"libevent >= 2.1" \
6 years ago
json-c \
openssl \
libsodium \
6 years ago
--cflags)
LIBPATH := /opt/local/lib/ /usr/local/lib
C++ = g++
CC = gcc
5 years ago
XXD := $(shell command -v xxd 2> /dev/null)
6 years ago
STORE = build/$(TYPE)
SOURCE := $(foreach DIR,$(DIRS),$(wildcard $(DIR)/*.cpp))
CSOURCE := $(foreach DIR,$(DIRS),$(wildcard $(DIR)/*.c))
5 years ago
SSOURCE := $(foreach DIR,$(DIRS),$(wildcard $(DIR)/*.S))
6 years ago
HTMLSOURCE := $(foreach DIR,$(DIRS),$(wildcard $(DIR)/*.html))
HEADERS := $(foreach DIR,$(DIRS),$(wildcard $(DIR)/*.h))
OBJECTS := $(addprefix $(STORE)/, $(SOURCE:.cpp=.o))
COBJECTS := $(addprefix $(STORE)/, $(CSOURCE:.c=.o))
5 years ago
SOBJECTS := $(addprefix $(STORE)/, $(SSOURCE:.S=.o))
6 years ago
HTMLOBJECTS := $(addprefix $(STORE)/, $(HTMLSOURCE:.html=.o))
DFILES := $(addprefix $(STORE)/,$(SOURCE:.cpp=.d))
CDFILES := $(addprefix $(STORE)/,$(CSOURCE:.c=.d))
5 years ago
SDFILES := $(addprefix $(STORE)/,$(CSOURCE:.S=.d))
6 years ago
.PHONY: clean dirs debug release preflight
6 years ago
$(TARGET): preflight dirs $(OBJECTS) $(COBJECTS) $(SOBJECTS) $(HTMLOBJECTS)
6 years ago
@echo Linking $(OBJECTS)...
$(C++) -o $(STORE)/$(TARGET) $(OBJECTS) $(COBJECTS) $(SOBJECTS) $(HTMLOBJECTS) \
$(LDPARAM) $(MONERO_LIBS) \
$(foreach LIBRARY, $(LIBS),-l$(LIBRARY)) \
$(foreach LIB,$(LIBPATH),-L$(LIB)) \
$(PKG_LIBS) $(STATIC_LIBS)
6 years ago
@cp pool.conf $(STORE)/
@cp tools/* $(STORE)/
6 years ago
$(STORE)/%.o: %.cpp
@echo Creating object file for $*...
$(C++) -Wp,-MMD,$(STORE)/$*.dd $(CCPARAM) $(CXXFLAGS) \
$(foreach INC,$(INCPATH),-I$(INC)) \
$(PKG_INC) \
$(foreach CPPDEF,$(CPPDEFS),-D$(CPPDEF)) \
-c $< -o $@
6 years ago
@sed -e '1s/^\(.*\)$$/$(subst /,\/,$(dir $@))\1/' $(STORE)/$*.dd > $(STORE)/$*.d
@rm -f $(STORE)/$*.dd
$(STORE)/%.o: %.c
@echo Creating object file for $*...
$(CC) -Wp,-MMD,$(STORE)/$*.dd $(CCPARAM) $(foreach INC,$(INCPATH),-I$(INC)) $(PKG_INC)\
$(foreach CPPDEF,$(CPPDEFS),-D$(CPPDEF)) -c $< -o $@
@sed -e '1s/^\(.*\)$$/$(subst /,\/,$(dir $@))\1/' $(STORE)/$*.dd > $(STORE)/$*.d
@rm -f $(STORE)/$*.dd
5 years ago
$(STORE)/%.o: %.S
@echo Creating object file for $*...
$(CC) -Wp,-MMD,$(STORE)/$*.dd $(CCPARAM) $(foreach INC,$(INCPATH),-I$(INC)) $(PKG_INC)\
$(foreach CPPDEF,$(CPPDEFS),-D$(CPPDEF)) -c $< -o $@
@sed -e '1s/^\(.*\)$$/$(subst /,\/,$(dir $@))\1/' $(STORE)/$*.dd > $(STORE)/$*.d
@rm -f $(STORE)/$*.dd
6 years ago
$(STORE)/%.o: %.html
@echo Creating object file for $*...
xxd -i $< | sed -e 's/src_//' -e 's/embed_//' > $(STORE)/$*.c
$(CC) $(CCPARAM) -c $(STORE)/$*.c -o $@
@rm -f $(STORE)/$*.c
# Empty rule to prevent problems when a header is deleted.
%.h: ;
debug release : $(TARGET)
6 years ago
clean:
@echo Making clean.
5 years ago
@find ./build -type f -name '*.o' -delete
@find ./build -type f -name '*.d' -delete
@find ./build -type f -name $(TARGET) -delete
6 years ago
dirs:
@-if [ ! -e $(STORE) ]; then mkdir -p $(STORE); fi;
@-$(foreach DIR,$(DIRS), \
if [ ! -e $(STORE)/$(DIR) ]; then mkdir -p $(STORE)/$(DIR); fi; )
6 years ago
preflight:
ifeq ($(origin MONERO_ROOT), undefined)
$(error You need to set an environment variable MONERO_ROOT to your monero repository root)
endif
ifndef PKG_LIBS
$(error Missing dependencies)
endif
5 years ago
ifndef XXD
$(error Command xxd not found)
endif
6 years ago
-include $(DFILES)
-include $(CDFILES)
5 years ago
-include $(SDFILES)
6 years ago