Embedded 실습/환경설정

lcd.c lcd.h의 makefile 수정하기

중동콜링 2013. 4. 22. 16:16

#------------------------------------------------------

# 2013 SmartController Cource - By CM SueHong Jue, 2013.04.08.

#------------------------------------------------------

ifndef ERASE_FCT

# rm -rf: 묻지도 따지지도 않고 강제 삭제

ERASE_FCT=rm -rf

endif

ifndef WCCROSS_COMPILE

WCCROSS_COMPILE=arm-elf-

endif


WCTOOL=gcc


WCOUTFILE_SRAM=at91sam7s_sram_wc

WCOUTFILE_FLASH=at91sam7s_flash_wc


WCTARGET=AT91SAM7S256

# include 폴더 위치 지정

WCINCL=./include


# Debug Mode, OPTIM: 컴파일 최적화 옵션 -Os: 파일 크기 최적화 

OPTIM=-Os

# ifeq: if equal

ifeq ($(WCTOOL), gcc)


# AS(어셈블러) = arm-elf-gcc, CC(C 컴파일러), LD(링커)

AS=$(WCCROSS_COMPILE)gcc

CC=$(WCCROSS_COMPILE)gcc

LD=$(WCCROSS_COMPILE)gcc


OBJCOPY=$(WCCROSS_COMPILE)objcopy

OBJDUMP=$(WCCROSS_COMPILE)objdump


NM= $(WCCROSS_COMPILE)nm

SIZE=$(WCCROSS_COMPILE)size


#-----------------컴파일 옵션---------------------

# CCFLAGS : C컴파일 옵션, arm7tdmi : arm core명칭, Warning All 출력, 

# I:include directory, -D: define 효과

CCFLAGS=-g -mcpu=arm7tdmi $(OPTIM) -Wall -I$(WCINCL) -D$(WCTARGET) --save-temps

ASFLAGS=-D__ASSEMBLY__ -D$(WCTARGET) -g -mcpu=arm7tdmi -c $(OPTIM) -Wall -I$(WCINCL)


LDFLAGS+=-nostartfiles -Wl,--cref

LDFLAGS+=-lc -lgcc

LDFLAGS+=-T elf32-littlearm.lds


OBJS=cstartup.o

# ifeq ~ endif

endif


# 값 추가, \ : 아래 윗줄 합치기 C에서도 가능

OBJS+= lowlevel.o \

       main.o \

       lcd.o


all: sram flash


rebuild: clean all


sram: $(OBJS)

$(LD) $(LDFLAGS) -Ttext 0x201000 -Tdata 0x200000 -n -o $(WCOUTFILE_SRAM).elf $(OBJS)

$(OBJCOPY) --strip-debug --strip-unneeded $(WCOUTFILE_SRAM).elf -O binary $(WCOUTFILE_SRAM).bin


flash: $(OBJS)

$(LD) $(LDFLAGS) -Ttext 0x100000 -Tdata 0x200000 -n -o $(WCOUTFILE_FLASH).elf                                               $(OBJS)

$(OBJCOPY) --strip-debug --strip-unneeded $(WCOUTFILE_FLASH).elf -O binary $(WCOUTFILE_FLASH).bin


main.o: main.c

$(CC) -c $(CCFLAGS) main.c -o main.o


lowlevel.o: lowlevel.c

$(CC) -c $(CCFLAGS) lowlevel.c -o lowlevel.o


lcd.o: lcd.c

$(CC) -c $(CCFLAGS) lcd.c -o lcd.o


# cstartup.S 파일이 있는지 없는지 검사 -> dependency 의존성 검사

# A : B -> B에 A가 의존. 

cstartup.o:  cstartup.S

$(AS) $(ASFLAGS) cstartup.S -o cstartup.o

# arm-elf-gcc /-D__ASSEMBLY__ -D$(WCTARGET) -g -mcpu=arm7tdmi -c $(OPTIM) -Wall -I$(WCINCL)           # /cstartup.S...

#      -DAT91SAM7S256


clean:

$(ERASE_FCT) *.o *.bin *.elf *.map




새로 소스파일을 추가했을 때 추가해줘야 하는 부분
주석