Index: bootstrap
===================================================================
--- bootstrap	(revision 2548)
+++ bootstrap	(working copy)
@@ -18,7 +18,7 @@ export AUTOMAKE AUTOCONF ACLOCAL AUTOHEA
 set -x
 
 rm -rf avr/lib
-./devtools/gen-avr-lib-tree.sh
+./devtools/gen-avr-lib-tree.sh || exit 1
 
 rm -rf autom4te.cache
 
Index: configure.ac
===================================================================
--- configure.ac	(revision 2548)
+++ configure.ac	(working copy)
@@ -122,7 +122,7 @@ dnl Minimum version of Automake is 1.8.
 dnl We don't want the gzip distribution tarball anymore.
 AM_INIT_AUTOMAKE([1.8 dist-bzip2 no-dist-gzip])
 
-# We don't want touse the cflags from the environment since we need control
+# We don't want to use the cflags from the environment since we need control
 # of this when we're building the libs.
 CFLAGS=""
 
@@ -454,8 +454,10 @@ CHECK_MNO_TABLEJUMP
 CHECK_FNO_JUMP_TABLES
 CHECK_BUILTIN_DELAY_CYCLES
 
+asm_only="at90s1200 attiny11 attiny12 attiny15 attiny28"
+
 dnl Some devices are only handled by newer version of gcc. This macro lets us
-dnl probe to see if the installed avr-gcc supports a questionable device.
+dnl probe whether the installed avr-gcc supports a device.
 AC_DEFUN(
   CHECK_AVR_DEVICE,
   [
@@ -469,813 +471,116 @@ AC_DEFUN(
       [has_dev_support=yes],
       [has_dev_support=no]
     )
+    for d in ${asm_only}; do
+        if test "$1" = "$d"; then
+            has_dev_support=yes
+        fi
+    done
     if test "x$has_dev_support" = "xyes"
     then
-      HAS_$1=yes
+      MULTIDIR_$1=`${CC} ${CFLAGS} -print-multi-directory`
+      AC_MSG_RESULT([yes, in ${MULTIDIR_$1}])
+dnl Same replacements as performed by mlib-gen.py::to_ident().
+      ident=`echo "${MULTIDIR_$1}" \
+      		| sed -e 's:^\.$:avr2:' \
+		| sed -e 's:/:_:g' \
+		| sed -e 's:-:_:g' \
+		`
+      eval "DEVLIST_${ident}=\"\${DEVLIST_${ident}} $1\""
+    else
+      MULTIDIR_$1=
+      AC_MSG_RESULT(no)
     fi
-    AC_MSG_RESULT($has_dev_support)
+    AC_SUBST(MULTIDIR_$1)
     CC=${old_CC}
     CFLAGS=${old_CFLAGS}
+    AM_CONDITIONAL(HAS_$1, test "x${MULTIDIR_$1}" != "x")
   ]
 )
 
 
