diff options
author | Roland Reichwein <mail@reichwein.it> | 2020-06-06 13:58:22 +0200 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2020-06-06 13:58:22 +0200 |
commit | d0db131a73933d0a6c65bab59d1e0e4f6a185338 (patch) | |
tree | 06edad4d845c8ba4102843fc3b306d7b5cc485d6 /libcommon | |
parent | 343922258d57261021daca42eb488c1205ae491c (diff) |
Code cleanup, use gcc 8 on debian 10
Diffstat (limited to 'libcommon')
-rw-r--r-- | libcommon/Makefile | 79 | ||||
-rw-r--r-- | libcommon/tempfile.cpp | 11 |
2 files changed, 15 insertions, 75 deletions
diff --git a/libcommon/Makefile b/libcommon/Makefile index ab76ed1..d3d781d 100644 --- a/libcommon/Makefile +++ b/libcommon/Makefile @@ -1,60 +1,10 @@ # Static library to be included both in main program an in plugins (.so) -DISTROS=debian10 -VERSION=$(shell dpkg-parsechangelog --show-field Version) -PROJECTNAME=libcommon - -CXX=clang++-10 - -ifeq ($(shell which $(CXX)),) -CXX=clang++ -endif - -ifeq ($(shell which $(CXX)),) -CXX=g++-9 -endif +include ../common.mk -ifeq ($(CXXFLAGS),) -#CXXFLAGS=-O2 -DNDEBUG -CXXFLAGS=-O0 -g -D_DEBUG -endif -# -fprofile-instr-generate -fcoverage-mapping -# gcc:--coverage - -CXXFLAGS+= -Wall -I. - -CXXFLAGS+= -pthread -fvisibility=hidden -fPIC -ifeq ($(CXX),clang++-10) -CXXFLAGS+=-std=c++20 #-stdlib=libc++ -else -CXXFLAGS+=-std=c++17 -endif - -LIBS=\ --lboost_context \ --lboost_coroutine \ --lboost_program_options \ --lboost_system \ --lboost_thread \ --lboost_filesystem \ --lboost_regex \ --lpthread \ --lssl -lcrypto \ --ldl +PROJECTNAME=libcommon -ifeq ($(CXX),clang++-10) -LIBS+= \ --fuse-ld=lld-10 \ --lstdc++ -#-lc++ \ -#-lc++abi -#-lc++fs -#-lstdc++fs -else -LIBS+= \ --lstdc++ \ --lstdc++fs -endif +CXXFLAGS+= -fvisibility=hidden -fPIC PROGSRC=\ file.cpp \ @@ -79,29 +29,10 @@ $(PROJECTNAME).a: $(SRC:.cpp=.o) ADD_DEP=Makefile - # misc --------------------------------------------------- -deb: - # build binary deb package - dpkg-buildpackage -us -uc -rfakeroot - -deb-src: - dpkg-source -b . - -$(DISTROS): deb-src - sudo pbuilder build --basetgz /var/cache/pbuilder/$@.tgz --buildresult result/$@ ../webserver_$(VERSION).dsc ; \ - -debs: $(DISTROS) - clean: + -rm -f *.o *.a *.d -zip: clean - -rm -f ../$(PROJECTNAME).zip - zip -r ../$(PROJECTNAME).zip * - ls -l ../$(PROJECTNAME).zip - - - -.PHONY: clean all zip install deb deb-src debs all $(DISTROS) +.PHONY: clean all install -include $(wildcard $(SRC:.cpp=.d)) diff --git a/libcommon/tempfile.cpp b/libcommon/tempfile.cpp index 5d3a086..c30bb57 100644 --- a/libcommon/tempfile.cpp +++ b/libcommon/tempfile.cpp @@ -1,5 +1,9 @@ #include "tempfile.h" +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + #include <iostream> namespace fs = std::filesystem; @@ -12,7 +16,12 @@ fs::path Tempfile::GetPath() const Tempfile::Tempfile() { try { - m_path = std::string{tmpnam(NULL)} + ".zip"s; + char name[] = "/tmp/tempfileXXXXXX.zip"; + int fd = mkstemps(name, 4); + if (fd == -1) + std::runtime_error("mkstemps: "s + strerror(errno)); + close(fd); + m_path = std::string{name}; } catch (const std::exception& ex) { throw std::runtime_error("Tempfile error: "s + ex.what()); } |