diff --git a/Makefile.inc1 b/Makefile.inc1 index ab4343e..4f3bd67 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -797,6 +797,7 @@ _gcc34_tools= gnu/usr.bin/cc34/cc_prep gnu/usr.bin/cc34/cc_tools .endif _gcc41_cross= gnu/usr.bin/cc41 _gcc41_tools= gnu/usr.bin/cc41/cc_prep gnu/usr.bin/cc41/cc_tools +_custom_cross= libexec/customcc _binutils= gnu/usr.bin/binutils217 .if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \ @@ -826,7 +827,7 @@ _btxld= usr.sbin/btxld cross-tools: .for _tool in ${_btxld} ${_binutils} \ usr.bin/objformat usr.bin/crunch/crunchide \ - ${_gcc34_cross} ${_gcc41_cross} + ${_gcc34_cross} ${_gcc41_cross} ${_custom_cross} ${ECHODIR} "===> ${_tool} (cross-tools)"; \ cd ${.CURDIR}/${_tool}; \ ${MAKE} DIRPRFX=${_tool}/ obj; \ diff --git a/etc/Makefile b/etc/Makefile index 67921e8..bfc08ea 100644 --- a/etc/Makefile +++ b/etc/Makefile @@ -54,7 +54,7 @@ DIRS+= secure/usr.bin/openssl # BIN2= pccard_ether rc.firewall rc.suspend rc.resume -DEFAULTS= rc.conf make.conf periodic.conf uuids +DEFAULTS= compilers.conf make.conf periodic.conf rc.conf uuids MTREE= BSD.include.dist BSD.local.dist BSD.root.dist BSD.usr.dist \ BSD.var.dist diff --git a/etc/defaults/compilers.conf b/etc/defaults/compilers.conf new file mode 100644 index 0000000..ea9ba41 --- /dev/null +++ b/etc/defaults/compilers.conf @@ -0,0 +1,9 @@ +# clang from SVN trunk +clang_CC=/usr/local/bin/clang +clang_CFLAGS="-fno-color-diagnostics -std=gnu89" +clang_VERSION=4.1.2 + +# gcc44 from pkgsrc +gcc44_CC=/usr/pkg/gcc44/bin/cc +gcc44_CXX=/usr/pkg/gcc44/bin/c++ +gcc44_CPP=/usr/pkg/gcc44/bin/cpp diff --git a/etc/mtree/BSD.usr.dist b/etc/mtree/BSD.usr.dist index f4b8ad4..2a6106f 100644 --- a/etc/mtree/BSD.usr.dist +++ b/etc/mtree/BSD.usr.dist @@ -65,6 +65,8 @@ elf .. .. + custom + .. gcc34 .. gcc41 diff --git a/libexec/Makefile b/libexec/Makefile index f4d8a0e..471a9f7 100644 --- a/libexec/Makefile +++ b/libexec/Makefile @@ -6,6 +6,7 @@ SUBDIR= atrun \ bootpd \ comsat \ + customcc \ dma \ fingerd \ ftpd \ diff --git a/libexec/customcc/Makefile b/libexec/customcc/Makefile new file mode 100644 index 0000000..1627f9b --- /dev/null +++ b/libexec/customcc/Makefile @@ -0,0 +1,13 @@ +SCRIPTS= cc +SCRIPTSDIR= /usr/libexec/custom +SYMLINKS= cc ${SCRIPTSDIR}/cpp \ + cc ${SCRIPTSDIR}/c++ \ + cc ${SCRIPTSDIR}/gcc \ + cc ${SCRIPTSDIR}/g++ +CLEANFILES= cc +NOMAN= + +beforeinstall: + sed "s#@@PREFIX2@@#${USRDATA_PREFIX}/usr#g" ${.CURDIR}/cc.sh >cc + +.include diff --git a/libexec/customcc/cc.sh b/libexec/customcc/cc.sh new file mode 100644 index 0000000..d0e4127 --- /dev/null +++ b/libexec/customcc/cc.sh @@ -0,0 +1,49 @@ +#!/bin/sh + +CDIR=$(dirname $0) +CNAME=$(basename $0) + +# XXX clang needs some special handling +# +# it is called only for "cc" and "gcc" and even then it could have been +# run on c++ files +# +if [ "${CCVER}" = "clang" ]; then + if [ "${CNAME}" = "cpp" ]; then + exec ${CDIR}/../gcc41/cpp "$@" + elif [ "${CNAME}" = "c++" -o "${CNAME}" = "g++" ]; then + exec ${CDIR}/../gcc41/c++ "$@" + elif [ -z $beenhere ]; then + export beenhere=1 + oldargs="$@" + export oldargs + INCOPT="-isystem @@PREFIX2@@/include \ + -isystem @@PREFIX2@@/libdata/gcc41" + elif [ "${CNAME}" = "cc" -o "${CNAME}" = "gcc" ]; then + exec ${CDIR}/../gcc41/cc $oldargs + fi +fi + +. /etc/defaults/compilers.conf +[ -f /etc/compilers.conf ] && . /etc/compilers.conf + +CUSTOM_CC=`eval echo \$\{${CCVER}_CC\}` +CUSTOM_CFLAGS=`eval echo \$\{${CCVER}_CFLAGS\}` +CUSTOM_CXX=`eval echo \$\{${CCVER}_CXX\}` +CUSTOM_CXXFLAGS=`eval echo \$\{${CCVER}_CXXFLAGS\}` +CUSTOM_CPP=`eval echo \$\{${CCVER}_CPP\}` +CUSTOM_CPPFLAGS=`eval echo \$\{${CCVER}_CPPFLAGS\}` +CUSTOM_VERSION=`eval echo \$\{${CCVER}_VERSION\}` + +if [ "${CUSTOM_VERSION}" != "" -a "$1" = "-dumpversion" ]; then + echo ${CUSTOM_VERSION} +elif [ "${CNAME}" = "cc" -o "${CNAME}" = "gcc" ]; then + exec ${CUSTOM_CC} ${INCOPT} ${CUSTOM_CFLAGS} "$@" +elif [ "${CNAME}" = "c++" -o "${CNAME}" = "g++" ]; then + exec ${CUSTOM_CXX} ${INCOPT} ${CUSTOM_CXXFLAGS} "$@" +elif [ "${CNAME}" = "cpp" ]; then + exec ${CUSTOM_CPP} ${INCOPT} ${CUSTOM_CPPFLAGS} "$@" +else + echo "unknown compiler ${CNAME}" + exit 1 +fi diff --git a/share/examples/etc/README.examples b/share/examples/etc/README.examples index 3d30dbb..d2bf37f 100644 --- a/share/examples/etc/README.examples +++ b/share/examples/etc/README.examples @@ -15,6 +15,7 @@ This directory contains the following files: amd.map - configuration file for amd(8) apmd.conf - configuration file for apmd(8) auth.conf - authentication capability database +compilers.conf - configuration for non-base compilers crontab - system scheduled command table csh.cshrc - system-wide .cshrc for csh(1) csh.login - system-wide .login for csh(1) diff --git a/share/man/man5/Makefile b/share/man/man5/Makefile index dc8808b..2ec1fc6 100644 --- a/share/man/man5/Makefile +++ b/share/man/man5/Makefile @@ -5,6 +5,7 @@ #MISSING: dump.5 plot.5 MAN= acct.5 \ a.out.5 \ + compilers.conf.5 \ core.5 \ devices.conf.5 \ dir.5 \ diff --git a/share/man/man5/compilers.conf.5 b/share/man/man5/compilers.conf.5 new file mode 100644 index 0000000..49ac8b2 --- /dev/null +++ b/share/man/man5/compilers.conf.5 @@ -0,0 +1,116 @@ +.\" +.\" Copyright (c) 2009 +.\" The DragonFly 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 DragonFly Project 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 HOLDERS 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. +.\" +.Dd June 6, 2009 +.Os +.Dt COMPILERS.CONF 5 +.Sh NAME +.Nm compilers.conf +.Nd configuration file for external compilers +.Sh SYNOPSIS +.Pa /etc/compilers.conf +.Sh DESCRIPTION +The +.Nm +file allows to configure +.Dq external +compilers for usage with the +.Dx +.Xr build 7 +system. +.Pp +The +.Pa /etc/defaults/compilers.conf +file specifies the default settings for all variables, the +.Pa /etc/compilers.conf +file specifies override settings. +.Pp +The following variables are available: +.Bl -tag -width ".Va _CPPFLAGS" +.It Va _CC +The pathname of the +.Nm cc +program of the compiler. +.It Va _CFLAGS +Any additional flags to pass to +.Va _CC . +.It Va _CPP +The pathname of the +.Nm cpp +program of the compiler. +.It Va _CPPFLAGS +Any additional flags to pass to +.Va _CPP . +.It Va _CXX +The pathname of the +.Nm c++ +program of the compiler. +.It Va _CXXFLAGS +Any additional flags to pass to +.Va _CXX . +.It Va _VERSION +What to output when the +.Fl dumpversion +option is used. +This helps +.Nm clang +with +.Xr pkgsrc 7 . +.El +.Pp +Once configured the compiler can then be used like this: +.Bd -literal -offset indent +cd /usr/pkgsrc/wip/gcc44 +[build and install gcc44] +cd /usr/src +env WORLD_CCVER=gcc44 make buildworld +.Ed +.Pp +Defaults are provided for +.Nm clang +(installed from SVN trunk) +and +.Nm gcc44 +(installed from +.Pa pkgsrc/wip ) . +.Sh FILES +.Bl -tag -width ".Pa /etc/compilers.conf" -compact +.It Pa /etc/compilers.conf +external compiler configuration file +.El +.Sh SEE ALSO +.Xr objformat 1 , +.Xr build 7 +.Sh HISTORY +The +.Nm +file first appeared in +.Dx 2.3 . diff --git a/share/mk/Makefile b/share/mk/Makefile index 116dd52..a26ca3b 100644 --- a/share/mk/Makefile +++ b/share/mk/Makefile @@ -3,7 +3,7 @@ # @(#)Makefile 8.1 (Berkeley) 6/8/93 FILES= bsd.README -FILES+= bsd.cpu.mk bsd.cpu.gcc34.mk bsd.cpu.gcc41.mk +FILES+= bsd.cpu.mk bsd.cpu.gcc34.mk bsd.cpu.gcc41.mk bsd.cpu.custom.mk FILES+= bsd.dep.mk bsd.doc.mk bsd.files.mk bsd.patch.mk FILES+= bsd.incs.mk bsd.info.mk bsd.init.mk FILES+= bsd.kmod.mk bsd.hostlib.mk diff --git a/share/mk/bsd.cpu.custom.mk b/share/mk/bsd.cpu.custom.mk new file mode 100644 index 0000000..65ca858 --- /dev/null +++ b/share/mk/bsd.cpu.custom.mk @@ -0,0 +1,7 @@ +# Set default CPU compile flags for custom compilers. Not much to see here. + +. if ${MACHINE_ARCH} == "i386" +MACHINE_CPU = i486 +. elif ${MACHINE_ARCH} == "amd64" +MACHINE_CPU = amd64 sse2 sse +. endif diff --git a/share/mk/bsd.cpu.mk b/share/mk/bsd.cpu.mk index e7aa9a2..fcad0d7 100644 --- a/share/mk/bsd.cpu.mk +++ b/share/mk/bsd.cpu.mk @@ -17,11 +17,19 @@ CCVER ?= gcc41 _CCVER := ${CCVER} +.if ${_CCVER} == "gcc34" || ${_CCVER} == "gcc41" .if exists(/usr/libexec/${_CCVER}/cc) HOST_CCVER?= ${_CCVER} .else HOST_CCVER?= gcc34 .endif +.else +.if exists(/usr/libexec/custom/cc) +HOST_CCVER?= ${CCVER} +.else +HOST_CCVER?= gcc34 +.endif +.endif .if ${CCVER} == "gcc34" . include @@ -32,7 +40,7 @@ HOST_CCVER?= gcc34 . include "${CCVER_BSD_CPU_MK}" . endif .else -.error "Either set CCVER to a known compiler or specify CCVER_BSD_CPU_MK" +. include .endif # /usr/bin/cc depend on the CCVER environment variable, make sure CCVER is diff --git a/usr.bin/objformat/objformat.c b/usr.bin/objformat/objformat.c index f2e4d0e..b853230 100644 --- a/usr.bin/objformat/objformat.c +++ b/usr.bin/objformat/objformat.c @@ -181,8 +181,14 @@ main(int argc, char **argv) asprintf(&newcmd, "%s%s/%s/%s/%s", chunk, base_path, env_value, objformat, cmd); } else { - asprintf(&newcmd, "%s%s/%s/%s", - chunk, base_path, env_value, cmd); + if (strncmp(env_value, "gcc34", 5) != 0 && + strncmp(env_value, "gcc41", 5) != 0) { + asprintf(&newcmd, "%s%s/custom/%s", + chunk, base_path, cmd); + } else { + asprintf(&newcmd, "%s%s/%s/%s", + chunk, base_path, env_value, cmd); + } } if (newcmd == NULL) err(1, "cannot allocate memory");