-# avr1
-AM_CONDITIONAL(HAS_avr1, true)
-AM_CONDITIONAL(HAS_at90s1200, true)
-AM_CONDITIONAL(HAS_attiny11, true)
-AM_CONDITIONAL(HAS_attiny12, true)
-AM_CONDITIONAL(HAS_attiny15, true)
-AM_CONDITIONAL(HAS_attiny28, true)
-
-
-# avr2
-AM_CONDITIONAL(HAS_avr2, true)
-AM_CONDITIONAL(HAS_at90s2313, true)
-AM_CONDITIONAL(HAS_at90s2323, true)
-AM_CONDITIONAL(HAS_at90s2333, true)
-AM_CONDITIONAL(HAS_at90s2343, true)
-AM_CONDITIONAL(HAS_at90s4414, true)
-AM_CONDITIONAL(HAS_at90s4433, true)
-AM_CONDITIONAL(HAS_at90s4434, true)
-AM_CONDITIONAL(HAS_at90s8515, true)
-AM_CONDITIONAL(HAS_at90c8534, true)
-AM_CONDITIONAL(HAS_at90s8535, true)
-AM_CONDITIONAL(HAS_attiny22, true)
-AM_CONDITIONAL(HAS_attiny26, true)
-
-
-#avr25
-CHECK_AVR_DEVICE(avr25)
-AM_CONDITIONAL(HAS_avr25, test "x$HAS_avr25" = "xyes")
-
-CHECK_AVR_DEVICE(ata5272)
-AM_CONDITIONAL(HAS_ata5272, test "x$HAS_ata5272" = "xyes")
-
-CHECK_AVR_DEVICE(ata6616c)
-AM_CONDITIONAL(HAS_ata6616c, test "x$HAS_ata6616c" = "xyes")
-
-CHECK_AVR_DEVICE(attiny13)
-AM_CONDITIONAL(HAS_attiny13, test "x$HAS_attiny13" = "xyes")
-
-CHECK_AVR_DEVICE(attiny13a)
-AM_CONDITIONAL(HAS_attiny13a, test "x$HAS_attiny13a" = "xyes")
-
-CHECK_AVR_DEVICE(attiny2313)
-AM_CONDITIONAL(HAS_attiny2313, test "x$HAS_attiny2313" = "xyes")
-
-CHECK_AVR_DEVICE(attiny2313a)
-AM_CONDITIONAL(HAS_attiny2313a, test "x$HAS_attiny2313a" = "xyes")
-
-CHECK_AVR_DEVICE(attiny24)
-AM_CONDITIONAL(HAS_attiny24, test "x$HAS_attiny24" = "xyes")
-
-CHECK_AVR_DEVICE(attiny24a)
-AM_CONDITIONAL(HAS_attiny24a, test "x$HAS_attiny24a" = "xyes")
-
-CHECK_AVR_DEVICE(attiny25)
-AM_CONDITIONAL(HAS_attiny25, test "x$HAS_attiny25" = "xyes")
-
-CHECK_AVR_DEVICE(attiny261)
-AM_CONDITIONAL(HAS_attiny261, test "x$HAS_attiny261" = "xyes")
-
-CHECK_AVR_DEVICE(attiny261a)
-AM_CONDITIONAL(HAS_attiny261a, test "x$HAS_attiny261a" = "xyes")
-
-CHECK_AVR_DEVICE(attiny43u)
-AM_CONDITIONAL(HAS_attiny43u, test "x$HAS_attiny43u" = "xyes")
-
-CHECK_AVR_DEVICE(attiny4313)
-AM_CONDITIONAL(HAS_attiny4313, test "x$HAS_attiny4313" = "xyes")
-
-CHECK_AVR_DEVICE(attiny44)
-AM_CONDITIONAL(HAS_attiny44, test "x$HAS_attiny44" = "xyes")
-
-CHECK_AVR_DEVICE(attiny441)
-AM_CONDITIONAL(HAS_attiny441, test "x$HAS_attiny441" = "xyes")
-
-CHECK_AVR_DEVICE(attiny44a)
-AM_CONDITIONAL(HAS_attiny44a, test "x$HAS_attiny44a" = "xyes")
-
-CHECK_AVR_DEVICE(attiny45)
-AM_CONDITIONAL(HAS_attiny45, test "x$HAS_attiny45" = "xyes")
-
-CHECK_AVR_DEVICE(attiny461)
-AM_CONDITIONAL(HAS_attiny461, test "x$HAS_attiny461" = "xyes")
-
-CHECK_AVR_DEVICE(attiny461a)
-AM_CONDITIONAL(HAS_attiny461a, test "x$HAS_attiny461a" = "xyes")
-
-CHECK_AVR_DEVICE(attiny48)
-AM_CONDITIONAL(HAS_attiny48, test "x$HAS_attiny48" = "xyes")
-
-CHECK_AVR_DEVICE(attiny828)
-AM_CONDITIONAL(HAS_attiny828, test "x$HAS_attiny828" = "xyes")
-
-CHECK_AVR_DEVICE(attiny84)
-AM_CONDITIONAL(HAS_attiny84, test "x$HAS_attiny84" = "xyes")
-
-CHECK_AVR_DEVICE(attiny841)
-AM_CONDITIONAL(HAS_attiny841, test "x$HAS_attiny841" = "xyes")
-
-CHECK_AVR_DEVICE(attiny84a)
-AM_CONDITIONAL(HAS_attiny84a, test "x$HAS_attiny84a" = "xyes")
-
-CHECK_AVR_DEVICE(attiny85)
-AM_CONDITIONAL(HAS_attiny85, test "x$HAS_attiny85" = "xyes")
-
-CHECK_AVR_DEVICE(attiny861)
-AM_CONDITIONAL(HAS_attiny861, test "x$HAS_attiny861" = "xyes")
-
-CHECK_AVR_DEVICE(attiny861a)
-AM_CONDITIONAL(HAS_attiny861a, test "x$HAS_attiny861a" = "xyes")
-
-CHECK_AVR_DEVICE(attiny87)
-AM_CONDITIONAL(HAS_attiny87, test "x$HAS_attiny87" = "xyes")
-
-CHECK_AVR_DEVICE(attiny88)
-AM_CONDITIONAL(HAS_attiny88, test "x$HAS_attiny88" = "xyes")
-
-CHECK_AVR_DEVICE(at86rf401)
-AM_CONDITIONAL(HAS_at86rf401, test "x$HAS_at86rf401" = "xyes")
-
-
-# avr3
-AM_CONDITIONAL(HAS_avr3, true)
-AM_CONDITIONAL(HAS_at43usb320, true)
-AM_CONDITIONAL(HAS_at43usb355, true)
-AM_CONDITIONAL(HAS_at76c711, true)
-
-#avr31
-CHECK_AVR_DEVICE(avr31)
-AM_CONDITIONAL(HAS_avr31, test "x$HAS_avr31" = "xyes")
-
-AM_CONDITIONAL(HAS_atmega103, true)
-
-
-#avr35
-CHECK_AVR_DEVICE(avr35)
-AM_CONDITIONAL(HAS_avr35, test "x$HAS_avr35" = "xyes")
-
-CHECK_AVR_DEVICE(at90usb82)
-AM_CONDITIONAL(HAS_at90usb82, test "x$HAS_at90usb82" = "xyes")
-
-CHECK_AVR_DEVICE(at90usb162)
-AM_CONDITIONAL(HAS_at90usb162, test "x$HAS_at90usb162" = "xyes")
-
-CHECK_AVR_DEVICE(ata5505)
-AM_CONDITIONAL(HAS_ata5505, test "x$HAS_ata5505" = "xyes")
-
-CHECK_AVR_DEVICE(ata6617c)
-AM_CONDITIONAL(HAS_ata6617c, test "x$HAS_ata6617c" = "xyes")
-
-CHECK_AVR_DEVICE(ata664251)
-AM_CONDITIONAL(HAS_ata664251, test "x$HAS_ata664251" = "xyes")
-
-CHECK_AVR_DEVICE(atmega8u2)
-AM_CONDITIONAL(HAS_atmega8u2, test "x$HAS_atmega8u2" = "xyes")
-
-CHECK_AVR_DEVICE(atmega16u2)
-AM_CONDITIONAL(HAS_atmega16u2, test "x$HAS_atmega16u2" = "xyes")
-
-CHECK_AVR_DEVICE(atmega32u2)
-AM_CONDITIONAL(HAS_atmega32u2, test "x$HAS_atmega32u2" = "xyes")
-
-CHECK_AVR_DEVICE(attiny167)
-AM_CONDITIONAL(HAS_attiny167, test "x$HAS_attiny167" = "xyes")
-
-CHECK_AVR_DEVICE(attiny1634)
-AM_CONDITIONAL(HAS_attiny1634, test "x$HAS_attiny1634" = "xyes")
-
-
-# avr4
-AM_CONDITIONAL(HAS_avr4, true)
-AM_CONDITIONAL(HAS_atmega8, true)
-AM_CONDITIONAL(HAS_atmega8515, true)
-AM_CONDITIONAL(HAS_atmega8535, true)
-
-CHECK_AVR_DEVICE(ata6285)
-AM_CONDITIONAL(HAS_ata6285, test "x$HAS_ata6285" = "xyes")
-
-CHECK_AVR_DEVICE(ata6286)
-AM_CONDITIONAL(HAS_ata6286, test "x$HAS_ata6286" = "xyes")
-
-CHECK_AVR_DEVICE(ata6289)
-AM_CONDITIONAL(HAS_ata6289, test "x$HAS_ata6289" = "xyes")
-
-CHECK_AVR_DEVICE(ata6612c)
-AM_CONDITIONAL(HAS_ata6612c, test "x$HAS_ata6612c" = "xyes")
-
-CHECK_AVR_DEVICE(atmega8a)
-AM_CONDITIONAL(HAS_atmega8a, test "x$HAS_atmega8a" = "xyes")
-
-CHECK_AVR_DEVICE(atmega48)
-AM_CONDITIONAL(HAS_atmega48, test "x$HAS_atmega48" = "xyes")
-
-CHECK_AVR_DEVICE(atmega48a)
-AM_CONDITIONAL(HAS_atmega48a, test "x$HAS_atmega48a" = "xyes")
-
-CHECK_AVR_DEVICE(atmega48pa)
-AM_CONDITIONAL(HAS_atmega48pa, test "x$HAS_atmega48pa" = "xyes")
-
-CHECK_AVR_DEVICE(atmega48pb)
-AM_CONDITIONAL(HAS_atmega48pb, test "x$HAS_atmega48pb" = "xyes")
-
-CHECK_AVR_DEVICE(atmega48p)
-AM_CONDITIONAL(HAS_atmega48p, test "x$HAS_atmega48p" = "xyes")
-
-CHECK_AVR_DEVICE(atmega88)
-AM_CONDITIONAL(HAS_atmega88, test "x$HAS_atmega88" = "xyes")
-
-CHECK_AVR_DEVICE(atmega88a)
-AM_CONDITIONAL(HAS_atmega88a, test "x$HAS_atmega88a" = "xyes")
-
-CHECK_AVR_DEVICE(atmega88p)
-AM_CONDITIONAL(HAS_atmega88p, test "x$HAS_atmega88p" = "xyes")
-
-CHECK_AVR_DEVICE(atmega88pa)
-AM_CONDITIONAL(HAS_atmega88pa, test "x$HAS_atmega88pa" = "xyes")
-
-CHECK_AVR_DEVICE(atmega88pb)
-AM_CONDITIONAL(HAS_atmega88pb, test "x$HAS_atmega88pb" = "xyes")
-
-CHECK_AVR_DEVICE(atmega8hva)
-AM_CONDITIONAL(HAS_atmega8hva, test "x$HAS_atmega8hva" = "xyes")
-
-CHECK_AVR_DEVICE(at90pwm1)
-AM_CONDITIONAL(HAS_at90pwm1, test "x$HAS_at90pwm1" = "xyes")
-
-CHECK_AVR_DEVICE(at90pwm2)
-AM_CONDITIONAL(HAS_at90pwm2, test "x$HAS_at90pwm2" = "xyes")
-
-CHECK_AVR_DEVICE(at90pwm2b)
-AM_CONDITIONAL(HAS_at90pwm2b, test "x$HAS_at90pwm2b" = "xyes")
-
-CHECK_AVR_DEVICE(at90pwm3)
-AM_CONDITIONAL(HAS_at90pwm3, test "x$HAS_at90pwm3" = "xyes")
-
-CHECK_AVR_DEVICE(at90pwm3b)
-AM_CONDITIONAL(HAS_at90pwm3b, test "x$HAS_at90pwm3b" = "xyes")
-
-CHECK_AVR_DEVICE(at90pwm81)
-AM_CONDITIONAL(HAS_at90pwm81, test "x$HAS_at90pwm81" = "xyes")
-
-
-# avr5
-AM_CONDITIONAL(HAS_avr5, true)
-
-CHECK_AVR_DEVICE(at90can32)
-AM_CONDITIONAL(HAS_at90can32, test "x$HAS_at90can32" = "xyes")
-
-CHECK_AVR_DEVICE(at90can64)
-AM_CONDITIONAL(HAS_at90can64, test "x$HAS_at90can64" = "xyes")
-
-CHECK_AVR_DEVICE(at90scr100)
-AM_CONDITIONAL(HAS_at90scr100, test "x$HAS_at90scr100" = "xyes")
-
-CHECK_AVR_DEVICE(at90usb646)
-AM_CONDITIONAL(HAS_at90usb646, test "x$HAS_at90usb646" = "xyes")
-
-CHECK_AVR_DEVICE(at90usb647)
-AM_CONDITIONAL(HAS_at90usb647, test "x$HAS_at90usb647" = "xyes")
-
-CHECK_AVR_DEVICE(at90pwm316)
-AM_CONDITIONAL(HAS_at90pwm316, test "x$HAS_at90pwm316" = "xyes")
-
-CHECK_AVR_DEVICE(at90pwm216)
-AM_CONDITIONAL(HAS_at90pwm216, test "x$HAS_at90pwm216" = "xyes")
-
-CHECK_AVR_DEVICE(at90pwm161)
-AM_CONDITIONAL(HAS_at90pwm161, test "x$HAS_at90pwm161" = "xyes")
-
-CHECK_AVR_DEVICE(at94k)
-AM_CONDITIONAL(HAS_at94k, test "x$HAS_at94k" = "xyes")
-
-CHECK_AVR_DEVICE(ata5702m322)
-AM_CONDITIONAL(HAS_ata5702m322, test "x$HAS_ata5702m322" = "xyes")
-
-CHECK_AVR_DEVICE(ata5782)
-AM_CONDITIONAL(HAS_ata5782, test "x$HAS_ata5782" = "xyes")
-
-CHECK_AVR_DEVICE(ata5790)
-AM_CONDITIONAL(HAS_ata5790, test "x$HAS_ata5790" = "xyes")
-
-CHECK_AVR_DEVICE(ata5790n)
-AM_CONDITIONAL(HAS_ata5790n, test "x$HAS_ata5790n" = "xyes")
-
-CHECK_AVR_DEVICE(ata5795)
-AM_CONDITIONAL(HAS_ata5795, test "x$HAS_ata5795" = "xyes")
-
-CHECK_AVR_DEVICE(ata5831)
-AM_CONDITIONAL(HAS_ata5831, test "x$HAS_ata5831" = "xyes")
-
-CHECK_AVR_DEVICE(ata6613c)
-AM_CONDITIONAL(HAS_ata6613c, test "x$HAS_ata6613c" = "xyes")
-
-CHECK_AVR_DEVICE(ata6614q)
-AM_CONDITIONAL(HAS_ata6614q, test "x$HAS_ata6614q" = "xyes")
-
-CHECK_AVR_DEVICE(atmega16)
-AM_CONDITIONAL(HAS_atmega16, test "x$HAS_atmega16" = "xyes")
-
-CHECK_AVR_DEVICE(atmega16a)
-AM_CONDITIONAL(HAS_atmega16a, test "x$HAS_atmega16a" = "xyes")
-
-CHECK_AVR_DEVICE(atmega161)
-AM_CONDITIONAL(HAS_atmega161, test "x$HAS_atmega161" = "xyes")
-
-CHECK_AVR_DEVICE(atmega162)
-AM_CONDITIONAL(HAS_atmega162, test "x$HAS_atmega162" = "xyes")
-
-CHECK_AVR_DEVICE(atmega163)
-AM_CONDITIONAL(HAS_atmega163, test "x$HAS_atmega163" = "xyes")
-
-CHECK_AVR_DEVICE(atmega164a)
-AM_CONDITIONAL(HAS_atmega164a, test "x$HAS_atmega164a" = "xyes")
-
-CHECK_AVR_DEVICE(atmega164p)
-AM_CONDITIONAL(HAS_atmega164p, test "x$HAS_atmega164p" = "xyes")
-
-CHECK_AVR_DEVICE(atmega164pa)
-AM_CONDITIONAL(HAS_atmega164pa, test "x$HAS_atmega164pa" = "xyes")
-
-CHECK_AVR_DEVICE(atmega165)
-AM_CONDITIONAL(HAS_atmega165, test "x$HAS_atmega165" = "xyes")
-
-CHECK_AVR_DEVICE(atmega165a)
-AM_CONDITIONAL(HAS_atmega165a, test "x$HAS_atmega165a" = "xyes")
-
-CHECK_AVR_DEVICE(atmega165p)
-AM_CONDITIONAL(HAS_atmega165p, test "x$HAS_atmega165p" = "xyes")
-
-CHECK_AVR_DEVICE(atmega165pa)
-AM_CONDITIONAL(HAS_atmega165pa, test "x$HAS_atmega165pa" = "xyes")
-
-CHECK_AVR_DEVICE(atmega168)
-AM_CONDITIONAL(HAS_atmega168, test "x$HAS_atmega168" = "xyes")
-
-CHECK_AVR_DEVICE(atmega168a)
-AM_CONDITIONAL(HAS_atmega168a, test "x$HAS_atmega168a" = "xyes")
-
-CHECK_AVR_DEVICE(atmega168p)
-AM_CONDITIONAL(HAS_atmega168p, test "x$HAS_atmega168p" = "xyes")
-
-CHECK_AVR_DEVICE(atmega168pa)
-AM_CONDITIONAL(HAS_atmega168pa, test "x$HAS_atmega168pa" = "xyes")
-
-CHECK_AVR_DEVICE(atmega169)
-AM_CONDITIONAL(HAS_atmega169, test "x$HAS_atmega169" = "xyes")
-
-CHECK_AVR_DEVICE(atmega169a)
-AM_CONDITIONAL(HAS_atmega169a, test "x$HAS_atmega169a" = "xyes")
-
-CHECK_AVR_DEVICE(atmega169p)
-AM_CONDITIONAL(HAS_atmega169p, test "x$HAS_atmega169p" = "xyes")
-
-CHECK_AVR_DEVICE(atmega169pa)
-AM_CONDITIONAL(HAS_atmega169pa, test "x$HAS_atmega169pa" = "xyes")
-
-CHECK_AVR_DEVICE(atmega16hva)
-AM_CONDITIONAL(HAS_atmega16hva, test "x$HAS_atmega16hva" = "xyes")
-
-CHECK_AVR_DEVICE(atmega16hva2)
-AM_CONDITIONAL(HAS_atmega16hva2, test "x$HAS_atmega16hva2" = "xyes")
-
-CHECK_AVR_DEVICE(atmega16hvb)
-AM_CONDITIONAL(HAS_atmega16hvb, test "x$HAS_atmega16hvb" = "xyes")
-
-CHECK_AVR_DEVICE(atmega16hvbrevb)
-AM_CONDITIONAL(HAS_atmega16hvbrevb, test "x$HAS_atmega16hvbrevb" = "xyes")
-
-CHECK_AVR_DEVICE(atmega16m1)
-AM_CONDITIONAL(HAS_atmega16m1, test "x$HAS_atmega16m1" = "xyes")
-
-CHECK_AVR_DEVICE(atmega16u4)
-AM_CONDITIONAL(HAS_atmega16u4, test "x$HAS_atmega16u4" = "xyes")
-
-CHECK_AVR_DEVICE(atmega32)
-AM_CONDITIONAL(HAS_atmega32, test "x$HAS_atmega32" = "xyes")
-
-CHECK_AVR_DEVICE(atmega32a)
-AM_CONDITIONAL(HAS_atmega32a, test "x$HAS_atmega32a" = "xyes")
-
-CHECK_AVR_DEVICE(atmega323)
-AM_CONDITIONAL(HAS_atmega323, test "x$HAS_atmega323" = "xyes")
-
-CHECK_AVR_DEVICE(atmega324a)
-AM_CONDITIONAL(HAS_atmega324a, test "x$HAS_atmega324a" = "xyes")
-
-CHECK_AVR_DEVICE(atmega324p)
-AM_CONDITIONAL(HAS_atmega324p, test "x$HAS_atmega324p" = "xyes")
-
-CHECK_AVR_DEVICE(atmega324pa)
-AM_CONDITIONAL(HAS_atmega324pa, test "x$HAS_atmega324pa" = "xyes")
-
-CHECK_AVR_DEVICE(atmega325)
-AM_CONDITIONAL(HAS_atmega325, test "x$HAS_atmega325" = "xyes")
-
-CHECK_AVR_DEVICE(atmega325a)
-AM_CONDITIONAL(HAS_atmega325a, test "x$HAS_atmega325a" = "xyes")
-
-CHECK_AVR_DEVICE(atmega325p)
-AM_CONDITIONAL(HAS_atmega325p, test "x$HAS_atmega325p" = "xyes")
-
-CHECK_AVR_DEVICE(atmega325pa)
-AM_CONDITIONAL(HAS_atmega325pa, test "x$HAS_atmega325pa" = "xyes")
-
-CHECK_AVR_DEVICE(atmega3250)
-AM_CONDITIONAL(HAS_atmega3250, test "x$HAS_atmega3250" = "xyes")
-
-CHECK_AVR_DEVICE(atmega3250a)
-AM_CONDITIONAL(HAS_atmega3250a, test "x$HAS_atmega3250a" = "xyes")
-
-CHECK_AVR_DEVICE(atmega3250p)
-AM_CONDITIONAL(HAS_atmega3250p, test "x$HAS_atmega3250p" = "xyes")
-
-CHECK_AVR_DEVICE(atmega3250pa)
-AM_CONDITIONAL(HAS_atmega3250pa, test "x$HAS_atmega3250pa" = "xyes")
-
-CHECK_AVR_DEVICE(atmega328)
-AM_CONDITIONAL(HAS_atmega328, test "x$HAS_atmega328" = "xyes")
-
-CHECK_AVR_DEVICE(atmega328p)
-AM_CONDITIONAL(HAS_atmega328p, test "x$HAS_atmega328p" = "xyes")
-
-CHECK_AVR_DEVICE(atmega329)
-AM_CONDITIONAL(HAS_atmega329, test "x$HAS_atmega329" = "xyes")
-
-CHECK_AVR_DEVICE(atmega329a)
-AM_CONDITIONAL(HAS_atmega329a, test "x$HAS_atmega329a" = "xyes")
-
-CHECK_AVR_DEVICE(atmega329p)
-AM_CONDITIONAL(HAS_atmega329p, test "x$HAS_atmega329p" = "xyes")
-
-CHECK_AVR_DEVICE(atmega329pa)
-AM_CONDITIONAL(HAS_atmega329pa, test "x$HAS_atmega329pa" = "xyes")
-
-CHECK_AVR_DEVICE(atmega3290)
-AM_CONDITIONAL(HAS_atmega3290, test "x$HAS_atmega3290" = "xyes")
-
-CHECK_AVR_DEVICE(atmega3290a)
-AM_CONDITIONAL(HAS_atmega3290a, test "x$HAS_atmega3290a" = "xyes")
-
-CHECK_AVR_DEVICE(atmega3290p)
-AM_CONDITIONAL(HAS_atmega3290p, test "x$HAS_atmega3290p" = "xyes")
-
-CHECK_AVR_DEVICE(atmega3290pa)
-AM_CONDITIONAL(HAS_atmega3290pa, test "x$HAS_atmega3290pa" = "xyes")
-
-CHECK_AVR_DEVICE(atmega32c1)
-AM_CONDITIONAL(HAS_atmega32c1, test "x$HAS_atmega32c1" = "xyes")
-
-CHECK_AVR_DEVICE(atmega32hvb)
-AM_CONDITIONAL(HAS_atmega32hvb, test "x$HAS_atmega32hvb" = "xyes")
-
-CHECK_AVR_DEVICE(atmega32hvbrevb)
-AM_CONDITIONAL(HAS_atmega32hvbrevb, test "x$HAS_atmega32hvbrevb" = "xyes")
-
-CHECK_AVR_DEVICE(atmega32m1)
-AM_CONDITIONAL(HAS_atmega32m1, test "x$HAS_atmega32m1" = "xyes")
-
-CHECK_AVR_DEVICE(atmega32u4)
-AM_CONDITIONAL(HAS_atmega32u4, test "x$HAS_atmega32u4" = "xyes")
-
-CHECK_AVR_DEVICE(atmega32u6)
-AM_CONDITIONAL(HAS_atmega32u6, test "x$HAS_atmega32u6" = "xyes")
-
-CHECK_AVR_DEVICE(atmega406)
-AM_CONDITIONAL(HAS_atmega406, test "x$HAS_atmega406" = "xyes")
-
-CHECK_AVR_DEVICE(atmega644rfr2)
-AM_CONDITIONAL(HAS_atmega644rfr2, test "x$HAS_atmega644rfr2" = "xyes")
-
-CHECK_AVR_DEVICE(atmega64rfr2)
-AM_CONDITIONAL(HAS_atmega64rfr2, test "x$HAS_atmega64rfr2" = "xyes")
-
-CHECK_AVR_DEVICE(atmega64)
-AM_CONDITIONAL(HAS_atmega64, test "x$HAS_atmega64" = "xyes")
-
-CHECK_AVR_DEVICE(atmega64a)
-AM_CONDITIONAL(HAS_atmega64a, test "x$HAS_atmega64a" = "xyes")
-
-CHECK_AVR_DEVICE(atmega640)
-AM_CONDITIONAL(HAS_atmega640, test "x$HAS_atmega640" = "xyes")
-
-CHECK_AVR_DEVICE(atmega644)
-AM_CONDITIONAL(HAS_atmega644, test "x$HAS_atmega644" = "xyes")
-
-CHECK_AVR_DEVICE(atmega644a)
-AM_CONDITIONAL(HAS_atmega644a, test "x$HAS_atmega644a" = "xyes")
-
-CHECK_AVR_DEVICE(atmega644p)
-AM_CONDITIONAL(HAS_atmega644p, test "x$HAS_atmega644p" = "xyes")
-
-CHECK_AVR_DEVICE(atmega644pa)
-AM_CONDITIONAL(HAS_atmega644pa, test "x$HAS_atmega644pa" = "xyes")
-
-CHECK_AVR_DEVICE(atmega645)
-AM_CONDITIONAL(HAS_atmega645, test "x$HAS_atmega645" = "xyes")
-
-CHECK_AVR_DEVICE(atmega645a)
-AM_CONDITIONAL(HAS_atmega645a, test "x$HAS_atmega645a" = "xyes")
-
-CHECK_AVR_DEVICE(atmega645p)
-AM_CONDITIONAL(HAS_atmega645p, test "x$HAS_atmega645p" = "xyes")
-
-CHECK_AVR_DEVICE(atmega6450)
-AM_CONDITIONAL(HAS_atmega6450, test "x$HAS_atmega6450" = "xyes")
-
-CHECK_AVR_DEVICE(atmega6450a)
-AM_CONDITIONAL(HAS_atmega6450a, test "x$HAS_atmega6450a" = "xyes")
-
-CHECK_AVR_DEVICE(atmega6450p)
-AM_CONDITIONAL(HAS_atmega6450p, test "x$HAS_atmega6450p" = "xyes")
-
-CHECK_AVR_DEVICE(atmega649)
-AM_CONDITIONAL(HAS_atmega649, test "x$HAS_atmega649" = "xyes")
-
-CHECK_AVR_DEVICE(atmega649a)
-AM_CONDITIONAL(HAS_atmega649a, test "x$HAS_atmega649a" = "xyes")
-
-CHECK_AVR_DEVICE(atmega649p)
-AM_CONDITIONAL(HAS_atmega649p, test "x$HAS_atmega649p" = "xyes")
-
-CHECK_AVR_DEVICE(atmega6490)
-AM_CONDITIONAL(HAS_atmega6490, test "x$HAS_atmega6490" = "xyes")
-
-CHECK_AVR_DEVICE(atmega6490a)
-AM_CONDITIONAL(HAS_atmega6490a, test "x$HAS_atmega6490a" = "xyes")
-
-CHECK_AVR_DEVICE(atmega6490p)
-AM_CONDITIONAL(HAS_atmega6490p, test "x$HAS_atmega6490p" = "xyes")
-
-CHECK_AVR_DEVICE(atmega64c1)
-AM_CONDITIONAL(HAS_atmega64c1, test "x$HAS_atmega64c1" = "xyes")
-
-CHECK_AVR_DEVICE(atmega64hve)
-AM_CONDITIONAL(HAS_atmega64hve, test "x$HAS_atmega64hve" = "xyes")
-
-CHECK_AVR_DEVICE(atmega64hve2)
-AM_CONDITIONAL(HAS_atmega64hve2, test "x$HAS_atmega64hve2" = "xyes")
-
-CHECK_AVR_DEVICE(atmega64m1)
-AM_CONDITIONAL(HAS_atmega64m1, test "x$HAS_atmega64m1" = "xyes")
-
-CHECK_AVR_DEVICE(atmega128rfa1)
-AM_CONDITIONAL(HAS_atmega128rfa1, test "x$HAS_atmega128rfa1" = "xyes")
-
-CHECK_AVR_DEVICE(m3000)
-AM_CONDITIONAL(HAS_m3000, test "x$HAS_m3000" = "xyes")
-
-
-
-#avr51
-CHECK_AVR_DEVICE(avr51)
-AM_CONDITIONAL(HAS_avr51, test "x$HAS_avr51" = "xyes")
-
-AM_CONDITIONAL(HAS_atmega128, true)
-
-CHECK_AVR_DEVICE(atmega128a)
-AM_CONDITIONAL(HAS_atmega128a, test "x$HAS_atmega128a" = "xyes")
-
-CHECK_AVR_DEVICE(atmega1280)
-AM_CONDITIONAL(HAS_atmega1280, test "x$HAS_atmega1280" = "xyes")
-
-CHECK_AVR_DEVICE(atmega1281)
-AM_CONDITIONAL(HAS_atmega1281, test "x$HAS_atmega1281" = "xyes")
-
-CHECK_AVR_DEVICE(atmega1284)
-AM_CONDITIONAL(HAS_atmega1284, test "x$HAS_atmega1284" = "xyes")
-
-CHECK_AVR_DEVICE(atmega1284p)
-AM_CONDITIONAL(HAS_atmega1284p, test "x$HAS_atmega1284p" = "xyes")
-
-CHECK_AVR_DEVICE(at90can128)
-AM_CONDITIONAL(HAS_at90can128, test "x$HAS_at90can128" = "xyes")
-
-CHECK_AVR_DEVICE(at90usb1286)
-AM_CONDITIONAL(HAS_at90usb1286, test "x$HAS_at90usb1286" = "xyes")
-
-CHECK_AVR_DEVICE(at90usb1287)
-AM_CONDITIONAL(HAS_at90usb1287, test "x$HAS_at90usb1287" = "xyes")
-
-CHECK_AVR_DEVICE(atmega1284rfr2)
-AM_CONDITIONAL(HAS_atmega1284rfr2, test "x$HAS_atmega1284rfr2" = "xyes")
-
-CHECK_AVR_DEVICE(atmega128rfr2)
-AM_CONDITIONAL(HAS_atmega128rfr2, test "x$HAS_atmega128rfr2" = "xyes")
-
-
-# avr6
-CHECK_AVR_DEVICE(avr6)
-AM_CONDITIONAL(HAS_avr6, test "x$HAS_avr6" = "xyes")
-
-CHECK_AVR_DEVICE(atmega2560)
-AM_CONDITIONAL(HAS_atmega2560, test "x$HAS_atmega2560" = "xyes")
-
-CHECK_AVR_DEVICE(atmega2561)
-AM_CONDITIONAL(HAS_atmega2561, test "x$HAS_atmega2561" = "xyes")
-
-CHECK_AVR_DEVICE(atmega2564rfr2)
-AM_CONDITIONAL(HAS_atmega2564rfr2, test "x$HAS_atmega2564rfr2" = "xyes")
-
-CHECK_AVR_DEVICE(atmega256rfr2)
-AM_CONDITIONAL(HAS_atmega256rfr2, test "x$HAS_atmega256rfr2" = "xyes")
-
-
-# avrxmega2
-CHECK_AVR_DEVICE(avrxmega2)
-AM_CONDITIONAL(HAS_avrxmega2, test "x$HAS_avrxmega2" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega8e5)
-AM_CONDITIONAL(HAS_atxmega8e5, test "x$HAS_atxmega8e5" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega16a4)
-AM_CONDITIONAL(HAS_atxmega16a4, test "x$HAS_atxmega16a4" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega16a4u)
-AM_CONDITIONAL(HAS_atxmega16a4u, test "x$HAS_atxmega16a4u" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega16c4)
-AM_CONDITIONAL(HAS_atxmega16c4, test "x$HAS_atxmega16c4" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega16d4)
-AM_CONDITIONAL(HAS_atxmega16d4, test "x$HAS_atxmega16d4" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega32a4)
-AM_CONDITIONAL(HAS_atxmega32a4, test "x$HAS_atxmega32a4" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega32a4u)
-AM_CONDITIONAL(HAS_atxmega32a4u, test "x$HAS_atxmega32a4u" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega32c3)
-AM_CONDITIONAL(HAS_atxmega32c3, test "x$HAS_atxmega32c3" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega32c4)
-AM_CONDITIONAL(HAS_atxmega32c4, test "x$HAS_atxmega32c4" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega32d3)
-AM_CONDITIONAL(HAS_atxmega32d3, test "x$HAS_atxmega32d3" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega32d4)
-AM_CONDITIONAL(HAS_atxmega32d4, test "x$HAS_atxmega32d4" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega32e5)
-AM_CONDITIONAL(HAS_atxmega32e5, test "x$HAS_atxmega32e5" = "xyes")
-
-
-# avrxmega3
-CHECK_AVR_DEVICE(avrxmega3)
-AM_CONDITIONAL(HAS_avrxmega3, test "x$HAS_avrxmega3" = "xyes")
-
-
-# avrxmega4
-CHECK_AVR_DEVICE(avrxmega4)
-AM_CONDITIONAL(HAS_avrxmega4, test "x$HAS_avrxmega4" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega64a3)
-AM_CONDITIONAL(HAS_atxmega64a3, test "x$HAS_atxmega64a3" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega64a3u)
-AM_CONDITIONAL(HAS_atxmega64a3u, test "x$HAS_atxmega64a3u" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega64a4u)
-AM_CONDITIONAL(HAS_atxmega64a4u, test "x$HAS_atxmega64a4u" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega64b1)
-AM_CONDITIONAL(HAS_atxmega64b1, test "x$HAS_atxmega64b1" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega64b3)
-AM_CONDITIONAL(HAS_atxmega64b3, test "x$HAS_atxmega64b3" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega64c3)
-AM_CONDITIONAL(HAS_atxmega64c3, test "x$HAS_atxmega64c3" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega64d3)
-AM_CONDITIONAL(HAS_atxmega64d3, test "x$HAS_atxmega64d3" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega64d4)
-AM_CONDITIONAL(HAS_atxmega64d4, test "x$HAS_atxmega64d4" = "xyes")
-
-
-# avrxmega5
-CHECK_AVR_DEVICE(avrxmega5)
-AM_CONDITIONAL(HAS_avrxmega5, test "x$HAS_avrxmega5" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega64a1)
-AM_CONDITIONAL(HAS_atxmega64a1, test "x$HAS_atxmega64a1" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega64a1u)
-AM_CONDITIONAL(HAS_atxmega64a1u, test "x$HAS_atxmega64a1u" = "xyes")
-
-
-# avrxmega6
-CHECK_AVR_DEVICE(avrxmega6)
-AM_CONDITIONAL(HAS_avrxmega6, test "x$HAS_avrxmega6" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega128a3)
-AM_CONDITIONAL(HAS_atxmega128a3, test "x$HAS_atxmega128a3" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega128a3u)
-AM_CONDITIONAL(HAS_atxmega128a3u, test "x$HAS_atxmega128a3u" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega128b1)
-AM_CONDITIONAL(HAS_atxmega128b1, test "x$HAS_atxmega128b1" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega128b3)
-AM_CONDITIONAL(HAS_atxmega128b3, test "x$HAS_atxmega128b3" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega128c3)
-AM_CONDITIONAL(HAS_atxmega128c3, test "x$HAS_atxmega128c3" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega128d3)
-AM_CONDITIONAL(HAS_atxmega128d3, test "x$HAS_atxmega128d3" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega128d4)
-AM_CONDITIONAL(HAS_atxmega128d4, test "x$HAS_atxmega128d4" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega192a3)
-AM_CONDITIONAL(HAS_atxmega192a3, test "x$HAS_atxmega192a3" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega192a3u)
-AM_CONDITIONAL(HAS_atxmega192a3u, test "x$HAS_atxmega192a3u" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega192c3)
-AM_CONDITIONAL(HAS_atxmega192c3, test "x$HAS_atxmega192c3" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega192d3)
-AM_CONDITIONAL(HAS_atxmega192d3, test "x$HAS_atxmega192d3" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega256a3)
-AM_CONDITIONAL(HAS_atxmega256a3, test "x$HAS_atxmega256a3" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega256a3u)
-AM_CONDITIONAL(HAS_atxmega256a3u, test "x$HAS_atxmega256a3u" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega256a3b)
-AM_CONDITIONAL(HAS_atxmega256a3b, test "x$HAS_atxmega256a3b" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega256a3bu)
-AM_CONDITIONAL(HAS_atxmega256a3bu, test "x$HAS_atxmega256a3bu" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega256c3)
-AM_CONDITIONAL(HAS_atxmega256c3, test "x$HAS_atxmega256c3" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega256d3)
-AM_CONDITIONAL(HAS_atxmega256d3, test "x$HAS_atxmega256d3" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega384c3)
-AM_CONDITIONAL(HAS_atxmega384c3, test "x$HAS_atxmega384c3" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega384d3)
-AM_CONDITIONAL(HAS_atxmega384d3, test "x$HAS_atxmega384d3" = "xyes")
-
-# avrxmega7
-CHECK_AVR_DEVICE(avrxmega7)
-AM_CONDITIONAL(HAS_avrxmega7, test "x$HAS_avrxmega7" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega128a1)
-AM_CONDITIONAL(HAS_atxmega128a1, test "x$HAS_atxmega128a1" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega128a1u)
-AM_CONDITIONAL(HAS_atxmega128a1u, test "x$HAS_atxmega128a1u" = "xyes")
-
-CHECK_AVR_DEVICE(atxmega128a4u)
-AM_CONDITIONAL(HAS_atxmega128a4u, test "x$HAS_atxmega128a4u" = "xyes")
-
-
-# avrtiny
-CHECK_AVR_DEVICE(avrtiny)
-AM_CONDITIONAL(HAS_avrtiny, test "x$HAS_avrtiny" = "xyes")
-
-CHECK_AVR_DEVICE(attiny4)
-AM_CONDITIONAL(HAS_attiny4, test "x$HAS_attiny4" = "xyes")
-
-CHECK_AVR_DEVICE(attiny5)
-AM_CONDITIONAL(HAS_attiny5, test "x$HAS_attiny5" = "xyes")
+dnl Check whether options like -mdouble=64 act as a multilib selector,
+dnl i.e. $CC will mention it like @mdouble64 with $CC -print-multi-lib.
+dnl If so, set DIR_$2=$3 and DIR_$2=<empty>, otherwise.  $3 is the
+dnl multi-subdirectory associated to option $1.  In addition, set automake
+dnl variable HAS_MULTIOPT_$2 to 0 or 1 depending on the result.
+dnl The only consumer of this test is Device.am which mlib-gen.py uses to
+dnl produce ./avr/devices/<device>/Makefile.am.
+AC_DEFUN(
+  CHECK_MULTI_OPTION,
+  [
+    old_CC=${CC}
+    CC=`echo "${CC}" | sed 's/-mmcu=avr.//'`
+    AC_MSG_CHECKING(whether ${CC} supports $1 as a multilib selector)
 
-CHECK_AVR_DEVICE(attiny9)
-AM_CONDITIONAL(HAS_attiny9, test "x$HAS_attiny9" = "xyes")
+    pml=`${CC} -print-multi-lib | sed 's/@/ -/g'`
+    opt=`echo "$1" | sed 's/-/\\\\-/g'`
+    if echo "$pml" | grep -e "$opt" > /dev/null 2>&1; then
+       AC_MSG_RESULT([yes, in $3])
+       DIR_$2=$3
+    else
+       AC_MSG_RESULT(no)
+       DIR_$2=
+    fi
+    CC=${old_CC}
+    AC_SUBST(DIR_$2)
+    AM_CONDITIONAL(HAS_MULTIOPT_$2, test "x${DIR_$2}" != "x")
+  ]
+)
 
