Commits

Anonymous committed 6ae3d92

#179 makefiles, ansi and docs; check-in on branch

Comments (0)

Files changed (22)

docs/src/BuildSystem.txt

 Overview
 --------
 
-PyMite shall use a makefile based build system with an allowance for
-using features of `GNU make`_.  The project shall have a
-``Makefile`` in the project root directory that, when called by
-typing ``make`` at the command prompt, will compile:
+PyMite use a makefile-based build system with an allowance for
+using features of `GNU make`_.  The project has a ``Makefile`` in the project
+root directory that, when called by typing ``make`` at the command prompt,
+compiles for the desktop platform:
 
-    - the PyMite standard library ``src/lib/`` to an image file,
+    - the PyMite standard library ``src/lib/`` image file,
       ``src/vm/pmstdlib_img.c``, and native code file, ``src/vm/pmstdlib_nat.c``
-    - the PyMite VM to an archive, ``libpmvm.a``
-      that shall be linked with PyMite end-user programs.
+    - the PyMite VM archive, ``libpmvm.desktop.a``
+    - the PyMite executable, ``src/platform/desktop/main.out``
 
 More options for building the project are available by using the available
 ``make`` targets as explained in the next section.
 other hand, converts Python code that is meant to run inside the PyMite VM
 to an `image` file, an equivalent to a ``.pyc`` file.  The `image` file is
 a C file, ``pmstdlib_img.c``, containing an array of bytes.
-The file containing the image of the PyMite libraries is what is built when
-``make`` is run in ``src/lib/``.
+The directory ``src/lib/`` is responsible for holding the files of Python
+source code which are used to build the standard library.
 
 .. _`GNU make`: http://www.gnu.org/software/make/
 
 Requirements
 ------------
 
-The PyMite build process requires Python version 2.4 or later to be used
-to compile Python source for use in PyMite.  While most semantics in PyMite
-need only Python 2.0 or later, the ``assert`` statement specifically requires
-Python 2.4.  This is because the bytecode generated from an ``assert``
-statement changed in Python 2.4.  PyMite attempts to keep up-to-date with the
-desktop Python and therefore implements the 2.4 method of handling ``assert``.
-Python 2.5 is supported and may be used.
+The PyMite interpreter requires bytecodes created by Python version 2.5 or 2.6.
+
 
 Available Targets
 -----------------
 by typing ``make`` `<target>` at the command prompt:
 
 ``all``:
-    Compiles the entire program.  This shall be the default target.
+    Compiles PyMite for the desktop platform.  This is the default target.
 
 ``clean``:
-    Deletes all files in the current directory that are normally created by
-    building the program. Also deletes files in other directories if they are
-    created by this makefile.
+    Deletes the files in this and other directories that are created by
+    building the program.
 
 ``TAGS``:
-    Updates a tags table for this program.
-    Also updates a cscope database for the VM and pmstdlib source code.
+    Updates a tags index file for this project.
+    Also updates cscope databases for the VM and pmstdlib source code.
 
 ``html``:
     Generates the documentation files from ``docs/src/`` and
 ``HEAP_SIZE``:
     Specifies the desired size of the PyMite heap in bytes.
     Possible values can be any positive integer.  To avoid errors, the size
-    should be less than the size of physical memory and (for 32-bit targets)
-    an integer multiple of 4.  The default value depends on the ``TARGET``.
-    See the Makefile for details.  Example: ``make HEAP_SIZE=0x1000``
+    should be less than the size of physical memory and an integer multiple
+    of 4.  The default value is defined in the platform's Makefile.
+    Example: ``make HEAP_SIZE=0x1000``
 
-``TARGET``:
-    Specifies the intended build target.  Possible values: ``AT91SAM7S``,
-    ``AVR``, ``DESKTOP``.  The default is ``DESKTOP``.
-    Example: ``make TARGET=AVR``
-
-``TARGET_MCU``:
-    Specifies the precise chip to compile for when ``TARGET`` is something
-    other than ``DESKTOP``.  For example, if the ``TARGET=AVR``, the
-    ``TARGET_MCU`` can be any value that would be given as an argument to
-    ``avr-gcc -mmcu``.  The default value depends on ``TARGET``; there is no
-    value when ``TARGET`` is ``DESKTOP``.  See the Makefile for details.
-    Example: ``make TARGET=AVR TARGET_MCU=atmega128``.
+``PLATFORM``:
+    Specifies the intended target platform.  Possible values are the names
+    of the subdirectories in ``src/platform``: ``at91sam7s-ek``,
+    ``avr``, ``mmb103`` and ``desktop``.  The default is ``desktop``.
+    Example: ``make PLATFORM=avr``
 
 
 Self Testing

docs/src/ErrorsAndExceptions.txt

     =================   =========   ========================================
     PM_RET_EX           0xE0        General exception
     PM_RET_EX_EXIT      0xE1        System exit
-    PM_RET_EX_FLOAT     0xE2        Floating point error
+    PM_RET_EX_IO        0xE2        Input/output error
     PM_RET_EX_ZDIV      0xE3        Zero division error
     PM_RET_EX_ASSRT     0xE4        Assertion error
     PM_RET_EX_ATTR      0xE5        Attribute error
     PM_RET_EX_MEM       0xE9        Memory error
     PM_RET_EX_NAME      0xEA        Name error
     PM_RET_EX_RUNTIME   0xEB        Runtime error
-    PM_RET_EX_SYNTAX    0xEC        Syntax error
-    PM_RET_EX_SYS       0xED        System error
-    PM_RET_EX_TYPE      0xEE        Type error
-    PM_RET_EX_VAL       0xEF        Value error
-    PM_RET_EX_WARN      0xD0        Warning
+    PM_RET_EX_SYNTAX    0xEB        Syntax error
+    PM_RET_EX_SYS       0xEc        System error
+    PM_RET_EX_TYPE      0xED        Type error
+    PM_RET_EX_VAL       0xEE        Value error
+    PM_RET_EX_STOP      0xEF        Stop iteration
+    PM_RET_EX_WARN      0xF0        Warning
     =================   =========   ========================================
 
 In PyMite, there is only one kind of exception object and the PyMite user

docs/src/FrequentlyAskedQuestions.txt

 
 PyMite is so easy to port (there are 4 functions to adapt, see examples in
 the src/vm/plat directory) that any microcontroller with 8 KB or more of RAM
-will do.  I recommend 8 KB of RAM because 4 KB is rather tight and doesn't
-allow much more than simple programs.
+will do.  I recommend 8 KB or more of RAM because 4 KB is rather tight and 
+doesn't allow much more than simple programs.
 
 
 What do I need on my computer?

