Test that C++ code can use our installed headers
authorKen Raeburn <raeburn@mit.edu>
Mon, 29 Oct 2007 22:00:53 +0000 (22:00 +0000)
committerKen Raeburn <raeburn@mit.edu>
Mon, 29 Oct 2007 22:00:53 +0000 (22:00 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20149 dc483132-0cff-0310-8789-dd5450dbe970

src/config/pre.in
src/configure.in
src/tests/misc/Makefile.in
src/tests/misc/test_cxx_gss.cpp [new file with mode: 0644]
src/tests/misc/test_cxx_krb5.cpp [new file with mode: 0644]

index 023e846751e8332a0bf78dcfd2e54179b4b12ff7..07478530369b3553cf4aa8914a9bc7d82539707c 100644 (file)
@@ -160,14 +160,19 @@ FAKELIBDIR=$(FAKEPREFIX)/lib
 ALL_CFLAGS = $(DEFS) $(DEFINES) $(KRB_INCLUDES) $(LOCALINCLUDES) \
        -DKRB5_DEPRECATED=1 \
        $(CPPFLAGS) $(CFLAGS) $(PTHREAD_CFLAGS)
+ALL_CXXFLAGS = $(DEFS) $(DEFINES) $(KRB_INCLUDES) $(LOCALINCLUDES) \
+       -DKRB5_DEPRECATED=1 \
+       $(CPPFLAGS) $(CXXFLAGS) $(PTHREAD_CFLAGS)
 
 CFLAGS = @CFLAGS@
+CXXFLAGS = @CXXFLAGS@
 PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
 PTHREAD_LIBS = @PTHREAD_LIBS@
 THREAD_LINKOPTS = $(PTHREAD_CFLAGS) $(PTHREAD_LIBS)
 CPPFLAGS = @CPPFLAGS@
 DEFS = @DEFS@
 CC = @CC@
+CXX = @CXX@
 LD = $(PURE) @LD@
 DEPLIBS = @DEPLIBS@
 KRB_INCLUDES = -I$(BUILDTOP)/include -I$(SRCTOP)/include
@@ -457,9 +462,14 @@ COMPILE_ET-k5= $(BUILDTOP)/util/et/compile_et -d $(SRCTOP)/util/et
 
 # rule to make object files
 #
-.SUFFIXES: .c .o
+.SUFFIXES: .cpp .c .o
 .c.o:
        $(CC) $(ALL_CFLAGS) -c $<
+# Use .cpp because that's what autoconf uses in its test.
+# If the compiler doesn't accept a .cpp suffix here, it wouldn't
+# have accepted it when autoconf tested it.
+.cpp.o:
+       $(CXX) $(ALL_CXXFLAGS) -c $<
 
 # ss command table rules
 #
index d010d03883cdf83fdd5216fe76639091354a8406..f1f415e20521d009f2f3c817d30bcebeb0188883 100644 (file)
@@ -1057,6 +1057,8 @@ AC_SUBST(ldap_plugin_dir)
 
 AC_CHECK_HEADERS(Python.h python2.3/Python.h)
 
+AC_PROG_CXX
+
 dnl
 dnl Kludge for simple server --- FIXME is this the best way to do this?
 dnl
index 0dc4260ebc9ba50105230b77ebdd49462656e51a..a6fa1a4aa1f6e5ff2481be26e573c024d9be9e7d 100644 (file)
@@ -11,8 +11,10 @@ SRCS=$(srcdir)/test_getpw.c
 
 all:: test_getpw
 
-check:: test_getpw
+check:: test_getpw test_cxx_krb5 test_cxx_gss
        $(RUN_SETUP) $(VALGRIND) ./test_getpw
+       $(RUN_SETUP) $(VALGRIND) ./test_cxx_krb5
+       $(RUN_SETUP) $(VALGRIND) ./test_cxx_gss
 
 test_getpw: $(OUTPRE)test_getpw.$(OBJEXT) $(SUPPORT_DEPLIB)
        $(CC_LINK) $(ALL_CFLAGS) -o test_getpw $(OUTPRE)test_getpw.$(OBJEXT) $(SUPPORT_LIB)
@@ -20,10 +22,20 @@ test_getpw: $(OUTPRE)test_getpw.$(OBJEXT) $(SUPPORT_DEPLIB)
 test_getsockname: $(OUTPRE)test_getsockname.$(OBJEXT)
        $(CC_LINK) $(ALL_CFLAGS) -o test_getsockname $(OUTPRE)test_getsockname.$(OBJEXT) $(LIBS)
 
+CXX_LINK=$(CC_LINK) # hack!
+test_cxx_krb5 test_cxx_gss: CC=$(CXX)
+test_cxx_krb5: $(OUTPRE)test_cxx_krb5.$(OBJEXT) $(KRB5_DEPLIB)
+       $(CXX_LINK) $(ALL_CXXFLAGS) -o test_cxx_krb5 $(OUTPRE)test_cxx_krb5.$(OBJEXT) $(KRB5_LIB) $(LIBS)
+test_cxx_gss: $(OUTPRE)test_cxx_gss.$(OBJEXT)
+       $(CXX_LINK) $(ALL_CXXFLAGS) -o test_cxx_gss $(OUTPRE)test_cxx_gss.$(OBJEXT) $(LIBS)
+
+test_cxx_krb5.$(OBJEXT): test_cxx_krb5.cpp
+test_cxx_gss.$(OBJEXT): test_cxx_gss.cpp
+
 install::
 
 clean::
-       $(RM) test_getpw
+       $(RM) test_getpw test_cxx_krb5 test_cxx_gss *.o
 
 # +++ Dependency line eater +++
 # 
diff --git a/src/tests/misc/test_cxx_gss.cpp b/src/tests/misc/test_cxx_gss.cpp
new file mode 100644 (file)
index 0000000..6602c83
--- /dev/null
@@ -0,0 +1,10 @@
+// Test that the krb5.h header is compatible with C++ application code.
+
+#include <stdio.h>
+#include "gssapi/gssapi.h"
+
+int main ()
+{
+    printf("hello, world\n");
+    return 0;
+}
diff --git a/src/tests/misc/test_cxx_krb5.cpp b/src/tests/misc/test_cxx_krb5.cpp
new file mode 100644 (file)
index 0000000..906c21d
--- /dev/null
@@ -0,0 +1,16 @@
+// Test that the krb5.h header is compatible with C++ application code.
+
+#include <stdio.h>
+#include "krb5.h"
+
+int main (int argc, char *argv[])
+{
+    krb5_context ctx;
+
+    if (krb5_init_context(&ctx) != 0) {
+       printf("krb5_init_context returned an error\n");
+       return 1;
+    }
+    printf("hello, world\n");
+    return 0;
+}