summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorAlexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de>2005-05-24 15:58:51 +0000
committerAlexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de>2005-05-24 15:58:51 +0000
commite6db93aff3a4e92b8d13998866a787bdc08b6f35 (patch)
tree0d43c59fba5a18d21fed5b72878c3b55d16cdd3c /util
parent82f3473668ed08af059e094a696911d2347e5d57 (diff)
Diffstat (limited to 'util')
-rw-r--r--util/makestrs.c39
-rw-r--r--util/makestrs.man6
2 files changed, 42 insertions, 3 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)
diff --git a/util/makestrs.man b/util/makestrs.man
index 4fe23e8..cd96841 100644
--- a/util/makestrs.man
+++ b/util/makestrs.man
@@ -29,7 +29,7 @@
.SH NAME
makestrs \- makes string table C source and header(s)
.SH SYNOPSIS
-.B makestrs [-f source] [-abioptions ...]
+.B makestrs [-f source] [-i includedir] [-abioptions ...]
.SH DESCRIPTION
The
.I makestrs
@@ -83,6 +83,10 @@ forces the generation of the "normal" string table even
if makestrs was compiled with -DARRAYPERSTR. Since makestrs is almost
never compiled with -DARRAYPERSTR this is the default behavior if
no abioptions are specified.
+.LP
+.I -i includedir
+forces the reading of templates from the includedir instead of the local
+directory. This is useful to have separate source and build directories.
.SH SYNTAX
The syntax for string-list file is (items in square brackets are optional):
.RS 4