From: Ken Raeburn Date: Mon, 29 Oct 2007 22:00:53 +0000 (+0000) Subject: Test that C++ code can use our installed headers X-Git-Tag: krb5-1.7-alpha1~792 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=6ced4e0fa11dc0e2752ad03f8264a531470495b4;p=krb5.git Test that C++ code can use our installed headers git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20149 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/config/pre.in b/src/config/pre.in index 023e84675..074785303 100644 --- a/src/config/pre.in +++ b/src/config/pre.in @@ -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 # diff --git a/src/configure.in b/src/configure.in index d010d0388..f1f415e20 100644 --- a/src/configure.in +++ b/src/configure.in @@ -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 diff --git a/src/tests/misc/Makefile.in b/src/tests/misc/Makefile.in index 0dc4260eb..a6fa1a4aa 100644 --- a/src/tests/misc/Makefile.in +++ b/src/tests/misc/Makefile.in @@ -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 index 000000000..6602c8393 --- /dev/null +++ b/src/tests/misc/test_cxx_gss.cpp @@ -0,0 +1,10 @@ +// Test that the krb5.h header is compatible with C++ application code. + +#include +#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 index 000000000..906c21d83 --- /dev/null +++ b/src/tests/misc/test_cxx_krb5.cpp @@ -0,0 +1,16 @@ +// Test that the krb5.h header is compatible with C++ application code. + +#include +#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; +}