CONVERTER is now in dependencies
git-svn-id: https://asn1c.svn.sourceforge.net/svnroot/asn1c/trunk@1173 59561ff5-6e30-0410-9f3c-9617f08c8826
diff --git a/libasn1compiler/asn1c_fdeps.c b/libasn1compiler/asn1c_fdeps.c
index 80ba2f6..eb83d7c 100644
--- a/libasn1compiler/asn1c_fdeps.c
+++ b/libasn1compiler/asn1c_fdeps.c
@@ -13,7 +13,7 @@
return 0;
if(!cur) cur = deps;
- if(cur->used_somewhere)
+ if(cur->usage != FDEP_NOTUSED)
return 1; /* Already activated */
fname = data;
@@ -37,7 +37,7 @@
}
if(cur->filename && strcmp(cur->filename, fname) == 0) {
- cur->used_somewhere = 1;
+ cur->usage = FDEP_REFERRED;
/* Activate subdependencies */
for(i = 0; i < cur->el_count; i++) {
@@ -62,16 +62,11 @@
asn1c_fdeps_t *
asn1c_read_file_dependencies(arg_t *arg, const char *datadir) {
+ char buf[4096];
asn1c_fdeps_t *deps;
asn1c_fdeps_t *cur;
- char buf[4096];
FILE *f;
- enum {
- SS_DYNAMIC, /* Dynamic list of dependencies */
- SS_CODEC_PER, /* Use contents only if -gen-PER */
- SS_COMMON_FILES, /* Section for dependencies */
- SS_IGNORE /* Ignore contents of this section */
- } special_section = SS_DYNAMIC;
+ enum fdep_usage special_section = FDEP_REFERRED;
(void)arg;
@@ -101,22 +96,24 @@
* Special "prefix" section.
*/
if(strchr(p, ':')) {
- special_section = SS_IGNORE;
+ special_section = FDEP_IGNORE;
if(strcmp(p, "COMMON-FILES:") == 0) {
- special_section = SS_COMMON_FILES;
+ special_section = FDEP_COMMON_FILES;
+ } else if(strcmp(p, "CONVERTER:") == 0) {
+ special_section = FDEP_CONVERTER;
} else if((arg->flags & A1C_GEN_PER)
&& strcmp(p, "CODEC-PER:") == 0) {
- special_section = SS_CODEC_PER;
+ special_section = FDEP_CODEC_PER;
}
break;
}
- if(special_section == SS_IGNORE)
+ if(special_section == FDEP_IGNORE)
continue;
d = asn1c_new_dep(p);
assert(d);
- d->used_somewhere = special_section;
+ d->usage = special_section;
if(asn1c_dep_add(cur, d) == 1)
cur = d;
@@ -178,8 +175,9 @@
dlist = asn1c_new_dep(0);
- if(deps->filename && deps->used_somewhere) {
+ if(deps->filename && deps->usage != FDEP_NOTUSED) {
d = asn1c_new_dep(deps->filename);
+ d->usage = deps->usage;
asn1c_dep_add(dlist, d);
}
diff --git a/libasn1compiler/asn1c_fdeps.h b/libasn1compiler/asn1c_fdeps.h
index bb9496f..27ef2c6 100644
--- a/libasn1compiler/asn1c_fdeps.h
+++ b/libasn1compiler/asn1c_fdeps.h
@@ -4,7 +4,14 @@
typedef struct asn1c_fdeps_s {
char *filename; /* Or 0, if root. */
- int used_somewhere; /* Somefile refers to it */
+ enum fdep_usage {
+ FDEP_IGNORE = -1, /* Ignore contents of the section */
+ FDEP_NOTUSED = 0,
+ FDEP_REFERRED = 1, /* Dynamic list of dependencies */
+ FDEP_CONVERTER = 2, /* Name of the int main() file */
+ FDEP_COMMON_FILES = 3, /* Section for mandatory dependencies */
+ FDEP_CODEC_PER = 4, /* Use contents only if -gen-PER */
+ } usage; /* Some file refers to it */
struct asn1c_fdeps_s **elements;
int el_size;
diff --git a/libasn1compiler/asn1c_save.c b/libasn1compiler/asn1c_save.c
index 3fed83d..3e467af 100644
--- a/libasn1compiler/asn1c_save.c
+++ b/libasn1compiler/asn1c_save.c
@@ -90,6 +90,8 @@
*dir_end++ = '/';
for(i = 0; i < dlist->el_count; i++) {
+ char *what_class; /* MODULE or CONVERTER */
+ char *what_kind; /* HEADERS or SOURCES */
char *fname = dlist->elements[i]->filename;
char *dotH;
@@ -101,17 +103,26 @@
fclose(mkf);
return -1;
}
- dotH = strrchr(fname, 'h');
- if(dotH && fname<dotH && dotH[-1] == '.' && !dotH[1]) {
- fprintf(mkf, "ASN_MODULE_HEADERS+=%s\n", fname);
- } else {
- fprintf(mkf, "ASN_MODULE_SOURCES+=%s\n", fname);
+
+ /* MODULE data versus CONVERTER data */
+ switch(dlist->elements[i]->usage) {
+ case FDEP_CONVERTER: what_class = "CONVERTER"; break;
+ default: what_class= "MODULE"; break;
}
+
+ /* HEADERS versus SOURCES */
+ dotH = strrchr(fname, 'h');
+ if(dotH && fname<dotH && dotH[-1] == '.' && !dotH[1])
+ what_kind = "HEADERS";
+ else
+ what_kind = "SOURCES";
+ fprintf(mkf, "ASN_%s_%s+=%s\n",
+ what_class, what_kind, fname);
}
}
if(arg->flags & A1C_PDU_AUTO) {
- fprintf(mkf, "ASN_MODULE_SOURCES+=pdu_collection.c\n");
+ fprintf(mkf, "ASN_CONVERTER_SOURCES+=pdu_collection.c\n");
if(generate_pdu_collection_file(arg))
return -1;
}
@@ -125,7 +136,8 @@
"# Remove the lines below to convert it into a pure .am file\n"
"TARGET = progname\n"
"CFLAGS += -I.\n"
- "OBJS=${ASN_MODULE_SOURCES:.c=.o} $(TARGET).o\n"
+ "OBJS=${ASN_MODULE_SOURCES:.c=.o}"
+ " ${ASN_CONVERTER_SOURCES:.c=.o}\n"
"\nall: $(TARGET)\n"
"\n$(TARGET): ${OBJS}"
"\n\t$(CC) $(CFLAGS) -o $(TARGET) ${OBJS} $(LDFLAGS) $(LIBS)\n"