Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame^] | 1 | def glibc_cfg(feature, tokens, cnf): |
| 2 | if type(tokens) == type(""): |
| 3 | tokens = [tokens] |
| 4 | if feature: |
| 5 | cnf.extend([token + '=y' for token in tokens]) |
| 6 | else: |
| 7 | for token in tokens: |
| 8 | cnf.extend([token + '=n']) |
| 9 | if token == 'OPTION_EGLIBC_NSSWITCH': |
| 10 | cnf.extend(["OPTION_EGLIBC_NSSWITCH_FIXED_CONFIG=\"${S}/nss/nsswitch.conf\""]) |
| 11 | cnf.extend(["OPTION_EGLIBC_NSSWITCH_FIXED_FUNCTIONS=\"${S}/nss/fixed-nsswitch.functions\""]) |
| 12 | |
| 13 | # Map distro features to glibc options settings |
| 14 | def features_to_glibc_settings(d): |
| 15 | cnf = ([]) |
| 16 | |
| 17 | ipv4 = bb.utils.contains('DISTRO_FEATURES', 'ipv4', True, False, d) |
| 18 | ipv6 = bb.utils.contains('DISTRO_FEATURES', 'ipv6', True, False, d) |
| 19 | libc_backtrace = bb.utils.contains('DISTRO_FEATURES', 'libc-backtrace', True, False, d) |
| 20 | libc_big_macros = bb.utils.contains('DISTRO_FEATURES', 'libc-big-macros', True, False, d) |
| 21 | libc_bsd = bb.utils.contains('DISTRO_FEATURES', 'libc-bsd', True, False, d) |
| 22 | libc_cxx_tests = bb.utils.contains('DISTRO_FEATURES', 'libc-cxx-tests', True, False, d) |
| 23 | libc_catgets = bb.utils.contains('DISTRO_FEATURES', 'libc-catgets', True, False, d) |
| 24 | libc_charsets = bb.utils.contains('DISTRO_FEATURES', 'libc-charsets', True, False, d) |
| 25 | libc_crypt = bb.utils.contains('DISTRO_FEATURES', 'libc-crypt', True, False, d) |
| 26 | libc_crypt_ufc = bb.utils.contains('DISTRO_FEATURES', 'libc-crypt-ufc', True, False, d) |
| 27 | libc_db_aliases = bb.utils.contains('DISTRO_FEATURES', 'libc-db-aliases', True, False, d) |
| 28 | libc_envz = bb.utils.contains('DISTRO_FEATURES', 'libc-envz', True, False, d) |
| 29 | libc_fcvt = bb.utils.contains('DISTRO_FEATURES', 'libc-fcvt', True, False, d) |
| 30 | libc_fmtmsg = bb.utils.contains('DISTRO_FEATURES', 'libc-fmtmsg', True, False, d) |
| 31 | libc_fstab = bb.utils.contains('DISTRO_FEATURES', 'libc-fstab', True, False, d) |
| 32 | libc_ftraverse = bb.utils.contains('DISTRO_FEATURES', 'libc-ftraverse', True, False, d) |
| 33 | libc_getlogin = bb.utils.contains('DISTRO_FEATURES', 'libc-getlogin', True, False, d) |
| 34 | libc_idn = bb.utils.contains('DISTRO_FEATURES', 'libc-idn', True, False, d) |
| 35 | libc_inet_anl = bb.utils.contains('DISTRO_FEATURES', 'libc-inet-anl', True, False, d) |
| 36 | libc_libm = bb.utils.contains('DISTRO_FEATURES', 'libc-libm', True, False, d) |
| 37 | libc_locales = bb.utils.contains('DISTRO_FEATURES', 'libc-locales', True, False, d) |
| 38 | libc_locale_code = bb.utils.contains('DISTRO_FEATURES', 'libc-locale-code', True, False, d) |
| 39 | libc_memusage = bb.utils.contains('DISTRO_FEATURES', 'libc-memusage', True, False, d) |
| 40 | libc_nis = bb.utils.contains('DISTRO_FEATURES', 'libc-nis', True, False, d) |
| 41 | libc_nsswitch = bb.utils.contains('DISTRO_FEATURES', 'libc-nsswitch', True, False, d) |
| 42 | libc_rcmd = bb.utils.contains('DISTRO_FEATURES', 'libc-rcmd', True, False, d) |
| 43 | libc_rtld_debug = bb.utils.contains('DISTRO_FEATURES', 'libc-rtld-debug', True, False, d) |
| 44 | libc_spawn = bb.utils.contains('DISTRO_FEATURES', 'libc-spawn', True, False, d) |
| 45 | libc_streams = bb.utils.contains('DISTRO_FEATURES', 'libc-streams', True, False, d) |
| 46 | libc_sunrpc = bb.utils.contains('DISTRO_FEATURES', 'libc-sunrpc', True, False, d) |
| 47 | libc_utmp = bb.utils.contains('DISTRO_FEATURES', 'libc-utmp', True, False, d) |
| 48 | libc_utmpx = bb.utils.contains('DISTRO_FEATURES', 'libc-utmpx', True, False, d) |
| 49 | libc_wordexp = bb.utils.contains('DISTRO_FEATURES', 'libc-wordexp', True, False, d) |
| 50 | libc_posix_clang_wchar = bb.utils.contains('DISTRO_FEATURES', 'libc-posix-clang-wchar', True, False, d) |
| 51 | libc_posix_regexp = bb.utils.contains('DISTRO_FEATURES', 'libc-posix-regexp', True, False, d) |
| 52 | libc_posix_regexp_glibc = bb.utils.contains('DISTRO_FEATURES', 'libc-posix-regexp-glibc', True, False, d) |
| 53 | libc_posix_wchar_io = bb.utils.contains('DISTRO_FEATURES', 'libc-posix-wchar-io', True, False, d) |
| 54 | |
| 55 | # arrange the dependencies among glibc configuable options according to file option-groups.def from glibc source code |
| 56 | new_dep = True |
| 57 | while new_dep: |
| 58 | new_dep = False |
| 59 | |
| 60 | if ipv6 and not ipv4: |
| 61 | new_dep = True |
| 62 | ipv4 = True |
| 63 | |
| 64 | if ipv4 and not libc_nsswitch: |
| 65 | new_dep = True |
| 66 | libc_nsswitch = True |
| 67 | |
| 68 | if libc_cxx_tests: |
| 69 | if not libc_posix_wchar_io: |
| 70 | new_dep = True |
| 71 | libc_posix_wchar_io = True |
| 72 | if not libc_libm: |
| 73 | new_dep = True |
| 74 | libc_libm = True |
| 75 | |
| 76 | if libc_catgets and not libc_locale_code: |
| 77 | new_dep = True |
| 78 | libc_locale_code = True |
| 79 | |
| 80 | if libc_crypt_ufc and not libc_crypt: |
| 81 | new_dep = True |
| 82 | libc_crypt = True |
| 83 | |
| 84 | if libc_getlogin and not libc_utmp: |
| 85 | new_dep = True |
| 86 | libc_utmp = True |
| 87 | |
| 88 | if libc_inet_anl and not ipv4: |
| 89 | new_dep = True |
| 90 | ipv4 = True |
| 91 | |
| 92 | if libc_locale_code and not libc_posix_clang_wchar: |
| 93 | new_dep = True |
| 94 | libc_posix_clang_wchar = True |
| 95 | |
| 96 | if libc_nis: |
| 97 | if not ipv4: |
| 98 | new_dep = True |
| 99 | ipv4 = True |
| 100 | if not libc_sunrpc: |
| 101 | new_dep = True |
| 102 | libc_sunrpc = True |
| 103 | |
| 104 | if libc_rcmd and not ipv4: |
| 105 | new_dep = True |
| 106 | ipv4 = True |
| 107 | |
| 108 | if libc_sunrpc and not ipv4: |
| 109 | new_dep = True |
| 110 | ipv4 = True |
| 111 | |
| 112 | if libc_utmpx and not libc_utmp: |
| 113 | new_dep = True |
| 114 | libc_utmp = True |
| 115 | |
| 116 | if libc_posix_regexp_glibc and not libc_posix_regexp: |
| 117 | new_dep = True |
| 118 | libc_posix_regexp = True |
| 119 | |
| 120 | if libc_posix_wchar_io and not libc_posix_clang_wchar: |
| 121 | new_dep = True |
| 122 | libc_posix_clang_wchar = True |
| 123 | |
| 124 | glibc_cfg(ipv6, 'OPTION_EGLIBC_ADVANCED_INET6', cnf) |
| 125 | glibc_cfg(libc_backtrace, 'OPTION_EGLIBC_BACKTRACE', cnf) |
| 126 | glibc_cfg(libc_big_macros, 'OPTION_EGLIBC_BIG_MACROS', cnf) |
| 127 | glibc_cfg(libc_bsd, 'OPTION_EGLIBC_BSD', cnf) |
| 128 | glibc_cfg(libc_cxx_tests, 'OPTION_EGLIBC_CXX_TESTS', cnf) |
| 129 | glibc_cfg(libc_catgets, 'OPTION_EGLIBC_CATGETS', cnf) |
| 130 | glibc_cfg(libc_charsets, 'OPTION_EGLIBC_CHARSETS', cnf) |
| 131 | glibc_cfg(libc_crypt, 'OPTION_EGLIBC_CRYPT', cnf) |
| 132 | glibc_cfg(libc_crypt_ufc, 'OPTION_EGLIBC_CRYPT_UFC', cnf) |
| 133 | glibc_cfg(libc_db_aliases, 'OPTION_EGLIBC_DB_ALIASES', cnf) |
| 134 | glibc_cfg(libc_envz, 'OPTION_EGLIBC_ENVZ', cnf) |
| 135 | glibc_cfg(libc_fcvt, 'OPTION_EGLIBC_FCVT', cnf) |
| 136 | glibc_cfg(libc_fmtmsg, 'OPTION_EGLIBC_FMTMSG', cnf) |
| 137 | glibc_cfg(libc_fstab, 'OPTION_EGLIBC_FSTAB', cnf) |
| 138 | glibc_cfg(libc_ftraverse, 'OPTION_EGLIBC_FTRAVERSE', cnf) |
| 139 | glibc_cfg(libc_getlogin, 'OPTION_EGLIBC_GETLOGIN', cnf) |
| 140 | glibc_cfg(libc_idn, 'OPTION_EGLIBC_IDN', cnf) |
| 141 | glibc_cfg(ipv4, 'OPTION_EGLIBC_INET', cnf) |
| 142 | glibc_cfg(libc_inet_anl, 'OPTION_EGLIBC_INET_ANL', cnf) |
| 143 | glibc_cfg(libc_libm, 'OPTION_EGLIBC_LIBM', cnf) |
| 144 | glibc_cfg(libc_locales, 'OPTION_EGLIBC_LOCALES', cnf) |
| 145 | glibc_cfg(libc_locale_code, 'OPTION_EGLIBC_LOCALE_CODE', cnf) |
| 146 | glibc_cfg(libc_memusage, 'OPTION_EGLIBC_MEMUSAGE', cnf) |
| 147 | glibc_cfg(libc_nis, 'OPTION_EGLIBC_NIS', cnf) |
| 148 | glibc_cfg(libc_nsswitch, 'OPTION_EGLIBC_NSSWITCH', cnf) |
| 149 | glibc_cfg(libc_rcmd, 'OPTION_EGLIBC_RCMD', cnf) |
| 150 | glibc_cfg(libc_rtld_debug, 'OPTION_EGLIBC_RTLD_DEBUG', cnf) |
| 151 | glibc_cfg(libc_spawn, 'OPTION_EGLIBC_SPAWN', cnf) |
| 152 | glibc_cfg(libc_streams, 'OPTION_EGLIBC_STREAMS', cnf) |
| 153 | glibc_cfg(libc_sunrpc, 'OPTION_EGLIBC_SUNRPC', cnf) |
| 154 | glibc_cfg(libc_utmp, 'OPTION_EGLIBC_UTMP', cnf) |
| 155 | glibc_cfg(libc_utmpx, 'OPTION_EGLIBC_UTMPX', cnf) |
| 156 | glibc_cfg(libc_wordexp, 'OPTION_EGLIBC_WORDEXP', cnf) |
| 157 | glibc_cfg(libc_posix_clang_wchar, 'OPTION_POSIX_C_LANG_WIDE_CHAR', cnf) |
| 158 | glibc_cfg(libc_posix_regexp, 'OPTION_POSIX_REGEXP', cnf) |
| 159 | glibc_cfg(libc_posix_regexp_glibc, 'OPTION_POSIX_REGEXP_GLIBC', cnf) |
| 160 | glibc_cfg(libc_posix_wchar_io, 'OPTION_POSIX_WIDE_CHAR_DEVICE_IO', cnf) |
| 161 | |
| 162 | return "\n".join(cnf) |