Subject: buildlink3 conversion problem and fix
To: None <>
From: Thomas Klausner <>
List: tech-pkg
Date: 05/04/2004 10:07:49

For all those here doing or wanting to do bl3ifications:
I encountered the same problem in two packages yesternight,
so I thought I'd mention the problem and a fix here.

Some configure scripts add '\$(top_srcdir)' or '\$(rootdir)'
to CFLAGS, with the intention that it only gets expanded in
the Makefile itself. [The proper way to do this is, of course,
adding it in the Makefile(s) that need it.]

Then some configure test tries something like the following
	gcc -o conftest -I$(top_srcdir) -I/usr/pkg/include/glib/glib-1.2 conftest.c
and it fails with
	top_srcdir: not found
	conftest.c:1:18: glib.h: No such file or directory
because the buildlink3 gcc wrapper script expands $(top_srcdir) to
the empty string (warning that top_srcdir is not defined) and the
effective command line is
	gcc -o conftest -I -I/usr/pkg/include/glib/glib-1.2 conftest.c
so that gcc looks for files in '-I/usr/pkg/...' instead of

I don't think there's a sane way for bl3 to fix this.  Also, I
think it's bad style in the configure scripts to do it like this.

My proposed fix is to remove the -I\$(top_srcdir) from the configure
script and add it, if necessary, to the appropriate Makefile(s).