Skip site navigation (1)Skip section navigation (2)
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

--vtzGhvizbBRQ85DL
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

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 mention=
ed it
> > > > > > would be nice to add the libstdc++ dependancy also.  But even w=
/o tha
>     t,
> > > > > > this patch is a help.
> > > > >=20
> > > > > No, do what Max Khon suggested.  Use PROG_CXX like NetBSD does.
> > > >=20
> > > > Why can't we do both?  If we can make PROG=3Dfoo do the right thing=
 in the
> > > > common case we should make it do so.
> > >=20
> > > 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=3D
> > > anymore. This can only lead to a third one PROG_C, which is almost
> > > exactly like PROG. This is confusing.
> > >=20
> > > I think only PROG_CXX is better. This automaticly means that PROG
> > > is for C. Always...
> >=20
> > There is a patch that implements PROG=3D 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.
>=20
> It is not "no better option than to commit ..." - nothing is broken.
>=20
> I have a PROG_CXX patch already FWIW.
>=20
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+=3D${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
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
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.
=20
+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}.
=20
 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.
=20
 DPADD		Additional dependencies for the program.  Usually used for
 		libraries.  For example, to depend on the compatibility and
Index: bsd.prog.mk
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
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+=3D -static
 .endif
=20
+.if defined(PROG_CXX)
+PROG=3D	${PROG_CXX}
+DPADD+=3D	${LIBSTDCPLUSPLUS}
+LDADD+=3D	-lstdc++
+.endif
+
 .if defined(PROG)
 .if defined(SRCS)
=20
@@ -37,7 +43,11 @@
 .else !defined(SRCS)
=20
 .if !target(${PROG})
+.if defined(PROG_CXX)
+SRCS=3D	${PROG}.cc
+.else
 SRCS=3D	${PROG}.c
+.endif
=20
 # 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
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
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/0=
4/17 12:37:11 ru Exp $
=20
-PROG=3D		soelim
-SRCS=3D		soelim.cc
+PROG_CXX=3D	soelim
 DPADD=3D		${LIBGROFF}
 LDADD=3D		${LIBGROFF}
 CLEANFILES=3D	${MAN}
%%%


Cheers,
--=20
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

--vtzGhvizbBRQ85DL
Content-Type: application/pgp-signature
Content-Disposition: inline

-----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-----

--vtzGhvizbBRQ85DL--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020411093353.GA42484>