Skip to content
Snippets Groups Projects
Commit d29bbce6 authored by Lev Walkin's avatar Lev Walkin
Browse files

versatile Makefile creation

parent 59d426ee
No related branches found
No related tags found
No related merge requests found
...@@ -52,12 +52,22 @@ asn1c_save_compiled_output(arg_t *arg, const char *datadir) { ...@@ -52,12 +52,22 @@ asn1c_save_compiled_output(arg_t *arg, const char *datadir) {
TQ_FOR(arg->expr, &(arg->mod->members), next) { TQ_FOR(arg->expr, &(arg->mod->members), next) {
if(asn1_lang_map[arg->expr->meta_type] if(asn1_lang_map[arg->expr->meta_type]
[arg->expr->expr_type].type_cb) { [arg->expr->expr_type].type_cb) {
fprintf(mkf, "\t\\\n\t%s.c %s.h", fprintf(mkf, "\t\\\n\t%s.c",
arg->expr->Identifier,
arg->expr->Identifier); 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. * 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) { ...@@ -75,6 +85,7 @@ asn1c_save_compiled_output(arg_t *arg, const char *datadir) {
for(i = 0; i < dlist->el_count; i++) { for(i = 0; i < dlist->el_count; i++) {
char *fname = dlist->elements[i]->filename; char *fname = dlist->elements[i]->filename;
char *dotH;
assert(strlen(fname) < (sizeof(buf) / 2)); assert(strlen(fname) < (sizeof(buf) / 2));
strcpy(dir_end, fname); strcpy(dir_end, fname);
...@@ -83,15 +94,38 @@ asn1c_save_compiled_output(arg_t *arg, const char *datadir) { ...@@ -83,15 +94,38 @@ asn1c_save_compiled_output(arg_t *arg, const char *datadir) {
fprintf(mkf, ">>>ABORTED<<<"); fprintf(mkf, ">>>ABORTED<<<");
fclose(mkf); fclose(mkf);
return -1; return -1;
}
dotH = strrchr(fname, 'h');
if(dotH && fname<dotH && dotH[-1] == '.' && !dotH[1]) {
fprintf(mkf, "ASN_MODULE_HEADERS+=%s\n", fname);
} else { } else {
fprintf(mkf, "\t\\\n\t%s", fname); fprintf(mkf, "ASN_MODULE_SOURCES+=%s\n", fname);
} }
} }
} }
fprintf(mkf, "\n\n"); fprintf(mkf, "\n\n"
fprintf(mkf, "lib_LTLIBRARIES=libsomething.la\n"); "lib_LTLIBRARIES=libsomething.la\n"
fprintf(mkf, "libsomething_la_SOURCES=$(ASN_MODULE_SOURCES)\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); fclose(mkf);
fprintf(stderr, "Generated Makefile.am.sample\n"); fprintf(stderr, "Generated Makefile.am.sample\n");
...@@ -158,7 +192,8 @@ asn1c_save_streams(arg_t *arg, asn1c_fdeps_t *deps) { ...@@ -158,7 +192,8 @@ asn1c_save_streams(arg_t *arg, asn1c_fdeps_t *deps) {
fprintf(fp_c, fprintf(fp_c,
"/*\n" "/*\n"
" * Generated by asn1c-" VERSION " (http://lionet.info/asn1c)\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", " */\n\n",
arg->mod->Identifier, arg->mod->Identifier,
arg->mod->source_file_name arg->mod->source_file_name
...@@ -166,7 +201,8 @@ asn1c_save_streams(arg_t *arg, asn1c_fdeps_t *deps) { ...@@ -166,7 +201,8 @@ asn1c_save_streams(arg_t *arg, asn1c_fdeps_t *deps) {
fprintf(fp_h, fprintf(fp_h,
"/*\n" "/*\n"
" * Generated by asn1c-" VERSION " (http://lionet.info/asn1c)\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", " */\n\n",
arg->mod->Identifier, arg->mod->Identifier,
arg->mod->source_file_name arg->mod->source_file_name
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment