Add the possibility to search headers in several subdirectories of /usr/local/include and /usr/include. A possible use case would be for tcc to search for headers in /usr/local/include/x86_64-linux-gnu, /usr/local/include, /usr/include/x86_64-linux-gnu and /usr/include in turn.
Unified · Split
| @@ -1328,8 +1328,23 @@ LIBTCCAPI int tcc_set_output_type(TCCState *s, int output_type) · 1327 unmodified lines | ||
| 1328 | 1328 | /* default include paths */ |
| 1329 | 1329 | /* -isystem paths have already been handled */ |
| 1330 | 1330 | #ifndef TCC_TARGET_PE |
| 1331 | − tcc_add_sysinclude_path(s, CONFIG_SYSROOT "/usr/local/include"); | |
| 1332 | − tcc_add_sysinclude_path(s, CONFIG_SYSROOT "/usr/include"); | |
| 1331 | + { | |
| 1332 | + int i, nb_extra_incdirs, nb_prefixs; | |
| 1333 | + char **extra_incdirs; | |
| 1334 | + const char incdir_prefix1[] = CONFIG_SYSROOT "/usr/local/include"; | |
| 1335 | + const char incdir_prefix2[] = CONFIG_SYSROOT "/usr/include"; | |
| 1336 | + const char * const incdir_prefixs[] = {incdir_prefix1, | |
| 1337 | + incdir_prefix2}; | |
| 1338 | + | |
| 1339 | + nb_prefixs = sizeof incdir_prefixs / sizeof *incdir_prefixs; | |
| 1340 | + nb_extra_incdirs = tcc_split_path_components(CONFIG_TCC_INCSUBDIR, | |
| 1341 | + incdir_prefixs, | |
| 1342 | + nb_prefixs, | |
| 1343 | + &extra_incdirs); | |
| 1344 | + for (i = 0; i < nb_extra_incdirs; i++) | |
| 1345 | + tcc_add_sysinclude_path(s, extra_incdirs[i]); | |
| 1346 | + dynarray_reset(&extra_incdirs, &nb_extra_incdirs); | |
| 1347 | + } | |
| 1333 | 1348 | #endif |
| 1334 | 1349 | snprintf(buf, sizeof(buf), "%s/include", s->tcc_lib_path); |
| 1335 | 1350 | tcc_add_sysinclude_path(s, buf); |
| @@ -150,6 +150,9 @@ typedef int BOOL; · 149 unmodified lines | ||
| 150 | 150 | #endif |
| 151 | 151 | #endif |
| 152 | 152 | #define CONFIG_TCC_CRT_PREFIX CONFIG_SYSROOT "/usr" CONFIG_TCC_LDDIR |
| 153 | +#ifndef CONFIG_TCC_INCSUBDIR | |
| 154 | + #define CONFIG_TCC_INCSUBDIR "" | |
| 155 | +#endif | |
| 153 | 156 | |
| 154 | 157 | #define INCLUDE_STACK_SIZE 32 |
| 155 | 158 | #define IFDEF_STACK_SIZE 64 |