I wrote a makefile for arduino using various sources on the net. Part of the makefile's text is here (but the whole thing is too long for the forum) and a bit more info, including a sample project with the BlinkM LEDs is posted on my site at http://alejandroerickson.com/joomla/personal-projects/73-a-makefile-for-arduino-v-0021 :).
#
# A basic makefile for compiling .c and .cpp files for Arduino
# By Alejandro Erickson alejandro.erickson@gmail.com
# and some ideas snarfed from the Internet,
# Especially
# David Wolever
# http://blog.codekills.net/
# and
# eighthave, oli.keller,
# alex norman [with help from http://code.google.com/p/arduino/issues/detail?id=65#c5]
# also
# mimicking the output from Verbose Verify and Verbose Upload in the Arduino IDE 0021
#
# Disclaimer: I am a GNUmake and Arduino newbie. Suggestions and improvments are
# welcome. This makefile does not deal with list files or assembly (except
# where I used a few lines from makefiles that do and was afraid to delete
# something). Also, note that this builds the core library files in the
# Arduino IDE directory instead of this directory.
# Sorry if it messes up another project you have going...
#
# Instructions:
#
# This makefile assumes you are using Mac OS X and Arduino IDE. You may
# have to specify a different location for the Arduino IDE and even for
# it's internal file structure. I've tried to indicate where that might come up.
#
# Make a project folder for your code and add to it your main.cpp along with (this)
# Makefile. You can also include library files there, but you don't have to.
#
# I think your main.cpp file should look more less like this:
#
# #include "WProgram.h"
# //#include <other library headers>
#
# //<#defines and globals>
#
# extern "C" void __cxa_pure_virtual()
# {
# cli(); // disable interrupts
# for(;;); // do nothing until hard reset
# }
#
# void setup(){
# //code...
# }
#
# void loop(){
# \\code...
# }
#
# int main(){
# init();
# setup();
# for(;;) loop();
# return 0;
# }
#***************************** HARDWARE
#these things are specific to the board. Try finding the parameters
#for yours on the Internet ^_^
#I've used the ones for the Arduino Duemilanove (or Nano w/ ATmega328)
#UPLOAD_SPEED = 57600
#UPLOAD_PROTOCOL = stk500
#BUILD_MCU = atmega328p
#F_CPU = 16000000
#I've used the ones for the Arduino UNO (or Nano w/ ATmega328)
#UPLOAD_SPEED = 115200
#UPLOAD_PROTOCOL = stk500v1
#BUILD_MCU = atmega328p
# why *L? I don't know but that's what shows up in the Arduino IDE output
#F_CPU = 16000000L
#Seeeduino Mega
UPLOAD_SPEED = 57600
UPLOAD_PROTOCOL = stk500v1
BUILD_MCU = atmega1280
# why *L? I don't know but that's what shows up in the Arduino IDE output
F_CPU = 16000000L
#this is where your Arduino is plugged in. You can check it's exact
#location by plugging the board into your computer and typing cd /dev/tty. <tab>
#it might show up as a usb modem instead...
PORT = /dev/tty.usbserial-A7004J48
#PORT = /dev/tty.usbmodem1d11
#/dev/tty.usbserial*
#*********************************** END HARDWARE
#********************* PATHS TO IMPORTANT STUFF
#your main() should be in main.cpp. don't change this, you'll mess things up
TARGET = main.cpp