diff --git a/devel/ccache-devel/Makefile b/devel/ccache-devel/Makefile new file mode 100644 index 000000000000..3b8f04dfbc51 --- /dev/null +++ b/devel/ccache-devel/Makefile @@ -0,0 +1,105 @@ +# Created by: Dominic Marks + +PORTNAME= ccache +PORTVERSION= 4.3 +CATEGORIES= devel +PKGNAMESUFFIX= -devel + +PATCH_SITES= https://github.com/${GH_ACCOUNT}/${GH_PROJECT}/commit/ + +MAINTAINER= rozhuk.im@gmail.com +COMMENT= Tool to minimize the compile time of C/C++ programs + +LICENSE= GPLv3+ +LICENSE_FILE= ${WRKSRC}/GPL-3.0.txt + +USES= cmake:noninja pathfix shebangfix compiler:c++11-lang +CONFLICTS_INSTALL?= ccache-[0-9]* ccache-static-[0-9]* \ + ccache-memcached-[0-9]* ccache-memcached-static-[0-9]* + +PORTDOCS= AUTHORS.adoc AUTHORS.html MANUAL.html MANUAL.adoc \ + NEWS.adoc NEWS.html + +USE_GITHUB= yes +SUB_FILES= world-ccache ccache-update-links.sh ccache_clean +# Prevent infinite recursion. +NO_CCACHE_DEPEND= yes + +LIB_DEPENDS+= libzstd.so:archivers/zstd + +# /bin/bash -> /bin/sh to reduce tests dep. +SHEBANG_FILES= test/* +SHEBANG_GLOB= *.sh *.bash +bash_CMD= /bin/sh + +CMAKE_OFF= WARNINGS_AS_ERRORS \ + ENABLE_IPO \ + ZSTD_FROM_INTERNET \ + ENABLE_TRACING \ + STATIC_LINK + +OPTIONS_DEFINE= DOCS CLANGLINK LLVMLINK STATIC TEST +OPTIONS_DEFAULT=CLANGLINK LLVMLINK +OPTIONS_SUB= yes + +DOCS_BUILD_DEPENDS= a2x:textproc/asciidoc +DOCS_ALL_TARGET= all doc +DOCS_USES= perl5 + +CLANGLINK_DESC= Create clang compiler links if clang is installed +LLVMLINK_DESC= Create llvm compiler links if llvm is installed + +STATIC_LDFLAGS= -static + +TEST_CMAKE_BOOL=ENABLE_TESTING +TEST_TARGET= check + +.include + +CCLINKDIR= libexec/ccache +PLIST_SUB+= CCLINKDIR="${CCLINKDIR}" + +.if ${ARCH}=="i386" +CCACHE_COMPILERS+= icc icpc +.endif + +GNU_COMPILERS+= 34 42 43 44 45 46 47 48 49 5 6 7 8 9 10 11 12 +CCACHE_COMPILERS+= cc c++ CC gcc g++ ${GNU_COMPILERS:S|^|gcc|} \ + ${GNU_COMPILERS:S|^|g++|} \ + ${GNU_COMPILERS:S|^|cpp|} + +.if ${PORT_OPTIONS:MCLANGLINK} +CLANG_COMPILERS+= 33 34 35 36 37 38 39 40 50 60 70 80 90 10 11 12 -devel +CCACHE_COMPILERS+= clang clang++ ${CLANG_COMPILERS:S|^|clang|} \ + ${CLANG_COMPILERS:S|^|clang++|} \ + ${CLANG_COMPILERS:S|^|cpp|} +.endif + +.if ${PORT_OPTIONS:MLLVMLINK} +CCACHE_COMPILERS+= llvm-gcc llvm-c++ llvm-g++ +.endif + +CCACHE_COMPILERS+= ${EXTRA_COMPILERS} +SUB_LIST+= CCACHE_COMPILERS="${CCACHE_COMPILERS}" \ + CCLINKDIR="${CCLINKDIR}" + +post-patch-DOCS-off: + @${REINPLACE_CMD} -e 's|add_subdirectory(doc)||g' \ + ${WRKSRC}/CMakeLists.txt + +post-install: + ${MKDIR} ${STAGEDIR}${PREFIX}/${CCLINKDIR}/world + ${INSTALL_SCRIPT} ${WRKDIR}/world-ccache \ + ${STAGEDIR}${PREFIX}/${CCLINKDIR}/world/ccache + ${INSTALL_SCRIPT} ${WRKDIR}/ccache-update-links.sh \ + ${STAGEDIR}${PREFIX}/bin/ccache-update-links + @${MKDIR} ${STAGEDIR}${PREFIX}/etc/periodic/daily + ${INSTALL_SCRIPT} ${WRKDIR}/ccache_clean \ + ${STAGEDIR}${PREFIX}/etc/periodic/daily + +post-install-DOCS-on: + ${MKDIR} ${STAGEDIR}${DOCSDIR} + ${INSTALL_DATA} ${BUILD_WRKSRC}/doc/*.html ${STAGEDIR}${DOCSDIR} + ${INSTALL_DATA} ${WRKSRC}/doc/*.adoc ${STAGEDIR}${DOCSDIR} + +.include diff --git a/devel/ccache-devel/distinfo b/devel/ccache-devel/distinfo new file mode 100644 index 000000000000..3ceaebc468ee --- /dev/null +++ b/devel/ccache-devel/distinfo @@ -0,0 +1,3 @@ +TIMESTAMP = 1628533564 +SHA256 (ccache-ccache-4.3_GH0.tar.gz) = b9789c42e52c73e99428f311a34def9ffec3462736439afd12dbacc7987c1533 +SIZE (ccache-ccache-4.3_GH0.tar.gz) = 593767 diff --git a/devel/ccache-devel/files/ccache-update-links.sh.in b/devel/ccache-devel/files/ccache-update-links.sh.in new file mode 100644 index 000000000000..15bc180aef2d --- /dev/null +++ b/devel/ccache-devel/files/ccache-update-links.sh.in @@ -0,0 +1,72 @@ +#!/bin/sh +# +# Author: Emanuel Haupt +# +# $FreeBSD: head/devel/ccache/files/ccache-update-links.sh.in 435560 2017-03-06 17:50:14Z bdrewery $ +# + +CCACHE_COMPILERS="%%CCACHE_COMPILERS%% ${EXTRA_COMPILERS}" +CCLINKDIR="%%CCLINKDIR%%" +PREFIX="%%PREFIX%%" + +usage() { + cat << "EOUSAGE" +Usage: ccache-update-links [hv] + +ccache-update-links maintains symlinks needed by ccache to work with additional +compilers. + + -h, --help this help + -v verbose + +EOUSAGE +} + +case "$1" +in + -h|--help) + usage + ;; +esac + +strip_path() { + local IFS=":" + local path + set -- ${PATH} + while [ $# -gt 0 ]; do + if ! [ "${1}" = "${PREFIX}/libexec/ccache" ]; then + path="${path}${path:+:}${1}" + fi + shift + done + echo "${path}" +} + +# Remove ccache wrappers from PATH +PATH=$(strip_path) + +# create compiler links +for comp in ${CCACHE_COMPILERS} +do + if command -v "${comp}" >/dev/null; then + if [ ! -L "${PREFIX}/${CCLINKDIR}/${comp}" ]; then + [ "$1" = "-v" ] && echo "create symlink for ${comp}" + ln -sf ${PREFIX}/bin/ccache ${PREFIX}/${CCLINKDIR}/${comp} + fi + + if [ ! -L "${PREFIX}/${CCLINKDIR}/world/${comp}" ]; then + [ "$1" = "-v" ] && echo "create symlink for ${comp} (world)" + ln -sf ccache ${PREFIX}/${CCLINKDIR}/world/${comp} + fi + else + if [ -L "${PREFIX}/${CCLINKDIR}/${comp}" ]; then + [ "$1" = "-v" ] && echo "remove symlink for ${comp}" + rm -f ${PREFIX}/${CCLINKDIR}/${comp} + fi + + if [ -L "${PREFIX}/${CCLINKDIR}/world/${comp}" ]; then + [ "$1" = "-v" ] && echo "remove symlink for ${comp} (world)" + rm -f ${PREFIX}/${CCLINKDIR}/world/${comp} + fi + fi +done diff --git a/devel/ccache-devel/files/ccache_clean.in b/devel/ccache-devel/files/ccache_clean.in new file mode 100755 index 000000000000..c68d621bba64 --- /dev/null +++ b/devel/ccache-devel/files/ccache_clean.in @@ -0,0 +1,71 @@ +#!/bin/sh +# +# Copyright (c) 2020 Rozhuk Ivan +# 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. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. +# +# $FreeBSD$ +# + +if [ -r /etc/defaults/periodic.conf ]; then + . /etc/defaults/periodic.conf + source_periodic_confs +fi + + +case "${daily_ccache_clean_enable:-YES}" in +[Nn][Oo]) + ;; +*) + SYS_CCACHE_DIR=`make -V CCACHE_DIR` + if [ -z "${SYS_CCACHE_DIR}" ]; then + SYS_CCACHE_DIR='/var/cache/ccache' + fi + if [ -d "${SYS_CCACHE_DIR}" ]; then + echo "ccache dir: ${SYS_CCACHE_DIR}" + env CCACHE_DIR="${SYS_CCACHE_DIR}" \ + /usr/bin/nice -n 15 \ + %%PREFIX%%/bin/ccache --cleanup + fi + + _USERS_HOME_DIRS=`pw usershow -a | awk -F":" '{print $9}' | sort -u` + for _USER_HOME in ${_USERS_HOME_DIRS}; do + if [ -d "${_USER_HOME}/.ccache" ]; then + echo "ccache dir: ${_USER_HOME}/.ccache" + env CCACHE_DIR="${_USER_HOME}/.ccache" \ + /usr/bin/nice -n 15 \ + %%PREFIX%%/bin/ccache --cleanup + fi + if [ -d "${_USER_HOME}/.cache/ccache" ]; then + echo "ccache dir: ${_USER_HOME}/.cache/ccache" + env CCACHE_DIR="${_USER_HOME}/.cache/ccache" \ + CCACHE_CONFIGPATH="${_USER_HOME}/.config/ccache/ccache.conf" \ + /usr/bin/nice -n 15 \ + %%PREFIX%%/bin/ccache --cleanup + fi + done + ;; +esac + + +exit 0 diff --git a/devel/ccache-devel/files/world-ccache.in b/devel/ccache-devel/files/world-ccache.in new file mode 100644 index 000000000000..9803d12b8298 --- /dev/null +++ b/devel/ccache-devel/files/world-ccache.in @@ -0,0 +1,9 @@ +#!/bin/sh + +[ "${0##*/}" = "ccache" ] && + printf "Please, use one of the compiler links in\n%%PREFIX%%/%%CCLINKDIR%%/world\nto invoke ccache\n" >&2 && + exit 1 + +unset CCACHE_PATH +export CCACHE_COMPILERCHECK=content +exec %%PREFIX%%/%%CCLINKDIR%%/${0##*/} "$@" diff --git a/devel/ccache-devel/pkg-descr b/devel/ccache-devel/pkg-descr new file mode 100644 index 000000000000..4ee9e3a189f4 --- /dev/null +++ b/devel/ccache-devel/pkg-descr @@ -0,0 +1,6 @@ +ccache is a compiler cache. It acts as a caching pre-processor to C/C++ +compilers, using the -E compiler switch and a hash to detect when a +compilation can be satisfied from cache. This often results in a 5 to 10 +times speedup in common compilations. + +WWW: https://ccache.samba.org/ diff --git a/devel/ccache-devel/pkg-plist b/devel/ccache-devel/pkg-plist new file mode 100644 index 000000000000..733aec1958f9 --- /dev/null +++ b/devel/ccache-devel/pkg-plist @@ -0,0 +1,9 @@ +etc/periodic/daily/ccache_clean +bin/ccache +bin/ccache-update-links +%%PORTDOCS%%man/man1/ccache.1.gz +%%PORTDOCS%%%%DOCSDIR%%/LICENSE.html +%%CCLINKDIR%%/world/ccache +@postexec echo "Create compiler links..." +@postexec %D/bin/ccache-update-links -v +@preunexec find %D/%%CCLINKDIR%% -type l -exec rm -f {} \;