docs/src/HowToProgramTheAt91sam7s64-ek.txt

 Subversion_ SCM.
 
 The developer shall download the sam7utils_ open source software::
-    
+
     svn co https://oss.tekno.us/svn/sam7utils/trunk sam7utils
 
 The developer shall build same7utils for his host computer::
 Preparing the Device
 --------------------
 
-The AT91SAM7S64-EK needs to have its program memory erased and its bootloader
-restored before a new program can be flashed.
-
-To erase the AT91SAM7S64's program memory:
-
-    - Connect the AT91SAM7S-EK to the computer via a USB cable
-    - Apply a jumper to JP28 for 5 seconds to clear flash; remove the jumper
+The AT91SAM7S64-EK needs to have its bootloader restored in order to flash
+a new program.
 
 To restore the bootloader (SAM-BA):
 
-    - Apply a jumper to JP5 for 30 seconds to restore SAM-BA; remove
+    - Apply a jumper to JP5 for 15 seconds to restore SAM-BA; remove
       the jumper
     - Disconnect, pause and reconnect the AT91SAM7S-EK's USB cable
       to reset the connection
 
+
 Loading the PyMite Program
 --------------------------
 

docs/src/HowToReleasePyMite.txt

         - ``make html``
         - ``make TAGS``
         - ``make check``
-        - ``make clean; make TARGET=AT91SAM7``
-        - ``cd src/sample/at91sam7; make``
-        - ``cd ../../..; make clean; make TARGET=AVR``
-        - ``cd src/sample/avr; make; cd ../../..``
+        - ``make ipm``
+        - ``map(range, range(5))``
+        - ``Ctrl+D``
+        - ``make PLATFORM=at91sam7s-ek``
+        - ``make PLATFORM=avr``
+        - ``cd src/platform/avr; avr-size main.elf``
         - Record the size of the AVR sample app in the ticket
 
     - Verify that a sample app runs on an AVR device; this can be done in
 
         - Download and run a known good app on an actual AT91SAM7 device
 
-            - ``make clean; make TARGET=AT91SAM7; cd src/sample/at91sam7; make``
+            - ``cd src/platform/at91sam7s-ek; make``
             - Connect the AT91SAM7S-EK to the computer via a USB cable
-            - Apply a jumper to JP28 for 5 seconds to clear flash; remove the
-              jumper
-            - Apply a jumper to JP5 for 30 seconds to restore SAM-BA; remove
+            - Apply a jumper to JP5 for 10 seconds to restore SAM-BA; remove
               the jumper
             - Disconnect, pause and reconnect the AT91SAM7S-EK's USB cable
               to reset the connection

docs/src/HowToUsePyMite.txt

 --------------
 
 This section demonstrates how a trivial program is written to run
-in the PyMite VM.  A more detailed example can be found in the PyMite
-source tree in ``src/sample``.
+in the PyMite VM.  An example can be found in the PyMite source tree in
+``src/platform/desktop/``.
 
 First write the Python application, ``trivial.py`` that will run in the VM::
 
     def funcname(n):
         return n-42
 
-    funcname(6*7)
+    print funcname(6*7)
 
 Notice that an application in PyMite does not use the
 ``if __name__ == "__main__":`` convention that Python does;
 such as ``pm_init()``, ``pm_run()``, and ``MEMSPACE_PROG`` into the namespace
 of this file.  The ``extern`` line tells the compiler that the variable
 ``usrlib_img[]`` is defined in another file.  Next the ``main()`` function
-means this program will run as the primary executable on the target.
+means this program will run as the primary executable.
 
 Inside ``main()`` the ``retval`` variable is declared.  It is used to catch
 any error codes that might come from the PyMite API functions.
 
 The next PyMite API, ``pm_run()`` tries to execute the module with the same
 name as the string you give to the function.  Here we tell the VM to find
-the module ``trivial`` in the global list of modules and run it.
-Behind the scenes, the module is loaded from its image into a structure in RAM
-and bytecodes are executed until program completion or an unhandled exception
-occurs.
+the module, ``trivial`` and run it.  Behind the scenes, the module is loaded
+from its image into a structure in RAM and bytecodes are executed until program
+completion or an unhandled exception occurs.
 
 .. :mode=rest:

docs/src/InteractivePyMite.txt

 cross-platform implementation of ipm-host that runs from a command prompt.
 
 
-Using ipm-desktop
------------------
+Runnin ipm on the Desktop
+-------------------------
 
-The sample project in ``src/sample/ipm-desktop/`` was created to build PyMite
+The sample project in ``src/platform/desktop/`` was created to build PyMite
 for the desktop target. The output of this project is used by ipm-host when it
 is commanded to connect using the "desktop" connection.  Perform the following
-steps from the project root directory to run ipm on the desktop::
+steps from the project root directory to build and run ipm on the desktop::
 
     make ipm
 
 Running ipm on an embedded target
 ---------------------------------
 
-The sample project in ``src/sample/mmb103`` demonstrates running ipm on an
+The sample project in ``src/platform/mmb103`` demonstrates running ipm on an
 Atmel ATmega103 microcontroller and connecting to its UART.  This project is
 specific to hardware that is not publicly availble; so it cannot be used as is.
 However, it serves as an example that can be copied.

docs/src/index.txt

 ErrorsAndExceptions.html_           N       Y           the software design
                                                         of VM errors and
                                                         exceptions
+FrequentlyAskedQuestions.html_      Y       Y           Answers FAQs.
 HeapDesign.html_                    N       Y           the software design
                                                         of the VM heap
 HowToProgramTheAt91sam7s64-ek.html_ Y       Y           how to flash
 .. _BuildSystem.html: BuildSystem.html
 .. _DevelopmentProcess.html: DevelopmentProcess.html
 .. _ErrorsAndExceptions.html: ErrorsAndExceptions.html
+.. _FrequentlyAskedQuestions.html: FrequentlyAskedQuestions.html
 .. _HeapDesign.html: HeapDesign.html
 .. _HowToProgramTheAt91sam7s64-ek.html: HowToProgramTheAt91sam7s64-ek.html
 .. _HowToReleasePyMite.html: HowToReleasePyMite.html

src/platform/at91sam7s-ek/Makefile

 CFLAGS += -Wall -Wcast-align -Wimplicit
 CFLAGS += -Wpointer-arith -Wswitch
 CFLAGS += -Wredundant-decls -Wreturn-type -Wshadow -Wunused
-CFLAGS += -Wa,-adhlns=$(subst $(suffix $<),.lst,$<)
+#CFLAGS += -Wa,-adhlns=$(subst $(suffix $<),.lst,$<)
 CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
 #### CFLAGS += -ffunction-sections -fdata-sections
 

src/platform/at91sam7s-ek/README

