simple_self_test2.sh (Source)

#!/bin/bash -x
#rm -f test.o test.c test.elf
rm -f  *.c* *.elf *.asm *.edump  *.hdump  *.hex  *.o *.h2info *.h2dump *.h2bin
if [ "$1" == "--clean" ]; then exit; fi
avr-gcc --version
cat >test.c <<EOF
int main(void) {
  return 0;
}
EOF
cat test.c
avr-gcc -std=c99 -g -mmcu=atmega328p -Os -DF_CPU=16000000 -c test.c
avr-gcc -std=c99 -g -mmcu=atmega328p -o test.elf test.o
cat >test2.cpp <<EOF
int main(void) {
  return 0;
}
EOF
cat test2.cpp
avr-gcc -c test2.cpp -o test2.o
#avr-gcc -c lib_4DM8010.cpp -o lib_4DM8010.o
#avr-gcc test2.o lib_4DM8010.o -o test2.elf
avr-gcc test2.o -o test2.elf
####
for name in test test2; do
avr-objcopy -O ihex -R .eeprom ${name}.elf ${name}.hex
avr-gcc  -S -c  ${name}.c* -o ${name}.asm
avr-objdump -DCfhlSwz ${name}.elf >${name}.edump
avr-objdump -DCfhlSwz -m avr  ${name}.hex >${name}.hdump
hexinfo.py ${name}.hex >${name}.h2info
hex2dump.py ${name}.hex >${name}.h2dump
hex2bin.py ${name}.hex >${name}.h2bin
done