From 2ae05a906fefb10b1dfec041ae9eae5ea900d7f1 Mon Sep 17 00:00:00 2001
From: Sascha Wildner <saw@online.de>
Date: Sat, 3 Aug 2013 10:43:06 +0200
Subject: [PATCH 3/3] WIP

---
 Makefile.inc1               | 12 +++++++++++-
 etc/defaults/compilers.conf | 18 ++++++++++--------
 etc/defaults/make.conf      |  1 +
 gnu/lib/Makefile            |  2 ++
 gnu/lib/gcc47/Makefile.inc  |  8 ++++----
 gnu/usr.bin/Makefile        |  2 ++
 lib/Makefile                |  8 +++++---
 lib/csu/Makefile            |  1 +
 lib/libc/stdlib/nmalloc.c   |  2 +-
 libexec/customcc/cc.sh      | 14 +++++---------
 nrelease/Makefile           |  8 ++++++--
 share/mk/bsd.prog.mk        |  2 +-
 share/mk/bsd.sys.mk         |  4 ++++
 usr.bin/tip/libacu/hayes.c  |  2 ++
 usr.bin/tip/tip/cmds.c      |  2 +-
 15 files changed, 56 insertions(+), 30 deletions(-)

diff --git a/Makefile.inc1 b/Makefile.inc1
index 8ab7470..3d9195e 100644
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -840,13 +840,18 @@ bstrap-${_tool}!
 _share=	share/syscons/scrnmaps
 .endif
 
+.if !defined(NO_GCC44) || !defined(NO_GCC47)
 _gcc_common_cross= gnu/usr.bin/gmp gnu/usr.bin/mpfr
+.endif
 .if !defined(NO_GCC44)
 _gcc44_cross= gnu/usr.bin/cc44
 _gcc44_tools= gnu/usr.bin/cc44/cc_prep gnu/usr.bin/cc44/cc_tools
 .endif
+.if !defined(NO_GCC47)
 _gcc47_cross= lib/libz gnu/usr.bin/mpc gnu/usr.bin/cc47
 _gcc47_tools= gnu/usr.bin/cc47/cc_prep gnu/usr.bin/cc47/cc_tools
+.endif
+
 _custom_cross= libexec/customcc
 _binutils= gnu/usr.bin/${WORLD_BINUTILSVER}
 
@@ -912,9 +917,11 @@ hierarchy:
 # to specify the correct CCVER or 'cc' will not exec the correct compiler.
 #
 libraries:
+.if !defined(NO_GCC47)
 	cd ${.CURDIR}; \
 	    HOST_CCVER=${HOST_CCVER} CCVER=gcc47 \
 		make -f Makefile.inc1 _startup_libs47;
+.endif
 .if !defined(NO_GCC44)
 	cd ${.CURDIR}; \
 	    HOST_CCVER=${HOST_CCVER} CCVER=gcc44 \
@@ -942,7 +949,10 @@ _startup_libs44=	gnu/usr.bin/cc44/cc_prep \
 			gnu/usr.bin/cc44/cc_tools \
 			gnu/lib/gcc44/csu \
 			gnu/lib/gcc44/libgcc
-_startup_libs=		lib/csu lib/libc lib/libc_rtld
+.if !defined(NO_GCC44) || !defined(NO_GCC47)
+_startup_libs=		lib/csu
+.endif
+_startup_libs+=		lib/libc lib/libc_rtld
 
 _prebuild_libs=		lib/libbz2 lib/liblzma lib/libz
 _prebuild_libs+=	lib/libutil
diff --git a/etc/defaults/compilers.conf b/etc/defaults/compilers.conf
index 46549e6..e845fc3 100644
--- a/etc/defaults/compilers.conf
+++ b/etc/defaults/compilers.conf
@@ -1,16 +1,18 @@
 # clang from SVN trunk
 #
