aboutsummaryrefslogtreecommitdiffstats
path: root/libasn1compiler
diff options
context:
space:
mode:
authorLev Walkin <vlm@lionet.info>2004-09-23 22:19:14 +0000
committerLev Walkin <vlm@lionet.info>2004-09-23 22:19:14 +0000
commitd29bbce66d15dee6a39e7933860831d1f55c288b (patch)
tree470e39da5aa895d9b5f99324f37b2b46dae4a510 /libasn1compiler
parent59d426ee7dac49c1ea74be78e0a382e989efea2e (diff)
versatile Makefile creation
Diffstat (limited to 'libasn1compiler')
-rw-r--r--libasn1compiler/asn1c_save.c52
1 files changed, 44 insertions, 8 deletions
diff --git a/libasn1compiler/asn1c_save.c b/libasn1compiler/asn1c_save.c
index 2db1c2ef..00a4496e 100644
--- a/libasn1compiler/asn1c_save.c
+++ b/libasn1compiler/asn1c_save.c
@@ -52,12 +52,22 @@ asn1c_save_compiled_output(arg_t *arg, const char *datadir) {
TQ_FOR(arg->expr, &(arg->mod->members), next) {
if(asn1_lang_map[arg->expr->meta_type]
[arg->expr->expr_type].type_cb) {
- fprintf(mkf, "\t\\\n\t%s.c %s.h",
- arg->expr->Identifier,
+ fprintf(mkf, "\t\\\n\t%s.c",
arg->expr->Identifier);
}
}
}
+ fprintf(mkf, "\n\nASN_MODULE_HEADERS=");
+ TQ_FOR(arg->mod, &(arg->asn->modules), mod_next) {
+ TQ_FOR(arg->expr, &(arg->mod->members), next) {
+ if(asn1_lang_map[arg->expr->meta_type]
+ [arg->expr->expr_type].type_cb) {
+ fprintf(mkf, "\t\\\n\t%s.h",
+ arg->expr->Identifier);
+ }
+ }
+ }
+ fprintf(mkf, "\n\n");
/*
* Move necessary skeleton files and add them to Makefile.am.sample.
@@ -75,6 +85,7 @@ asn1c_save_compiled_output(arg_t *arg, const char *datadir) {
for(i = 0; i < dlist->el_count; i++) {
char *fname = dlist->elements[i]->filename;
+ char *dotH;
assert(strlen(fname) < (sizeof(buf) / 2));
strcpy(dir_end, fname);
@@ -83,15 +94,38 @@ asn1c_save_compiled_output(arg_t *arg, const char *datadir) {
fprintf(mkf, ">>>ABORTED<<<");
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, "\t\\\n\t%s", fname);
+ fprintf(mkf, "ASN_MODULE_SOURCES+=%s\n", fname);
}
}
}
- fprintf(mkf, "\n\n");
- fprintf(mkf, "lib_LTLIBRARIES=libsomething.la\n");
- fprintf(mkf, "libsomething_la_SOURCES=$(ASN_MODULE_SOURCES)\n");
+ fprintf(mkf, "\n\n"
+ "lib_LTLIBRARIES=libsomething.la\n"
+ "libsomething_la_SOURCES="
+ "$(ASN_MODULE_SOURCES) $(ASN_MODULE_HEADERS)\n"
+ "\n"
+ "# This file may be used as an input for make(3)\n"
+ "# 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"
+ "\nall: $(TARGET)\n"
+ "\n$(TARGET): ${OBJS}"
+ "\n\t$(CC) $(CFLAGS) -o $(TARGET) ${OBJS} $(LDFLAGS) $(LIBS)\n"
+ "\n.SUFFIXES:"
+ "\n.SUFFIXES: .c .o\n"
+ "\n.c.o:"
+ "\n\t$(CC) $(CFLAGS) -o $@ -c $<\n"
+ "\nclean:"
+ "\n\trm -f $(TARGET)"
+ "\n\trm -f $(OBJS)\n"
+ "\n"
+ );
fclose(mkf);
fprintf(stderr, "Generated Makefile.am.sample\n");
@@ -158,7 +192,8 @@ asn1c_save_streams(arg_t *arg, asn1c_fdeps_t *deps) {
fprintf(fp_c,
"/*\n"
" * Generated by asn1c-" VERSION " (http://lionet.info/asn1c)\n"
- " * From ASN.1 module \"%s\" found in \"%s\"\n"
+ " * From ASN.1 module \"%s\"\n"
+ " * \tfound in \"%s\"\n"
" */\n\n",
arg->mod->Identifier,
arg->mod->source_file_name
@@ -166,7 +201,8 @@ asn1c_save_streams(arg_t *arg, asn1c_fdeps_t *deps) {
fprintf(fp_h,
"/*\n"
" * Generated by asn1c-" VERSION " (http://lionet.info/asn1c)\n"
- " * From ASN.1 module \"%s\" found in \"%s\"\n"
+ " * From ASN.1 module \"%s\"\n"
+ " * \tfound in \"%s\"\n"
" */\n\n",
arg->mod->Identifier,
arg->mod->source_file_name