Making msktutil compile

Checking the ./configure failure in config.log, we see that it creates a small program conftest.cpp:


extern "C" {
#include <com_err.h>
 
int main(void) {
  error_message(0);
}
}

      

... and it fails to compile with the command g++ -o conftest -g -O2 conftest.cpp -lkrb5.

But the following does work:

jurjen@lwp05:~/packaging/msktutil/msktutil-0.4$ g++ -o conftest -g -O2   conftest.cpp -lkrb5 -lcom_err

, the solution being that conftest should've been linked against libcomerr. That can be fixed by patching configure.in with this patch:

	
--- a/configure.in
+++ b/configure.in
@@ -104,19 +104,20 @@
 # Checks for libraries.
 AC_CHECK_LIB([krb5], [krb5_init_context], , [AC_MSG_ERROR([libkrb5 not found])])
 AC_CHECK_LIB([ldap], [ldap_initialize], , [AC_MSG_ERROR([libldap not found])])
+AC_CHECK_LIB([com_err], [error_message], , [AC_MSG_ERROR([libcom_err not found])])
 
 if test "$ac_cv_header_com_err_h"; then
 AC_MSG_CHECKING([whether com_err.h needs extern "C"]);
 
-AC_LINK_IFELSE([[
+AC_LINK_IFELSE([AC_LANG_SOURCE([
 #include <com_err.h>
 
 int main(void) {
     error_message(0);
 }
-]], [AC_MSG_RESULT(no); com_err_needs_extern_c=no], [
+])], [AC_MSG_RESULT(no); com_err_needs_extern_c=no], [
 
-AC_LINK_IFELSE([[
+AC_LINK_IFELSE([AC_LANG_SOURCE([
 extern "C" {
 #include <com_err.h>
 }
@@ -124,7 +125,7 @@
 int main(void) {
     error_message(0);
 }
-]], [AC_MSG_RESULT(yes); com_err_needs_extern_c=yes], [AC_MSG_ERROR([Couldn't get error_message to work.])])])
+])], [AC_MSG_RESULT(yes); com_err_needs_extern_c=yes], [AC_MSG_ERROR([Couldn't get error_message to work.])])])
 
 if test "$com_err_needs_extern_c=yes"; then
   AC_DEFINE(COM_ERR_NEEDS_EXTERN_C, 1, [Does com_err.h need extern "C" around it?])

      

After that, ./configure runs, but make still fails with undefined references. That is because the link order is wrong in Makefile.in, which can be fixed with the following patch:

	
--- a/Makefile.in
+++ b/Makefile.in
@@ -26,7 +26,7 @@
 
 $(PROG) : $(objects)
        @$(ECHO) "Assembling $(PROG)"
-       $(CXX) $(LDFLAGS) $(LIBS) $(objects) -o $(PROG)
+       $(CXX) $(LDFLAGS) $(objects) $(LIBS) -o $(PROG)
 
 %.o : %.cpp msktutil.h krb5wrap.h config.h
        @$(ECHO) "Compiling $<"

      

... and then still the right libraries need to be linked against, which we fix rather ad-hoc, in Makefile.in as well:

	
--- a/Makefile.in
+++ b/Makefile.in
@@ -8,7 +8,8 @@
 CPPFLAGS=@CPPFLAGS@
 CXXFLAGS=@CXXFLAGS@ $(WARNFLAGS)
 LDFLAGS=@LDFLAGS@
-LIBS=@LIBS@
+#LIBS=@LIBS@
+LIBS=-l krb5 -lldap -lcom_err
 INSTALL=@INSTALL@
 RM=@RM@ -rf
 CP=@CP@ -f

      

With the build phase thus fixed, a rather standard debian/rules can be used[1]:

#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

# Uncomment this to turn on verbose mode.
# export DH_VERBOSE=1

%:
        dh $@ 

override_dh_auto_configure:
        autoconf
        dh_auto_configure

override_dh_installman:
        dh_installman msktutil.M

      

... and the package will build.

The package is now free of Lintian errors, and it will mount an NFS3 share from a Windows 2008 R2 server with Kerberos authentication.



[1] The debian/rules that came with the tarball IMHO took too many tasks away from the Makefile.