-clangsvn_CC=/usr/local/bin/clang
-clangsvn_CXX=/usr/local/bin/clang++
-clangsvn_CFLAGS="-fno-color-diagnostics -Qunused-arguments -Wno-unknown-warning-option -std=gnu89"
-clangsvn_CXXFLAGS="-fno-color-diagnostics -Qunused-arguments -Wno-unknown-warning-option -std=gnu++98"
+clang_CC=/usr/local/bin/clang
+clang_CPP=/usr/local/bin/clang-cpp
+clang_CXX=/usr/local/bin/clang++
+clang_CFLAGS="-fheinous-gnu-extensions -fno-color-diagnostics -no-integrated-as -Qunused-arguments -Wno-unknown-warning-option"
+clang_CPPFLAGS="-fheinous-gnu-extensions -fno-color-diagnostics -no-integrated-as -Qunused-arguments -Wno-unknown-warning-option"
+clang_CXXFLAGS="-fheinous-gnu-extensions -fno-color-diagnostics -no-integrated-as -Qunused-arguments -Wno-unknown-warning-option"
 
 # clang from pkgsrc
 #
-clang_CC=/usr/pkg/bin/clang
-clang_CXX=/usr/pkg/bin/clang++
-clang_CFLAGS="-fno-color-diagnostics -Qunused-arguments -Wno-unknown-warning-option -std=gnu89"
-clang_CXXFLAGS="-fno-color-diagnostics -Qunused-arguments -Wno-unknown-warning-option -std=gnu++98"
+#clang_CC=/usr/pkg/bin/clang
+#clang_CXX=/usr/pkg/bin/clang++
+#clang_CFLAGS="-fno-color-diagnostics -Qunused-arguments -Wno-unknown-warning-option -std=gnu89"
+#clang_CXXFLAGS="-fno-color-diagnostics -Qunused-arguments -Wno-unknown-warning-option -std=gnu++98"
 
 # gnat-aux (i.e. gcc 4.6) from pkgsrc
 #
diff --git a/etc/defaults/make.conf b/etc/defaults/make.conf
index db5ef60..c4469f6 100644
--- a/etc/defaults/make.conf
+++ b/etc/defaults/make.conf
@@ -106,6 +106,7 @@ THREAD_LIB?=	thread_xu
 #NO_CVS=	true	# do not build CVS
 #NO_GAMES=	true	# do not enter the games subdirectory
 #NO_GCC44=	true	# do not build gcc-4.4
+#NO_GCC47=	true	# do not build gcc-4.7
 #NO_GDB=	true	# do not build GDB
 #NO_LIBC_R=	true	# do not build libc_r (re-entrant version of libc)
 #NO_LPR=	true	# do not build lpr and related programs
diff --git a/gnu/lib/Makefile b/gnu/lib/Makefile
index 1e47406..58b19e4 100644
--- a/gnu/lib/Makefile
+++ b/gnu/lib/Makefile
@@ -5,7 +5,9 @@
 SUBDIR= gcc44
 .endif
 
+.if !defined(NO_GCC47)
 SUBDIR+= gcc47
+.endif
 
 SUBDIR+= libcryptsetup
 SUBDIR+= libdevmapper
diff --git a/gnu/lib/gcc47/Makefile.inc b/gnu/lib/gcc47/Makefile.inc
index 4500118..0333af2 100644
--- a/gnu/lib/gcc47/Makefile.inc
+++ b/gnu/lib/gcc47/Makefile.inc
@@ -17,10 +17,10 @@ GCC_CPU=	i386
 TRAMPSIZE=	24
 .endif
 
-TARGET_LIBDIR=		${LIBDIR}/${CCVER}
-TARGET_DEBUGLIBDIR=	${LIBDIR}/${CCVER}/debug
-TARGET_PROFLIBDIR=	${LIBDIR}/${CCVER}/profile
-TARGET_SHLIBDIR=	${LIBDIR}/${CCVER}
+TARGET_LIBDIR=		${LIBDIR}/gcc${GCCSHORTVER}
+TARGET_DEBUGLIBDIR=	${LIBDIR}/gcc${GCCSHORTVER}/debug
+TARGET_PROFLIBDIR=	${LIBDIR}/gcc${GCCSHORTVER}/profile
+TARGET_SHLIBDIR=	${LIBDIR}/gcc${GCCSHORTVER}
 
 LIBSUPCPP=		${.OBJDIR}/../libsupc++/libsupc++.a
 
diff --git a/gnu/usr.bin/Makefile b/gnu/usr.bin/Makefile
index 0a1489e..67f464d 100644
--- a/gnu/usr.bin/Makefile
+++ b/gnu/usr.bin/Makefile
@@ -17,6 +17,7 @@ SUBDIR+= ${BU_PRIMARY}
 SUBDIR+= ${BU_BACKUP}
 .endif
 
