2 # Copyright (C) 2012-2013 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # Stress test on Objective C/C++.
20 am_create_testdir
=empty
23 ## Autotools Input Files.
25 cat > configure.ac
<< 'END'
26 AC_INIT
([play
], [1.3], [bug-automake@gnu.org
])
28 AC_CONFIG_SRCDIR
([play.c
])
29 AC_CONFIG_AUX_DIR
([build-aux
])
30 AC_CONFIG_MACRO_DIR
([m4])
42 AC_LANG_PUSH
([Objective C
])
44 [whether the Objective C compiler really works
],
46 [AC_LINK_IFELSE
([AC_LANG_PROGRAM
([[#import <stdio.h>]],
47 [[printf ("foo\n");]])],
48 [my_cv_objc_works
=yes],
49 [my_cv_objc_works
=no
])])
50 AC_LANG_POP
([Objective C
])
52 AC_LANG_PUSH
([Objective C
++])
54 [whether the Objective C
++ compiler really works
],
56 [AC_LINK_IFELSE
([AC_LANG_PROGRAM
([[#import <iostream>]],
57 [[std
::cout
<< "foo" << "\n";]])],
58 [my_cv_objcxx_works
=yes],
59 [my_cv_objcxx_works
=no
])])
60 AC_LANG_POP
([Objective C
++])
62 if test $my_cv_objc_works != yes; then
63 AC_MSG_ERROR
([couldn
't find a working Objective C compiler], [77])
66 if test $my_cv_objcxx_works != yes; then
67 AC_MSG_ERROR([couldn't
find a working Objective C
++ compiler
], [77])
70 AC_CONFIG_HEADERS
([config.h
])
71 AC_CONFIG_FILES
([Makefile
])
76 cat > Makefile.am
<< 'END'
78 play_SOURCES
= play.h play.c playxx.cxx playo.m playoxx.mm
79 play_LDADD
= libfoo.la
81 lib_LTLIBRARIES
= libfoo.la
82 libfoo_la_SOURCES
= foo.h foo.c fooxx.cxx fooo.m foooxx.mm
91 $AUTOMAKE --add-missing
105 void hello_cxx
(void
);
106 void hello_objc
(void
);
107 void hello_objcxx
(void
);
110 @interface Hello_ObjC
114 #endif /* __OBJC__ */
123 virtual ~Hello_CXX
() { }
128 @interface Hello_ObjCXX
137 virtual ~Hello_OBJCXX
() { }
140 #endif /* __OBJC__ */
142 #endif /* __cplusplus */
147 cat > play.c
<< 'END'
151 printf ("[Hello C,");
160 cat > playxx.cxx
<< 'END'
165 Hello_CXX
*hello
= new Hello_CXX
;
169 void Hello_CXX
::hello_cxx
()
171 std
::cout
<< "[Hello C++,";
172 World_CXX
*world
= new World_CXX
;
177 cat > playo.m
<< 'END'
180 void hello_objc
(void
)
182 [Hello_ObjC display
];
185 @implementation Hello_ObjC
188 printf ("[Hello ObjC,");
189 [World_ObjC display
];
194 cat > playoxx.mm
<< 'END'
197 // Calling
: C
-> C
++ -> ObjC
199 void hello_objcxx
(void
)
201 Hello_OBJCXX
*hello
= new Hello_OBJCXX
;
202 hello-
>hello_objcxx
();
205 void Hello_OBJCXX
::hello_objcxx
()
207 [Hello_ObjCXX display
];
210 @implementation Hello_ObjCXX
213 std
::cout
<< "[Hello ObjC++,";
214 [World_ObjCXX display
];
235 @interface World_ObjC
239 #endif /* __OBJC__ */
248 virtual ~World_CXX
() { }
257 virtual ~World_OBJCXX
() { }
258 void world_objcxx
();
261 @interface World_ObjCXX
265 #endif /* __OBJC__ */
267 #endif /* __cplusplus */
277 printf (" world C]\n");
281 cat > fooxx.cxx
<< 'END'
284 void World_CXX
::world_cxx
()
286 std
::cout
<< " world C++]" << "\n";
290 cat > fooo.m
<< 'END'
293 @implementation World_ObjC
296 printf (" world ObjC]\n");
301 cat > foooxx.mm
<< 'END'
304 // Calling
: ObjC
-> C
++
306 @implementation World_ObjCXX
309 World_OBJCXX
*world
= new World_OBJCXX
;
310 world-
>world_objcxx
();
314 void World_OBJCXX
::world_objcxx
()
316 std
::cout
<< " world ObjC++]" << "\n";
320 ## Configure and build.
325 if ! cross_compiling
; then
326 unindent
> exp
<< 'END'
328 [Hello C
++, world C
++]
329 [Hello ObjC
, world ObjC
]
330 [Hello ObjC
++, world ObjC
++]
332 .
/play
> got ||
{ cat got
; exit 1; }