본문 바로가기
WORK/Sotfware

makefile

by KANG Stroy 2008. 7. 11.
728x90
728x90

# 어디서 주서 온건지는 모르지만 잘 사용하고 있는 거라서 함 올려 봅니다.
# 0 //Do not modify any of lines. Be sure to put 'Tab' before command.
# 1 Default Makefile
# 2 define some variables based on the AVR base path in $(AVR)
 CC=avr-gcc
 AS=avr-gcc -x assembler-with-cpp
 RM=rm -f
 RN=mv
 BIN=avr-objcopy
 ELFCOF=elfcoff
 SIZE=avr-size
 INCDIR=.
 LIBDIR=$(AVR)/WinAvr/Avr/Lib
 SHELL=$(AVR)/WinAvr/Bin/sh.exe
# 13 output format can be srec, ihex (avrobj is always created) #######
  FORMAT=ihex
# 15 put the name of the target mcu here (at90s8515, at90s8535, attiny22, atmega603 etc.)

 MCU=atmega128  # 칩 이름 넣기

# 17 put the name of the target file here (without extension)

 TRG=LED_TEST  # 컴파일 하기 위한 C파일

# 19 put your C sourcefiles here
 SRC=$(TRG).c
# 21 put additional assembler source file here
 ASRC=
# 23 additional libraries and object files to link
 LIB=
# 25 additional includes to compile
 INC=LCD_Font
# 27 ###################### default compiler flags ##########################
 CPFLAGS=-gdwarf-2 -O0 -Wall -Wstrict-prototypes -Wa,-ahlms=$(<:.c=.lst)
 ASFLAGS=-Wa,-gstabs
 LDFLAGS=-Wl,-Map=$(TRG).map,--cref,-lm
# 31 define all project specific object files
 OBJ= $(ASRC:.s=.o) $(SRC:.c=.o)
 CPFLAGS += -mmcu=$(MCU)
 ASFLAGS += -mmcu=$(MCU)
 LDFLAGS += -mmcu=$(MCU)
# 36 this defines the aims of the make process    
all: $(TRG).elf $(TRG).hex $(TRG).ok
# 38 compile: instructions to create assembler and/or object files from C source48 .cof
%o : %c
 $(CC) -c $(CPFLAGS) -I$(INCDIR) $< -o $@
%s : %c
 $(CC) -S $(CPFLAGS) -I$(INCDIR) $< -o $@
# 43 assemble: instructions to create object file from assembler files53
%o : %s
 $(AS) -c $(ASFLAGS) -I$(INCDIR) $< -o $@
# 46 link: instructions to create elf output file from object files56
%elf: $(OBJ)
 $(CC) $(OBJ) $(LIB) $(LDFLAGS) -o $@
%hex: %elf
 $(BIN) -O $(FORMAT) $< $@
#59 If all other steps compile ok then echo "Errors: none".$(ELFCOF) $< $(OUT) $@ $*cof
%ok:
 @echo "Errors: none"
# 62 make instruction to delete created files67
clean:
 $(RM) $(OBJ)
 $(RM) $(SRC:.c=.s)
 $(RM) $(SRC:.c=.lst)
 $(RM) $(TRG).map
 $(RM) $(TRG).elf
 $(RM) $(TRG).hex
 $(RM) *.bak
 $(RM) *.log
size:
 $(SIZE) $(TRG).elf
# 77 ##### dependecies, add any dependencies you need here ###################
$(TRG).o : $(TRG).c



728x90

댓글