Date: Thu, 11 Apr 2002 12:33:53 +0300 From: Ruslan Ermilov <ru@FreeBSD.org> To: Peter Wemm <peter@wemm.org> Cc: "David O'Brien" <obrien@FreeBSD.org>, Marcel Moolenaar <marcel@xcllnt.net>, cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/gnu/usr.bin/gperf Makefile src/gnu/usr.bin/groff/src/devices/grodvi Makefile src/gnu/usr.bin/groff/src/devices/grohtml Makefile src/gnu/usr.bin/groff/src/devices/grolbp Makefile sr Message-ID: <20020411093353.GA42484@sunbay.com> In-Reply-To: <20020411051528.8663638FD@overcee.wemm.org> References: <20020410180443.D84993@dragon.nuxi.com> <20020411051528.8663638FD@overcee.wemm.org>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
On Wed, Apr 10, 2002 at 10:15:28PM -0700, Peter Wemm wrote:
> "David O'Brien" wrote:
> > On Tue, Apr 09, 2002 at 09:48:21PM -0700, Marcel Moolenaar wrote:
> > > On Mon, Apr 08, 2002 at 07:10:29PM -0700, David O'Brien wrote:
> > > > On Mon, Apr 08, 2002 at 04:20:40PM -0700, Peter Wemm wrote:
> > > > > > Please commit this as it does improve things. As Peter mentioned it
> > > > > > would be nice to add the libstdc++ dependancy also. But even w/o tha
> t,
> > > > > > this patch is a help.
> > > > >
> > > > > No, do what Max Khon suggested. Use PROG_CXX like NetBSD does.
> > > >
> > > > Why can't we do both? If we can make PROG=foo do the right thing in the
> > > > common case we should make it do so.
> > >
> > > The common case is all C. That already works. If you do both, you
> > > break the uncommon case, in which you have C++ source files (or at
> > > least named like them) but want C linkage. You cannot use PROG=
> > > anymore. This can only lead to a third one PROG_C, which is almost
> > > exactly like PROG. This is confusing.
> > >
> > > I think only PROG_CXX is better. This automaticly means that PROG
> > > is for C. Always...
> >
> > There is a patch that implements PROG= such that we can remove the
> > explicit linkage of libstdc++. Unless someone writes and commits the
> > PROG_CXX, we have no better option than to commit ru's patch.
>
> It is not "no better option than to commit ..." - nothing is broken.
>
> I have a PROG_CXX patch already FWIW.
>
I agree with all of the above, and I also have a working patch.
I have taken the NetBSD version as the basis and modified it slightly.
Now about what's different. We have the DPADD+=${LIBSTDCPLUSPLUS}
dependency automatically. They don't. We still use "cc" for linking
in this case for two reasons:
1. We must add -lstdc++ to LDADD because otherwise we break "checkdpadd".
2. c++ runs linker with "-lstdc++ -lm". The bogus part here is -lm.
While libstdc++.so depends on libm.so, yes, the program itself
doesn't necessarily, and libstdc++.so already has the necessary
dependency on libm.so recorded in.
Here's the patch:
%%%
Index: bsd.README
===================================================================
RCS file: /home/ncvs/src/share/mk/bsd.README,v
retrieving revision 1.21
diff -u -r1.21 bsd.README
--- bsd.README 17 Dec 2001 13:59:32 -0000 1.21
+++ bsd.README 11 Apr 2002 09:30:55 -0000
@@ -226,11 +226,17 @@
PROG The name of the program to build. If not supplied, nothing
is built.
+PROG_CXX If defined, the name of the program to build. Also
+ causes <bsd.prog.mk> to link the program with the
+ standard C++ library. PROG_CXX overrides the value
+ of PROG if PROG is also set.
+
PROGNAME The name that the above program will be installed as, if
different from ${PROG}.
SRCS List of source files to build the program. If SRCS is not
- defined, it's assumed to be ${PROG}.c.
+ defined, it's assumed to be ${PROG}.c or, if PROG_CXX is
+ defined, ${PROG_CXX}.cc.
DPADD Additional dependencies for the program. Usually used for
libraries. For example, to depend on the compatibility and
Index: bsd.prog.mk
===================================================================
RCS file: /home/ncvs/src/share/mk/bsd.prog.mk,v
retrieving revision 1.106
diff -u -r1.106 bsd.prog.mk
--- bsd.prog.mk 11 Apr 2002 08:54:21 -0000 1.106
+++ bsd.prog.mk 11 Apr 2002 09:30:55 -0000
@@ -20,6 +20,12 @@
LDFLAGS+= -static
.endif
+.if defined(PROG_CXX)
+PROG= ${PROG_CXX}
+DPADD+= ${LIBSTDCPLUSPLUS}
+LDADD+= -lstdc++
+.endif
+
.if defined(PROG)
.if defined(SRCS)
@@ -37,7 +43,11 @@
.else !defined(SRCS)
.if !target(${PROG})
+.if defined(PROG_CXX)
+SRCS= ${PROG}.cc
+.else
SRCS= ${PROG}.c
+.endif
# Always make an intermediate object file because:
# - it saves time rebuilding when only the library has changed
%%%
Look how a typical C++ program's makefile would look now:
%%%
Index: Makefile
===================================================================
RCS file: /home/ncvs/src/gnu/usr.bin/groff/src/preproc/soelim/Makefile,v
retrieving revision 1.1
diff -u -r1.1 Makefile
--- Makefile 17 Apr 2001 12:37:11 -0000 1.1
+++ Makefile 11 Apr 2002 09:32:28 -0000
@@ -1,7 +1,6 @@
# $FreeBSD: src/gnu/usr.bin/groff/src/preproc/soelim/Makefile,v 1.1 2001/04/17 12:37:11 ru Exp $
-PROG= soelim
-SRCS= soelim.cc
+PROG_CXX= soelim
DPADD= ${LIBGROFF}
LDADD= ${LIBGROFF}
CLEANFILES= ${MAN}
%%%
Cheers,
--
Ruslan Ermilov Sysadmin and DBA,
ru@sunbay.com Sunbay Software AG,
ru@FreeBSD.org FreeBSD committer,
+380.652.512.251 Simferopol, Ukraine
http://www.FreeBSD.org The Power To Serve
http://www.oracle.com Enabling The Information Age
[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (FreeBSD)
Comment: For info see http://www.gnupg.org
iD8DBQE8tViBUkv4P6juNwoRAoUaAJwOvvuNGF9rnWIH4m3EbUOlbv+SAwCgjMBS
zK/f4V6/IH52N/VnnGqK/BQ=
=pISP
-----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020411093353.GA42484>
