Skip to content

Conversation

marisn
Copy link
Contributor

@marisn marisn commented Oct 10, 2025

At the moment we usually just check for presence of pthread headers and then assume pthread library is also fine. This PR introduces more common HAVE_PTHREAD that generally should be used instead of HAVE_PTHREAD_H in most of our cases.

Actual change is only in configure.ac, the rest is just a side effect of running autoreconf

Comment on lines -373 to -441

/*
* configuration information solely dependent on the above
* nothing below this point should need changing
*/

#if defined(HAVE_VALUES_H) && !defined(HAVE_LIMITS_H)
#define INT_MIN -MAXINT
#endif



/*
* Defines needed to get large file support - from cdrtools-2.01
*/

/* MINGW32 LFS */

/* define if we have LFS */
#undef HAVE_LARGEFILES

#ifdef HAVE_LARGEFILES /* If we have working largefiles at all */
/* This is not defined with glibc-2.1.3 */

#if 0

/* what to do with these four? configure comments these out */

#undef _LARGEFILE_SOURCE /* To make ftello() visible (HP-UX 10.20). */
#undef _LARGE_FILES /* Large file defined on AIX-style hosts. */
#undef _XOPEN_SOURCE /* To make ftello() visible (glibc 2.1.3). */
#undef _XOPEN_SOURCE_EXTENDED
/* XXX We don't use this because glibc2.1.3*/
/* XXX is bad anyway. If we define */
/* XXX _XOPEN_SOURCE we will loose caddr_t */

#endif

#if defined(__MINGW32__) && (!defined(_FILE_OFFSET_BITS) || (_FILE_OFFSET_BITS != 64))

/* add/remove as needed */
/* redefine off_t */
#include <sys/types.h>
#define off_t off64_t
/* fseeko and ftello are safe because not defined by MINGW */
#define HAVE_FSEEKO
#define fseeko fseeko64
#define ftello ftello64
/* redefine lseek */
#include <unistd.h>
#define lseek lseek64
/* redefine stat and fstat */
/* use _stati64 compatible with MSVCRT < 6.1 */
#include <sys/stat.h>
#define stat _stati64
#define fstat _fstati64

#endif /* MINGW32 LFS */

#endif /* HAVE_LARGEFILES */


/* define if langinfo.h exists */
#undef HAVE_LANGINFO_H

/* Use framebuffer objects for off-screen OpenGL rendering */
#define OPENGL_FBO 1

#endif /* _config_h */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is any of this supposed to be kept? I see some mingw stuff

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea. But having custom code in files that are generated/re-generated is not the correct way to go. Anyone running autoreconf would then nuke them. Thus – if it is necessary, then this is a wrong place to have it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My initial periodic update script was running that each time, and got trimmed down to only keep the guess file and another because of this. It would have kept it in sync and prevented the deviation from arriving

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to configure.ac thus making autotools friendly (survive autoreconfigure).

#ifndef _config_h
#define _config_h

#define GDEBUG 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this one of our overrides on the file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. If we have overrides, we should implement them in a robust way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to configure.ac thus making autotools friendly (survive autoreconfigure).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So now we see the results after autoreconf?

For original history, see config.h.in before this commit.
@marisn marisn requested a review from echoix October 10, 2025 11:42
Comment on lines +7 to +34
/* MINGW32 LFS */

/* define if we have LFS */
#undef HAVE_LARGEFILES

#ifdef HAVE_LARGEFILES /* If we have working largefiles at all */
/* This is not defined with glibc-2.1.3 */

#if defined(__MINGW32__) && (!defined(_FILE_OFFSET_BITS) || (_FILE_OFFSET_BITS != 64))

/* add/remove as needed */
/* redefine off_t */
#include <sys/types.h>
#define off_t off64_t
/* fseeko and ftello are safe because not defined by MINGW */
#define HAVE_FSEEKO
#define fseeko fseeko64
#define ftello ftello64
/* redefine lseek */
#include <unistd.h>
#define lseek lseek64
/* redefine stat and fstat */
/* use _stati64 compatible with MSVCRT < 6.1 */
#include <sys/stat.h>
#define stat _stati64
#define fstat _fstati64

#endif /* MINGW32 LFS */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it matter if it isn't guarded by the #ifndef _config_h anymore? And does the order matter too? (I couldn't determine easily on my phone if the variables/defines used there were already set at the time of use)

AC_CANONICAL_HOST
AC_PROG_CC

# Start some config.h customizations
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like comment on other file, is it possible to have it at the end, where the HAVE defines are already defined?

Copy link
Member

@wenzeslaus wenzeslaus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe that's because I'm viewing this on my phone, but does the PR description capture what is in the changes? I can't match one to the other.

Copy link
Member

@wenzeslaus wenzeslaus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as the content goes, this is fine with me, except two three things:

  1. Description of the minGW and OpenGL changes should be included somewhere.
  2. Why this does not include CMake change? (Included in #6480)
  3. OpenGL needs fixes for macOS which now fails in /Users/runner/work/grass/grass/lib/ogsf

Since I already tested the follow-up PR #6480, I see that this is valuable and generally functional.

@wenzeslaus
Copy link
Member

Correction of my comment: The macOS build fails on the follow-up PR #6480 (I suppose because the OpenGL fixes are only here).

@marisn marisn marked this pull request as draft October 13, 2025 06:58
@marisn
Copy link
Contributor Author

marisn commented Oct 13, 2025

Maybe that's because I'm viewing this on my phone, but does the PR description capture what is in the changes? I can't match one to the other.

Yes, because three lines of code revealed a problem in our build system. I'll create a separate PR with build system fixes to be merged first and then reference it here. Thus there will be a chain of PRs to be merged to get #6480 in.

CMake experts can comment more on this, but as I understood, modern CMake practice is to not pollute global space with local defines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants