From c3078dfc9f61658f14c3854ad0c39d0df07fe80b Mon Sep 17 00:00:00 2001 From: Maxim Mamontov Date: Sat, 24 Mar 2018 12:04:39 +0200 Subject: [PATCH] Fix build on osx. --- 3rdparty/snmp++/Makefile | 2 +- Makefile | 20 ++++++++++++++------ include/logger.h | 2 +- include/pidfile.h | 2 +- include/settings.h | 2 +- include/settings.inl.h | 2 +- src/settingsfileparser.cpp | 6 ------ src/syncer.cpp | 2 +- 8 files changed, 20 insertions(+), 18 deletions(-) diff --git a/3rdparty/snmp++/Makefile b/3rdparty/snmp++/Makefile index 2a67cd9..2c34f34 100644 --- a/3rdparty/snmp++/Makefile +++ b/3rdparty/snmp++/Makefile @@ -1,6 +1,6 @@ SHELL = /bin/sh DEFS += -D_USE_OPENSSL -INCS += -Iinclude +INCS += -I/opt/local/include -Iinclude CXXFLAGS += -W -Wall -Wextra $(DEFS) $(INCS) PROG = libsnmp++.a diff --git a/Makefile b/Makefile index ad0f662..5b86f16 100644 --- a/Makefile +++ b/Makefile @@ -3,11 +3,18 @@ ifeq ($(BUILD),Debug) CXXFLAGS += -g3 endif -INCS = -Iinclude -I3rdparty/snmp++/include +UNAME = $(shell uname -s) + +ifeq ($(UNAME), Darwin) + BOOST_SUFFIX = -mt +endif + +INCS = -I/opt/local/include -Iinclude -I3rdparty/snmp++/include CXXFLAGS += -W -Wall -Wextra $(INCS) $(DEFS) -LIBS = 3rdparty/snmp++/libsnmp++.a \ - -lboost_system \ - -lboost_program_options \ +LIBS = -L/opt/local/lib \ + 3rdparty/snmp++/libsnmp++.a \ + -lboost_system$(BOOST_SUFFIX) \ + -lboost_program_options$(BOOST_SUFFIX) \ -lcurl \ -lssl \ -lcrypto \ @@ -45,8 +52,9 @@ snmplib: include/version.h: version version: - @sed 's/@VERSION@/$(VERSION)/g' include/version.h.in > include/version.h - @sed -i 's/@GIT_SHA@/'`git rev-parse --short HEAD`'/g' include/version.h + @sed 's/@VERSION@/$(VERSION)/g' include/version.h.in > include/version.h.tmp + @sed "s/@GIT_SHA@/$$(git rev-parse --short HEAD)/g" include/version.h.tmp > include/version.h + @rm include/version.h.tmp $(PROG): version $(subst .cpp,.o,$(SOURCES)) snmplib $(CXX) $(subst .cpp,.o,$(SOURCES)) $(LIBS) -o $@ diff --git a/include/logger.h b/include/logger.h index 7207003..7906548 100644 --- a/include/logger.h +++ b/include/logger.h @@ -15,7 +15,7 @@ public: : fout(), consoleLog(true) {} - Logger(const std::string & fileName) + explicit Logger(const std::string & fileName) : fout(fileName.c_str(), std::ios::app), logFile(fileName), consoleLog(!fout.is_open()) diff --git a/include/pidfile.h b/include/pidfile.h index ba9adec..a791c65 100644 --- a/include/pidfile.h +++ b/include/pidfile.h @@ -10,7 +10,7 @@ namespace SSMD { class PIDFile : private boost::noncopyable { public: PIDFile(); - PIDFile(const std::string & file); + explicit PIDFile(const std::string & file); ~PIDFile(); private: const std::string fileName; diff --git a/include/settings.h b/include/settings.h index 041453a..6a7dfec 100644 --- a/include/settings.h +++ b/include/settings.h @@ -18,7 +18,7 @@ class Settings { Settings(const Settings & rvalue); ~Settings(); - const Settings & operator=(const Settings & rvalue); + Settings & operator=(const Settings & rvalue); // Accessors bool isHelp() const throw() { return _isHelp; } diff --git a/include/settings.inl.h b/include/settings.inl.h index e922c82..c93e40b 100644 --- a/include/settings.inl.h +++ b/include/settings.inl.h @@ -50,7 +50,7 @@ Settings::~Settings() } inline -const Settings & Settings::operator=(const Settings & rvalue) +Settings & Settings::operator=(const Settings & rvalue) { _isHelp = rvalue._isHelp; _isVersion = rvalue._isVersion; diff --git a/src/settingsfileparser.cpp b/src/settingsfileparser.cpp index a211307..0066269 100644 --- a/src/settingsfileparser.cpp +++ b/src/settingsfileparser.cpp @@ -42,12 +42,6 @@ struct IniGrammar qi::rule comment, space, eol; }; -inline -bool sectionExists(const SectionsType & data, const std::string & sectionName) throw() -{ - return data.find(sectionName) != data.end(); -} - inline bool fieldExists(const SectionsType & data, const std::string & sectionName, const std::string & fieldName) throw() { diff --git a/src/syncer.cpp b/src/syncer.cpp index fefd843..436c396 100644 --- a/src/syncer.cpp +++ b/src/syncer.cpp @@ -64,7 +64,7 @@ Syncer::~Syncer() void Syncer::run(const bool & running, bool & reload) { logger << "Syncer::run()" << std::endl; - while (running) { + while (true) { if (wait()) { logger << "Syncer::run() - wait stopped by signal" << std::endl; if (!running) -- 2.44.2