+============================
+The AT91SAM7S Sample Project
+============================
+
+:Author:    Dean Hall
+:Id:        $Id$
+
+Purpose
+-------
+
+This is a sample project that demonstrates running interactive PyMite (ipm)
+on the Atmel `AT91SAM7S-EK`_ which is an evaluation board for the 
+`SAM7S family`_ of microcontrollers.  Any SAM7 with at least 
+64 KiB of program memory and 8 KiB of RAM can run PyMite.
+
+.. _`AT91SAM7S-EK`: http://atmel.com/dyn/products/tools_card.asp?tool_id=3784
+.. _`SAM7S family`: http://atmel.com/products/at91/default.asp
+
+
+Building the Project
+--------------------
+
+Start with a clean PyMite tree.  Build the PyMite VM archive as well as the 
+sample application::
+
+    $ cd src/platform/avr
+    $ make
+
+
+Flashing the Binary
+-------------------
+
+Use your ISP programming method of choice to program
+``src/platform/at91sam7s-ek/main.hex`` onto your target AVR device.
+
+.. :mode=rest:

src/platform/avr/Makefile

 # Hey Emacs, this is a -*- makefile -*-
-#
-# WinAVR Sample makefile written by Eric B. Weddington, J�rg Wunsch, et al.
-# Released to the Public Domain
-# Please read the make user manual!
-#
-# Additional material for this makefile was submitted by:
-#  Tim Henigan
-#  Peter Fleury
-#  Reiner Patommel
-#  Sander Pool
-#  Frederik Rouleau
-#  Markus Pfaff
-#
-# On command line:
-#
-# make all = Make software.
-#
-# make clean = Clean out built project files.
-#
-# make coff = Convert ELF to AVR COFF (for use with AVR Studio 3.x or VMLAB).
-#
-# make extcoff = Convert ELF to AVR Extended COFF (for use with AVR Studio
-#                4.07 or greater).
-#
-# make program = Download the hex file to the device, using avrdude.  Please
-#                customize the avrdude settings below first!
-#
-# make filename.s = Just compile filename.c into the assembler code only
-#
-# To rebuild project do "make clean" then "make all".
-#
+
+# AVR-GCC Makefile template, derived from the WinAVR template (which
+# is public domain), believed to be neutral to any flavor of "make"
+# (GNU make, BSD make, SysV make)
 
 
 # PyMite Configuration
 PM_USR_SOURCES = main.py ../../lib/avr.py
 PM_HEAP_SIZE = 0x0D00
 PMIMGCREATOR := ../../tools/pmImgCreator.py
+IPM=false
 
 
 # Platform Configuration
 MCU = atmega103
+FORMAT = ihex
+TARGET = main
 F_CPU = 4000000UL
 UART_BAUD = 19200UL
-
-
-# Output format. (can be srec, ihex, binary)
-FORMAT = ihex
-
-# Target file name (without extension).
-TARGET = main
-
-
-# List C source files here. (C dependencies are automatically generated.)
 SRC = $(TARGET).c plat.c $(TARGET)_nat.c $(TARGET)_img.c
-
-
-# List Assembler source files here.
-# Make them always end in a capital .S.  Files ending in a lowercase .s
-# will not be considered source files but generated files (assembler
-# output from the compiler), and will be deleted upon "make clean"!
-# Even though the DOS/Win* filesystem matches both .s and .S the same,
-# it will preserve the spelling of the filenames, and gcc itself does
-# care about how the name is spelled on its command-line.
 ASRC =
-
-
-
-# Optimization level, can be [0, 1, 2, 3, s].
-# 0 = turn off optimization. s = optimize for size.
-# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
 OPT = s
 
 # Debugging format.
 # AVR (extended) COFF requires stabs, plus an avr-objcopy run.
 DEBUG_FMT = stabs
 
-# List any extra directories to look for include files here.
-#     Each directory must be seperated by a space.
-EXTRAINCDIRS =
-
-
 # Compiler flag to set the C Standard level.
 # c89   - "ANSI" C
 # gnu89 - c89 plus GCC extensions
 # Place -D or -U options here
 CDEFS = -DF_CPU=$(F_CPU) -DUART_BAUD=$(UART_BAUD)
 # PyMite CDEFS
-CDEFS += -DHEAP_SIZE=$(PM_HEAP_SIZE) 
+CDEFS += -DHEAP_SIZE=$(PM_HEAP_SIZE)
 ifeq ($(DEBUG),true)
 	CDEFS += -g -g$(DEBUG_FMT) -D__DEBUG__=1
 endif
 CINCS = -I../../vm
 
 
-# Compiler flags.
-#  -g*:          generate debugging information
-#  -O*:          optimization level
-#  -f...:        tuning, see GCC manual and avr-libc documentation
-#  -Wall...:     warning level
-#  -Wa,...:      tell GCC to pass this to the assembler.
-#    -adhlns...: create assembler listing
-CFLAGS = $(CDEFS) $(CINCS)
-CFLAGS += -O$(OPT)
-CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
-CFLAGS += -Wall -Wstrict-prototypes -Werror
-CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
-CFLAGS += $(CSTANDARD)
+CDEBUG = -g$(DEBUG_FMT)
+CWARN = -Wall -Wstrict-prototypes
+CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
+#CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
+CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CSTANDARD) $(CTUNING) $(CEXTRA)
 
 
-# Assembler flags.
-#  -Wa,...:   tell GCC to pass this to the assembler.
-#  -ahlms:    create listing
-#  -gstabs:   have the assembler create line number information; note that
-#             for use in COFF files, additional information about filenames
-#             and function names needs to be present in the assembler source
-#             files -- see avr-libc docs [FIXME: not yet described there]
-ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
-
+#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
 
 
 #Additional libraries.
 
 SCANF_LIB =
 
-MATH_LIB =
+#MATH_LIB = -lm
 
 # External memory options
 
 
 EXTMEMOPTS =
 
-# Linker flags.
-#  -Wl,...:     tell GCC to pass this to linker.
-#    -Map:      create map file
-#    --cref:    add cross reference to  map file
-LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
-LDFLAGS += $(EXTMEMOPTS)
-LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
+#LDMAP = $(LDFLAGS) -Wl,-Map=$(TARGET).map,--cref
+LDFLAGS = $(EXTMEMOPTS) $(LDMAP) $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
 # PyMite
 LDFLAGS += -L../../vm -l$(PM_LIB_ROOT) -L.
 
 
-
 # Programming support using avrdude. Settings and variables.
 
-# Programming hardware: alf avr910 avrisp bascom bsd
-# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500 stk500v2
-#
-# Type: avrdude -c ?
-# to get a full listing.
-#
-#AVRDUDE_PROGRAMMER = stk200
 AVRDUDE_PROGRAMMER = stk500v2
