From 0ad857c80e174ddcaa8a8ecf6ab6d2cc14e1d84c Mon Sep 17 00:00:00 2001 From: Andrew Aladjev Date: Tue, 19 Feb 2013 14:47:36 +0300 Subject: [PATCH] added CPATH, C_INCLUDE_PATH and LD_LIBRARY_PATH --- libtcc.c | 18 ++++++++++++++++++ tcc.c | 1 + tcc.h | 2 ++ 3 files changed, 21 insertions(+) diff --git a/libtcc.c b/libtcc.c index 7fc9827d..25d004c4 100644 --- a/libtcc.c +++ b/libtcc.c @@ -1941,3 +1941,21 @@ PUB_FUNC void tcc_print_stats(TCCState *s, int64_t total_time) tt, (int)(total_lines / tt), total_bytes / tt / 1000000.0); } + +PUB_FUNC void tcc_set_environment(TCCState *s) +{ + char * path; + + path = getenv("C_INCLUDE_PATH"); + if(path != NULL) { + tcc_add_include_path(s, path); + } + path = getenv("CPATH"); + if(path != NULL) { + tcc_add_include_path(s, path); + } + path = getenv("LD_LIBRARY_PATH"); + if(path != NULL) { + tcc_add_library_path(s, path); + } +} \ No newline at end of file diff --git a/tcc.c b/tcc.c index cd306b0d..52638efc 100644 --- a/tcc.c +++ b/tcc.c @@ -252,6 +252,7 @@ int main(int argc, char **argv) s->output_type = TCC_OUTPUT_EXE; optind = tcc_parse_args(s, argc - 1, argv + 1); + tcc_set_environment(s); if (optind == 0) { help(); diff --git a/tcc.h b/tcc.h index 119f8624..e94f91f7 100644 --- a/tcc.h +++ b/tcc.h @@ -1061,6 +1061,8 @@ ST_FUNC int tcc_add_dll(TCCState *s, const char *filename, int flags); PUB_FUNC void tcc_print_stats(TCCState *s, int64_t total_time); PUB_FUNC int tcc_parse_args(TCCState *s, int argc, char **argv); +PUB_FUNC void tcc_set_environment(TCCState *s); + /* ------------ tccpp.c ------------ */ ST_DATA struct BufferedFile *file; -- 2.11.4.GIT