| Arnaldo Carvalho de Melo | f9af3a4 | 2010-06-09 16:57:39 -0300 | [diff] [blame] | 1 | define SOURCE_HELLO | 
|  | 2 | #include <stdio.h> | 
|  | 3 | int main(void) | 
|  | 4 | { | 
|  | 5 | return puts(\"hi\"); | 
|  | 6 | } | 
|  | 7 | endef | 
|  | 8 |  | 
|  | 9 | ifndef NO_DWARF | 
|  | 10 | define SOURCE_DWARF | 
|  | 11 | #include <dwarf.h> | 
|  | 12 | #include <libdw.h> | 
|  | 13 | #include <version.h> | 
|  | 14 | #ifndef _ELFUTILS_PREREQ | 
|  | 15 | #error | 
|  | 16 | #endif | 
|  | 17 |  | 
|  | 18 | int main(void) | 
|  | 19 | { | 
|  | 20 | Dwarf *dbg = dwarf_begin(0, DWARF_C_READ); | 
|  | 21 | return (long)dbg; | 
|  | 22 | } | 
|  | 23 | endef | 
|  | 24 | endif | 
|  | 25 |  | 
|  | 26 | define SOURCE_LIBELF | 
|  | 27 | #include <libelf.h> | 
|  | 28 |  | 
|  | 29 | int main(void) | 
|  | 30 | { | 
|  | 31 | Elf *elf = elf_begin(0, ELF_C_READ, 0); | 
|  | 32 | return (long)elf; | 
|  | 33 | } | 
|  | 34 | endef | 
|  | 35 |  | 
|  | 36 | define SOURCE_GLIBC | 
|  | 37 | #include <gnu/libc-version.h> | 
|  | 38 |  | 
|  | 39 | int main(void) | 
|  | 40 | { | 
|  | 41 | const char *version = gnu_get_libc_version(); | 
|  | 42 | return (long)version; | 
|  | 43 | } | 
|  | 44 | endef | 
|  | 45 |  | 
|  | 46 | define SOURCE_ELF_MMAP | 
|  | 47 | #include <libelf.h> | 
|  | 48 | int main(void) | 
|  | 49 | { | 
|  | 50 | Elf *elf = elf_begin(0, ELF_C_READ_MMAP, 0); | 
|  | 51 | return (long)elf; | 
|  | 52 | } | 
|  | 53 | endef | 
|  | 54 |  | 
|  | 55 | ifndef NO_NEWT | 
|  | 56 | define SOURCE_NEWT | 
|  | 57 | #include <newt.h> | 
|  | 58 |  | 
|  | 59 | int main(void) | 
|  | 60 | { | 
|  | 61 | newtInit(); | 
|  | 62 | newtCls(); | 
|  | 63 | return newtFinished(); | 
|  | 64 | } | 
|  | 65 | endef | 
|  | 66 | endif | 
|  | 67 |  | 
|  | 68 | ifndef NO_LIBPERL | 
|  | 69 | define SOURCE_PERL_EMBED | 
|  | 70 | #include <EXTERN.h> | 
|  | 71 | #include <perl.h> | 
|  | 72 |  | 
|  | 73 | int main(void) | 
|  | 74 | { | 
|  | 75 | perl_alloc(); | 
|  | 76 | return 0; | 
|  | 77 | } | 
|  | 78 | endef | 
|  | 79 | endif | 
|  | 80 |  | 
|  | 81 | ifndef NO_LIBPYTHON | 
|  | 82 | define SOURCE_PYTHON_EMBED | 
|  | 83 | #include <Python.h> | 
|  | 84 |  | 
|  | 85 | int main(void) | 
|  | 86 | { | 
|  | 87 | Py_Initialize(); | 
|  | 88 | return 0; | 
|  | 89 | } | 
|  | 90 | endef | 
|  | 91 | endif | 
|  | 92 |  | 
|  | 93 | define SOURCE_BFD | 
|  | 94 | #include <bfd.h> | 
|  | 95 |  | 
|  | 96 | int main(void) | 
|  | 97 | { | 
|  | 98 | bfd_demangle(0, 0, 0); | 
|  | 99 | return 0; | 
|  | 100 | } | 
|  | 101 | endef | 
|  | 102 |  | 
|  | 103 | define SOURCE_CPLUS_DEMANGLE | 
|  | 104 | extern char *cplus_demangle(const char *, int); | 
|  | 105 |  | 
|  | 106 | int main(void) | 
|  | 107 | { | 
|  | 108 | cplus_demangle(0, 0); | 
|  | 109 | return 0; | 
|  | 110 | } | 
|  | 111 | endef | 
|  | 112 |  | 
|  | 113 | # try-cc | 
|  | 114 | # Usage: option = $(call try-cc, source-to-build, cc-options) | 
|  | 115 | try-cc = $(shell sh -c						  \ | 
| Kusanagi Kouichi | ecafda6 | 2010-08-18 13:32:37 -0300 | [diff] [blame] | 116 | 'TMP="$(OUTPUT)$(TMPOUT).$$$$";				  \ | 
| Arnaldo Carvalho de Melo | f9af3a4 | 2010-06-09 16:57:39 -0300 | [diff] [blame] | 117 | echo "$(1)" |						  \ | 
|  | 118 | $(CC) -x c - $(2) -o "$$TMP" > /dev/null 2>&1 && echo y; \ | 
|  | 119 | rm -f "$$TMP"') |