-
-# com1 = serial port. Use lpt1 to connect to parallel port.
-#AVRDUDE_PORT = lpt1    # programmer connected to parallel port
 AVRDUDE_PORT = /dev/cu.Pololu
 
 AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
 # to submit bug reports.
 #AVRDUDE_VERBOSE = -v -v
 
-AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
-AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
-AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
-AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
+AVRDUDE_BASIC = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
+AVRDUDE_FLAGS = $(AVRDUDE_BASIC) $(AVRDUDE_NO_VERIFY) $(AVRDUDE_VERBOSE) $(AVRDUDE_ERASE_COUNTER)
 
 
-
-# ---------------------------------------------------------------------------
-
-# Define directories, if needed.
-DIRAVR = c:/winavr
-DIRAVRBIN = $(DIRAVR)/bin
-DIRAVRUTILS = $(DIRAVR)/utils/bin
-DIRINC = .
-DIRLIB = $(DIRAVR)/avr/lib
-
-
-# Define programs and commands.
 SHELL = sh
 CC = avr-gcc
 OBJCOPY = avr-objcopy
 NM = avr-nm
 AVRDUDE = avrdude
 REMOVE = rm -f
+MV = mv -f
 COPY = cp
 
-
-
-
-# Define Messages
-# English
-MSG_ERRORS_NONE = Errors: none
-MSG_BEGIN = -------- begin --------
-MSG_END = --------  end  --------
-MSG_SIZE_BEFORE = Size before:
-MSG_SIZE_AFTER = Size after:
-MSG_COFF = Converting to AVR COFF:
-MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
-MSG_FLASH = Creating load file for Flash:
-MSG_EEPROM = Creating load file for EEPROM:
-MSG_EXTENDED_LISTING = Creating Extended Listing:
-MSG_SYMBOL_TABLE = Creating Symbol Table:
-MSG_LINKING = Linking:
-MSG_COMPILING = Compiling:
-MSG_ASSEMBLING = Assembling:
-MSG_CLEANING = Cleaning project:
-
-
 # Define all object files.
 OBJ = $(SRC:.c=.o) $(ASRC:.S=.o)
 
 # Define all listing files.
 LST = $(ASRC:.S=.lst) $(SRC:.c=.lst)
 
-
-# Compiler flags to generate dependency files.
-GENDEPFLAGS = -Wp,-M,-MP,-MT,$(*F).o,-MF,.dep/$(@F).d
-
-
 # Combine all necessary flags and optional flags.
 # Add target processor to flags.
-# Removed from below until cygwin's make (3.81) is corrected: $(GENDEPFLAGS)
 ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
 ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
 
 
+# Default target.
+all: pmvm build
 
-
-
-# Default target.
-all: begin gccversion sizebefore pmvm build sizeafter finished end
-
-build: elf hex eep lss sym
+build: elf hex eep
 
 elf: $(TARGET).elf
 hex: $(TARGET).hex
 sym: $(TARGET).sym
 
 
