diff options
author | Alexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de> | 2005-05-24 15:58:51 +0000 |
---|---|---|
committer | Alexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de> | 2005-05-24 15:58:51 +0000 |
commit | e6db93aff3a4e92b8d13998866a787bdc08b6f35 (patch) | |
tree | 0d43c59fba5a18d21fed5b72878c3b55d16cdd3c /util/makestrs.c | |
parent | 82f3473668ed08af059e094a696911d2347e5d57 (diff) |
Make source directory for templates configurableXORG-6_8_99_9XORG-6_8_99_15XORG-6_8_99_14XORG-6_8_99_13XORG-6_8_99_12XORG-6_8_99_11XORG-6_8_99_10
Diffstat (limited to 'util/makestrs.c')
-rw-r--r-- | util/makestrs.c | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/util/makestrs.c b/util/makestrs.c index 6e79bd5..ae8c157 100644 --- a/util/makestrs.c +++ b/util/makestrs.c @@ -89,6 +89,35 @@ static int solaris_abi_names = FALSE; #define X_MAGIC_STRING "<<<STRING_TABLE_GOES_HERE>>>" +/* Wrapper for fopen() + * Prepend filename with an includedir which can be specified on the + * commandline. Needed to separate source and build directories. + */ +static char* includedir = NULL; +static FILE *ifopen(const char *file, const char *mode) +{ + size_t len; + char *buffer; + FILE *ret; + + if (includedir == NULL) + return fopen(file, mode); + + len = strlen(file) + strlen(includedir) + 1; + buffer = (char*)malloc(len + 1); + if (buffer == NULL) + return NULL; + + strcpy(buffer, includedir); + strcat(buffer, "/"); + strcat(buffer, file); + + ret = fopen(buffer, mode); + + free(buffer); + return ret; +} + static void WriteHeaderProlog (FILE *f, File *phile) { Table* t; @@ -398,7 +427,7 @@ static void WriteSource(char *tagline, int abi) FILE* tmpl; if (ctmplstr) { - tmpl = fopen (ctmplstr, "r"); + tmpl = ifopen (ctmplstr, "r"); if (tmpl) CopyTmplProlog (tmpl, stdout); else { @@ -541,7 +570,7 @@ static void DoLine(char *buf) (void) strcpy (ctmplstr, buf + strlen (ctmpl_str) + 1); break; case X_HTMPL_TOKEN: - if ((filecurrent->tmpl = fopen (buf + strlen (htmpl_str) + 1, "r")) == NULL) { + if ((filecurrent->tmpl = ifopen (buf + strlen (htmpl_str) + 1, "r")) == NULL) { (void) fprintf (stderr, "Expected template %s, not found\n", htmpl_str); exit (1); @@ -676,6 +705,12 @@ int main(int argc, char *argv[]) else return 1; } + if (strcmp (argv[i], "-i") == 0) { + if (++i < argc) + includedir = argv[i]; + else + return 1; + } if (strcmp (argv[i], "-sparcabi") == 0) abi = X_SPARC_ABI; if (strcmp (argv[i], "-intelabi") == 0) |