+.if defined(XXXOMG)
 SUBDIR+= gmp
 SUBDIR+= mpfr
 SUBDIR+= mpc
@@ -28,6 +29,7 @@ SUBDIR+= cc47
 SUBDIR+= cc44
 .ORDER: ${BU_PRIMARY} gmp mpfr mpc cc47 cc44
 .endif
+.endif
 
 # maximum parallelism
 #
diff --git a/lib/Makefile b/lib/Makefile
index cfd60e1..4c58a85 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -29,9 +29,11 @@ SUBDIR_ORDERED=	${_libc_r} \
 	libthread_xu \
 	libutil \
 	libpthread
-SUBDIR=	${SUBDIR_ORDERED} \
-	csu \
-	i18n_module \
+SUBDIR=	${SUBDIR_ORDERED}
+.if !defined(NO_GCC44) || !defined(NO_GCC47)
+SUBDIR+=csu
+.endif
+SUBDIR+=i18n_module \
 	libalias \
 	libarchive \
 	libatm \
diff --git a/lib/csu/Makefile b/lib/csu/Makefile
index f6205ce..6a06f21 100644
--- a/lib/csu/Makefile
+++ b/lib/csu/Makefile
@@ -4,6 +4,7 @@ SED_FIX_NOTE= -i "" -e '/\.note\.tag/s/progbits/note/'
 .include "${.CURDIR}/${MACHINE_ARCH}/Makefile.csu"
 
 OBJS+=	${SRCS:M*.[cS]:R:C/$/.o/g}
+CCVER=	gcc47
 
 all: ${OBJS}
 