+# Program the device.  
+program: $(TARGET).hex $(TARGET).eep
+	$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
+
+
+
+
+# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
+COFFCONVERT=$(OBJCOPY) --debugging \
+--change-section-address .data-0x800000 \
+--change-section-address .bss-0x800000 \
+--change-section-address .noinit-0x800000 \
+--change-section-address .eeprom-0x810000 
+
+
 # PyMite: Build the VM archive if it doesn't exist
 pmvm : $(PM_LIB_PATH)
 
 $(PM_LIB_PATH) : ../../vm/*.c ../../vm/*.h
 	make -C ../../vm
 
-
-# Eye candy.
-# AVR Studio 3.x does not check make's exit code but relies on
-# the following magic strings to be generated by the compile job.
-begin:
-	@echo
-	@echo $(MSG_BEGIN)
-
-finished:
-	@echo $(MSG_ERRORS_NONE)
-
-end:
-	@echo $(MSG_END)
-	@echo
-
-
-# Display size of file.
-HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
-ELFSIZE = $(SIZE) -A $(TARGET).elf
-sizebefore:
-	@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi
-
-sizeafter:
-	@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
-
-
-
-# Display compiler version information.
-gccversion :
-	@$(CC) --version
-
-
-
-# Program the device.
-program: $(TARGET).hex $(TARGET).eep
-	$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
-
-
-
-
-# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
-COFFCONVERT=$(OBJCOPY) --debugging \
---change-section-address .data-0x800000 \
---change-section-address .bss-0x800000 \
---change-section-address .noinit-0x800000 \
---change-section-address .eeprom-0x810000
+$(TARGET)_nat.c $(TARGET)_img.c: $(PM_USR_SOURCES)
+	$(PMIMGCREATOR) -c -u --memspace=flash -o $(TARGET)_img.c --native-file=$(TARGET)_nat.c $(PM_USR_SOURCES)
 
 
 coff: $(TARGET).elf
-	@echo
-	@echo $(MSG_COFF) $(TARGET).cof
-	$(COFFCONVERT) -O coff-avr $< $(TARGET).cof
+	$(COFFCONVERT) -O coff-avr $(TARGET).elf $(TARGET).cof
 
 
 extcoff: $(TARGET).elf
-	@echo
-	@echo $(MSG_EXTENDED_COFF) $(TARGET).cof
-	$(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
+	$(COFFCONVERT) -O coff-ext-avr $(TARGET).elf $(TARGET).cof
 
 
+.SUFFIXES: .elf .hex .eep .lss .sym
 
-# Create final output files (.hex, .eep) from ELF output file.
-%.hex: %.elf
-	@echo
-	@echo $(MSG_FLASH) $@
+.elf.hex:
 	$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
 
-%.eep: %.elf
-	@echo
-	@echo $(MSG_EEPROM) $@
+.elf.eep:
 	-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
 	--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
 
 # Create extended listing file from ELF output file.
-%.lss: %.elf
-	@echo
-	@echo $(MSG_EXTENDED_LISTING) $@
+.elf.lss:
 	$(OBJDUMP) -h -S $< > $@
 
 # Create a symbol table from ELF output file.
-%.sym: %.elf
-	@echo
-	@echo $(MSG_SYMBOL_TABLE) $@
+.elf.sym:
 	$(NM) -n $< > $@
 
 
 
 # Link: create ELF output file from object files.
-.SECONDARY : $(TARGET).elf
-.PRECIOUS : $(OBJ)
-%.elf: $(OBJ)
-	@echo
-	@echo $(MSG_LINKING) $@
+$(TARGET).elf: $(OBJ)
 	$(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS)
 
 
 # Compile: create object files from C source files.
-%.o : %.c
-	@echo
-	@echo $(MSG_COMPILING) $<
-	$(CC) -c $(ALL_CFLAGS) $< -o $@
+.c.o:
+	$(CC) -c $(ALL_CFLAGS) $< -o $@ 
 
 
 # Compile: create assembler files from C source files.
-%.s : %.c
+.c.s:
 	$(CC) -S $(ALL_CFLAGS) $< -o $@
 
 
 # Assemble: create object files from assembler source files.
-%.o : %.S
-	@echo
-	@echo $(MSG_ASSEMBLING) $<
+.S.o:
 	$(CC) -c $(ALL_ASFLAGS) $< -o $@
 
-# PyMite: The native fxn table and bytecode image are generated from python source
-$(TARGET)_nat.c $(TARGET)_img.c: $(PM_USR_SOURCES)
-	$(PMIMGCREATOR) -c -u --memspace=flash -o $(TARGET)_img.c --native-file=$(TARGET)_nat.c $(PM_USR_SOURCES)
 
 
 # Target: clean project.
-clean: begin clean_list finished end
-
-clean_list :
-	@echo
-	@echo $(MSG_CLEANING)
-	$(REMOVE) $(TARGET).hex
-	$(REMOVE) $(TARGET).eep
-	$(REMOVE) $(TARGET).obj
-	$(REMOVE) $(TARGET).cof
-	$(REMOVE) $(TARGET).elf
-	$(REMOVE) $(TARGET).map
-	$(REMOVE) $(TARGET).obj
-	$(REMOVE) $(TARGET).a90
-	$(REMOVE) $(TARGET).sym
-	$(REMOVE) $(TARGET).lnk
-	$(REMOVE) $(TARGET).lss
+clean:
+	$(REMOVE) $(TARGET).hex $(TARGET).eep $(TARGET).cof $(TARGET).elf \
+	$(TARGET).map $(TARGET).sym $(TARGET).lss \
+	$(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d)
 	$(REMOVE) $(TARGET)_img.*
 	$(REMOVE) $(TARGET)_nat.*
-	$(REMOVE) $(OBJ)
-	$(REMOVE) $(LST)
-	$(REMOVE) $(SRC:.c=.s)
-	$(REMOVE) $(SRC:.c=.d)
-	$(REMOVE) .dep/*
 
+depend:
+	if grep '^# DO NOT DELETE' $(MAKEFILE) >/dev/null; \
+	then \
+		sed -e '/^# DO NOT DELETE/,$$d' $(MAKEFILE) > \
+			$(MAKEFILE).$$$$ && \
+		$(MV) $(MAKEFILE).$$$$ $(MAKEFILE); \
+	fi
+	echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' \
+		>> $(MAKEFILE); \
+	$(CC) -M -mmcu=$(MCU) $(CDEFS) $(CINCS) $(SRC) $(ASRC) >> $(MAKEFILE)
 
-
-# Include the dependency files.
--include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
-
-
-# Listing of phony targets.
-.PHONY : all begin finish end sizebefore sizeafter gccversion \
-build elf hex eep lss sym coff extcoff clean clean_list program pmvm
-
+.PHONY:	all build elf hex eep lss sym program coff extcoff clean depend pmvm
 
 export CC OBJCOPY NM CFLAGS ALL_CFLAGS AR IPM PM_HEAP_SIZE PM_LIB_FN

src/platform/avr/README

 -------
 
 This sample project demonstrates a simple use case of PyMite on a
-microcontroller.  The file ``sample.c`` is used to initialize PyMite
+microcontroller.  The file ``main.c`` is used to initialize PyMite
 and indicate the name of the module it should run.  In this case, it
-will run the module ``sample.py``
+will run the module ``main.py``
 
-In the module ``sample.py``, we see that the program prints a "Hello world"
+In the module ``main.py``, we see that the program prints a "Hello world"
 message, defines and runs an initialization function and then imports the
 ``avr`` module that is provided by PyMite.  The function ``avr.portA()`` is
 called with the argument ``0xaa`` which will set the Port A pins to binary
 Building the Project
 --------------------
 
-Start with a clean PyMite tree.  Edit the ``src/sample/avr/Makefile`` near
-line 42 to set the type of AVR you are using and near line 42 to set the
+Start with a clean PyMite tree.  Edit the ``src/platform/avr/Makefile`` near
+line 20 to set the type of AVR you are using and near line 23 to set the
 frequency of your AVR's main clock.  The default values are::
 
     MCU = atmega103
     F_CPU = 4000000UL
 
-Then build the PyMite archive with ``TARGET=AVR`` and this sample project.::
+``platform/avr/Makefile`` will build the PyMite VM archive as well as the 
+sample application::
 
-    $ make TARGET=AVR
-    $ cd src/sample/avr
+    $ cd src/platform/avr
     $ make
 
 
     $ make program
 
 Otherwise, use your AVR programmer of choice to program
-``src/sample/avr/sample.hex`` onto your target AVR device.
+``src/platform/avr/main.hex`` onto your target AVR device.
 
 .. :mode=rest:

src/platform/desktop/Makefile

 ifeq ($(DEBUG),true)
 	CDEFS += -g -ggdb -D__DEBUG__=1
 endif
-CFLAGS = -Os -Wall -gstabs -Wstrict-prototypes -Werror -ansi -I../../vm $(CDEFS)
+CFLAGS = -Os -Wall -gstabs -Wstrict-prototypes -Werror -I../../vm $(CDEFS)
 
 %.out : %*_nat.c %*_img.c %.c
 	$(CC) $(CFLAGS) -o $@ $*_nat.c $*_img.c $*.c ../../vm/libpmvm.a
 
 clean :
 	$(MAKE) -C ../../vm clean
-	$(RM) $(OBJS) $(TARGET)_img.* $(TARGET)_nat.*
+	$(RM) $(TARGET).out $(OBJS) $(TARGET)_img.* $(TARGET)_nat.*

src/platform/desktop/README

+==========================
+The Desktop Sample Project
+==========================
+
+:Author:    Dean Hall
+:Id:        $Id$
+
+Purpose
+-------
+
+This is a sample project that demonstrates running interactive PyMite on the
+desktop.  Any POSIX-compliant OS should work (Mac OS X, Linux, Cygwin).
+
+
+Building the Project
+--------------------
+
+Start with a clean PyMite tree.  Build the PyMite VM archive as well as the 
+sample application::
+
+    $ cd src/platform/desktop
+    $ make
+
+
+Read ``docs/src/InteractivePyMite.txt`` to learn how to run ipm.
+
+
+.. :mode=rest:

src/platform/desktop/plat.c

 /** PyMite platform-specific routines for Desktop target */
 
 
