Here is a simple makefile example.
What it does is define constants like PROJECT or SOURCE and gives them a value you choose.
Then that is run by a make command which is an automake type program which compiles the program according to your makefile's instructions
PROJECT=blink
SOURCES=$(PROJECT).c
MMCU=atmega328p
F_CPU=10000000
# The serial port of your Arduino board (if using Arduino as ISP):
# - on Mac OS X, use: /dev/tty.usbserial-*
# - on Windows, use the appropriate COM port, e.g.: COM3
# - on Linux, use: /dev/ttyUSB0
SERIAL=/dev/ttyUSB4
CFLAGS=-mmcu=$(MMCU) -DF_CPU=$(F_CPU) -Os
$(PROJECT).hex: $(PROJECT).out
avr-objcopy -j .text -O ihex $(PROJECT).out $(PROJECT).hex
$(PROJECT).out: $(SOURCES)
avr-gcc $(CFLAGS) -o $(PROJECT).out $(SOURCES)
program-arduinoisp: $(PROJECT).hex
avrdude -p $(MMCU) -P $(SERIAL) -c stk500v1 -U flash:w:$(PROJECT).hex
program-avrisp2: $(PROJECT).hex
avrdude -p $(MMCU) -P usb -c avrisp2 -U flash:w:$(PROJECT).hex
program-usbtiny: $(PROJECT).hex
/arduino-1.0.1/hardware/tools/avrdude -p $(MMCU) -c usbtiny -U flash:w:$(PROJECT).hex
clean:
rm $(PROJECT).out $(PROJECT).hex