Charles Hardin <ckhardin@gmail.com> - hopefully final word on startup.tcl => c conversion

git-svn-id: svn://svn.berlios.de/openocd/trunk@803 b42882b7-edfa-0310-969c-e2dbd0fdcd60
This commit is contained in:
oharboe 2008-07-13 17:31:40 +00:00
parent 6956527849
commit 766b0ca8ac
3 changed files with 43 additions and 14 deletions

View File

@ -1,4 +1,6 @@
bin_PROGRAMS = openocd
bin_PROGRAMS = openocd bin2char
bin2char_SOURCES = bin2char.c
if ECOSBOARD
MAINFILE = ecosboard.c
@ -6,7 +8,7 @@ else
MAINFILE = main.c jim.c
endif
openocd_SOURCES = $(MAINFILE) openocd.c
openocd_SOURCES = $(MAINFILE) openocd.c startup_tcl.c
# set the include path found by configure
INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/src/helper \
@ -70,7 +72,7 @@ FTD2XXLIB =
endif
endif
openocd_LDADD = $(top_builddir)/src/startup.o $(top_builddir)/src/xsvf/libxsvf.a \
openocd_LDADD = $(top_builddir)/src/xsvf/libxsvf.a \
$(top_builddir)/src/target/libtarget.a $(top_builddir)/src/jtag/libjtag.a \
$(top_builddir)/src/helper/libhelper.a \
$(top_builddir)/src/server/libserver.a $(top_builddir)/src/helper/libhelper.a \
@ -94,9 +96,6 @@ nobase_dist_pkglib_DATA = \
tcl/mmr_helpers.tcl \
tcl/readable.tcl
# Convert .tcl to object
$(top_builddir)/src/startup.o: $(top_srcdir)/src/startup.tcl
abs_builddir=`cd $(top_builddir) && pwd` && \
cd $(top_srcdir)/src && \
${OBJCOPY} -I binary -O ${OBJCOPY_FORMAT} -B ${OBJCOPY_ARCH} startup.tcl $$abs_builddir/src/startup.o
# Convert .tcl to cfile
startup_tcl.c: bin2char startup.tcl
./bin2char startup_tcl < $(srcdir)/startup.tcl > startup_tcl.c

30
src/bin2char.c Normal file
View File

@ -0,0 +1,30 @@
#include <stdio.h>
#include <stdlib.h>
int
main(int argc, char **argv)
{
int c;
unsigned int n;
char *name;
if (argc == 1) {
fprintf(stderr, "bin2char <varname>\n");
fprintf(stderr, "read from standard input and write a char"
" array out to standard output\n");
exit(1);
}
n = 0;
name = argv[1];
fprintf(stdout, "/* autogenerated from %s */\n", argv[0]);
fprintf(stdout, "unsigned const char %s[] = {\n", name);
while ((c = getc(stdin)) != EOF) {
fprintf(stdout, "0x%02x,", c & 0xff);
if ((++n % 16) == 0)
fprintf(stdout, "\n");
}
fprintf(stdout, "0 /* terminate with a nil */};\n");
fprintf(stdout, "unsigned int %s_len = %u;\n", name, n);
return 0;
}

View File

@ -714,8 +714,8 @@ void add_jim(const char *name, int (*cmd)(Jim_Interp *interp, int argc, Jim_Obj
Jim_ListAppendElement(interp, helptext, cmd_entry);
}
extern char binary_startup_tcl_start;
extern char binary_startup_tcl_size;
extern unsigned const char startup_tcl[];
extern unsigned int startup_tcl_len;
void initJim(void)
{
@ -741,10 +741,10 @@ void initJim(void)
add_default_dirs();
script_len = (int)&binary_startup_tcl_size;
script_len = startup_tcl_len;
script = malloc(script_len + sizeof(char));
memcpy(script, &binary_startup_tcl_start, script_len);
memcpy(script, startup_tcl, script_len);
/* null terminate */
script[script_len] = 0;