-/* PyMite build process uses -ansi which disables certain features that
- * in turn disable features needed for signal processing. To work around
- * this, temporarily disable the corresponding #define. This is not
- * needed for Cygwin but for Linux. The -ansi option of GCC is explained
- * here: http://gcc.gnu.org/onlinedocs/gcc-4.0.3/gcc/C-Dialect-Options.html
- */
-#ifdef __STRICT_ANSI__
-#undef __STRICT_ANSI__
 #include <stdio.h>
-#define __STRICT_ANSI__
-#else
-#include <stdio.h>
-#endif
 #include <unistd.h>
 #include <signal.h>
 #include <string.h>

src/platform/mmb103/Makefile

 # Hey Emacs, this is a -*- makefile -*-
-#
-# WinAVR Sample makefile written by Eric B. Weddington, J�rg Wunsch, et al.
-# Released to the Public Domain
-# Please read the make user manual!
-#
-# Additional material for this makefile was submitted by:
-#  Tim Henigan
-#  Peter Fleury
-#  Reiner Patommel
-#  Sander Pool
-#  Frederik Rouleau
-#  Markus Pfaff
-#
-# On command line:
-#
-# make all = Make software.
-#
-# make clean = Clean out built project files.
-#
-# make coff = Convert ELF to AVR COFF (for use with AVR Studio 3.x or VMLAB).
-#
-# make extcoff = Convert ELF to AVR Extended COFF (for use with AVR Studio
-#                4.07 or greater).
-#
-# make program = Download the hex file to the device, using avrdude.  Please
-#                customize the avrdude settings below first!
-#
-# make filename.s = Just compile filename.c into the assembler code only
-#
-# To rebuild project do "make clean" then "make all".
-#
+
+# AVR-GCC Makefile template, derived from the WinAVR template (which
+# is public domain), believed to be neutral to any flavor of "make"
+# (GNU make, BSD make, SysV make)
 
 
 # PyMite Configuration
 PM_USR_SOURCES = main.py mmb.py
 PM_HEAP_SIZE = 0x0D00
 PMIMGCREATOR := ../../tools/pmImgCreator.py
+IPM=false
 
 
 # Platform Configuration
 MCU = atmega103
+FORMAT = ihex
+TARGET = main
 F_CPU = 4000000UL
 UART_BAUD = 19200UL
-
-
-# Output format. (can be srec, ihex, binary)
-FORMAT = ihex
-
-# Target file name (without extension).
-TARGET = main
-
-
-# List C source files here. (C dependencies are automatically generated.)
 SRC = $(TARGET).c plat.c $(TARGET)_nat.c $(TARGET)_img.c
-
-
-# List Assembler source files here.
-# Make them always end in a capital .S.  Files ending in a lowercase .s
-# will not be considered source files but generated files (assembler
-# output from the compiler), and will be deleted upon "make clean"!
-# Even though the DOS/Win* filesystem matches both .s and .S the same,
-# it will preserve the spelling of the filenames, and gcc itself does
-# care about how the name is spelled on its command-line.
 ASRC =
-
-
-
-# Optimization level, can be [0, 1, 2, 3, s].
-# 0 = turn off optimization. s = optimize for size.
-# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
 OPT = s
 
 # Debugging format.
 # AVR (extended) COFF requires stabs, plus an avr-objcopy run.
 DEBUG_FMT = stabs
 
-# List any extra directories to look for include files here.
-#     Each directory must be seperated by a space.
-EXTRAINCDIRS = ../../vm
-
-
 # Compiler flag to set the C Standard level.
 # c89   - "ANSI" C
 # gnu89 - c89 plus GCC extensions
 # Place -D or -U options here
 CDEFS = -DF_CPU=$(F_CPU) -DUART_BAUD=$(UART_BAUD)
 # PyMite CDEFS
-CDEFS += -DHEAP_SIZE=$(PM_HEAP_SIZE) 
+CDEFS += -DHEAP_SIZE=$(PM_HEAP_SIZE)
 ifeq ($(DEBUG),true)
 	CDEFS += -g -g$(DEBUG_FMT) -D__DEBUG__=1
 endif
 
 # Place -I options here
-CINCS =
+CINCS = -I../../vm
 
 
-# Compiler flags.
-#  -g*:          generate debugging information
-#  -O*:          optimization level
-#  -f...:        tuning, see GCC manual and avr-libc documentation
-#  -Wall...:     warning level
-#  -Wa,...:      tell GCC to pass this to the assembler.
-#    -adhlns...: create assembler listing
-CFLAGS = $(CDEFS) $(CINCS)
-CFLAGS += -O$(OPT)
-CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
-CFLAGS += -Wall -Wstrict-prototypes -Werror
-CFLAGS += -Wa,-adhlns=$(subst $(suffix $<),.lst,$<)
-CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
-CFLAGS += $(CSTANDARD)
-# PyMite CFLAGS
-#CFLAGS += -ansi # Removed because it causes a build error
+CDEBUG = -g$(DEBUG_FMT)
+CWARN = -Wall -Wstrict-prototypes
+CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
+#CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
+CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CSTANDARD) $(CTUNING) $(CEXTRA)
 
 
-# Assembler flags.
-#  -Wa,...:   tell GCC to pass this to the assembler.
-#  -ahlms:    create listing
-#  -gstabs:   have the assembler create line number information; note that
-#             for use in COFF files, additional information about filenames
-#             and function names needs to be present in the assembler source
-#             files -- see avr-libc docs [FIXME: not yet described there]
-ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
-
+#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
 
 
 #Additional libraries.
 
 SCANF_LIB =
 
-MATH_LIB =
+#MATH_LIB = -lm
 
 # External memory options
 
 
 EXTMEMOPTS =
 
-# Linker flags.
-#  -Wl,...:     tell GCC to pass this to linker.
-#    -Map:      create map file
-#    --cref:    add cross reference to  map file
-LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
-LDFLAGS += $(EXTMEMOPTS)
-LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
+#LDMAP = $(LDFLAGS) -Wl,-Map=$(TARGET).map,--cref
+LDFLAGS = $(EXTMEMOPTS) $(LDMAP) $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
 # PyMite
 LDFLAGS += -L../../vm -l$(PM_LIB_ROOT) -L. -lmmb103
 
 
-
-#---------------- Programming Options (avrdude) ----------------
-
-# Programming hardware: alf avr910 avrisp bascom bsd
-# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500 stk500v2
-#
-# Type: avrdude -c ?
-# to get a full listing.
-#
+# Programming support using avrdude. Settings and variables.
 
 AVRDUDE_PROGRAMMER = stk500v2
 AVRDUDE_PORT = /dev/cu.Pololu
 
 AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
-AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
+#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
 
 
 # Uncomment the following if you want avrdude's erase cycle counter.
 
 # Uncomment the following if you do /not/ wish a verification to be
 # performed after programming the device.
-AVRDUDE_NO_VERIFY = -V
+#AVRDUDE_NO_VERIFY = -V
 
 # Increase verbosity level.  Please use this when submitting bug
 # reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
 # to submit bug reports.
 #AVRDUDE_VERBOSE = -v -v
 
-AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
-AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
-AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
-AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
+AVRDUDE_BASIC = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
+AVRDUDE_FLAGS = $(AVRDUDE_BASIC) $(AVRDUDE_NO_VERIFY) $(AVRDUDE_VERBOSE) $(AVRDUDE_ERASE_COUNTER)
 
 
-
-# ---------------------------------------------------------------------------
-
-# Define directories, if needed.
-DIRAVR = c:/winavr
-DIRAVRBIN = $(DIRAVR)/bin
-DIRAVRUTILS = $(DIRAVR)/utils/bin
-DIRINC = .
-DIRLIB = $(DIRAVR)/avr/lib
-
-
-# Define programs and commands.
 SHELL = sh
 CC = avr-gcc
 OBJCOPY = avr-objcopy
 NM = avr-nm
 AVRDUDE = avrdude
 REMOVE = rm -f
+MV = mv -f
 COPY = cp
 
-
-# Define Messages
-# English
-MSG_ERRORS_NONE = Errors: none
-MSG_BEGIN = -------- begin --------
-MSG_END = --------  end  --------
-MSG_SIZE_BEFORE = Size before:
-MSG_SIZE_AFTER = Size after:
-MSG_COFF = Converting to AVR COFF:
-MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
-MSG_FLASH = Creating load file for Flash:
-MSG_EEPROM = Creating load file for EEPROM:
-MSG_EXTENDED_LISTING = Creating Extended Listing:
-MSG_SYMBOL_TABLE = Creating Symbol Table:
-MSG_LINKING = Linking:
-MSG_COMPILING = Compiling:
-MSG_ASSEMBLING = Assembling:
-MSG_CLEANING = Cleaning project:
-
-
 # Define all object files.
 OBJ = $(SRC:.c=.o) $(ASRC:.S=.o)
 
 # Define all listing files.
 LST = $(ASRC:.S=.lst) $(SRC:.c=.lst)
 
-
-# Compiler flags to generate dependency files.
-GENDEPFLAGS = -Wp,-M,-MP,-MT,$(*F).o,-MF,.dep/$(@F).d
-
-
 # Combine all necessary flags and optional flags.
 # Add target processor to flags.
-# Removed from below until cygwin's make (3.81) is corrected: $(GENDEPFLAGS)
 ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
 ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
 
 
 # Default target.
-all: begin gccversion pmvm sizebefore build sizeafter finished end
+all: pmvm build
 
-build: elf hex eep lss sym
+build: elf hex eep
 
 elf: $(TARGET).elf
 hex: $(TARGET).hex
 sym: $(TARGET).sym
 
 
-# PyMite: Build the VM archive if it doesn't exist
-pmvm : $(PM_LIB_PATH)
-
-$(PM_LIB_PATH) :
-	make -C ../../vm
-
-# Eye candy.
-# AVR Studio 3.x does not check make's exit code but relies on
-# the following magic strings to be generated by the compile job.
-begin:
-	@echo
-	@echo $(MSG_BEGIN)
-
-finished:
-	@echo $(MSG_ERRORS_NONE)
-
-end:
-	@echo $(MSG_END)
-	@echo
-
-
-# Display size of file.
-HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
-ELFSIZE = $(SIZE) -A $(TARGET).elf
-sizebefore:
-	@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi
-
-sizeafter:
-	@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
-
-
-# Display compiler version information.
-gccversion :
-	@$(CC) --version
-
-
-# Program the device.
+# Program the device.  
 program: $(TARGET).hex $(TARGET).eep
 	$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
 
 --change-section-address .data-0x800000 \
 --change-section-address .bss-0x800000 \
 --change-section-address .noinit-0x800000 \