-CHECK_AVR_DEVICE(attiny10)
-AM_CONDITIONAL(HAS_attiny10, test "x$HAS_attiny10" = "xyes")
+dnl Check whether multilib variant $1 is supported by $CC where $1 is
+dnl a multilib directory like "." or "avr25/tiny-stack" as printed by
+dnl $CC -print-multi-lib.  $2 is to be used both as part of a variable
+dnl name and as part of a subdirectory name in avr/lib.  The checks are
+dnl issued by multilib.m4 which is generated by mlib-gen.py.
+AC_DEFUN(
+  CHECK_MULTI_VARIANT,
+  [
+    old_CC=${CC}
+    CC=`echo "${CC}" | sed 's/-mmcu=avr.//'`
+    AC_MSG_CHECKING(whether ${CC} supports $1 as a multilib path)
+    mdir=`echo "$1" | sed -e 's/\\./\\\\./g'`
+    pml=`${CC} -print-multi-lib | grep -e "^${mdir};"`
+    if test "x$pml" != "x"; then
+       MULTIDIR_$2=$1
+       MULTIOPT_$2=`echo "${pml}" | cut -d ';' -f 2 | sed 's/@/ -/g'`
+       AC_MSG_RESULT([yes, with options:${MULTIOPT_$2}])
+    else
+       MULTIDIR_$2=
+       MULTIOPT_$2=
+       AC_MSG_RESULT(no)
+    fi
+    CC=${old_CC}
+    AC_SUBST(MULTIDIR_$2)
+    AC_SUBST(MULTIOPT_$2)
+    AM_CONDITIONAL(HAS_MULTI_$2, test "x${MULTIDIR_$2}" != "x")
+  ]
+)
 
