[CDRIVER-1027] When running src/libmongoc/build/autotools/Versions.m4 out of scope, VERSION_* is cat'ed from the wrong directory Created: 02/Dec/15  Updated: 19/Oct/16  Resolved: 09/Dec/15

Status: Closed
Project: C Driver
Component/s: Build, libbson, libmongoc
Affects Version/s: 1.3.0-rc0
Fix Version/s: 1.3.0

Type: Bug Priority: Blocker - P1
Reporter: Derick Rethans Assignee: Hannes Magnusson
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by PHPC-495 Upgrade bundled libbson and libmongoc... Closed
Related
is related to CDRIVER-1013 Declare library version in one place Closed
is related to CDRIVER-1034 libtool version info Closed

 Description   

The phongo build process sources "Versions.m4":

```
if test "$PHP_LIBMONGOC" == "no"; then
m4_include(src/libmongoc/build/autotools/Versions.m4)
MONGOC_MAJOR_VERSION=mongoc_major_version
MONGOC_MINOR_VERSION=mongoc_minor_version
MONGOC_MICRO_VERSION=mongoc_micro_version
MONGOC_API_VERSION=1.0
MONGOC_VERSION=mongoc_version
AC_SUBST(MONGOC_MAJOR_VERSION)
AC_SUBST(MONGOC_MINOR_VERSION)
AC_SUBST(MONGOC_MICRO_VERSION)
AC_SUBST(MONGOC_API_VERSION)
AC_SUBST(MONGOC_VERSION)
AC_OUTPUT($srcdir/src/libmongoc/src/mongoc/mongoc-config.h)
AC_OUTPUT($srcdir/src/libmongoc/src/mongoc/mongoc-version.h)
fi
```
to be able to set the right MONGOC_*_CONSTANTS, but since 13f9dae1b99962b3989cbbf3dd115d169211944e, there are now issues as Versions.m4 does a "cat" on VERSION_CURRENT and VERSION_RELEASE, without taking into account that they might no longer live in the same directory.

This results in:
```
cat: VERSION_CURRENT: No such file or directory
cat: VERSION_RELEASED: No such file or directory
cat: VERSION_CURRENT: No such file or directory
cat: VERSION_RELEASED: No such file or directory
```

when running our "phpize" (akin to autogen.sh). It shows the errors once for libbson and once for libmongoc.

the "cat" needs to be done on the files in the right directory.



 Comments   
Comment by Hannes Magnusson [ 09/Dec/15 ]

Closing ticket – it was fixed in 1.3.0, accompanying a simplification in phongo

Comment by Githook User [ 07/Dec/15 ]

Author:

{u'username': u'bjori', u'name': u'Hannes Magnusson', u'email': u'bjori@php.net'}

Message: Revert "Unblock compile by copying VERSION_CURRENT and VERSION_RELEASED until CDRIVER-1027 is fixed."

This reverts commit aeb55cce75d1c18a38acd52847f29de9dfa22da4.
Branch: master
https://github.com/mongodb/mongo-php-driver/commit/30d29a0bf76eb15dbb526af068a31efd912ab717

Comment by Hannes Magnusson [ 04/Dec/15 ]

Heh. Now it gets passed the phpize stage but fails during ./configure.

And of course it fails. $srcdir is the phongo srcdir, not mongoc.
I can't think of a way to fix that in mongoc – we must be able to use $srcdir as if it referred to our src.

I've created a Pull Request for phongo to fix this though: https://github.com/mongodb/mongo-php-driver/pull/150
Is that acceptable to you?

Comment by Derick Rethans [ 04/Dec/15 ]

Sorry, but this is not yet fixed. The location of the cat/cut errors has changed, but I still get:

checking whether byte ordering is bigendian... no
checking for stdbool.h that conforms to C99... yes
checking for _Bool... yes
checking for clock_gettime... yes
checking for strnlen... (cached) yes
checking for snprintf... (cached) yes
cat: ./VERSION_CURRENT: No such file or directory
cut: ./VERSION_CURRENT: No such file or directory
cut: ./VERSION_CURRENT: No such file or directory
cut: ./VERSION_CURRENT: No such file or directory
cut: ./VERSION_CURRENT: No such file or directory
cat: ./VERSION_RELEASED: No such file or directory
cut: ./VERSION_RELEASED: No such file or directory
cut: ./VERSION_RELEASED: No such file or directory
cut: ./VERSION_RELEASED: No such file or directory
cut: ./VERSION_RELEASED: No such file or directory
configure: Current version (from VERSION_CURRENT file): 
configure: creating ./config.status
config.status: creating ./src/libmongoc/src/mongoc/mongoc-config.h

and hence the compile errors later on return.

By current branch for this is https://github.com/derickr/mongo-php-driver/tree/fix-libmongoc-version-issue

Comment by Githook User [ 04/Dec/15 ]

Author:

{u'username': u'bjori', u'name': u'Hannes Magnusson', u'email': u'bjori@php.net'}

Message: CDRIVER-1027: Simplify version declaration

Also remove unused BSON_LT_LDFLAGS variable that was never
substituted, and therefore always empty.
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/e894a547bffcc8001f2d609dfa2147c449083a73

Comment by Githook User [ 04/Dec/15 ]

Author:

{u'username': u'bjori', u'name': u'Hannes Magnusson', u'email': u'bjori@php.net'}

Message: CDRIVER-1027: Simplify version declaration

Also remove unused BSON_LT_LDFLAGS variable that was never substituted,
and therefore always empty.
Branch: master
https://github.com/mongodb/libbson/commit/1e0bd44bb8298dba8b698c043ac40ba5f3f05692

Comment by A. Jesse Jiryu Davis [ 02/Dec/15 ]

bjori I think the right answer is to chdir to the proper directory before invoking these macros, but I'm uncertain. Another option is to provide some m4_define'd source-directory variable that Versions.m4 can use to find the libbson or libmongoc source directory.

Notice, for example, that when libmongoc invokes libbson's ./autogen.sh, libbson does not encounter this problem, because it chdirs into src/libbson before invoking it. So it seems like expected behavior for our configure scripts to assume that the working directory is the repository root.

Comment by Githook User [ 02/Dec/15 ]

Author:

{u'username': u'derickr', u'name': u'Derick Rethans', u'email': u'github@derickrethans.nl'}

Message: Unblock compile by copying VERSION_CURRENT and VERSION_RELEASED until CDRIVER-1027 is fixed.
Branch: master
https://github.com/mongodb/mongo-php-driver/commit/aeb55cce75d1c18a38acd52847f29de9dfa22da4

Generated at Wed Feb 07 21:11:20 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.