--- /dev/null
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+inherit cmake-utils toolchain-funcs user
+
+DESCRIPTION="Yet another caching HTTP proxy for Debian/Ubuntu software packages"
+HOMEPAGE="
+ https://www.unix-ag.uni-kl.de/~bloch/acng/
+ https://packages.qa.debian.org/a/apt-cacher-ng.html
+"
+LICENSE="BSD-4 ZLIB public-domain"
+SLOT="0"
+SRC_URI="
+ mirror://debian/pool/main/a/${PN}/${PN}_${PV/_*}.orig.tar.xz
+ mirror://debian/pool/main/a/${PN}/${PN}_${PV/_p/-}.debian.tar.xz
+"
+
+KEYWORDS="~amd64 ~x86"
+IUSE="doc fuse systemd tcpd"
+
+COMMON_DEPEND="
+ app-arch/bzip2
+ app-arch/xz-utils
+ dev-libs/openssl:0=
+ sys-libs/zlib
+ systemd? (
+ sys-apps/systemd
+ )
+"
+BDEPEND="
+ ${COMMON_DEPEND}
+ dev-util/cmake
+ >sys-devel/gcc-4.8
+ virtual/pkgconfig
+"
+RDEPEND="
+ ${COMMON_DEPEND}
+ dev-lang/perl
+ fuse? ( sys-fs/fuse )
+ tcpd? ( sys-apps/tcp-wrappers )
+"
+PATCHES=(
+ "${FILESDIR}"/${PN}-3.3-flags.patch
+)
+S=${WORKDIR}/${P/_*}
+
+pkg_pretend() {
+ if [[ $(gcc-major-version) -lt 4 ]]; then
+ die "GCC 4.8 or greater is required but you have $(gcc-major-version).$(gcc-minor-version)"
+ elif [[ $(gcc-major-version) = 4 ]] && [[ $(gcc-minor-version) -lt 8 ]]; then
+ die "GCC 4.8 or greater is required but you have $(gcc-major-version).$(gcc-minor-version)"
+ fi
+}
+
+pkg_setup() {
+ # add new user & group for daemon
+ enewgroup ${PN}
+ enewuser ${PN} -1 -1 -1 ${PN}
+}
+
+src_configure(){
+ mycmakeargs=(
+ "-DCMAKE_INSTALL_PREFIX=/usr"
+ )
+ if use fuse; then
+ mycmakeargs+=( "-DHAVE_FUSE_25=yes" )
+ else
+ mycmakeargs+=( "-DHAVE_FUSE_25=no" )
+ fi
+ if use tcpd; then
+ mycmakeargs+=( "-DHAVE_LIBWRAP=yes" )
+ else
+ mycmakeargs+=( "-DHAVE_LIBWRAP=no" )
+ fi
+
+ cmake-utils_src_configure
+}
+
+src_install() {
+ pushd "${BUILD_DIR}" || die
+ dosbin ${PN} acngtool
+ dolib.so libsupacng.so
+ if use fuse; then
+ dobin acngfs
+ fi
+ popd || die
+
+ newinitd "${FILESDIR}"/initd-r1 ${PN}
+ newconfd "${FILESDIR}"/confd ${PN}
+
+ insinto /etc/logrotate.d
+ newins "${FILESDIR}"/logrotate ${PN}
+
+ doman doc/man/${PN}*
+ if use fuse; then
+ doman doc/man/acngfs*
+ fi
+
+ # Documentation
+ dodoc doc/README TODO VERSION INSTALL ChangeLog
+ if use doc; then
+ dodoc doc/*.pdf
+
+ docinto html
+ dodoc doc/html/*
+
+ find conf -name '*.gz' -exec gzip -d {} \; || die
+ docinto examples/conf
+ dodoc conf/*
+ fi
+
+ # perl daily cron script
+ dosbin scripts/expire-caller.pl
+ exeinto /etc/cron.daily
+ newexe "${FILESDIR}"/cron.daily ${PN}
+
+ # default configuration
+ insinto /etc/${PN}
+ newins "${BUILD_DIR}"/conf/acng.conf ${PN}.conf
+ doins $( echo conf/* | sed 's|conf/acng.conf.in||g' )
+
+ keepdir /var/log/${PN}
+ # Some directories must exists
+ keepdir /var/log/${PN}
+ fowners -R ${PN}:${PN} \
+ /etc/${PN} \
+ /var/log/${PN}
+}
--- /dev/null
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -14,7 +14,7 @@
+
+ set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
+ set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR})
+-#set(CMAKE_SKIP_BUILD_RPATH on) # no -rdynamic needed ever
++set(CMAKE_SKIP_BUILD_RPATH on) # no -rdynamic needed ever
+
+ INCLUDE(CheckIncludeFiles)
+ INCLUDE(CheckCXXSourceCompiles)
+@@ -27,7 +27,7 @@
+ INCLUDE(GNUInstallDirs)
+
+ IF(NOT DEFINED(CMAKE_INSTALL_PREFIX))
+-set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE STRING "Target file space")
++#_cmake_modify_IGNORE set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE STRING "Target file space")
+ ENDIF()
+ IF(NOT DEFINED(LIBDIR))
+ set(LIBDIR "${CMAKE_INSTALL_PREFIX}/lib/${PACKAGE}" CACHE STRING "Location of ${PACKAGE} extra files")
+@@ -94,23 +94,6 @@
+ _append(ACNG_CXXFLAGS -fvisibility-inlines-hidden)
+ endif()
+
+-foreach(linkarg -Wl,--as-needed -Wl,-O1 -Wl,--discard-all -Wl,--no-undefined -Wl,--build-id=sha1 -Wl,-fuse-ld=gold)
+- STRING(REGEX REPLACE "=|-|," "" optname "${linkarg}")
+- set(CMAKE_REQUIRED_FLAGS "${linkarg}")
+- CHECK_CXX_COMPILER_FLAG("" "LD_${optname}")
+- if(LD_${optname})
+- _append(CMAKE_EXE_LINKER_FLAGS ${linkarg})
+- endif()
+- set(CMAKE_REQUIRED_FLAGS "")
+-endforeach(linkarg)
+-
+-set(CMAKE_REQUIRED_FLAGS "-Wl,-fuse-ld=gold -Wl,--threads")
+-CHECK_CXX_COMPILER_FLAG("" LD_MULTITHREADED)
+-if(LD_MULTITHREADED)
+- _append(CMAKE_EXE_LINKER_FLAGS "-Wl,-fuse-ld=gold -Wl,--threads")
+-endif()
+-set(CMAKE_REQUIRED_FLAGS "")
+-
+ option(USE_SSL "Use OpenSSL library for TLS and other crypto functionality" on)
+
+ IF(CMAKE_SYSTEM MATCHES "Darwin")
+@@ -132,15 +115,6 @@
+ if(CMAKE_BUILD_TYPE MATCHES Debug)
+ set(USE_LTO_DEFAULT off)
+ _append(ACNG_COMPFLAGS -DDEBUG)
+-else()
+- set(CMAKE_REQUIRED_FLAGS "-Wl,--gc-sections")
+- CHECK_CXX_COMPILER_FLAG("-Os -fdata-sections -ffunction-sections -Wl,--gc-sections" GC_SECTIONS)
+- if(GC_SECTIONS)
+- _append(ACNG_COMPFLAGS -fdata-sections -ffunction-sections)
+- _append(CMAKE_EXE_LINKER_FLAGS -Wl,--gc-sections)
+- _append(CMAKE_SHARED_LINKER_FLAGS -Wl,--gc-sections)
+- endif()
+- set(CMAKE_REQUIRED_FLAGS "")
+ endif()
+
+ option(USE_LTO "Enable Link Time Optimization (requires modern compilers)" ${USE_LTO_DEFAULT})
+@@ -385,3 +359,14 @@
+ LIBDIR: ${LIBDIR}
+ AVAHIDIR: ${AVAHIDIR}
+ ")
++
++MESSAGE(STATUS "<<< Gentoo configuration >>>
++Build type ${CMAKE_BUILD_TYPE}
++Install path ${CMAKE_INSTALL_PREFIX}
++Compiler flags:
++C ${CMAKE_C_FLAGS}
++C++ ${CMAKE_CXX_FLAGS}
++Linker flags:
++Executable ${CMAKE_EXE_LINKER_FLAGS}
++Module ${CMAKE_MODULE_LINKER_FLAGS}
++Shared ${CMAKE_SHARED_LINKER_FLAGS}\n")