NAME   = demoh103_blink_rom

CC      = arm-none-eabi-gcc 
LD      = arm-none-eabi-ld -v
AR      = arm-none-eabi-ar
AS      = arm-none-eabi-as
CP      = arm-none-eabi-objcopy
OD		= arm-none-eabi-objdump
  
CFLAGS  =  -I./ -c -fno-common -O2 -g -mcpu=cortex-m3 -mthumb 
AFLAGS  = -ahls -mcpu=cortex-m3 -mthumb
LFLAGS  = -nostartfiles  -Tstm32.ld -Wl,-Map=output.map
CPFLAGS = -Obinary
ODFLAGS	= -S



all: test

clean:
	-rm -f startup_stm32f10x.lst startup_stm32f10x.o system_stm32f10x.o main.o main.out main.bin main.list output.map stm32f10x_rcc.o stm32f10x_gpio.o stm32f10x_tim.o stm32f10x_dma.o stm32f10x_adc.o stm32f10x_flash.o stm32f10x_i2c.o stm32f10x_it.o I2CRoutines.o misc.o stm32f10x_usart.o DCM.o DCM_test.o Constrain.o 
	


test: main.out
	@ echo "...copying"
	$(CP) $(CPFLAGS) main.out main.bin
	$(OD) $(ODFLAGS) main.out > main.list

main.out:  main.o startup_stm32f10x.o stm32.ld system_stm32f10x.o stm32f10x_rcc.o stm32f10x_gpio.o stm32f10x_tim.o stm32f10x_dma.o stm32f10x_adc.o stm32f10x_flash.o stm32f10x_i2c.o stm32f10x_it.o I2CRoutines.o misc.o stm32f10x_usart.o DCM.o Constrain.o 
	@ echo "..linking"
	$(CC) $(LFLAGS) -o main.out  main.o -lm startup_stm32f10x.o system_stm32f10x.o stm32f10x_rcc.o stm32f10x_gpio.o stm32f10x_tim.o stm32f10x_dma.o stm32f10x_adc.o stm32f10x_flash.o stm32f10x_i2c.o stm32f10x_it.o I2CRoutines.o misc.o stm32f10x_usart.o DCM.o -lm Constrain.o

startup_stm32f10x.o: startup_stm32f10x.s
	@ echo ".assembling"
	$(AS) $(AFLAGS) -o startup_stm32f10x.o startup_stm32f10x.s > startup_stm32f10x.lst
	
system_stm32f10x.o: system_stm32f10x.c
	@ echo ".compil"
	$(CC) $(CFLAGS) system_stm32f10x.c 

stm32f10x_rcc.o: stm32f10x_rcc.c 
	@ echo ".compil"
	 $(CC) $(CFLAGS) stm32f10x_rcc.c 
	 
stm32f10x_gpio.o: stm32f10x_gpio.c
	@ echo ".compili"
	 $(CC) $(CFLAGS) stm32f10x_gpio.c 

stm32f10x_tim.o: stm32f10x_tim.c
	@ echo ".compilin"
	 $(CC) $(CFLAGS) stm32f10x_tim.c 

stm32f10x_dma.o: stm32f10x_dma.c
	@ echo ".compilin"
	 $(CC) $(CFLAGS) stm32f10x_dma.c 
	 
stm32f10x_adc.o: stm32f10x_adc.c
	@ echo ".compilin"
	 $(CC) $(CFLAGS) stm32f10x_adc.c 
	 
stm32f10x_flash.o: stm32f10x_flash.c
	@ echo ".compilin"
	 $(CC) $(CFLAGS) stm32f10x_flash.c 
	 
stm32f10x_i2c.o: stm32f10x_i2c.c
	@ echo ".compilin"
	 $(CC) $(CFLAGS) stm32f10x_i2c.c 
	 
stm32f10x_it.o: stm32f10x_it.c
	@ echo ".compilin"
	 $(CC) $(CFLAGS) stm32f10x_it.c
	 
I2CRoutines.o: I2CRoutines.c
	@ echo ".compilin"
	 $(CC) $(CFLAGS) I2CRoutines.c 
	 
misc.o: misc.c
	@ echo ".compilin"
	 $(CC) $(CFLAGS) misc.c
	 
stm32f10x_usart.o: stm32f10x_usart.c
	@ echo ".compilin"
	 $(CC) $(CFLAGS) stm32f10x_usart.c
	 
DCM.o: DCM.c
	@ echo ".compilin"
	 $(CC) $(CFLAGS) DCM.c	
	 	 
Constrain.o: Constrain.c
	@ echo ".compiling"
	 $(CC) $(CFLAGS) Constrain.c  	 
	 
main.o: main.c
	@ echo ".compiling"
	 $(CC) $(CFLAGS) main.c