-CHECK_AVR_DEVICE(attiny20)
-AM_CONDITIONAL(HAS_attiny20, test "x$HAS_attiny20" = "xyes")
+# Used by Device.am i.e. avr/devices/<device>/Makefile.am.
+CHECK_MULTI_OPTION([-mdouble=32], [double32], [double32])
+CHECK_MULTI_OPTION([-mdouble=64], [double64], [double64])
+CHECK_MULTI_OPTION([-mlong-double=32], [long_double32], [long-double32])
+CHECK_MULTI_OPTION([-mlong-double=64], [long_double64], [long-double64])
 
-CHECK_AVR_DEVICE(attiny40)
-AM_CONDITIONAL(HAS_attiny40, test "x$HAS_attiny40" = "xyes")
+# avr1
+AM_CONDITIONAL(HAS_avr1, true)
+DIR_avr1=avr1
+AC_SUBST(DIR_avr1)
 
+m4_include([devices.m4])
 
+dnl The following include must preceed multilib.m4 and is only
+dnl needed with avr-gcc v4.9 or older, namely if !HAS_DEV_LIB.
+m4_include([devlist.m4])
 
+m4_include([multilib.m4])
 
 # Generate all files from *.in sources.
 
 AC_CONFIG_FILES([
 	Makefile
 	avr-libc.spec
-	avr/Makefile
-	avr/lib/Makefile
 	common/Makefile
 	crt1/Makefile
 	crt1/iosym/Makefile
@@ -1302,353 +607,6 @@ AC_CONFIG_FILES([
 	devtools/Makefile
 ])
 
-#avr1 and avr2
-AC_CONFIG_FILES([
-	avr/lib/avr2/Makefile
-	avr/lib/avr2/at90s1200/Makefile
-	avr/lib/avr2/at90s4414/Makefile
-	avr/lib/avr2/at90s4434/Makefile
-	avr/lib/avr2/at90s8515/Makefile
-	avr/lib/avr2/at90c8534/Makefile
-	avr/lib/avr2/at90s8535/Makefile
-	avr/lib/avr2/attiny11/Makefile
-	avr/lib/avr2/attiny12/Makefile
-	avr/lib/avr2/attiny15/Makefile
-	avr/lib/avr2/attiny28/Makefile
-])
-
-#avr2/tiny-stack
-AC_CONFIG_FILES([
-	avr/lib/avr2/tiny-stack/Makefile
-	avr/lib/avr2/tiny-stack/at90s2313/Makefile
-	avr/lib/avr2/tiny-stack/at90s2323/Makefile
-	avr/lib/avr2/tiny-stack/at90s2333/Makefile
-	avr/lib/avr2/tiny-stack/at90s2343/Makefile
-	avr/lib/avr2/tiny-stack/attiny22/Makefile
-	avr/lib/avr2/tiny-stack/attiny26/Makefile
-	avr/lib/avr2/tiny-stack/at90s4433/Makefile
-])
-
-#avr25
-AC_CONFIG_FILES([
-	avr/lib/avr25/Makefile
-	avr/lib/avr25/at86rf401/Makefile
-	avr/lib/avr25/ata5272/Makefile
-	avr/lib/avr25/ata6616c/Makefile
-	avr/lib/avr25/attiny4313/Makefile
-	avr/lib/avr25/attiny43u/Makefile
-	avr/lib/avr25/attiny44/Makefile
-	avr/lib/avr25/attiny44a/Makefile
-	avr/lib/avr25/attiny441/Makefile
-	avr/lib/avr25/attiny45/Makefile
-	avr/lib/avr25/attiny461/Makefile
-	avr/lib/avr25/attiny461a/Makefile
-	avr/lib/avr25/attiny48/Makefile
-	avr/lib/avr25/attiny828/Makefile
-	avr/lib/avr25/attiny84/Makefile
-	avr/lib/avr25/attiny84a/Makefile
-	avr/lib/avr25/attiny841/Makefile
-	avr/lib/avr25/attiny85/Makefile
-	avr/lib/avr25/attiny861/Makefile
-	avr/lib/avr25/attiny861a/Makefile
-	avr/lib/avr25/attiny87/Makefile
-	avr/lib/avr25/attiny88/Makefile
-])
-
-#avr25/tiny-stack
-AC_CONFIG_FILES([
-	avr/lib/avr25/tiny-stack/Makefile
-	avr/lib/avr25/tiny-stack/attiny13/Makefile
-	avr/lib/avr25/tiny-stack/attiny13a/Makefile
-	avr/lib/avr25/tiny-stack/attiny2313/Makefile
-	avr/lib/avr25/tiny-stack/attiny2313a/Makefile
-	avr/lib/avr25/tiny-stack/attiny24/Makefile
-	avr/lib/avr25/tiny-stack/attiny24a/Makefile
-	avr/lib/avr25/tiny-stack/attiny25/Makefile
-	avr/lib/avr25/tiny-stack/attiny261/Makefile
-	avr/lib/avr25/tiny-stack/attiny261a/Makefile
-])
-
-#avr3
-AC_CONFIG_FILES([
-	avr/lib/avr3/Makefile
-	avr/lib/avr3/at43usb355/Makefile
-	avr/lib/avr3/at76c711/Makefile
-])
-
-#avr31
-AC_CONFIG_FILES([
-	avr/lib/avr31/Makefile
-	avr/lib/avr31/atmega103/Makefile
-	avr/lib/avr31/at43usb320/Makefile
-])
-
-#avr35
-AC_CONFIG_FILES([
-	avr/lib/avr35/Makefile
-	avr/lib/avr35/at90usb82/Makefile
-	avr/lib/avr35/at90usb162/Makefile
-	avr/lib/avr35/ata5505/Makefile
-	avr/lib/avr35/ata6617c/Makefile
-	avr/lib/avr35/ata664251/Makefile
-	avr/lib/avr35/atmega8u2/Makefile
-	avr/lib/avr35/atmega16u2/Makefile
-	avr/lib/avr35/atmega32u2/Makefile
-	avr/lib/avr35/attiny167/Makefile
-	avr/lib/avr35/attiny1634/Makefile
-])
-
-#avr4
-AC_CONFIG_FILES([
-	avr/lib/avr4/Makefile
-	avr/lib/avr4/ata6285/Makefile
-	avr/lib/avr4/ata6286/Makefile
-	avr/lib/avr4/ata6289/Makefile
-	avr/lib/avr4/ata6612c/Makefile
-	avr/lib/avr4/atmega48/Makefile
-	avr/lib/avr4/atmega48a/Makefile
-	avr/lib/avr4/atmega48pa/Makefile
-	avr/lib/avr4/atmega48pb/Makefile
-	avr/lib/avr4/atmega48p/Makefile
-	avr/lib/avr4/atmega8/Makefile
-	avr/lib/avr4/atmega8a/Makefile
-	avr/lib/avr4/atmega88/Makefile
-	avr/lib/avr4/atmega88a/Makefile
-	avr/lib/avr4/atmega88p/Makefile
-	avr/lib/avr4/atmega88pa/Makefile
-	avr/lib/avr4/atmega88pb/Makefile
-	avr/lib/avr4/atmega8515/Makefile
-	avr/lib/avr4/atmega8535/Makefile
-	avr/lib/avr4/atmega8hva/Makefile
-	avr/lib/avr4/at90pwm1/Makefile
-	avr/lib/avr4/at90pwm2/Makefile
-	avr/lib/avr4/at90pwm2b/Makefile
-	avr/lib/avr4/at90pwm3/Makefile
-	avr/lib/avr4/at90pwm3b/Makefile
-	avr/lib/avr4/at90pwm81/Makefile
-])
-
-#avr5
-AC_CONFIG_FILES([
-	avr/lib/avr5/Makefile
-	avr/lib/avr5/at90can32/Makefile
-	avr/lib/avr5/at90can64/Makefile
-	avr/lib/avr5/at90pwm216/Makefile
-	avr/lib/avr5/at90pwm316/Makefile
-	avr/lib/avr5/at90pwm161/Makefile
-	avr/lib/avr5/at90scr100/Makefile
-	avr/lib/avr5/at90usb646/Makefile
-	avr/lib/avr5/at90usb647/Makefile
-	avr/lib/avr5/at94k/Makefile 
-	avr/lib/avr5/ata5702m322/Makefile 
-	avr/lib/avr5/ata5782/Makefile 
-	avr/lib/avr5/ata5790/Makefile 
-	avr/lib/avr5/ata5790n/Makefile 
-	avr/lib/avr5/ata5795/Makefile 
-	avr/lib/avr5/ata5831/Makefile 
-	avr/lib/avr5/ata6613c/Makefile 
-	avr/lib/avr5/ata6614q/Makefile 
-	avr/lib/avr5/atmega16/Makefile
-	avr/lib/avr5/atmega16a/Makefile
-	avr/lib/avr5/atmega161/Makefile
-	avr/lib/avr5/atmega162/Makefile
-	avr/lib/avr5/atmega163/Makefile
-	avr/lib/avr5/atmega164a/Makefile
-	avr/lib/avr5/atmega164p/Makefile
-	avr/lib/avr5/atmega164pa/Makefile
-	avr/lib/avr5/atmega165/Makefile
-	avr/lib/avr5/atmega165a/Makefile
-	avr/lib/avr5/atmega165p/Makefile
-	avr/lib/avr5/atmega165pa/Makefile
-	avr/lib/avr5/atmega168/Makefile
-	avr/lib/avr5/atmega168a/Makefile
-	avr/lib/avr5/atmega168p/Makefile
-	avr/lib/avr5/atmega168pa/Makefile
-	avr/lib/avr5/atmega169/Makefile
-	avr/lib/avr5/atmega169a/Makefile
-	avr/lib/avr5/atmega169p/Makefile
-	avr/lib/avr5/atmega169pa/Makefile
-	avr/lib/avr5/atmega16hva/Makefile
-	avr/lib/avr5/atmega16hva2/Makefile
-	avr/lib/avr5/atmega16hvb/Makefile
-	avr/lib/avr5/atmega16hvbrevb/Makefile
-	avr/lib/avr5/atmega16m1/Makefile
-	avr/lib/avr5/atmega16u4/Makefile
-	avr/lib/avr5/atmega32/Makefile
-	avr/lib/avr5/atmega32a/Makefile
-	avr/lib/avr5/atmega323/Makefile
-	avr/lib/avr5/atmega324a/Makefile
-	avr/lib/avr5/atmega324p/Makefile
-	avr/lib/avr5/atmega324pa/Makefile
-	avr/lib/avr5/atmega325/Makefile
-	avr/lib/avr5/atmega325a/Makefile
-	avr/lib/avr5/atmega325p/Makefile
-	avr/lib/avr5/atmega325pa/Makefile
-	avr/lib/avr5/atmega3250/Makefile
-	avr/lib/avr5/atmega3250a/Makefile
-	avr/lib/avr5/atmega3250p/Makefile
-	avr/lib/avr5/atmega3250pa/Makefile
-	avr/lib/avr5/atmega328/Makefile
-	avr/lib/avr5/atmega328p/Makefile
-	avr/lib/avr5/atmega329/Makefile
-	avr/lib/avr5/atmega329a/Makefile
-	avr/lib/avr5/atmega329p/Makefile
-	avr/lib/avr5/atmega329pa/Makefile
-	avr/lib/avr5/atmega3290/Makefile
-	avr/lib/avr5/atmega3290a/Makefile
-	avr/lib/avr5/atmega3290p/Makefile
-	avr/lib/avr5/atmega3290pa/Makefile
-	avr/lib/avr5/atmega32c1/Makefile
-	avr/lib/avr5/atmega32hvb/Makefile
-	avr/lib/avr5/atmega32hvbrevb/Makefile
-	avr/lib/avr5/atmega32m1/Makefile
-	avr/lib/avr5/atmega32u4/Makefile
-	avr/lib/avr5/atmega32u6/Makefile
-	avr/lib/avr5/atmega406/Makefile
-	avr/lib/avr5/atmega64rfr2/Makefile
-	avr/lib/avr5/atmega644rfr2/Makefile
-	avr/lib/avr5/atmega64/Makefile
-	avr/lib/avr5/atmega64a/Makefile
-	avr/lib/avr5/atmega640/Makefile
-	avr/lib/avr5/atmega644/Makefile
-	avr/lib/avr5/atmega644a/Makefile
-	avr/lib/avr5/atmega644p/Makefile
-	avr/lib/avr5/atmega644pa/Makefile
-	avr/lib/avr5/atmega645/Makefile
-	avr/lib/avr5/atmega645a/Makefile
-	avr/lib/avr5/atmega645p/Makefile
-	avr/lib/avr5/atmega6450/Makefile
-	avr/lib/avr5/atmega6450a/Makefile
-	avr/lib/avr5/atmega6450p/Makefile
-	avr/lib/avr5/atmega649/Makefile
-	avr/lib/avr5/atmega649a/Makefile
-	avr/lib/avr5/atmega649p/Makefile
-	avr/lib/avr5/atmega6490/Makefile
-	avr/lib/avr5/atmega6490a/Makefile
-	avr/lib/avr5/atmega6490p/Makefile
-	avr/lib/avr5/atmega64c1/Makefile
-	avr/lib/avr5/atmega64hve/Makefile
-	avr/lib/avr5/atmega64hve2/Makefile
-	avr/lib/avr5/atmega64m1/Makefile
-	avr/lib/avr5/m3000/Makefile
-])
-
-#avr51
-AC_CONFIG_FILES([
-	avr/lib/avr51/Makefile
-	avr/lib/avr51/atmega128/Makefile
-	avr/lib/avr51/atmega128a/Makefile
-	avr/lib/avr51/atmega1280/Makefile
-	avr/lib/avr51/atmega1281/Makefile
-	avr/lib/avr51/atmega1284/Makefile
-	avr/lib/avr51/atmega1284p/Makefile
-	avr/lib/avr51/atmega128rfa1/Makefile
-	avr/lib/avr51/atmega128rfr2/Makefile
-	avr/lib/avr51/atmega1284rfr2/Makefile
-	avr/lib/avr51/at90can128/Makefile
-	avr/lib/avr51/at90usb1286/Makefile
-	avr/lib/avr51/at90usb1287/Makefile
-])
-
-#avr6
-AC_CONFIG_FILES([
-	avr/lib/avr6/Makefile
-	avr/lib/avr6/atmega2560/Makefile
-	avr/lib/avr6/atmega2561/Makefile
-	avr/lib/avr6/atmega256rfr2/Makefile
-	avr/lib/avr6/atmega2564rfr2/Makefile
-])
-
-# avrxmega2
-AC_CONFIG_FILES([
-	avr/lib/avrxmega2/Makefile
-	avr/lib/avrxmega2/atxmega8e5/Makefile
-	avr/lib/avrxmega2/atxmega16a4/Makefile
-	avr/lib/avrxmega2/atxmega16a4u/Makefile
-	avr/lib/avrxmega2/atxmega16c4/Makefile
-	avr/lib/avrxmega2/atxmega16d4/Makefile
-	avr/lib/avrxmega2/atxmega32a4/Makefile
-	avr/lib/avrxmega2/atxmega32a4u/Makefile
-	avr/lib/avrxmega2/atxmega32c3/Makefile
-	avr/lib/avrxmega2/atxmega32c4/Makefile
-	avr/lib/avrxmega2/atxmega32d3/Makefile
-	avr/lib/avrxmega2/atxmega32d4/Makefile
-	avr/lib/avrxmega2/atxmega32e5/Makefile
-])
-
-# avrxmega3
-AC_CONFIG_FILES([
-	avr/lib/avrxmega3/Makefile
-])
-
-# avrxmega3/short-calls
-AC_CONFIG_FILES([
-	avr/lib/avrxmega3/short-calls/Makefile
-])
-
-# avrxmega4
-AC_CONFIG_FILES([
-	avr/lib/avrxmega4/Makefile
-	avr/lib/avrxmega4/atxmega64a3/Makefile
-	avr/lib/avrxmega4/atxmega64a3u/Makefile
-	avr/lib/avrxmega4/atxmega64a4u/Makefile
-	avr/lib/avrxmega4/atxmega64b1/Makefile
-	avr/lib/avrxmega4/atxmega64b3/Makefile
-	avr/lib/avrxmega4/atxmega64c3/Makefile
-	avr/lib/avrxmega4/atxmega64d3/Makefile
-	avr/lib/avrxmega4/atxmega64d4/Makefile
-])
-
-# avrxmega5
-AC_CONFIG_FILES([
-	avr/lib/avrxmega5/Makefile
-	avr/lib/avrxmega5/atxmega64a1/Makefile
-	avr/lib/avrxmega5/atxmega64a1u/Makefile
-])
-
-# avrxmega6
-AC_CONFIG_FILES([
-	avr/lib/avrxmega6/Makefile
-	avr/lib/avrxmega6/atxmega128a3/Makefile
-	avr/lib/avrxmega6/atxmega128a3u/Makefile
-	avr/lib/avrxmega6/atxmega128b1/Makefile
-	avr/lib/avrxmega6/atxmega128b3/Makefile
-	avr/lib/avrxmega6/atxmega128c3/Makefile
-	avr/lib/avrxmega6/atxmega128d3/Makefile
-	avr/lib/avrxmega6/atxmega128d4/Makefile
-	avr/lib/avrxmega6/atxmega192a3/Makefile
-	avr/lib/avrxmega6/atxmega192a3u/Makefile
-	avr/lib/avrxmega6/atxmega192c3/Makefile
-	avr/lib/avrxmega6/atxmega192d3/Makefile
-	avr/lib/avrxmega6/atxmega256a3/Makefile
-	avr/lib/avrxmega6/atxmega256a3u/Makefile
-	avr/lib/avrxmega6/atxmega256a3b/Makefile
-	avr/lib/avrxmega6/atxmega256a3bu/Makefile
-	avr/lib/avrxmega6/atxmega256c3/Makefile
-	avr/lib/avrxmega6/atxmega256d3/Makefile
-	avr/lib/avrxmega6/atxmega384c3/Makefile
-	avr/lib/avrxmega6/atxmega384d3/Makefile
-])
-
-# avrxmega7
-AC_CONFIG_FILES([
-	avr/lib/avrxmega7/Makefile
-	avr/lib/avrxmega7/atxmega128a1/Makefile
-	avr/lib/avrxmega7/atxmega128a1u/Makefile
-	avr/lib/avrxmega7/atxmega128a4u/Makefile
-])
-
-
-# avrtiny
-AC_CONFIG_FILES([
-	avr/lib/avrtiny/Makefile
-	avr/lib/avrtiny/attiny4/Makefile
-	avr/lib/avrtiny/attiny5/Makefile
-	avr/lib/avrtiny/attiny9/Makefile
-	avr/lib/avrtiny/attiny10/Makefile
-	avr/lib/avrtiny/attiny20/Makefile
-	avr/lib/avrtiny/attiny40/Makefile
-])
-
+m4_include([files.m4])
 
 AC_OUTPUT
Index: devtools/Architecture.am
===================================================================
--- devtools/Architecture.am	(revision 2548)
+++ devtools/Architecture.am	(working copy)
@@ -28,28 +28,26 @@
 # POSSIBILITY OF SUCH DAMAGE.
 #
 
-SUBDIRS = <<dev_subdirs>>
-
 AVR_TARGET          = <<arh>>
 AVR_TARGET_DEFS     = <<lib_defs>>
-AVR_TARGET_CFLAGS   = <<lib_cflags>>
-AVR_TARGET_ASFLAGS  = <<lib_asflags>>
-AVR_INSTALL_DIR     = <<install_dir>>
+AVR_TARGET_CFLAGS   = $(MULTIOPT_<<ident>>) <<lib_cflags>>
+AVR_TARGET_ASFLAGS  = $(MULTIOPT_<<ident>>) <<lib_asflags>>
+AVR_INSTALL_DIR     = $(MULTIDIR_<<ident>>)
 
 VPATH = $(top_srcdir)/libc/stdlib:$(top_srcdir)/libc/pmstring:$(top_srcdir)/libc/string:$(top_srcdir)/libc/misc:$(top_srcdir)/libc/stdio:$(top_srcdir)/libm/fplib:$(top_srcdir)/libc/time
 
-if HAS_<<arh>>
+if HAS_MULTI_<<ident>>
 
-AVRLIB_DEVLIST =
-if HAS_<<dev>>
-  AVRLIB_DEVLIST += <<dev>>
-endif	# <<dev>>
+if !HAS_DEV_LIB
+## Used by libc/misc/Rules.am
+AVRLIB_DEVLIST = $(DEVLIST_<<ident>>)
+endif
 
 AM_CPPFLAGS = -I$(top_srcdir)/common -I$(top_srcdir)/include -I$(top_builddir)/include
 
-AVRLIB_CFLAGS = @CDEBUG@ -Wall -W -Wstrict-prototypes -mmcu=$(AVR_TARGET) $(AVR_TARGET_DEFS) $(AVR_TARGET_CFLAGS)
+AVRLIB_CFLAGS = @CDEBUG@ -Wall -W -Wstrict-prototypes $(AVR_TARGET_DEFS) $(AVR_TARGET_CFLAGS)
 
-AVRLIB_ASFLAGS = -x assembler-with-cpp @ASDEBUG@ -mmcu=$(AVR_TARGET) $(AVR_TARGET_DEFS) $(AVR_TARGET_ASFLAGS)
+AVRLIB_ASFLAGS = -x assembler-with-cpp @ASDEBUG@ $(AVR_TARGET_DEFS) $(AVR_TARGET_ASFLAGS)
 
 AM_CFLAGS = $(AVRLIB_CFLAGS)
 AM_CCASFLAGS = $(AM_CPPFLAGS) $(AVRLIB_ASFLAGS)
Index: devtools/Avr.am
===================================================================
--- devtools/Avr.am	(revision 2548)
+++ devtools/Avr.am	(nonexistent)
@@ -1,30 +0,0 @@
-# Copyright (c) 2008  Anatoly Sokolov
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-#
-# * Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in
-#   the documentation and/or other materials provided with the
-#   distribution.
-# * Neither the name of the copyright holders nor the names of
-#   contributors may be used to endorse or promote products derived
-#   from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-#
-
-SUBDIRS = lib

Property changes on: devtools/Avr.am
___________________________________________________________________
Deleted: svn:eol-style
## -1 +0,0 ##
-native
\ No newline at end of property
Deleted: svn:keywords
## -1 +0,0 ##
-Author Id Date
\ No newline at end of property
Deleted: svn:mime-type
## -1 +0,0 ##
-text/plain
\ No newline at end of property
Index: devtools/Device.am
===================================================================
--- devtools/Device.am	(revision 2548)
+++ devtools/Device.am	(working copy)
@@ -39,11 +39,11 @@ else
 # avr-gcc > 5.1.0 expects crt file as crt<device name>.o and
 # device library in multi-lib directory itself
 AVR_TARGET_CRT      = crt<<dev>>.o
-AVR_INSTALL_DIR     = <<install_dir>>
+AVR_INSTALL_DIR     = $(MULTIDIR_<<dev>>)
 endif
 else
 AVR_TARGET_CRT      = <<crt>>
-AVR_INSTALL_DIR     = <<install_dir>>
+AVR_INSTALL_DIR     = $(MULTIDIR_<<dev>>)
 endif
 AVR_TARGET_DEFS     = <<crt_defs>>
 AVR_TARGET_CFLAGS   = <<crt_cflags>>
@@ -51,12 +51,12 @@ AVR_TARGET_ASFLAGS  = <<crt_asflags>>
 
 VPATH = $(top_srcdir)/crt1:$(top_srcdir)/libc/misc
 
+if HAS_<<dev>>
+
 if HAS_DEV_LIB
 include $(top_srcdir)/libc/misc/Rules.am
 endif
 
-if HAS_<<dev>>
-
 AM_CPPFLAGS = -I$(top_srcdir)/common -I$(top_srcdir)/include -I$(top_builddir)/include
 
 AVRLIB_CFLAGS = @CDEBUG@ -Wall -W -Wstrict-prototypes -mmcu=$(AVR_TARGET) $(AVR_TARGET_DEFS) $(AVR_TARGET_CFLAGS)
@@ -94,6 +94,39 @@ $(AVR_TARGET_CRT): gcrt1.o
 	rm -f $@
 	ln $< $@ || cp $< $@
 
+## If -mdouble=32/64 resp. -mlong-double=32/64 is mentioned in
+## avr-gcc -print-multi-lib -- which means that there is some multilib
+## variant that needs the respective option -- then just copy
+## crt<<dev>>.o and lib<<dev>>.a to the respective multilib-subfolder.
+
+if HAS_MULTIOPT_double64
+avrD64dir = $(avrdir)/$(DIR_double64)
+avrD64libdir = $(avrlibdir)/$(DIR_double64)
+avrD64_DATA = $(AVR_TARGET_CRT)
+avrD64_LIBRARIES = lib<<dev>>.a
+endif
+
+if HAS_MULTIOPT_double32
+avrD32dir = $(avrdir)/$(DIR_double32)
+avrD32libdir = $(avrlibdir)/$(DIR_double32)
+avrD32_DATA = $(AVR_TARGET_CRT)
+avrD32_LIBRARIES = lib<<dev>>.a
+endif
+
+if HAS_MULTIOPT_long_double64
+avrL64dir = $(avrdir)/$(DIR_long_double64)
+avrL64libdir = $(avrlibdir)/$(DIR_long_double64)
+avrL64_DATA = $(AVR_TARGET_CRT)
+avrL64_LIBRARIES = lib<<dev>>.a
+endif
+
+if HAS_MULTIOPT_long_double32
+avrL32dir = $(avrdir)/$(DIR_long_double32)
+avrL32libdir = $(avrlibdir)/$(DIR_long_double32)
+avrL32_DATA = $(AVR_TARGET_CRT)
+avrL32_LIBRARIES = lib<<dev>>.a
+endif
+
 else
 
 echo all distdir install installdirs clean distclean uninstall check:
Index: devtools/Lib.am
===================================================================
--- devtools/Lib.am	(revision 2548)
+++ devtools/Lib.am	(nonexistent)
@@ -1,30 +0,0 @@
-# Copyright (c) 2008  Anatoly Sokolov
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-#
-# * Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in
-#   the documentation and/or other materials provided with the
-#   distribution.
-# * Neither the name of the copyright holders nor the names of
-#   contributors may be used to endorse or promote products derived
-#   from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-#
-
-SUBDIRS = <<arh_subdirs>>

Property changes on: devtools/Lib.am
___________________________________________________________________
Deleted: svn:eol-style
## -1 +0,0 ##
-native
\ No newline at end of property
Deleted: svn:keywords
## -1 +0,0 ##
-Author Id Date
\ No newline at end of property
Deleted: svn:mime-type
## -1 +0,0 ##
-text/plain
\ No newline at end of property
Index: devtools/Makefile.am
===================================================================
--- devtools/Makefile.am	(revision 2548)
+++ devtools/Makefile.am	(working copy)
@@ -31,9 +31,8 @@
 
 EXTRA_DIST = \
     Architecture.am \
-    Avr.am \
     Device.am \
-    Lib.am \
     cr_check.py \
     gen-avr-lib-tree.sh \
+    mlib-gen.py \
     make-binary-dist.sh
Index: devtools/gen-avr-lib-tree.sh
===================================================================
--- devtools/gen-avr-lib-tree.sh	(revision 2548)
+++ devtools/gen-avr-lib-tree.sh	(working copy)
@@ -32,27 +32,38 @@
 # $Id$
 #
 
-# This is a script to automate the generation of the avr/lib/ tree. Since
-# there is a build directory for each device and each of those directories is
-# virtually the same, it is easier to maintain a single file instead of an
-# ever growing number of small Makefile.am fragments.
+# This is a script to automate the generation of the avr/lib/ and avr/devices
+# trees.  Since there is a build directory for each device and each of
+# those directories is virtually the same, it is easier to maintain a single
+# file instead of an ever growing number of small Makefile.am fragments.
+# This file basically contains which devices avr-libc is capable to support,
+# where each supported device is represented by a line that also specifies
+# additional options to be set when generating code for that device.
+# This information -- together with extra flags for the multilib variants
+# of the C libraries -- is dumped to files tmp-device-info and tmp-core-info
+# which is picked up by mlib-gen.py.  The latter script is the working horse
+# that pops ./ avr into existence.
 
-# Make sure that we are the top-level of the source tree. We will look for the
-# the AUTHORS file in the current dir and the parent. After that, we complain
-# and fatal error out.
-
-# Define the special flags for special sub-targets.
 
 PATH=/usr/xpg4/bin:$PATH
 
+# Define extra flags for out devices.  These flags MUST NOT be any multilib
+# option.  Multlib options are:
+#     -mmcu=* -msp8 -mshort-calls
+#     -mdouble=32 -mdouble=64 -mlong-double=32 -mlong-double=64.
+
 CFLAGS_SPACE="-mcall-prologues -Os"
-CFLAGS_TINY_STACK="-msp8 -mcall-prologues -Os"
-CFLAGS_SHORT_CALLS="-mshort-calls -mcall-prologues -Os"
 CFLAGS_BIG_MEMORY='-Os $(FNO_JUMP_TABLES)'
 CFLAGS_SPEED="-Os"
 
 ASFLAGS_SPEED="-DOPTIMIZE_SPEED"
 
+# The devices we support. Assigning a device to a specific variable like
+# AVR12_DEV_INFO is for historical reasons.  Today, a device is no more
+# "bound" to a core, and the assignment is just for easier maintaining
+# this file with its many entries.  The outcome will be that each device
+# ends up as a line in tmp-device-info to be picked up by mlib-gen.py.
+
 AVR12_DEV_INFO="\
 at90s1200:crts1200.o:${DEV_DEFS}:${CFLAGS_SPACE}:${DEV_ASFLAGS};\
 attiny11:crttn11.o:${DEV_DEFS}:${CFLAGS_SPACE}:${DEV_ASFLAGS};\
@@ -63,17 +74,14 @@ at90s4414:crts4414.o:${DEV_DEFS}:${CFLAG
 at90s4434:crts4434.o:${DEV_DEFS}:${CFLAGS_SPACE}:${DEV_ASFLAGS};\
 at90s8515:crts8515.o:${DEV_DEFS}:${CFLAGS_SPACE}:${DEV_ASFLAGS};\
 at90s8535:crts8535.o:${DEV_DEFS}:${CFLAGS_SPACE}:${DEV_ASFLAGS};\
-at90c8534:crtc8534.o:${DEV_DEFS}:${CFLAGS_SPACE}:${DEV_ASFLAGS}\
-"
-
-AVR12TS_DEV_INFO="\
-at90s2313:crts2313.o:${DEV_DEFS}:${CFLAGS_TINY_STACK}:${DEV_ASFLAGS};\
-at90s2323:crts2323.o:${DEV_DEFS}:${CFLAGS_TINY_STACK}:${DEV_ASFLAGS};\
-at90s2333:crts2333.o:${DEV_DEFS}:${CFLAGS_TINY_STACK}:${DEV_ASFLAGS};\
-at90s2343:crts2343.o:${DEV_DEFS}:${CFLAGS_TINY_STACK}:${DEV_ASFLAGS};\
-at90s4433:crts4433.o:${DEV_DEFS}:${CFLAGS_TINY_STACK}:${DEV_ASFLAGS};\
-attiny22:crttn22.o:${DEV_DEFS}:${CFLAGS_TINY_STACK}:${DEV_ASFLAGS};\
-attiny26:crttn26.o:${DEV_DEFS}:${CFLAGS_TINY_STACK}:${DEV_ASFLAGS}\
+at90c8534:crtc8534.o:${DEV_DEFS}:${CFLAGS_SPACE}:${DEV_ASFLAGS};\
+at90s2313:crts2313.o:${DEV_DEFS}:${CFLAGS_SPACE}:${DEV_ASFLAGS};\
+at90s2323:crts2323.o:${DEV_DEFS}:${CFLAGS_SPACE}:${DEV_ASFLAGS};\
+at90s2333:crts2333.o:${DEV_DEFS}:${CFLAGS_SPACE}:${DEV_ASFLAGS};\
+at90s2343:crts2343.o:${DEV_DEFS}:${CFLAGS_SPACE}:${DEV_ASFLAGS};\
+at90s4433:crts4433.o:${DEV_DEFS}:${CFLAGS_SPACE}:${DEV_ASFLAGS};\
+attiny22:crttn22.o:${DEV_DEFS}:${CFLAGS_SPACE}:${DEV_ASFLAGS};\
+attiny26:crttn26.o:${DEV_DEFS}:${CFLAGS_SPACE}:${DEV_ASFLAGS}\
 "
 
 AVR25_DEV_INFO="\
@@ -97,19 +105,16 @@ attiny85:crttn85.o:${DEV_DEFS}:${CFLAGS_
 attiny861:crttn861.o:${DEV_DEFS}:${CFLAGS_SPACE}:${DEV_ASFLAGS};\
 attiny861a:crttn861a.o:${DEV_DEFS}:${CFLAGS_SPACE}:${DEV_ASFLAGS};\
 attiny87:crttn87.o:${DEV_DEFS}:${CFLAGS_SPACE}:${DEV_ASFLAGS};\
-attiny88:crttn88.o:${DEV_DEFS}:${CFLAGS_SPACE}:${DEV_ASFLAGS}\
-"
-
-AVR25TS_DEV_INFO="\
-attiny13:crttn13.o:${DEV_DEFS}:${CFLAGS_TINY_STACK}:${DEV_ASFLAGS};\
-attiny13a:crttn13a.o:${DEV_DEFS}:${CFLAGS_TINY_STACK}:${DEV_ASFLAGS};\
-attiny2313:crttn2313.o:${DEV_DEFS}:${CFLAGS_TINY_STACK}:${DEV_ASFLAGS};\
-attiny2313a:crttn2313a.o:${DEV_DEFS}:${CFLAGS_TINY_STACK}:${DEV_ASFLAGS};\
-attiny24:crttn24.o:${DEV_DEFS}:${CFLAGS_TINY_STACK}:${DEV_ASFLAGS};\
-attiny24a:crttn24a.o:${DEV_DEFS}:${CFLAGS_TINY_STACK}:${DEV_ASFLAGS};\
-attiny25:crttn25.o:${DEV_DEFS}:${CFLAGS_TINY_STACK}:${DEV_ASFLAGS};\
-attiny261:crttn261.o:${DEV_DEFS}:${CFLAGS_TINY_STACK}:${DEV_ASFLAGS};\
-attiny261a:crttn261a.o:${DEV_DEFS}:${CFLAGS_TINY_STACK}:${DEV_ASFLAGS}\
+attiny88:crttn88.o:${DEV_DEFS}:${CFLAGS_SPACE}:${DEV_ASFLAGS};\
+attiny13:crttn13.o:${DEV_DEFS}:${CFLAGS_SPACE}:${DEV_ASFLAGS};\
+attiny13a:crttn13a.o:${DEV_DEFS}:${CFLAGS_SPACE}:${DEV_ASFLAGS};\
+attiny2313:crttn2313.o:${DEV_DEFS}:${CFLAGS_SPACE}:${DEV_ASFLAGS};\
+attiny2313a:crttn2313a.o:${DEV_DEFS}:${CFLAGS_SPACE}:${DEV_ASFLAGS};\
+attiny24:crttn24.o:${DEV_DEFS}:${CFLAGS_SPACE}:${DEV_ASFLAGS};\
+attiny24a:crttn24a.o:${DEV_DEFS}:${CFLAGS_SPACE}:${DEV_ASFLAGS};\
+attiny25:crttn25.o:${DEV_DEFS}:${CFLAGS_SPACE}:${DEV_ASFLAGS};\
+attiny261:crttn261.o:${DEV_DEFS}:${CFLAGS_SPACE}:${DEV_ASFLAGS};\
+attiny261a:crttn261a.o:${DEV_DEFS}:${CFLAGS_SPACE}:${DEV_ASFLAGS}\
 "
 
 AVR3_DEV_INFO="\
@@ -306,9 +311,6 @@ atxmega32e5:crtx32e5.o:${DEV_DEFS}:${CFL
 AVRXMEGA3_DEV_INFO="\
 "
 
-AVRXMEGA3SC_DEV_INFO="\
-"
-
 AVRXMEGA4_DEV_INFO="\
 atxmega64a3:crtx64a3.o:${DEV_DEFS}:${CFLAGS_BIG_MEMORY}:${DEV_ASFLAGS};\
 atxmega64a3u:crtx64a3u.o:${DEV_DEFS}:${CFLAGS_BIG_MEMORY}:${DEV_ASFLAGS};\
@@ -362,14 +364,20 @@ attiny20:crttn20.o:${DEV_DEFS}:${CFLAGS_
 attiny40:crttn40.o:${DEV_DEFS}:${CFLAGS_SPACE}:${DEV_ASFLAGS}\
 "
 
+# The "architectures" or "cores".  The second row only serves as a pointer
+# to all the supported devices as we iterate over AVR_ARH_INFO below.
+# Mentioning AVR25_DEV_INFO after avr25 only serves the purpose to include
+# the devices in tmp-device-info -- it does NOT mean that these devices
+# are associated to the core in any way.
+
+# Extra options to be set when building the C libraries.  The options for the
+# cores MUST NOT contain any multlilb options.
 
 LIB_DEFS="-D__COMPILING_AVR_LIBC__"
 
 AVR_ARH_INFO="\
 avr2::AVR12_DEV_INFO:${LIB_DEFS}:${CFLAGS_SPACE}:${DEV_ASFLAGS};\
-avr2:tiny-stack:AVR12TS_DEV_INFO:${LIB_DEFS}:${CFLAGS_TINY_STACK}:${DEV_ASFLAGS};\
 avr25::AVR25_DEV_INFO:${LIB_DEFS}:${CFLAGS_SPACE}:${DEV_ASFLAGS};\
-avr25:tiny-stack:AVR25TS_DEV_INFO:${LIB_DEFS}:${CFLAGS_TINY_STACK}:${DEV_ASFLAGS};\
 avr3::AVR3_DEV_INFO:${LIB_DEFS}:${CFLAGS_SPACE}:${DEV_ASFLAGS};\
 avr31::AVR31_DEV_INFO:${LIB_DEFS}:${CFLAGS_SPACE}:${DEV_ASFLAGS};\
 avr35::AVR35_DEV_INFO:${LIB_DEFS}:${CFLAGS_SPACE}:${DEV_ASFLAGS};\
@@ -379,7 +387,6 @@ avr51::AVR51_DEV_INFO:${LIB_DEFS}:${CFLA
 avr6::AVR6_DEV_INFO:${LIB_DEFS}:${CFLAGS_BIG_MEMORY}:${DEV_ASFLAGS};\
 avrxmega2::AVRXMEGA2_DEV_INFO:${LIB_DEFS}:${CFLAGS_SPACE}:${DEV_ASFLAGS};\
 avrxmega3::AVRXMEGA3_DEV_INFO:${LIB_DEFS}:${CFLAGS_SPACE}:${DEV_ASFLAGS};\
-avrxmega3:short-calls:AVRXMEGA3SC_DEV_INFO:${LIB_DEFS}:${CFLAGS_SHORT_CALLS}:${DEV_ASFLAGS};\
 avrxmega4::AVRXMEGA4_DEV_INFO:${LIB_DEFS}:${CFLAGS_BIG_MEMORY}:${DEV_ASFLAGS};\
 avrxmega5::AVRXMEGA5_DEV_INFO:${LIB_DEFS}:${CFLAGS_BIG_MEMORY}:${DEV_ASFLAGS};\
 avrxmega6::AVRXMEGA6_DEV_INFO:${LIB_DEFS}:${CFLAGS_BIG_MEMORY}:${DEV_ASFLAGS};\
@@ -387,7 +394,9 @@ avrxmega7::AVRXMEGA7_DEV_INFO:${LIB_DEFS
 avrtiny::AVRTINY_DEV_INFO:${LIB_DEFS}:${CFLAGS_SPACE}:${DEV_ASFLAGS}\
 "
 
-echo "Generating source directories:"
+# Make sure that we are the top-level of the source tree. We will look for the
+# the AUTHORS file in the current dir and the parent. After that, we complain
+# and fatal error out.
 
 top_dir="UNKNOWN"
 
@@ -408,136 +417,26 @@ then
 	exit 1
 fi
 
-test -d avr || mkdir avr
-test -d avr/lib || mkdir avr/lib
+echo "Generating source directories: $PWD"
 
-cd avr/lib || exit 1
+# Print device info to file tmp-device-info and core info to file tmp-core-info
+# to be picked up by mlib-gen.py.
 
-IFS=';'
-ARH_SUBDIRS=""
+rm -f ./tmp-device-info
+rm -f ./tmp-core-info
+echo "unknown:unknown.o:${DEV_DEFS}:${CFLAGS_SPACE}:${DEV_ASFLAGS}" > tmp-device-info
 
+IFS=';'
 for ath_lib in $AVR_ARH_INFO
 do
-	arh=`echo $ath_lib | cut -d ':' -f 1`
-	sublib=`echo $ath_lib | cut -d ':' -f 2`
-	dev_info=`echo $ath_lib | cut -d ':' -f 3`
-	lib_defs=`echo $ath_lib | cut -d ':' -f 4`
-	lib_cflags=`echo $ath_lib | cut -d ':' -f 5`
-	lib_asflags=`echo $ath_lib | cut -d ':' -f 6`
-
-	install_dir=$arh
-	if [ $arh = avr2 ]
-	then
-		if [ -z "$sublib" ] ; then
-			install_dir=""
-		else
-			install_dir=$sublib
-		fi
-	else
-		if [ -z "$sublib" ] ; then
-			install_dir=$arh
-		else
-			install_dir=$arh'/'$sublib
-		fi
-	fi
-
-	# Install directory for sed substitution, the '/' character is masked.
-	inst_dir_masked=`echo $install_dir | sed 's/\\//\\\\\\//'`
-
-    # In build tree.
-    subdir=${arh}${sublib:+/}${sublib}
-    echo "  avr/lib/$subdir/"
-
-    # The first record of each arch must be sublib-free.
-    test -d $subdir || mkdir $subdir
-    cd $subdir || exit 1
-
-    DEV_SUBDIRS=""
-
-	eval DEV_INFO=\"\$\{$dev_info\}\"
-
-	for dev_crt in $DEV_INFO
-	do
-		dev=`echo $dev_crt | cut -d ':' -f 1`
-		crt=`echo $dev_crt | cut -d ':' -f 2`
-		crt_defs=`echo $dev_crt | cut -d ':' -f 3`
-		crt_cflags=`echo $dev_crt | cut -d ':' -f 4`
-		crt_asflags=`echo $dev_crt | cut -d ':' -f 5`
-
-		echo "  avr/lib/$subdir/$dev"
-
-		test -d $dev || mkdir $dev
-
-		cat $top_dir/devtools/Device.am > $dev/Makefile.am
-
-		sed -e "s/<<dev>>/$dev/g" \
-		    -e "s/<<crt>>/$crt/g" \
-		    -e "s/<<crt_defs>>/$crt_defs/g" \
-		    -e "s/<<crt_cflags>>/$crt_cflags/g" \
-		    -e "s/<<crt_asflags>>/$crt_asflags/g"  \
-		    -e "s/<<install_dir>>/$inst_dir_masked/g" $dev/Makefile.am \
-		    > $dev/tempfile
-
-		case "$dev" in
-		  at90s1200|attiny11|attiny12|attiny15|attiny28)
-			sed -e "s/\$(eeprom_c_sources)//g" \
-				-e "s/\$(dev_c_sources)//g" $dev/tempfile \
-			> $dev/tempfile_2 && mv -f $dev/tempfile_2 $dev/Makefile.am
-			;;
-		  *)
-			mv -f $dev/tempfile $dev/Makefile.am
-			;;
-		esac
-
-		DEV_SUBDIRS="$DEV_SUBDIRS $dev"
-	done
-
-	cat $top_dir/devtools/Architecture.am > Makefile.am
-
-	sed -e "s/<<dev_subdirs>>/$DEV_SUBDIRS/g" \
-	    -e "s/<<arh>>/$arh/g" \
-	    -e "s/<<lib_defs>>/$lib_defs/g" \
-	    -e "s/<<lib_cflags>>/$lib_cflags/g" \
-	    -e "s/<<lib_asflags>>/$lib_asflags/g" \
-	    -e "s/<<install_dir>>/$inst_dir_masked/g" Makefile.am \
-	    > tempfile && mv -f tempfile Makefile.am
-
-	# Find the first and the last lines of <<dev>> block.
-	n1=`grep -En '^if[[:blank:]]+HAS_<<dev>>' Makefile.am	\
-	    | cut -d ':' -f 1`
-	n2=`grep -En '^endif[[:blank:]]+#[[:blank:]]*<<dev>>' Makefile.am \
-	    | cut -d ':' -f 1`
-
-	# Before the <<dev>> block.
-	head -n `expr $n1 - 1` Makefile.am > tempfile
-
-	# Duplicate the <<dev>> block and substitute.
-	for dev_crt in $DEV_INFO ; do
-		dev=`echo $dev_crt | cut -d ':' -f 1`
-		tail -n +$n1 Makefile.am	\
-		    | head -n `expr $n2 - $n1 + 1`	\
-		    | sed -e "s/<<dev>>/$dev/g" >> tempfile
-	done
-
-	# After the <<dev>> block.
-	tail -n +`expr $n2 + 1` Makefile.am >> tempfile
-
-	# Result.
-	mv -f tempfile Makefile.am
-
-	ARH_SUBDIRS="$ARH_SUBDIRS $subdir"
-
-	cd .. || exit 1
-	if [ -n "$sublib" ] ; then
-		cd .. || exit 1
-	fi
+    arh=`echo $ath_lib | cut -d ':' -f 1`
+    dev_info=`echo $ath_lib | cut -d ':' -f 3`
+    eval DEV_INFO=\"\$\{$dev_info\}\"
+    echo $ath_lib >> tmp-core-info
+    for d in $DEV_INFO
+    do
+	echo $d >> tmp-device-info
+    done
 done
 
-cat $top_dir/devtools/Lib.am > Makefile.am
-
-sed -e "s/<<arh_subdirs>>/`echo $ARH_SUBDIRS | sed 's/\\//\\\\\\//g'`/g" \
-    Makefile.am > tempfile && mv -f tempfile Makefile.am
-
-cd ..
-
-cat $top_dir/devtools/Avr.am > Makefile.am
+./devtools/mlib-gen.py -devices tmp-device-info -cores tmp-core-info || exit 1
Index: devtools/mlib-gen.py
===================================================================
--- devtools/mlib-gen.py	(nonexistent)
+++ devtools/mlib-gen.py	(working copy)
@@ -0,0 +1,478 @@
+#!/usr/bin/env python
+
+from __future__ import print_function
+import os, sys
+import re, argparse
+
+MMCU_DEFAULT = "avr2"
+
+parser = argparse.ArgumentParser('Generate multilib tree for avr-libc')
+
+parser.add_argument("-devices", dest="devices", required=True,
+                    help="Text file with devices supported by avr-libc")
+
+parser.add_argument("-cores", dest="cores", required=True,
+                    help="Text file with cores supported by avr-libc")
+
+args = parser.parse_args()
+
+def leave(msg):
+    """ Print message MSG to stderr and exit the program with exit code 1."""
+    print (msg, file=sys.stderr)
+    exit (1)
+
+
+# The output of "avr-gcc -print-multi-lib | grep -v double"
+# AND the union over all avr-gcc versions / configurations you
+# can imagine.
+#    The "double" variants are not mentioned here in order to keep
+# the list easier to grasp; under the assumption that the double
+# multilibs are orthogonal, i.e. for every non-double variant there are
+# double variants provided avr-gcc supports -m[long-]double=32/64.
+#    The @-encoded options right of ; are not used by this script except
+# for removing potential multilib options from gen-avr-lib-tree.sh. The very
+# multilib options are determinded by configure.ac's CHECK_MULTI_VARIANT
+# (by gcc -print-multi-lib for the C libraries) and CHECK_AVR_DEVICE
+# (by gcc -print-multi-directory -mmcu=<device> for the devices).
+
+Print_Multi_Lib = """\
+.;
+avr25;@mmcu=avr25
+avr3;@mmcu=avr3
+avr31;@mmcu=avr31
+avr35;@mmcu=avr35
+avr4;@mmcu=avr4
+avr5;@mmcu=avr5
+avr51;@mmcu=avr51
+avr6;@mmcu=avr6
+avrxmega2;@mmcu=avrxmega2
+avrxmega3;@mmcu=avrxmega3
+avrxmega4;@mmcu=avrxmega4
+avrxmega5;@mmcu=avrxmega5
+avrxmega6;@mmcu=avrxmega6
+avrxmega7;@mmcu=avrxmega7
+avrtiny;@mmcu=avrtiny
+tiny-stack;@msp8
+avr25/tiny-stack;@mmcu=avr25@msp8
+avrxmega3/short-calls;@mmcu=avrxmega3@mshort-calls
+"""
+
+def gcc_print_multi_lib ():
+    """Return a string that represents a superset of all `gcc -print-multi-lib`
+       which might be out there.  The assumption is that the [long] double
+       variants are orthogonal to the non-double ones, and that the we know
+       how avr-gcc will compose the multilib sub-directories."""
+
+    pml = Print_Multi_Lib.split()
+    pml = filter (lambda x: not "double" in x, pml)
+
+    # For each variant, add the 4 double variants.  Whether or not
+    # the compiler actually supports one of them is determined -- like
+    # for any other variant -- by configure.
+    pml2 = [ ]
+    for m in pml:
+        pml2 += [ m ]
+        (path,opt) = m.split(";")
+        path = "" if path == "." else (path + "/")
+        
+        pml2 += [ path + "double32;" + opt + "@mdouble=32" ]
+        pml2 += [ path + "double64;" + opt + "@mdouble=64" ]
+        pml2 += [ path + "long-double32;" + opt + "@mlong-double=32" ]
+        pml2 += [ path + "long-double64;" + opt + "@mlong-double=64" ]
+            
+    return "\n".join (pml2)
+
+
+def Info (*args):
+    print ("   " + " ".join (args))
+
+
+class MLib (object):
+    """One Multilib variant."""
+
+    def __init__(self, line_print_multi_lib):
+        """Set up multilib variant from one line of gcc -print-multi-lib."""
+
+        self.line = line_print_multi_lib
+        # A line from `gcc -print-multi-lib` looks like
+        # "avr25/tiny-stack;@mmcu=avr25@msp8".
+        # Left  of ";" is the relative path with "/" as path separator.
+        # Right of ";" are the options leading to the multilib variant.
+        (self.mdir, options) = self.line.split (";")
+
+        self.ident = to_ident(self.mdir)
+
+        # Work out the build directory like avr25_tiny_stack which might be
+        # emit as $(BUILDDIR_avr25_tiny_stack).
+        self.builddir = self.ident
+
+        # The options for this variant, as a set.
+        # Decode the options as retrieved from gcc_print_multi_lib().
+        self.options = set(options.replace ("@", " -").strip().split())
+
+        # The options for this variant but without -mmcu, as a set.
+        self.options_no_mmcu = set (filter (lambda x: not x.startswith("-mmcu"),
+                                            self.options))
+
+        # The "architecture":  This is the portion after "-mmcu=" if
+        # options contain -mmcu=, and "avr2" otherwise.
+        self.arch = list(filter (lambda x: x.startswith("-mmcu="),
+                                 self.options))
+        if self.arch:
+            self.arch = self.arch[0].replace ("-mmcu=", "")
+        else:
+            self.arch = MMCU_DEFAULT
+
+        # The options will be added from the "cores" by .add_options().
+        self.defs = set()
+        self.cflags = set()
+        self.asflags = set()
+
+    def __repr__ (self):
+        return "%s %s %s\n" % (self.mdir, self.options, self.options_no_mmcu)
+
+    def add_options (self, core):
+        """Add extra options specified in -cores=<file> for core family CORE
+           provided that core is compatible with this multilib variant.
+           Options might refer to Makefile variables like "$(var)"."""
+        if core.mcu == self.arch:
+            self.defs    |= core.defs
+            self.cflags  |= core.cflags
+            self.asflags |= core.asflags
+
+
+class Device (object):
+    """One AVR device represented by what follows -mmcu=*.  Each device
+       originates from one line in -devices=<file>."""
+
+    mcus_asm_only = ("at90s1200",
+                     "attiny11", "attiny12", "attiny15", "attiny28")
+
+    def __init__ (self, list5):
+        # Pop a device from a list of 5 string elements as retrieved from
+        # file args.device. Each line looks like
+        #     atxmega128a4u:crtx128a4u.o::-Os $(FNO_JUMP_TABLES):
+        # and originates from dumping the AVR*_DEV_INFO variables
+        # from gen-avr-lib-tree.sh.
+
+        if not type(list5) is list or len(list5) != 5:
+            raise ValueError("expecting list with 5 elements, got:", list5)
+        self.mcu     = list5[0] 
+        self.crt_o   = list5[1] if list5[1] != "" else ("crt"+self.mcu+".o")
+        self.defs    = set(list5[2].split())
+        self.cflags  = set(list5[3].split())
+        self.asflags = set(list5[4].split())
+        self.asm_only = (self.mcu in Device.mcus_asm_only)
+
+    __hash__ = None
+    # So that "in list" works as expected.
+    def __cmp__(self, other):
+        if not type(other) is Device:
+            return -1
+        return cmp (self.mcu, other.mcu)
+
+    def __repr__ (self):
+        return self.mcu
+
+
+class Core (object):
+    """Only a container for options as retrieved from -cores=<file>."""
+    def __init__ (self, list6):
+        if not type(list6) is list or len(list6) != 6:
+            raise ValueError("expecting list with 6 elements, got:", list6)
+        self.mcu = list6[0] if list6[0] != "" else MMCU_DEFAULT
+        self.defs    = set(list6[3].split())
+        self.cflags  = set(list6[4].split())
+        self.asflags = set(list6[5].split())
+
+    __hash__ = None
+
+    # Implement __eq__ so that "in list" works as expected.
+    def __eq__(self, other):
+        return self.mcu == other.mcu if type(other) is Core else False
+
+    def __repr__ (self):
+        return self.mcu
+
+class Makefile (object):
+    files = [ ]
+
+    def __init__(self, path):
+        self.path = path
+
+    def __cmp__(self, other):
+        if not type(other) is Makefile:
+            return -1
+        return cmp (self.path, other.path)
+
+    def __str__(self):
+        return self.path
+
+    @classmethod
+    def add(clazz, dirs):
+        """Register a Makefile (to be emit as AC_CONFIG_FILE to files.m4)
+           and prepare an according Makefile.am for the parallel build.
+           "parallel" means here that srcdir and builddir will have the same
+           layout.  Return the OS-dependent path to Makefile.am and add the
+           Makefile to .files."""
+
+        path = "/".join(dirs) + "/Makefile"
+        clazz.files += [ Makefile(path) ]
+
+        # Try to mkdir the directory in in which Makefile.am will live.
+        path = os.path.join(*dirs)
+        try:
+            os.mkdir (path)
+        except OSError:
+            # If we come here, the assumption is that path already existed.
+            pass
+
+        return os.path.join(path, "Makefile.am")
+
+
+def remove_multilib_options (opts):
+    if type(opts) is str:
+        opts = set (opts.split())
+    return opts - multilib_options
+
+
+def to_ident(var):
+    """Turn a string (usually a (sub)folder) into some canonical
+       representation that can be used as (part of) an indentifier
+       or of a file-name."""
+
+    # This are the same replacements that are performed by CHECK_AVR_DEVICE
+    # to get to DEVLIST_<<ident>> used by Architecture.am.  DEVLIST_<<ident>>
+    # is only needed if !HAS_DEV_LIB, i.e. with avr-gcc < v5.
+    repls = ((".", "avr2"),
+             ("-", "_"),
+             ("/", "_"))
+    for (a,b) in repls:
+        var = var.replace (a, b)
+    return var
+
+
+mlibs = gcc_print_multi_lib()
+mlibs = [ MLib (line) for line in mlibs.split() ]
+
+Info ("Have %d potential multilibs." % len(mlibs))
+
+multilib_options = set()
+for mlib in mlibs:
+    multilib_options |= set (mlib.options_no_mmcu)
+
+# Retrieve cores and their extra options form -cores=<file>.
+
+cores = [ ]
+
+Info ("Reading %s..." % args.cores)
+with open (args.cores, "r") as f:
+    for line in f.readlines():
+        m = line.strip().split(":")
+
+        # Expect each line to be composed of 6 fields, separated by 5 ":"s.
+        # Ignore empty lines (if any).
+        # Field #1: Core as to be specified with -mmcu=*.  Notice that to
+        #           identify a "core", more multilib options might be
+        #           required.
+        # Field #2: Unused (no more needed legacy).
+        # Field #3: Unused (no more needed legacy).
+        # Field #4: Options.
+        # Field #5: Options for C.
+        # Field #6: Options for Asm.
+        if m:
+            core = Core(m)
+            if not core in cores:
+                cores += [ core ]
+
+# Retrieve devices and their options from -devices=<file>.
+
+devices = [ ]
+
+Info ("Reading %s..." % args.devices)
+with open (args.devices, "r") as f:
+    for line in f.readlines():
+        m = line.strip().split(":")
+        # Expect each line to be composed of 5 fields, separated by 4 ":"s.
+        # Ignore empty lines (if any).
+        # Field #1: Device name to be passed as -mmcu=*.
+        # Field #2: File name of crt*.o.
+        # Field #3: Options.
+        # Field #4: Options for C.
+        # Field #5: Options for Asm.
+        if m:
+            device = Device(m)
+            if device in devices:
+                leave ("duplicate device: %s" % device)
+            devices += [ device ]
+
+Info ("Have %d devices." % len(devices))
+
+for mlib in mlibs:
+    """Add core-specific extra (non-multilib) options to our multilib-variants.
+       A "core" is specified by what follows -mmcu=, and the options for
+       "core" come from gen-avr-lib-tree.sh."""
+    for core in cores:
+        mlib.add_options (core)
+
+
+# The Makefile.am template for ./avr/lib/<multilib-buildir>
+Info ("Reading %s..." % "devtools/Architecture.am")
+with open ("devtools/Architecture.am", "r") as f:
+    Architecture_am = f.read()
+
+# The Makefile.am templates for ./avr/devices/<device>
+Info ("Reading %s..." % "devtools/Device.am")
+with open ("devtools/Device.am", "r") as f:
+    Device_am = f.read()
+
+path_avr = "avr"
+path_lib = "lib"
+path_devices = "devices"
+
+
+def makedir_avr():
+    """Build ./avr"""
+
+    Makefile_am = Makefile.add ([path_avr])
+
+    Info ("Writing %s..." % Makefile_am)
+    with open (Makefile_am, "w") as f:
+        f.write ("SUBDIRS = lib devices\n")
+
+def makedir_avr_lib():
+    """Build ./avr/lib"""
+
+    Makefile_am = Makefile.add ((path_avr, path_lib))
+
+    dirs = map (lambda x: x.builddir, mlibs)
+
+    Info ("Writing %s..." % Makefile_am)
+    with open (Makefile_am, "w") as f:
+        f.write ("SUBDIRS = %s\n" % " ".join (dirs))
+
+
+def makedir_avr_devices_device(device):
+    """Build ./avr/devices/<device.mcu>"""
+
+    Makefile_am = Makefile.add ((path_avr, path_devices, device.mcu))
+
+    # Remove any multilib options.
+    crt_defs    = remove_multilib_options (device.defs)
+    crt_cflags  = remove_multilib_options (device.cflags)
+    crt_asflags = remove_multilib_options (device.asflags)
+    replacements = {
+        "<<dev>>" : device.mcu,
+        "<<crt>>"         : device.crt_o,
+        "<<crt_defs>>"    : " ".join(crt_defs),
+        "<<crt_cflags>>"  : " ".join(crt_cflags),
+        "<<crt_asflags>>" : " ".join(crt_asflags),
+    }
+
+    if device.asm_only:
+        replacements["$(eeprom_c_sources)"] = ""
+        replacements["$(dev_c_sources)"] = ""
+
+    device_am = Device_am
+    for r in replacements:
+        device_am = device_am.replace (r, replacements[r])
+
+    Info ("Writing %s..." % Makefile_am)
+    with open (Makefile_am, "w") as f:
+        f.write (device_am)
+
+
+def makedir_avr_devices():
+    """Build ./avr/devices"""
+
+    Makefile_am = Makefile.add ((path_avr, path_devices))
+
+    # Map Devices like "atmega8" to "$(DIR_atmega8)".
+    dirs = map (lambda x: x.mcu, devices)
+
+    Info ("Writing %s..." % Makefile_am)
+    with open (Makefile_am, "w") as f:
+        f.write ("SUBDIRS = %s\n" % " ".join(dirs))
+
+
+def makedir_avr_lib_arch(mlib):
+    """Build ./avr/lib/<mlib.builddir>"""
+
+    path = os.path.join (path_avr, path_lib, mlib.builddir)
+    Makefile_am = Makefile.add ((path_avr, path_lib, mlib.builddir))
+
+    # Remove any multilib options, they are added by $(MULTIOPT_*).
+    lib_defs    = remove_multilib_options (mlib.defs)
+    lib_cflags  = remove_multilib_options (mlib.cflags)
+    lib_asflags = remove_multilib_options (mlib.asflags)
+
+    replacements = {
+        "<<arh>>" : mlib.arch,
+        "<<lib_defs>>"    : " ".join(lib_defs),
+        "<<lib_cflags>>"  : " ".join(lib_cflags),
+        "<<lib_asflags>>" : " ".join(lib_asflags),
+        "<<ident>>"       : mlib.ident
+    }
+
+    arch_am = Architecture_am
+    for r in replacements:
+        arch_am = arch_am.replace (r, replacements[r])
+
+    Info ("Writing %s..." % Makefile_am)
+    with open (Makefile_am, "w") as f:
+        f.write (arch_am)
+
+
+def make_lib_tree():
+    makedir_avr()
+    makedir_avr_lib()
+    makedir_avr_devices()
+
+    for mlib in mlibs:
+        makedir_avr_lib_arch(mlib)
+
+    for d in devices:
+        makedir_avr_devices_device(d)
+
+# devices.m4 will be lines of:
+check_avr_device = "CHECK_AVR_DEVICE(%s)\n"
+
+# multilib.m4 will be lines of:
+check_multi_variant = "CHECK_MULTI_VARIANT([%s], [%s])\n"
+
+# files.m4 will be lines of:
+ac_config_files = "AC_CONFIG_FILES([%s])\n"
+
+# devlist.m4 will be lines of:
+ac_subst_devlist = "AC_SUBST(DEVLIST_%s)\n"
+
+def make_m4():
+    """Auto-generates files to be included by configure.ac."""
+
+    Info ("Writing devices.m4...")
+    with open ("devices.m4", "w") as f:
+        for device in devices:
+            f.write (check_avr_device % device.mcu)
+
+    Info ("Writing devlist.m4...")
+    with open ("devlist.m4", "w") as f:
+        for mlib in mlibs:
+            f.write (ac_subst_devlist % mlib.ident)
+
+    Info ("Writing multilib.m4...")
+    with open ("multilib.m4", "w") as f:
+        for mlib in mlibs:
+            f.write (check_multi_variant % (mlib.mdir, mlib.ident))
+
+    Info ("Writing files.m4...")
+    with open ("files.m4", "w") as f:
+        for mk in Makefile.files:
+            f.write (ac_config_files % mk)
+
+make_lib_tree()
+
+Info ("Wrote %d Makefile.am's." % len(Makefile.files))
+
+make_m4()
+
+Info ("Done.")

Property changes on: devtools/mlib-gen.py
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
