Skip to contentSkip to conversation

fix hesiod check error, use correct $(LIBS)

PATCH In review Lan Yixun (dlan) 2 participants 3 messages Jul 23, 2013 – Jul 24, 2013 Kernel automounter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix hesiod check error, use correct $(LIBS)

From: "Lan Yixun (dlan)" <[email protected]>

the problem here is that hesiod checking always fail due to wrong $(LDFLAGS), no matter hesiod library is installed or not. moving "-lhesiod" into $(LIBS) solve this problem.

1) convert "char *" -> "void *" to fix the compile warning
2) put "-lhesiod -lresolv" into $(LIBS), not into $(LDFLAGS), otherwise we got link error

---
tst_hesiod.c: In function ‘main’:
tst_hesiod.c:38:3: warning: passing argument 1 of ‘hesiod_init’ from incompatible pointer type [enabled by default]
char *c; hesiod_init(&c);
^
In file included from tst_hesiod.c:34:0:
/usr/include/hesiod.h:36:5: note: expected ‘void **’ but argument is of type ‘char **’
int hesiod_init(void **context);

$ x86_64-pc-linux-gnu-gcc -o conftest -O2 -pipe -march=core2  -I/usr/include
 -Wl,-O1 -Wl,--as-needed -g -lhesiod -lresolv tst_hesiod.c -L/usr/lib64
 -lkrb5 -lhx509 -lcom_err -lhcrypto -lasn1 -lwind -lheimbase -lroken
-lcrypt -ldl -lresolv

/tmp/ccN6GW0r.o: In function `main':
/root/tst_hesiod.c:38: undefined reference to `hesiod_init'
collect2: error: ld returned 1 exit status

---
 aclocal.m4 | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
aclocal.m4 +6 -6
index 7a8b03c..637a775 100644
@@ -316,20 +316,20 @@ dnl --------------------------------------------------------------------------
 AC_DEFUN([AF_CHECK_LIBHESIOD],
 [AC_MSG_CHECKING(for libhesiod)
 
-# save current ldflags
-af_check_hesiod_save_ldflags="$LDFLAGS"
-LDFLAGS="$LDFLAGS -lhesiod -lresolv"
+# save current libs
+af_check_hesiod_save_libs="$LIBS"
+LIBS="$LIBS -lhesiod -lresolv"
 
 AC_TRY_LINK(
   [ #include <hesiod.h> ],
-  [ char *c; hesiod_init(&c); ],
+  [ void *c; hesiod_init(&c); ],
   [ HAVE_HESIOD=1
     LIBHESIOD="$LIBHESIOD -lhesiod -lresolv"
     AC_MSG_RESULT(yes) ],
   [ AC_MSG_RESULT(no) ])
 
-# restore ldflags
-LDFLAGS="$af_check_hesiod_save_ldflags"
+# restore libs
+LIBS="$af_check_hesiod_save_libs"
 ])
 
 dnl --------------------------------------------------------------------------
Signature · 1 line
1.8.2.1
maintainer
#1 lore raw
Quoted 8 lines · Lan Yixun (dlan)

From: "Lan Yixun (dlan)" <[email protected]>

the problem here is that hesiod checking always fail due to wrong $(LDFLAGS), no matter hesiod library is installed or not. moving "-lhesiod" into $(LIBS) solve this problem.

1) convert "char *" -> "void *" to fix the compile warning
2) put "-lhesiod -lresolv" into $(LIBS), not into $(LDFLAGS), otherwise we got link error

Right, on the queue, will push to the repo next time I commit. Thanks
Ian

Quoted 58 lines

---
tst_hesiod.c: In function ‘main’:
tst_hesiod.c:38:3: warning: passing argument 1 of ‘hesiod_init’ from incompatible pointer type [enabled by default]

   char *c; hesiod_init(&c);
   ^

In file included from tst_hesiod.c:34:0:
/usr/include/hesiod.h:36:5: note: expected ‘void **’ but argument is of type ‘char **’
int hesiod_init(void **context);

$ x86_64-pc-linux-gnu-gcc -o conftest -O2 -pipe -march=core2  -I/usr/include
 -Wl,-O1 -Wl,--as-needed -g -lhesiod -lresolv tst_hesiod.c -L/usr/lib64
 -lkrb5 -lhx509 -lcom_err -lhcrypto -lasn1 -lwind -lheimbase -lroken
-lcrypt -ldl -lresolv

