pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CFLAGS vs COPTS in mk.conf for pkgsrc compiling



Am 07.09.2024 um 08:37 schrieb Ramiro Aceves:
> Hello,
>
> I started reading mk.conf page to see what variables could be tuned:

The mk.conf manual page applies primarily to the NetBSD base system.
Some parts of it may not apply to pkgsrc.

The pkgsrc guide at https://www.netbsd.org/docs/pkgsrc/pkgsrc.html
mentions CFLAGS several times and never COPTS, so that should be the way
to go.

> "Also note that CFLAGS should never be set in mk.conf."

In the context where this sentence occurs, it can also be interpreted as
"appending to CFLAGS is fine, just don't override it, as its default
value includes the DBG variable". Not sure why nobody fixed this
ambiguous wording in the past 17 years.

> so I used COPTS instead of CFLAGS

That doesn't work in pkgsrc since in
pkgtools/bootstrap-mk-files/files/sys.mk, the default value for CFLAGS
does not include COPTS.

To find this out, I ran this command in emulators/dosbox:
> bmake -V CFLAGS -dA  2>&1 | less

In the output, I searched for "Global: CFLAGS" and then went backwards
to "Parse_PushInput" to see which file caused the variable assignment.

In the NetBSD base system, COPTS is not added to CFLAGS unconditionally,
as the output of this command reveals:
> grep 'CFLAGS.*COPTS' /usr/share/mk/*.mk

From the filenames in the output, you can see that COPTS only applies to
host libraries, kernel modules, libraries and programs. Notably, this
excludes pkgsrc packages.

Roland



Home | Main Index | Thread Index | Old Index