Skip to content
Snippets Groups Projects
Select Git revision
  • master default protected
1 result

Makefile

Blame
  • Makefile 1.85 KiB
    PROJECT=current_control
    CHIP=atmega16
    
    ARCH=avr
    AVRSOURCE=
    AVRAUTO=compiled/$(ARCH)/
    AVRARCH=compiled/$(ARCH)/
    LIB_TARGET=$(AVRARCH)lib$(TARGET).a
    
    CC=$(ARCH)-gcc
    CXX=$(ARCH)-gcc
    CCFLAGS=-mmcu=$(CHIP) -O5 -I. -I$(AVRAUTO) 
    AS=$(ARCH)-as
    ASFLAGS=-mmcu=$(CHIP)
    AR=$(ARCH)-ar
    LD=$(ARCH)-ld
    OBJDUMP=$(ARCH)-objdump
    LDFLAGS= -T $(CHIP).link
    
    all: $(AVRARCH)$(PROJECT)
    
    $(LIB_TARGET)(%.o):     $(AVRSOURCE)%.c Makefile
    	$(CC) $(CCFLAGS) -c -o $(AVRARCH)$(%) -I$(AVRSOURCE) -I$(AVRAUTO) $(<) 
    	$(AR) r $(@) $(AVRARCH)$(%)
    	rm $(AVRARCH)$(%)
    
    $(LIB_TARGET)(%.o):     $(AVRSOURCE)%.cc Makefile
    	$(CXX) $(CCFLAGS) -c -o $(AVRARCH)$(%) -I$(AVRSOURCE) -I$(AVRAUTO) $(<) 
    	$(AR) r $(@) $(AVRARCH)$(%)
    	rm $(AVRARCH)$(%)
    
    $(LIB_TARGET)(%.o):     $(AVRSOURCE)%.s Makefile
    	$(AS) $(ASFLAGS) -o $(AVRARCH)$(%) $(AVRSOURCE)$(*).s
    	$(AR) r $(@) $(AVRARCH)$(%)
    	rm $(AVRARCH)$(%)
    
    $(AVRARCH)%.o:           $(AVRSOURCE)%.s Makefile
    	$(AS) $(ASFLAGS) -o $@ $(AVRSOURCE)$(*).s
    
    $(AVRARCH)%.o:           $(AVRSOURCE)%.c Makefile
    	$(CC) $(CCFLAGS) -c -o $@ -I. -I$(AVRAUTO) $< 
    
    
    $(AVRARCH)%:           $(AVRARCH)%.o Makefile
    	$(CC) $(CCFLAGS) -o $@ $<  -lm
    
    $(AVRARCH)%.sr:	all $(AVRARCH)%
    	avr-objcopy -O srec $(AVRARCH)/$(*) $@ 
    
    %.sr:	$(AVRARCH)%.sr
    	@/bin/true
    
    %.load:	compiled/avr/%.sr
    #	/work/andersb/atmel/uisp/uisp-0.2b/src/uisp \
    #	 	-dno-poll -dstk200 --erase --upload if=$(AVRARCH)/$(*).sr
    	uisp \
    		-dprog=stk200 \
    		--erase \
    		--upload if=compiled/avr/$*.sr
    
    %.load.stk500:	compiled/avr/%.sr
    	uisp \
    		-dprog=stk500 \
    		--erase \
    		--upload if=compiled/avr/$*.sr
    
    %.dump:	all $(AVRARCH)/%
    	$(OBJDUMP) -D $(AVRARCH)/$(*)
    
    $(AVRARCH)fuse.sr:	fuse.s
    	avr-gcc -o $(AVRARCH)fuse.o -c fuse.s 
    	avr-objcopy -O srec $(AVRARCH)fuse.o $(AVRARCH)fuse.sr
    
    fuse.load:	$(AVRARCH)fuse.sr
    	uisp \
    		-dprog=stk200 \
    		--erase \
    		--segment=fuse \
    		--upload if=compiled/avr/fuse.sr
    
    load.stk500:	$(PROJECT).load.stk500