/tmp/ccN6GW0r.o: In function `main':
/root/tst_hesiod.c:38: undefined reference to `hesiod_init'
collect2: error: ld returned 1 exit status

---
 aclocal.m4 | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
aclocal.m4 +6 -6
index 7a8b03c..637a775 100644
@@ -316,20 +316,20 @@ dnl --------------------------------------------------------------------------
 AC_DEFUN([AF_CHECK_LIBHESIOD],
 [AC_MSG_CHECKING(for libhesiod)
 
-# save current ldflags
-af_check_hesiod_save_ldflags="$LDFLAGS"
-LDFLAGS="$LDFLAGS -lhesiod -lresolv"
+# save current libs
+af_check_hesiod_save_libs="$LIBS"
+LIBS="$LIBS -lhesiod -lresolv"
 
 AC_TRY_LINK(
   [ #include <hesiod.h> ],
-  [ char *c; hesiod_init(&c); ],
+  [ void *c; hesiod_init(&c); ],
   [ HAVE_HESIOD=1
     LIBHESIOD="$LIBHESIOD -lhesiod -lresolv"
     AC_MSG_RESULT(yes) ],
   [ AC_MSG_RESULT(no) ])
 
-# restore ldflags
-LDFLAGS="$af_check_hesiod_save_ldflags"
+# restore libs
+LIBS="$af_check_hesiod_save_libs"
 ])
 
 dnl --------------------------------------------------------------------------
#2 lore raw
Quoted 65 lines · Ian Kent
Quoted 8 lines · Lan Yixun (dlan)

From: "Lan Yixun (dlan)" <[email protected]>

the problem here is that hesiod checking always fail due to wrong $(LDFLAGS), no matter hesiod library is installed or not. moving "-lhesiod" into $(LIBS) solve this problem.

1) convert "char *" -> "void *" to fix the compile warning
2) put "-lhesiod -lresolv" into $(LIBS), not into $(LDFLAGS), otherwise we got link error

Right, on the queue, will push to the repo next time I commit. Thanks
Ian

Quoted 51 lines

---
tst_hesiod.c: In function ‘main’:
tst_hesiod.c:38:3: warning: passing argument 1 of ‘hesiod_init’ from incompatible pointer type [enabled by default]

   char *c; hesiod_init(&c);
   ^

In file included from tst_hesiod.c:34:0:
/usr/include/hesiod.h:36:5: note: expected ‘void **’ but argument is of type ‘char **’
int hesiod_init(void **context);

$ x86_64-pc-linux-gnu-gcc -o conftest -O2 -pipe -march=core2  -I/usr/include
 -Wl,-O1 -Wl,--as-needed -g -lhesiod -lresolv tst_hesiod.c -L/usr/lib64
 -lkrb5 -lhx509 -lcom_err -lhcrypto -lasn1 -lwind -lheimbase -lroken
-lcrypt -ldl -lresolv

/tmp/ccN6GW0r.o: In function `main':
/root/tst_hesiod.c:38: undefined reference to `hesiod_init'
collect2: error: ld returned 1 exit status

---
 aclocal.m4 | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
aclocal.m4 +4 -4
index 7a8b03c..637a775 100644
@@ -316,20 +316,20 @@ dnl --------------------------------------------------------------------------
 AC_DEFUN([AF_CHECK_LIBHESIOD],
 [AC_MSG_CHECKING(for libhesiod)
 
-# save current ldflags
-af_check_hesiod_save_ldflags="$LDFLAGS"
-LDFLAGS="$LDFLAGS -lhesiod -lresolv"
+# save current libs
+af_check_hesiod_save_libs="$LIBS"
+LIBS="$LIBS -lhesiod -lresolv"
 
 AC_TRY_LINK(
   [ #include <hesiod.h> ],
-  [ char *c; hesiod_init(&c); ],
+  [ void *c; hesiod_init(&c); ],
   [ HAVE_HESIOD=1
     LIBHESIOD="$LIBHESIOD -lhesiod -lresolv"
     AC_MSG_RESULT(yes) ],
   [ AC_MSG_RESULT(no) ])
 
Quoted 9 lines

aclocal.m4 dnl -------------------------------------------------------------------------- · line 335

Quoted 7 lines
aclocal.m4 +2 -2
-# restore ldflags
-LDFLAGS="$af_check_hesiod_save_ldflags"
+# restore libs
+LIBS="$af_check_hesiod_save_libs"
 ])
 
 dnl --------------------------------------------------------------------------

Hi Ian:
Great! Thanks.

Dennis Lan (dlan)