---change-section-address .eeprom-0x810000
+--change-section-address .eeprom-0x810000 
+
+
+# PyMite: Build the VM archive if it doesn't exist
+pmvm : $(PM_LIB_PATH)
+
+$(PM_LIB_PATH) : ../../vm/*.c ../../vm/*.h
+	make -C ../../vm
+
+$(TARGET)_nat.c $(TARGET)_img.c: $(PM_USR_SOURCES)
+	$(PMIMGCREATOR) -c -u --memspace=flash -o $(TARGET)_img.c --native-file=$(TARGET)_nat.c $(PM_USR_SOURCES)
 
 
 coff: $(TARGET).elf
-	@echo
-	@echo $(MSG_COFF) $(TARGET).cof
-	$(COFFCONVERT) -O coff-avr $< $(TARGET).cof
+	$(COFFCONVERT) -O coff-avr $(TARGET).elf $(TARGET).cof
 
 
 extcoff: $(TARGET).elf
-	@echo
-	@echo $(MSG_EXTENDED_COFF) $(TARGET).cof
-	$(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
+	$(COFFCONVERT) -O coff-ext-avr $(TARGET).elf $(TARGET).cof
 
 
+.SUFFIXES: .elf .hex .eep .lss .sym
 
-# Create final output files (.hex, .eep) from ELF output file.
-%.hex: %.elf
-	@echo
-	@echo $(MSG_FLASH) $@
+.elf.hex:
 	$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
 
-%.eep: %.elf
-	@echo
-	@echo $(MSG_EEPROM) $@
+.elf.eep:
 	-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
 	--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
 
 # Create extended listing file from ELF output file.
-%.lss: %.elf
-	@echo
-	@echo $(MSG_EXTENDED_LISTING) $@
+.elf.lss:
 	$(OBJDUMP) -h -S $< > $@
 
 # Create a symbol table from ELF output file.
-%.sym: %.elf
-	@echo
-	@echo $(MSG_SYMBOL_TABLE) $@
+.elf.sym:
 	$(NM) -n $< > $@
 
 
 
 # Link: create ELF output file from object files.
-.SECONDARY : $(TARGET).elf
-.PRECIOUS : $(OBJ)
-%.elf: $(OBJ)
-	@echo
-	@echo $(MSG_LINKING) $@
+$(TARGET).elf: $(OBJ)
 	$(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS)
 
 
 # Compile: create object files from C source files.
-%.o : %.c
-	@echo
-	@echo $(MSG_COMPILING) $<
-	$(CC) -c $(ALL_CFLAGS) $< -o $@
+.c.o:
+	$(CC) -c $(ALL_CFLAGS) $< -o $@ 
 
 
 # Compile: create assembler files from C source files.
-%.s : %.c
+.c.s:
 	$(CC) -S $(ALL_CFLAGS) $< -o $@
 
 
 # Assemble: create object files from assembler source files.
-%.o : %.S
-	@echo
-	@echo $(MSG_ASSEMBLING) $<
+.S.o:
 	$(CC) -c $(ALL_ASFLAGS) $< -o $@
 
-# PyMite: The native fxn table and bytecode image are generated from python source
-$(TARGET)_nat.c $(TARGET)_img.c: $(PM_USR_SOURCES)
-	$(PMIMGCREATOR) -c -u --memspace=flash -o $(TARGET)_img.c --native-file=$(TARGET)_nat.c $(PM_USR_SOURCES)
 
 
 # Target: clean project.
-clean: begin clean_list finished end
-
-clean_list :
-	@echo
-	@echo $(MSG_CLEANING)
-	$(REMOVE) $(TARGET).hex
-	$(REMOVE) $(TARGET).eep
-	$(REMOVE) $(TARGET).obj
-	$(REMOVE) $(TARGET).cof
-	$(REMOVE) $(TARGET).elf
-	$(REMOVE) $(TARGET).map
-	$(REMOVE) $(TARGET).obj
-	$(REMOVE) $(TARGET).a90
-	$(REMOVE) $(TARGET).sym
-	$(REMOVE) $(TARGET).lnk
-	$(REMOVE) $(TARGET).lss
+clean:
+	$(REMOVE) $(TARGET).hex $(TARGET).eep $(TARGET).cof $(TARGET).elf \
+	$(TARGET).map $(TARGET).sym $(TARGET).lss \
+	$(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d)
 	$(REMOVE) $(TARGET)_img.*
 	$(REMOVE) $(TARGET)_nat.*
-	$(REMOVE) $(OBJ)
-	$(REMOVE) $(LST)
-	$(REMOVE) $(SRC:.c=.s)
-	$(REMOVE) $(SRC:.c=.d)
-	$(REMOVE) .dep/*
 
+depend:
+	if grep '^# DO NOT DELETE' $(MAKEFILE) >/dev/null; \
+	then \
+		sed -e '/^# DO NOT DELETE/,$$d' $(MAKEFILE) > \
+			$(MAKEFILE).$$$$ && \
+		$(MV) $(MAKEFILE).$$$$ $(MAKEFILE); \
+	fi
+	echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' \
+		>> $(MAKEFILE); \
+	$(CC) -M -mmcu=$(MCU) $(CDEFS) $(CINCS) $(SRC) $(ASRC) >> $(MAKEFILE)
 
-
-# Include the dependency files.
--include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
-
-
-# Listing of phony targets.
-.PHONY : all begin finish end sizebefore sizeafter gccversion \
-build elf hex eep lss sym coff extcoff clean clean_list program pmvm
-
+.PHONY:	all build elf hex eep lss sym program coff extcoff clean depend pmvm
 
 export CC OBJCOPY NM CFLAGS ALL_CFLAGS AR IPM PM_HEAP_SIZE PM_LIB_FN

src/platform/mmb103/README

 Building the Project
 --------------------
 
-Start with a clean PyMite tree.  Build the PyMite archive with ``TARGET=AVR``
-and then build this sample project.::
+Start with a clean PyMite tree.  The following commands build the PyMite
+interpreter and the sample project.::
 
-    $ make TARGET=AVR
-    $ cd src/sample/mmb103
+    $ cd src/platform/mmb103
     $ make
 
-This will result in the file ``src/sample/mmb103/main.hex``.  Use your AVR
+This will result in the file ``src/platform/mmb103/main.hex``.  Use your AVR
 programmer of choice to program that file into the ATmega103 target device.
+The author's defaults are set in the Makefile, so this programs the device::
+
+    $ make program
 
 .. :mode=rest:

src/tests/system/Makefile

 ifeq ($(DEBUG),true)
 	CDEFS += -g -ggdb -D__DEBUG__=1
 endif
-CFLAGS = -Os -Wall -Wstrict-prototypes -Werror $(CDEFS) -ansi -I../../vm
+CFLAGS = -Os -Wall -Wstrict-prototypes -Werror $(CDEFS) -I../../vm
 
 
 # Build an executable from the C sources

src/tests/system/plat.c

 /** PyMite platform-specific routines for Desktop target */
 
 
-/* PyMite build process uses -ansi which disables certain features that
- * in turn disable features needed for signal processing. To work around
- * this, temporarily disable the corresponding #define. This is not
- * needed for Cygwin but for Linux. The -ansi option of GCC is explained
- * here: http://gcc.gnu.org/onlinedocs/gcc-4.0.3/gcc/C-Dialect-Options.html
- */
-#ifdef __STRICT_ANSI__
-#undef __STRICT_ANSI__
 #include <stdio.h>
-#define __STRICT_ANSI__
-#else
-#include <stdio.h>
-#endif
 #include <unistd.h>
 #include <signal.h>
 #include <string.h>

src/tests/unit/Makefile

 PM_LIB_ROOT = pmvm.$(PLATFORM)
 PM_LIB_FN = lib$(PM_LIB_ROOT).a
 PM_LIB_PATH = ../../vm/$(PM_LIB_FN)
-PM_HEAP_SIZE ?= 0x1000
+PM_HEAP_SIZE = 0x2000
 DEBUG = true
 
 UT_SOURCES = $(wildcard ut*.c)
 endif
 CFLAGS = -I../../vm $(CDEFS)
 
-.PHONY: all check clean
+.PHONY: all check clean $(PRODUCT)
 
 export CFLAGS IPM HEAP_SIZE PM_LIB_FN
 

src/tests/unit/plat.c

 /** PyMite platform-specific routines for Desktop target */
 
 
-/* PyMite build process uses -ansi which disables certain features that
- * in turn disable features needed for signal processing. To work around
- * this, temporarily disable the corresponding #define. This is not
- * needed for Cygwin but for Linux. The -ansi option of GCC is explained
- * here: http://gcc.gnu.org/onlinedocs/gcc-4.0.3/gcc/C-Dialect-Options.html
- */
-#ifdef __STRICT_ANSI__
-#undef __STRICT_ANSI__
 #include <stdio.h>
-#define __STRICT_ANSI__
-#else
-#include <stdio.h>
-#endif
 #include <unistd.h>
 #include <signal.h>
 #include <string.h>
 
 
 .PHONY: all size indent clean
+# Must delete/rebuild these intermediate files because they depend on the platform
 .INTERMEDIATE: $(SOURCE_IMG) $(SOURCE_NAT)
 
 # Default action is to build the archive from object files