This is an automated email from the git hooks/post-receive script. ildumi pushed a commit to branch development in repository libtool.
The following commit(s) were added to refs/heads/development by this push: new c010d1e9 libtool: Add tagging support for OBJC and OBJCXX c010d1e9 is described below commit c010d1e93fa6e3580543353e4cdc33a1fcb68781 Author: Ileana Dumitrescu <ileanadumitresc...@gmail.com> AuthorDate: Fri Jan 10 19:54:28 2025 +0200 libtool: Add tagging support for OBJC and OBJCXX Reported: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=67754 * Makefile.am: Set environment variables for tests. * configure.ac: Add language support for Objective-C and Objective-C++. * build-aux/ltmain.in: Update help message for tags available. * m4/libtool.m4: Add tagging support for OBJC and OBJCXX. * tests/flags.at: Add tests for passing OBJC and OBJCXX flags. * tests/infer-tag.at: Add tests for inferring OBJC and OBJCXX tags. * doc/libtool.texi: Update documentation. * NEWS: Update. --- Makefile.am | 2 + NEWS | 4 + build-aux/ltmain.in | 2 + configure.ac | 2 + doc/libtool.texi | 11 ++- m4/libtool.m4 | 207 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/flags.at | 52 ++++++++++++- tests/infer-tag.at | 68 +++++++++++++++++ 8 files changed, 344 insertions(+), 4 deletions(-) diff --git a/Makefile.am b/Makefile.am index 39872b6d..39b35bb7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -743,6 +743,8 @@ TESTS_ENVIRONMENT = MAKE="$(MAKE)" CC="$(CC)" CFLAGS="$(CFLAGS)" \ OBJEXT="$(OBJEXT)" EXEEXT="$(EXEEXT)" \ SHELL="$(SHELL)" CONFIG_SHELL="$(SHELL)" \ CXX="$(CXX)" CXXFLAGS="$(CXXFLAGS)" CXXCPP="$(CXXCPP)" \ + OBJC="$(OBJC)" OBJCFLAGS="$(OBJCFLAGS)" \ + OBJCXX="$(OBJCXX)" OBJCXXFLAGS="$(OBJCXXFLAGS)" \ F77="$(F77)" FFLAGS="$(FFLAGS)" \ FC="$(FC)" FCFLAGS="$(FCFLAGS)" \ GCJ="$(GCJ)" GCJFLAGS="$(GCJFLAGS)" \ diff --git a/NEWS b/NEWS index 0b2e8a11..e1302ab7 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,10 @@ NEWS - list of user-visible changes between releases of GNU Libtool * Noteworthy changes in release ?.? (????-??-??) [?] +** New features: + + - Add tagging for Objective-C and Objective-C++, OBJC and OBJCXX. + * Noteworthy changes in release 2.5.4 (2024-11-20) [stable] diff --git a/build-aux/ltmain.in b/build-aux/ltmain.in index 61266d20..43cd3b1a 100644 --- a/build-aux/ltmain.in +++ b/build-aux/ltmain.in @@ -154,6 +154,8 @@ If a TAG is supplied, it must use one of the tag names below: Tag Name Language Name CC C CXX C++ + OBJC Objective-C + OBJCXX Objective-C++ GCJ Java F77 Fortran 77 FC Fortran diff --git a/configure.ac b/configure.ac index 42bb2957..f9a485ba 100644 --- a/configure.ac +++ b/configure.ac @@ -152,6 +152,8 @@ _LTDL_SETUP # Enable all the language support we can LT_LANG(C++) +LT_LANG(Objective-C) +LT_LANG(Objective-C++) LT_LANG(Fortran 77) LT_LANG(Fortran) LT_LANG(Go) diff --git a/doc/libtool.texi b/doc/libtool.texi index 6fd164ac..6db39346 100644 --- a/doc/libtool.texi +++ b/doc/libtool.texi @@ -2381,7 +2381,8 @@ specifying @option{--enable-pic} to @command{configure}. @defmac LT_LANG (@var{language}) Enable @command{libtool} support for the language given if it has not yet already been enabled. Languages accepted are ``C++'', -``Fortran 77'', ``Java'', ``Go'', and ``Windows Resource''. +``Objective-C'', ``Objective-C++'', ``Fortran 77'', ``Java'', ``Go'', +and ``Windows Resource''. If Autoconf language support macros such as @code{AC_PROG_CXX} are used in your @file{configure.ac}, Libtool language support will automatically @@ -2997,6 +2998,8 @@ correspondence between language names and tags names. @item Language name @tab Tag name @item C @tab CC @item C++ @tab CXX +@item Objective-C @tab OBJC +@item Objective-C++ @tab OBJCXX @item Java @tab GCJ @item Fortran 77 @tab F77 @item Fortran @tab FC @@ -5512,7 +5515,8 @@ Automake. @item @file{tests/flags.at} Tests include checks that compile and linker flags get passed through -@command{libtool}. Tests flags for C, C++, Fortran 77, and Fortran 90. +@command{libtool}. Tests flags for C, C++, Objective-C, Objective-C++, +Fortran 77, Fortran 90, and Java. @item @file{tests/help.at} Tests a variety of mode commands, including mode short-hands, to ensure basic @@ -5525,7 +5529,8 @@ on @file{libconv}, which depends on @file{libb}, which depends on @file{liba}. @item @file{tests/infer-tag.at} Tests that @code{func_infer_tag} works by compiling various code snippets in -various languages (C, C++, Fortran, Java) without a @option{--tag} flag. +various languages (C, C++, Objective-C, Objective-C++, Fortran, Java) without +a @option{--tag} flag. @item @file{tests/inherited_flags.at} Tests the functionality of the @code{inherited_linker_flags} variable in diff --git a/m4/libtool.m4 b/m4/libtool.m4 index b77eaedb..c750f2d8 100644 --- a/m4/libtool.m4 +++ b/m4/libtool.m4 @@ -506,6 +506,36 @@ m4_define([_LT_LIBTOOL_TAG_VARS], # ------------------------------ m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])]) +# _LT_OBJECTIVE_C +# ------------------------------ +m4_defun([_LT_OBJECTIVE_C], [ + AC_CACHE_CHECK([for Objective C compilation], + [lt_cv_objc_compiles], + [ save_CFLAGS=$CFLAGS + CFLAGS=$OBJCFLAGS + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([#import <Foundation/Foundation.h> +@interface Addition : NSObject +- (int)this:(int)a that:(int)b; +@end + +@implementation Addition +- (int)this:(int)a that:(int)b +{ + return a + b; +} +@end +],[])], + lt_cv_objc_compiles=yes, + lt_cv_objc_compiles=no + ) + CFLAGS=$save_CFLAGS + ] + ) + objc_compiles=$lt_cv_objc_compiles + _LT_DECL([], [objc_compiles], [1], + [Check for compiling Objective C and C++ code]) +]) # _LT_CONFIG_COMMANDS # ------------------- @@ -826,6 +856,8 @@ AC_DEFUN([LT_LANG], m4_case([$1], [C], [_LT_LANG(C)], [C++], [_LT_LANG(CXX)], + [Objective-C], [_LT_LANG(OBJC)], + [Objective-C++], [_LT_LANG(OBJCXX)], [Go], [_LT_LANG(GO)], [Java], [_LT_LANG(GCJ)], [Fortran 77], [_LT_LANG(F77)], @@ -907,6 +939,14 @@ AC_PROVIDE_IFELSE([AC_PROG_GO], [LT_LANG(GO)], [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])]) +AC_PROVIDE_IFELSE([AC_PROG_OBJC], + [LT_LANG(OBJC)], + [m4_define([AC_PROG_OBJC], defn([AC_PROG_OBJC])[LT_LANG(OBJC)])]) + +AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], + [LT_LANG(OBJCXX)], + [m4_define([AC_PROG_OBJCXX], defn([AC_PROG_OBJCXX])[LT_LANG(OBJCXX)])]) + AC_PROVIDE_IFELSE([LT_PROG_RC], [LT_LANG(RC)], [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) @@ -8242,6 +8282,151 @@ CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_GO_CONFIG +# _LT_LANG_OBJC_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for the GNU Objective-C compiler +# are suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to 'libtool'. +m4_defun([_LT_LANG_OBJC_CONFIG], +[AC_REQUIRE([LT_PROG_OBJC])dnl +AC_LANG_SAVE + +# Source file extension for OBJC test sources. +ac_ext=m + +# Object file extension for compiled OBJC test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(void){return(0);}' + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_TAG_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Check for compilation issues with OBJC flags +_LT_OBJECTIVE_C +if test "yes" = "$lt_cv_gnustep_exists"; then + OBJCFLAGS="$OBJCFLAGS `gnustep-config --objc-flags`" +fi + +# Allow CC to be a program name with arguments. +lt_save_CC=$CC +lt_save_CFLAGS=$CFLAGS +lt_save_GCC=$GCC +GCC=yes +CC=${OBJC-"gcc"} +CFLAGS=$OBJCFLAGS +compiler=$CC +_LT_TAGVAR(compiler, $1)=$CC +_LT_TAGVAR(LD, $1)=$LD +_LT_CC_BASENAME([$compiler]) + +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(reload_flag, $1)=$reload_flag +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds + +## CAVEAT EMPTOR: +## There is no encapsulation within the following macros, do not change +## the running order or otherwise move them around unless you know exactly +## what you are doing... +if test -n "$compiler"; then + _LT_COMPILER_NO_RTTI($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) +fi + +AC_LANG_RESTORE + +GCC=$lt_save_GCC +CC=$lt_save_CC +CFLAGS=$lt_save_CFLAGS +])# _LT_LANG_OBJC_CONFIG + + +# _LT_LANG_OBJCXX_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for the GNU Objective-C++ compiler +# are suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to 'libtool'. +m4_defun([_LT_LANG_OBJCXX_CONFIG], +[AC_REQUIRE([LT_PROG_OBJCXX])dnl +AC_LANG_SAVE + +# Source file extension for OBJCXX test sources. +ac_ext=mm + +# Object file extension for compiled OBJCXX test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }' + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_TAG_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Check for compilation issues with OBJCXX flags +_LT_OBJECTIVE_C + +# Allow CC to be a program name with arguments. +lt_save_CC=$CC +lt_save_CFLAGS=$CFLAGS +lt_save_GCC=$GCC +GCC=yes +CC=${OBJCXX-"g++"} +CFLAGS=$OBJCXXFLAGS +compiler=$CC +_LT_TAGVAR(compiler, $1)=$CC +_LT_TAGVAR(LD, $1)=$LD +_LT_CC_BASENAME([$compiler]) + +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(reload_flag, $1)=$reload_flag +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds + +## CAVEAT EMPTOR: +## There is no encapsulation within the following macros, do not change +## the running order or otherwise move them around unless you know exactly +## what you are doing... +if test -n "$compiler"; then + _LT_COMPILER_NO_RTTI($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) +fi + +AC_LANG_RESTORE + +GCC=$lt_save_GCC +CC=$lt_save_CC +CFLAGS=$lt_save_CFLAGS +])# _LT_LANG_OBJCXX_CONFIG + + # _LT_LANG_RC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for the Windows resource compiler @@ -8295,6 +8480,28 @@ CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_RC_CONFIG +# LT_PROG_OBJC +# ----------- +AC_DEFUN([LT_PROG_OBJC], +[AC_CHECK_TOOL(OBJC, gcc,) + AC_CHECK_TOOL(GNUSTEP_CONFIG, gnustep-config,) + if test Xgnustep-config = X"$GNUSTEP_CONFIG"; then + test set = "${OBJCFLAGS+set}" || OBJCFLAGS="`gnustep-config --objc-flags`" + fi + AC_SUBST(OBJCFLAGS)])])[]dnl +]) + +# LT_PROG_OBJCXX +# ----------- +AC_DEFUN([LT_PROG_OBJCXX], +[AC_CHECK_TOOL(OBJCXX, g++,) + AC_CHECK_TOOL(GNUSTEP_CONFIG, gnustep-config,) + if test Xgnustep-config = X"$GNUSTEP_CONFIG"; then + test set = "${OBJCXXFLAGS+set}" || OBJCXXFLAGS="`gnustep-config --objc-flags`" + fi + AC_SUBST(OBJCXXFLAGS)])])[]dnl +]) + # LT_PROG_GCJ # ----------- AC_DEFUN([LT_PROG_GCJ], diff --git a/tests/flags.at b/tests/flags.at index 8c40a7af..425ba6af 100644 --- a/tests/flags.at +++ b/tests/flags.at @@ -18,7 +18,7 @@ # along with GNU Libtool. If not, see <https://www.gnu.org/licenses/>. #### -m4_foreach([lt_tag], [CC, CXX, F77, FC, GCJ], +m4_foreach([lt_tag], [CC, CXX, OBJC, OBJCXX, F77, FC, GCJ], [AT_SETUP([passing lt_tag flags through libtool]) AT_KEYWORDS([libtool]) LT_AT_TAG(m4_defn([lt_tag])) @@ -47,6 +47,52 @@ compile="$CC $CPPFLAGS $CFLAGS" link="$CC $CFLAGS $LDFLAGS" source=a.c ]]) compile="$CXX $CPPFLAGS $CXXFLAGS" link="$CXX $CXXFLAGS $LDFLAGS" source=a.cpp ], +[OBJC], [AT_DATA([a.m], +[[#import <Foundation/Foundation.h> + +@interface Addition : NSObject +- (int)this:(int)a that:(int)b; +@end + +@implementation Addition +- (int)this:(int)a that:(int)b +{ + return a + b; +} +@end + +int main() { + Addition *add = [[Addition alloc] init]; + int result = [add this:10 that:20]; + printf("add this:10 that:20 = %d", result); + return 0; +} +]]) +compile="$OBJC $CPPFLAGS $OBJCFLAGS" link="$OBJC $OBJCFLAGS $LDFLAGS" source=a.m +], +[OBJCXX], [AT_DATA([a.mm], +[[#import <Foundation/Foundation.h> + +@interface Addition : NSObject +- (int)this:(int)a that:(int)b; +@end + +@implementation Addition +- (int)this:(int)a that:(int)b +{ + return a + b; +} +@end + +int main() { + Addition *add = [[Addition alloc] init]; + int result = [add this:10 that:20]; + printf("add this:10 that:20 = %d", result); + return 0; +} +]]) +compile="$OBJCXX $CPPFLAGS $OBJCXXFLAGS" link="$OBJCXX $OBJCXXFLAGS $LDFLAGS" source="a.mm -o a.o" +], [F77], [AT_DATA([a.f], [[ program main end @@ -74,6 +120,10 @@ fi eval "`$LIBTOOL --tag=lt_tag --config | $EGREP '^(wl|archive_cmds)='`" +if test OBJC = lt_tag || test OBJCXX = lt_tag; then + AT_CHECK([$LIBTOOL --config | $EGREP '^objc_compiles="no"' && (exit 77)], 1) +fi + AT_CHECK([$LIBTOOL --tag=lt_tag --mode=compile $compile -c $source], [], [ignore], [ignore]) diff --git a/tests/infer-tag.at b/tests/infer-tag.at index 2f4e6777..2f1818e2 100644 --- a/tests/infer-tag.at +++ b/tests/infer-tag.at @@ -50,6 +50,74 @@ AT_CHECK([$LIBTOOL --mode=compile $CXX $CPPFLAGS $CXXFLAGS -c a.cpp], AT_CLEANUP +AT_SETUP([OBJC inferred tag]) +LT_AT_TAG([OBJC]) +AT_KEYWORDS([libtool]) + +AT_CHECK([$LIBTOOL --config | $EGREP '^objc_compiles="no"' && (exit 77)], 1) + +AT_DATA([a.m], +[[ +#import <Foundation/Foundation.h> + +@interface Addition : NSObject +- (int)this:(int)a that:(int)b; +@end + +@implementation Addition +- (int)this:(int)a that:(int)b +{ + return a + b; +} +@end + +int main() { + Addition *add = [[Addition alloc] init]; + int result = [add this:10 that:20]; + printf("add this:10 that:20 = %d", result); + return 0; +} +]]) + +AT_CHECK([$LIBTOOL --mode=compile $OBJC $CPPFLAGS $OBJCFLAGS -c a.m], + [], [ignore], [ignore]) + +AT_CLEANUP + +AT_SETUP([OBJCXX inferred tag]) +LT_AT_TAG([OBJCXX]) +AT_KEYWORDS([libtool]) + +AT_CHECK([$LIBTOOL --config | $EGREP '^objc_compiles="no"' && (exit 77)], 1) + +AT_DATA([a.mm], +[[ +#import <Foundation/Foundation.h> + +@interface Addition : NSObject +- (int)this:(int)a that:(int)b; +@end + +@implementation Addition +- (int)this:(int)a that:(int)b +{ + return a + b; +} +@end + +int main() { + Addition *add = [[Addition alloc] init]; + int result = [add this:10 that:20]; + printf("add this:10 that:20 = %d", result); + return 0; +} +]]) + +AT_CHECK([$LIBTOOL --mode=compile $OBJCXX $CPPFLAGS $OBJCXXFLAGS -c a.mm -o a.o], + [], [ignore], [ignore]) + +AT_CLEANUP + AT_SETUP([F77 inferred tag]) LT_AT_TAG([F77]) AT_KEYWORDS([libtool])