On 2023-09-11, Sébastien Hinderer <Sebastien.Hinderer@xxxxxxxxxxxx> wrote: > I am writing with a quesiton about the AC_SYS_LARGEFILE macro. > > It would be great to be able to use it but according to its > documentation, the macro adds its flags to the CC output variable, which > is not convenient in my context because we have dedicated variables not > only for C flags but also for C preprocessor flags. Autoconf is designed to facilitate build systems that comply with the GNU coding standards. CFLAGS and CPPFLAGS cannot be used for large-file support because these flags are required for proper compilation, and the standards say such flags don't go into CFLAGS or CPPFLAGS. This is because the user is supposed to be able to override these variables. For example: % ./configure % make CFLAGS=-g3 would almost certainly break horribly if configure put any large-file support options into CFLAGS. Looking at the code, CC is modified only if the -n32 option is needed to enable large-file support. The comments suggest this is required on IRIX. If large-file support can be enabled by preprocessor macros (which I imagine is the case on all current systems), AC_DEFINE is used. It has been this way since the macro was originally added to Autoconf. I can only speculate as to why the original author used CC, but the reason is probably so that you can just take an existing package and just add AC_SYS_LARGEFILE with no other modifications and it will almost certainly work without any major problems. Anything else would likely fail to comply with the standards or would require package maintainers to edit their makefiles to ensure some new variable is included on every compiler command line. If they miss one, then their program would work perfectly almost everywhere but fail when building on IRIX (probably a more serious concern when this macro was added back in 2000 than it is today). Furthermore, in the real world, package authors are notoriously bad at ensuring CFLAGS is properly passed to every single C compiler invocation. But people are usually much better at using CC consistently. > Thus, what I'd ideally need is a version of the macro where I can > somehow specify what to do with both large-file related CFLAGS and > CPPFLAGS. If you really don't want configure modifying CC on IRIX, while still complying with the GNU coding standards, then you can do something like this instead (untested): save_CC=$CC AC_SYS_LARGEFILE AS_IF([test x"$CC" != x"$save_CC"], [dnl The undocumented cache variable ac_cv_sys_largefile_CC dnl here exists in every version of Autoconf with AC_SYS_LARGEFILE; you could also dnl pick apart $CC to find out what flags were added. AC_SUBST([$LARGEFILE_FLAGS], [$ac_cv_sys_largefile_CC]) CC=$save_CC]) Then, modify your Makefiles to ensure $(LARGEFILE_FLAGS) is included on every compiler command line. Hope that helps, Nick