diff --git a/lib/libc/stdlib/nmalloc.c b/lib/libc/stdlib/nmalloc.c
index e2ea54b..4a5b709 100644
--- a/lib/libc/stdlib/nmalloc.c
+++ b/lib/libc/stdlib/nmalloc.c
@@ -302,7 +302,7 @@ typedef struct thr_mags {
  * this variable when the code is compiled -fPIC. Empty for libc_rtld
  * (like __thread).
  */
-#ifdef __LIBC_RTLD
+#if defined(__LIBC_RTLD) || defined(__clang__)
 #define TLS_ATTRIBUTE
 #else
 #define TLS_ATTRIBUTE __attribute__ ((tls_model ("initial-exec")))
diff --git a/libexec/customcc/cc.sh b/libexec/customcc/cc.sh
index 428a042..e83af67 100644
--- a/libexec/customcc/cc.sh
+++ b/libexec/customcc/cc.sh
@@ -34,15 +34,11 @@
 CDIR=$(dirname $0)
 CNAME=$(basename $0)
 
-if [ "${CCVER}" = "clang" -o "${CCVER}" = "clangsvn" ]; then
-	if [ "${CNAME}" = "cpp" ]; then
-		exec ${CDIR}/../gcc44/cpp "$@"
-	else
-		INCOPT="-nobuiltininc -nostdinc \
-		    -isysroot @@INCPREFIX@@ \
-		    -isystem /usr/include \
-		    -isystem /usr/include/c++/4.4"
-	fi
+if [ "${CCVER}" = "clang" ]; then
+	INCOPT="-nobuiltininc -nostdinc \
+	    -isysroot @@INCPREFIX@@ \
+	    -isystem /usr/include \
+	    -isystem /usr/include/c++/4.7"
 elif [ "${CCVER}" = "gcc46" ]; then
 	GCC46VER=`gnatc++ -dumpversion`
 	GCC46MAC=`gnatc++ -dumpmachine`
diff --git a/nrelease/Makefile b/nrelease/Makefile
index 9dfd5a1..6a222cc 100644
--- a/nrelease/Makefile
+++ b/nrelease/Makefile
@@ -36,6 +36,7 @@ CHROOT_CMD?=		/usr/sbin/chroot ${ISOROOT} sh -c
 #
 DPORTS_EXTRA_PACKAGES?=
 
+.if !make(nopkgs)
 # dports packages to be built and installed on the release ISO
 #
 # MISSING: csup
@@ -52,6 +53,7 @@ DPORTS_OPTIONS+=		-DBATCH
 .if !make(gui)
 DPORTS_OPTIONS.devel_git+=	-DWITHOUT_CONTRIB -DWITHOUT_PERL
 .endif
+.endif
 
 # Specify which root skeletons are required, and let the user include
 # their own.  They are copied into ISODIR during the `customizeiso'
@@ -171,7 +173,7 @@ check:
 buildworld1 buildworld2:
 	cd ${.CURDIR}/..; \
 	${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
-		make -j ${MAKE_JOBS} -DWANT_INSTALLER ${.TARGET:C/build(.*)2/quick\1/:C/1//}
+		make -j ${MAKE_JOBS} __MAKE_CONF=/tmp/m.conf -DWANT_INSTALLER ${.TARGET:C/build(.*)2/quick\1/:C/1//}
 
 buildkernel1 buildkernel2:
 	cd ${.CURDIR}/..; \
@@ -198,7 +200,7 @@ buildiso:
 	rm -rf ${ISOROOT}
 	mkdir -p ${ISOROOT}
 	if [ ! -d ${NRLOBJDIR}/nrelease ]; then mkdir -p ${NRLOBJDIR}/nrelease; fi
-	( cd ${.CURDIR}/..; make -DWANT_INSTALLER DESTDIR=${ISOROOT} installworld )
+	( cd ${.CURDIR}/..; make -DWANT_INSTALLER __MAKE_CONF=/tmp/m.conf DESTDIR=${ISOROOT} installworld )
 	( cd ${.CURDIR}/../etc; MAKEOBJDIRPREFIX=${NRLOBJDIR}/nrelease \
 		make -m ${.CURDIR}/../share/mk DESTDIR=${ISOROOT} distribution )
 	cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd
@@ -296,7 +298,9 @@ customizeiso:
 	# for dports manual pages, create an initial locate database and
 	# clean up
 	#
+.if !make(nopkgs)
 	${CHROOT_CMD} "yes | pkg autoremove"
+.endif
 	${CHROOT_CMD} "makewhatis /usr/local/man"
 	-umount ${ISOROOT}/usr/distfiles
 	umount ${ISOROOT}/usr/dports
diff --git a/share/mk/bsd.prog.mk b/share/mk/bsd.prog.mk
index f6567bd..0a16f2e 100644
--- a/share/mk/bsd.prog.mk
+++ b/share/mk/bsd.prog.mk
@@ -98,7 +98,7 @@ _INSTALLFLAGS:=	${INSTALLFLAGS}
 _INSTALLFLAGS:=	${_INSTALLFLAGS${ie}}
 .endfor
 
-.if !target(realinstall)
+.if !target(realinstall) && !defined(INTERNALPROG)
 realinstall: _proginstall
 .ORDER: beforeinstall _proginstall
 _proginstall:
diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk
index 4faf438..6615b54 100644
--- a/share/mk/bsd.sys.mk
+++ b/share/mk/bsd.sys.mk
@@ -20,6 +20,10 @@ CFLAGS		+= -std=${CSTD}
 # Enable various levels of compiler warning checks.  These may be
 # overridden (e.g. if using a non-gcc compiler) by defining NO_WARNS.
 
+#.if ${CCVER} == "clang"
+#CWARNFLAGS	+=	-Weverything
+#.endif
+
 .if !defined(NO_WARNS)
 . if defined(WARNS)
 .  if ${WARNS} >= 1
diff --git a/usr.bin/tip/libacu/hayes.c b/usr.bin/tip/libacu/hayes.c
index 365732b..5bea03b 100644
--- a/usr.bin/tip/libacu/hayes.c
+++ b/usr.bin/tip/libacu/hayes.c
@@ -62,6 +62,7 @@
 #define	min(a,b)	((a < b) ? a : b)
 
 static	void sigALRM();
+static	void error_rep(char);
 static	int timeout = 0;
 static	jmp_buf timeoutbuf;
 static 	char gobble();
@@ -194,6 +195,7 @@ gobble(match)
 	return (status);
 }
 
+static void
 error_rep(c)
 	char c;
 {
diff --git a/usr.bin/tip/tip/cmds.c b/usr.bin/tip/tip/cmds.c
index d924c24..5070d9e 100644
--- a/usr.bin/tip/tip/cmds.c
+++ b/usr.bin/tip/tip/cmds.c
@@ -716,7 +716,7 @@ consh(int c)
 	char buf[256];
 	putchar(c);
 	if (prompt("Local command? ", buf, sizeof(buf)))
-		return;
+		return -1;
 	tiplink (buf, TL_SIGNAL_TIPOUT | TL_VERBOSE);
 	return 0;
 }
-- 
1.8.2.2

