netbsdnoob
netbsdnoob How do i find what is overwriting CFLAGS? Is there anything specific i should look for?
Packages shouldn't set compiler/linker flags (e.g. with CFLAGS= -Wall...) ignoring host system default values. They should allow for user-settable environment (e.g. CFLAGS?=-O2), or append their setting to default (CFLAGS+=).
Where to look for these things depends on the build system used to generate Makefiles (GNU configure, BSD .mk files, autotools, imake, CMake, meson) and varies largely with software written in other languages (but C/C++).
Sometimes header files aren't found as result of circular inclusion. Sometimes the header is allegedly found, but included types are not, because a local header with the same name was included before the system's one. Sometimes some compiler flag may prevent linking against standard system libraries.
But this is not all. When dealing with pkgsrc, the level of abstraction it uses to match its flexibility and portability standards, comes at the expense of added complexity. At the same time, the fact that pkgsrc tries its hard to keep the tree self-contained (for reasons of security, standardization and reproducibility), will lead one to recognize problems in software and debug them, before ever being able to package it.