Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configure: Use AC_C_BIGENDIAN macro to check endianness. #2477

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 2 additions & 26 deletions configure.ac
Expand Up @@ -152,34 +152,10 @@ AC_CHECK_LIB(c, dlclose, LIBDL="", [AC_CHECK_LIB(dl, dlclose, LIBDL="-ldl")])
AC_SUBST(LIBDL)

# Check endianness.
AC_MSG_CHECKING([build system endianness])
ENDIAN=unknown
AC_RUN_IFELSE(
[AC_LANG_PROGRAM(
[[
#include <endian.h>
#if __BYTE_ORDER != __LITTLE_ENDIAN
#error
#endif
]]
)],
[ENDIAN=little]
)
AC_RUN_IFELSE(
[AC_LANG_PROGRAM(
[[
#include <endian.h>
#if __BYTE_ORDER != __BIG_ENDIAN
#error
#endif
]]
)],
[ENDIAN=big]
)
AC_C_BIGENDIAN([ENDIAN=big],[ENDIAN=little],[ENDIAN=unknown],[])
Copy link
Member

Choose a reason for hiding this comment

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

Please add a space char by comma char.
Probably I think "[ENDIAN=big]" can be applied to the 4th argument for the universal case at the moment.

if test x"$ENDIAN" != xlittle -a x"$ENDIAN" != xbig; then
AC_MSG_ERROR([Cannot deermine endianness without endian.h])
AC_MSG_ERROR([Cannot determine endianness])
fi
AC_MSG_RESULT($ENDIAN)
AC_SUBST(ENDIAN)
Copy link
Member

Choose a reason for hiding this comment

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

I think to append ENDIAN="$ENDIAN ($ac_cv_c_bigendian, use ac_cv_c_bigendian to yes or no)" next to AC_SUBST(ENDIAN) .

Copy link
Author

Choose a reason for hiding this comment

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

I think to append ENDIAN="$ENDIAN ($ac_cv_c_bigendian, use ac_cv_c_bigendian to yes or no)" next to AC_SUBST(ENDIAN) .

Sorry, I don't understand what the statement you suggested means.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

fi
-AC_MSG_RESULT($ENDIAN)
AC_SUBST(ENDIAN)

The change will effect the configure result. E.g.
https://github.com/ibus/ibus/actions/runs/4376470045/jobs/7895795597?pr=2477#step:7:385

Sorry I committed multiple revisions and github UI doesn't quote commentted lines exactly.
Which reivision/line is 'the change' you mean?

If you meant AC_MSG_RESULT($ENDIAN) line removed in f733c18 :
AC_MSG_RESULT() just print a result of a check and won't affect a value itself.
https://www.gnu.org/software/autoconf/manual/autoconf-2.71/html_node/Printing-Messages.html

If you meant 'the change' is to set/update ENDIAN value by
ENDIAN="$ENDIAN ($ac_cv_c_bigendian, use ac_cv_c_bigendian to yes or no)" next to AC_SUBST(ENDIAN)
line to print endianness description in AC_MSG_RESULT in configure.ac

Build endianness $ENDIAN

an actual value of $ENDIAN is already set by
AC_C_BIGENDIAN([ENDIAN=big],[ENDIAN=little],[ENDIAN=unknown],[])
line and this new one will be overwritten the value.
I wonder what happens on reference of $ENDIAN in and it's also referred in src/Makefile.am
compose/sequences-$(ENDIAN)-endian: gen-internal-compose-table

Copy link
Member

Choose a reason for hiding this comment

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

an actual value of $ENDIAN is already set by AC_C_BIGENDIAN([ENDIAN=big],[ENDIAN=little],[ENDIAN=unknown],[]) line and this new one will be overwritten the value.

That's why I asked to update ENDIAN after AC_SUBST(ENDIAN)

 AC_SUBST(ENDIAN)
+ENDIAN="$ENDIAN ($ac_cv_c_bigendian, use ac_cv_c_bigendian to yes or no)"

Copy link
Member

@fujiwarat fujiwarat Mar 27, 2023

Choose a reason for hiding this comment

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

Sorry, even if ENDIAN is updated after AC_SUBST(ENDIAN), the overriding ENDIAN reflects the Makefile recursively.

ENDIAN_MSG="$ENDIAN ($ac_cv_c_bigendian, use ac_cv_c_bigendian to yes or no)"

and

-  Build endianness              $ENDIAN
+  Build endianness              $ENDIAN_MSG

Copy link
Member

Choose a reason for hiding this comment

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

Are you fine to update the configure result?

Copy link
Author

Choose a reason for hiding this comment

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

Are you fine to update the configure result?

No problem for me.


# Check packages.
Expand Down