4 # Generate a linker script for GNU ld.
20 echo "warning: $*" 1>&2
24 info "usage: $0 [-p <pattern>] [-I <ignore-list>] -o <output> <inputs>"
34 PATTERN="^mrp_|^_mrp_" # export everything prefixed with mrp_
35 IGNORE="MRP_PRINTF_LIKE,MRP_NULLTERM" # ignore these symbols/macros
36 IT="," # ignore-list is comma-separated
37 SOURCES="" # no default input, must be specified
38 OUTPUT="" # no default output, must be specified
41 while [ -n "${1#-}" ]; do
44 if [ -z "$OUTPUT" ]; then
48 error "Multiple output files requested."
68 # This is only for command-line compatibility with collect-symbols
69 # to minimize the impact of switching back and forth (if needed).
70 # collect-symbols gets compilation flags passed using the -c
71 # option which we simply ignore here when using ctags.
75 error "Unknown option '$1'."
85 # check that we've got everything mandatory
86 if [ -z "$OUTPUT" ]; then
87 error "No output file specified (use the -o option)."
91 if [ -z "$SOURCES" ]; then
92 warning "No input files, generating local-only linker script."
100 if [ -z "$PATTERN" ]; then
104 if [ -n "$IGNORE" ]; then
105 ignore_opts="-I $IGNORE"
110 # check that we have ctags
111 which ctags >& /dev/null
112 if [ "$?" != "0" ]; then
113 error "Needs ctags to regenerate linker script $OUTPUT..."
117 # generate the output
118 [ -n "$QUIET" ] || info "Generating linker script $OUTPUT..."
124 ctags $ignore_opts -f - --c-kinds=px $SOURCES | \
125 awk "/$PATTERN/ { print \$1; }" | \