2019-07-05 21:28:04 +00:00
|
|
|
# Copyright (c) 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.
|
2019-05-11 05:53:03 +00:00
|
|
|
|
2018-08-12 13:46:08 +00:00
|
|
|
TARGET = monero-pool
|
|
|
|
|
|
|
|
TYPE = debug
|
|
|
|
|
2019-02-24 19:07:16 +00:00
|
|
|
ifeq ($(MAKECMDGOALS),release)
|
2019-07-05 21:28:04 +00:00
|
|
|
TYPE = release
|
2019-02-24 19:07:16 +00:00
|
|
|
endif
|
|
|
|
|
2019-07-05 21:28:04 +00:00
|
|
|
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
|
2019-05-11 05:53:03 +00:00
|
|
|
|
2019-07-05 21:28:04 +00:00
|
|
|
MONERO_INC = \
|
|
|
|
${MONERO_ROOT}/src \
|
|
|
|
${MONERO_ROOT}/external \
|
|
|
|
${MONERO_ROOT}/external/easylogging++ \
|
|
|
|
${MONERO_ROOT}/contrib/epee/include
|
2019-03-16 05:28:10 +00:00
|
|
|
|
|
|
|
MONERO_LIBS = \
|
|
|
|
${MONERO_BUILD_ROOT}/src/cryptonote_basic/libcryptonote_basic.a \
|
|
|
|
${MONERO_BUILD_ROOT}/src/crypto/libcncrypto.a \
|
|
|
|
${MONERO_BUILD_ROOT}/src/common/libcommon.a \
|
|
|
|
${MONERO_BUILD_ROOT}/src/ringct/libringct_basic.a \
|
|
|
|
${MONERO_BUILD_ROOT}/src/device/libdevice.a \
|
|
|
|
${MONERO_BUILD_ROOT}/contrib/epee/src/libepee.a \
|
2019-08-21 23:35:30 +00:00
|
|
|
${MONERO_BUILD_ROOT}/external/easylogging++/libeasylogging.a
|
|
|
|
|
|
|
|
LIBRX = ${MONERO_BUILD_ROOT}/external/randomx/librandomx.a
|
2019-03-16 05:28:10 +00:00
|
|
|
|
|
|
|
DIRS = src data rxi/log/src
|
2018-08-12 13:46:08 +00:00
|
|
|
|
|
|
|
OS := $(shell uname -s)
|
|
|
|
|
|
|
|
CPPDEFS = _GNU_SOURCE AUTO_INITIALIZE_EASYLOGGINGPP LOG_USE_COLOR
|
|
|
|
|
2019-08-21 23:35:30 +00:00
|
|
|
ifeq ($(wildcard ${LIBRX}),${LIBRX})
|
|
|
|
MONERO_LIBS += ${LIBRX}
|
|
|
|
CPPDEFS += HAVE_RX
|
|
|
|
else
|
|
|
|
ifneq ($(MAKECMDGOALS),clean)
|
|
|
|
$(warning Building without RandomX!)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2019-08-07 02:43:45 +00:00
|
|
|
W = -W -Wall -Wno-unused-parameter -Wuninitialized
|
|
|
|
OPT = -maes -fPIC
|
|
|
|
CFLAGS = $(W) -Wbad-function-cast $(OPT) -std=c99
|
|
|
|
CXXFLAGS = $(W) -Wno-reorder $(OPT) -std=c++11
|
|
|
|
LDPARAM = -fPIC -pie
|
2018-08-12 13:46:08 +00:00
|
|
|
|
|
|
|
ifeq ($(OS), Darwin)
|
2019-07-05 21:28:04 +00:00
|
|
|
CXXFLAGS += -stdlib=libc++
|
|
|
|
CPPDEFS += HAVE_MEMSET_S
|
|
|
|
LDPARAM =
|
2018-08-12 13:46:08 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(TYPE),debug)
|
2019-08-07 02:43:45 +00:00
|
|
|
CFLAGS += -g
|
|
|
|
CXXFLAGS += -g
|
2019-07-05 21:28:04 +00:00
|
|
|
CPPDEFS += DEBUG
|
2018-08-12 13:46:08 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(TYPE), release)
|
2019-08-07 02:43:45 +00:00
|
|
|
CFLAGS += -O3
|
|
|
|
CXXFLAGS += -O3
|
2018-08-12 13:46:08 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
LDPARAM += $(LDFLAGS)
|
|
|
|
|
2019-04-07 18:32:44 +00:00
|
|
|
LIBS := lmdb pthread microhttpd unbound
|
2018-08-12 13:46:08 +00:00
|
|
|
ifeq ($(OS), Darwin)
|
2019-07-05 21:28:04 +00:00
|
|
|
LIBS += c++ \
|
|
|
|
boost_system-mt boost_date_time-mt boost_chrono-mt \
|
|
|
|
boost_filesystem-mt boost_thread-mt boost_regex-mt \
|
|
|
|
boost_serialization-mt boost_program_options-mt
|
2018-08-12 13:46:08 +00:00
|
|
|
else
|
2019-07-05 21:28:04 +00:00
|
|
|
LIBS += dl uuid \
|
|
|
|
boost_system boost_date_time boost_chrono \
|
|
|
|
boost_filesystem boost_thread boost_regex \
|
|
|
|
boost_serialization boost_program_options
|
2018-08-12 13:46:08 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
PKG_LIBS := $(shell pkg-config \
|
2019-07-05 21:28:04 +00:00
|
|
|
"libevent >= 2.1" \
|
|
|
|
json-c \
|
|
|
|
openssl \
|
|
|
|
libsodium \
|
|
|
|
--libs)
|
2018-08-12 13:46:08 +00:00
|
|
|
|
|
|
|
STATIC_LIBS =
|
|
|
|
DLIBS =
|
|
|
|
|
2019-03-16 05:28:10 +00:00
|
|
|
INCPATH := $(DIRS) ${MONERO_INC} /opt/local/include /usr/local/include
|
2018-08-12 13:46:08 +00:00
|
|
|
|
|
|
|
PKG_INC := $(shell pkg-config \
|
2019-07-05 21:28:04 +00:00
|
|
|
"libevent >= 2.1" \
|
|
|
|
json-c \
|
|
|
|
openssl \
|
|
|
|
libsodium \
|
|
|
|
--cflags)
|
2018-08-12 13:46:08 +00:00
|
|
|
|
|
|
|
LIBPATH := /opt/local/lib/ /usr/local/lib
|
|
|
|
|
|
|
|
C++ = g++
|
|
|
|
CC = gcc
|
2019-05-04 18:15:01 +00:00
|
|
|
XXD := $(shell command -v xxd 2> /dev/null)
|
2018-08-12 13:46:08 +00:00
|
|
|
|
|
|
|
STORE = build/$(TYPE)
|
|
|
|
SOURCE := $(foreach DIR,$(DIRS),$(wildcard $(DIR)/*.cpp))
|
|
|
|
CSOURCE := $(foreach DIR,$(DIRS),$(wildcard $(DIR)/*.c))
|
2019-02-24 16:30:51 +00:00
|
|
|
SSOURCE := $(foreach DIR,$(DIRS),$(wildcard $(DIR)/*.S))
|
2018-08-12 13:46:08 +00:00
|
|
|
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))
|
2019-02-24 16:30:51 +00:00
|
|
|
SOBJECTS := $(addprefix $(STORE)/, $(SSOURCE:.S=.o))
|
2018-08-12 13:46:08 +00:00
|
|
|
HTMLOBJECTS := $(addprefix $(STORE)/, $(HTMLSOURCE:.html=.o))
|
|
|
|
DFILES := $(addprefix $(STORE)/,$(SOURCE:.cpp=.d))
|
|
|
|
CDFILES := $(addprefix $(STORE)/,$(CSOURCE:.c=.d))
|
2019-02-24 16:30:51 +00:00
|
|
|
SDFILES := $(addprefix $(STORE)/,$(CSOURCE:.S=.d))
|
2018-08-12 13:46:08 +00:00
|
|
|
|
|
|
|
|
2019-05-07 05:12:30 +00:00
|
|
|
.PHONY: clean dirs debug release preflight
|
2018-08-12 13:46:08 +00:00
|
|
|
|
2019-03-16 05:28:10 +00:00
|
|
|
$(TARGET): preflight dirs $(OBJECTS) $(COBJECTS) $(SOBJECTS) $(HTMLOBJECTS)
|
2018-08-12 13:46:08 +00:00
|
|
|
@echo Linking $(OBJECTS)...
|
2019-07-05 21:28:04 +00:00
|
|
|
$(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)
|
2018-08-12 13:46:08 +00:00
|
|
|
@cp pool.conf $(STORE)/
|
2019-05-07 05:12:30 +00:00
|
|
|
@cp tools/* $(STORE)/
|
2018-08-12 13:46:08 +00:00
|
|
|
|
|
|
|
$(STORE)/%.o: %.cpp
|
|
|
|
@echo Creating object file for $*...
|
2019-08-07 02:43:45 +00:00
|
|
|
$(C++) -Wp,-MMD,$(STORE)/$*.dd $(CXXFLAGS) \
|
2019-07-05 21:28:04 +00:00
|
|
|
$(foreach INC,$(INCPATH),-I$(INC)) \
|
|
|
|
$(PKG_INC) \
|
|
|
|
$(foreach CPPDEF,$(CPPDEFS),-D$(CPPDEF)) \
|
|
|
|
-c $< -o $@
|
|
|
|
@sed -e '1s/^\(.*\)$$/$(subst /,\/,$(dir $@))\1/' \
|
|
|
|
$(STORE)/$*.dd > $(STORE)/$*.d
|
2018-08-12 13:46:08 +00:00
|
|
|
@rm -f $(STORE)/$*.dd
|
|
|
|
|
|
|
|
$(STORE)/%.o: %.c
|
|
|
|
@echo Creating object file for $*...
|
2019-08-07 02:43:45 +00:00
|
|
|
$(CC) -Wp,-MMD,$(STORE)/$*.dd $(CFLAGS) \
|
2019-07-05 21:28:04 +00:00
|
|
|
$(foreach INC,$(INCPATH),-I$(INC)) $(PKG_INC) \
|
|
|
|
$(foreach CPPDEF,$(CPPDEFS),-D$(CPPDEF)) -c $< -o $@
|
|
|
|
@sed -e '1s/^\(.*\)$$/$(subst /,\/,$(dir $@))\1/' \
|
|
|
|
$(STORE)/$*.dd > $(STORE)/$*.d
|
2018-08-12 13:46:08 +00:00
|
|
|
@rm -f $(STORE)/$*.dd
|
|
|
|
|
2019-02-24 16:30:51 +00:00
|
|
|
$(STORE)/%.o: %.S
|
|
|
|
@echo Creating object file for $*...
|
2019-08-07 02:43:45 +00:00
|
|
|
$(CC) -Wp,-MMD,$(STORE)/$*.dd $(CFLAGS) \
|
2019-07-05 21:28:04 +00:00
|
|
|
$(foreach INC,$(INCPATH),-I$(INC)) $(PKG_INC) \
|
|
|
|
$(foreach CPPDEF,$(CPPDEFS),-D$(CPPDEF)) -c $< -o $@
|
|
|
|
@sed -e '1s/^\(.*\)$$/$(subst /,\/,$(dir $@))\1/' \
|
|
|
|
$(STORE)/$*.dd > $(STORE)/$*.d
|
2019-02-24 16:30:51 +00:00
|
|
|
@rm -f $(STORE)/$*.dd
|
|
|
|
|
2018-08-12 13:46:08 +00:00
|
|
|
$(STORE)/%.o: %.html
|
|
|
|
@echo Creating object file for $*...
|
|
|
|
xxd -i $< | sed -e 's/src_//' -e 's/embed_//' > $(STORE)/$*.c
|
2019-08-07 02:43:45 +00:00
|
|
|
$(CC) $(CFLAGS) -c $(STORE)/$*.c -o $@
|
2018-08-12 13:46:08 +00:00
|
|
|
@rm -f $(STORE)/$*.c
|
|
|
|
|
|
|
|
# Empty rule to prevent problems when a header is deleted.
|
|
|
|
%.h: ;
|
|
|
|
|
2019-03-16 05:28:10 +00:00
|
|
|
debug release : $(TARGET)
|
|
|
|
|
2018-08-12 13:46:08 +00:00
|
|
|
clean:
|
|
|
|
@echo Making clean.
|
2019-02-24 19:07:16 +00:00
|
|
|
@find ./build -type f -name '*.o' -delete
|
|
|
|
@find ./build -type f -name '*.d' -delete
|
|
|
|
@find ./build -type f -name $(TARGET) -delete
|
2018-08-12 13:46:08 +00:00
|
|
|
|
|
|
|
dirs:
|
|
|
|
@-if [ ! -e $(STORE) ]; then mkdir -p $(STORE); fi;
|
2019-05-11 05:53:03 +00:00
|
|
|
@-$(foreach DIR,$(DIRS), \
|
2019-07-05 21:28:04 +00:00
|
|
|
if [ ! -e $(STORE)/$(DIR) ]; then mkdir -p $(STORE)/$(DIR); fi; )
|
2018-08-12 13:46:08 +00:00
|
|
|
|
2019-03-16 05:28:10 +00:00
|
|
|
preflight:
|
|
|
|
ifeq ($(origin MONERO_ROOT), undefined)
|
2019-07-05 21:28:04 +00:00
|
|
|
$(error You need to set an environment variable MONERO_ROOT \
|
|
|
|
to your monero repository root)
|
2019-03-16 05:28:10 +00:00
|
|
|
endif
|
2019-04-16 03:44:03 +00:00
|
|
|
ifndef PKG_LIBS
|
2019-07-05 21:28:04 +00:00
|
|
|
$(error Missing dependencies)
|
2019-04-16 03:44:03 +00:00
|
|
|
endif
|
2019-04-16 04:08:54 +00:00
|
|
|
ifndef XXD
|
2019-07-05 21:28:04 +00:00
|
|
|
$(error Command xxd not found)
|
2019-04-16 04:08:54 +00:00
|
|
|
endif
|
2019-03-16 05:28:10 +00:00
|
|
|
|
2018-08-12 13:46:08 +00:00
|
|
|
-include $(DFILES)
|
|
|
|
-include $(CDFILES)
|
2019-02-24 19:07:16 +00:00
|
|
|
-include $(SDFILES)
|
2018-08-12 13:46:08 +00:00
|
|
|
|