little kernel的編譯系統(tǒng)學習心得

編譯時指定project凭豪,即包含project/$(PROJECT).mk焙蹭。這個mk里指定了$(TARGET)。
接著會包含target/$(TARGET)/rules.mk嫂伞。指定$(PLATFORM)孔厉。
接著會包含include platform/$(PLATFORM)/rules.mk。指定$(ARCH)和$(ARM_CPU)/$(CPU)和$(LINKER_SCRIPT)帖努。
接著會包含include arch/$(ARCH)/rules.mk撰豺。定義了linker script的規(guī)則。

include project/$(PROJECT).mk
include target/$(TARGET)/rules.mk
include platform/$(PLATFORM)/rules.mk
include arch/$(ARCH)/rules.mk
include platform/rules.mk
include target/rules.mk
include kernel/rules.mk
include dev/rules.mk
include app/rules.mk

include project/$(PROJECT).mk
include target/$(TARGET)/rules.mk
include platform/$(PLATFORM)/rules.mk
include arch/$(ARCH)/rules.mk
include platform/rules.mk
include target/rules.mk
include kernel/rules.mk
include dev/rules.mk
include app/rules.mk

Example: make aboot-surf7k
Platform:msm7k
Target:aboot-surf7k

First
all:: $(OUTBIN) $(OUTELF).lst $(OUTELF).debug.lst $(OUTELF).sym $(OUTELF).size
Extension
OUTBIN := $(BUILDDIR)/lk.bin
OUTELF := $(BUILDDIR)/lk

Next
$(OUTBIN): $(OUTELF)
Action
$(NOCOPY)$(OBJCOPY) -O binary $< $@
Extension
OBJCOPY := $(TOOLCHAIN_PREFIX)objcopy

Next
$(OUTELF): $(ALLOBJS) $(LINKER_SCRIPT)
Action
$(NOECHO)$(LD) $(LDFLAGS) -T $(LINKER_SCRIPT) $(ALLOBJS) $(LIBGCC) -o $@
Extension
LD := $(TOOLCHAIN_PREFIX)ld
LDFLAGS += -gc-sections
LINKER_SCRIPT += $(BUILDDIR)/system-onesegment.ld
BUILDDIR := build-$(PROJECT)
ALLOBJS :=
$(BOOTOBJS)
$(OBJS)
ALLOBJS := $(addprefix $(BUILDDIR)/,$(ALLOBJS))
LIBGCC := $(shell $(TOOLCHAIN_PREFIX)gcc $(CFLAGS) $(THUMBCFLAGS) -print-libgcc-file-name)

Next
BOOTOBJS +=
$(LOCAL_DIR)/crt0.o
OBJS由各個rules.mk里定義拼余。具體例子:
build-aboot-surf7k/arch/arm/crt0.o
build-aboot-surf7k/target/surf-msm7k/init.o
build-aboot-surf7k/target/surf-msm7k/keypad.o
build-aboot-surf7k/target/surf-msm7k/panel.o
build-aboot-surf7k/platform/msm7k/platform.o
build-aboot-surf7k/platform/msm7k/interrupts.o
build-aboot-surf7k/platform/msm7k/mddi.o
build-aboot-surf7k/platform/msm7k/gpio.o
build-aboot-surf7k/platform/msm_shared/uart.o
build-aboot-surf7k/platform/msm_shared/timer.o
build-aboot-surf7k/platform/msm_shared/proc_comm.o
build-aboot-surf7k/platform/msm_shared/debug.o
build-aboot-surf7k/platform/msm_shared/smem.o
build-aboot-surf7k/platform/msm_shared/smem_ptable.o
build-aboot-surf7k/platform/msm_shared/hsusb.o
build-aboot-surf7k/platform/msm_shared/nand.o
build-aboot-surf7k/arch/arm/arch.Ao
build-aboot-surf7k/arch/arm/asm.o
build-aboot-surf7k/arch/arm/cache.o
build-aboot-surf7k/arch/arm/cache-ops.o
build-aboot-surf7k/arch/arm/ops.o
build-aboot-surf7k/arch/arm/exceptions.o
build-aboot-surf7k/arch/arm/faults.o
build-aboot-surf7k/arch/arm/mmu.o
build-aboot-surf7k/arch/arm/thread.o
build-aboot-surf7k/arch/arm/dcc.o
build-aboot-surf7k/platform/debug.o
build-aboot-surf7k/platform/init.o
build-aboot-surf7k/target/init.o
build-aboot-surf7k/kernel/debug.o
build-aboot-surf7k/kernel/dpc.o
build-aboot-surf7k/kernel/event.o
build-aboot-surf7k/kernel/main.o
build-aboot-surf7k/kernel/mutex.o
build-aboot-surf7k/kernel/thread.o
build-aboot-surf7k/kernel/timer.o
build-aboot-surf7k/dev/dev.o
build-aboot-surf7k/app/app.o
build-aboot-surf7k/app/aboot/aboot.o
build-aboot-surf7k/app/aboot/fastboot.o
build-aboot-surf7k/dev/fbcon/fbcon.o
build-aboot-surf7k/dev/keys/keys.o
build-aboot-surf7k/dev/keys/gpio_keypad.o
build-aboot-surf7k/lib/debug/debug.o
build-aboot-surf7k/lib/heap/heap.o
build-aboot-surf7k/lib/libc/atoi.o
build-aboot-surf7k/lib/libc/ctype.o
build-aboot-surf7k/lib/libc/printf.o
build-aboot-surf7k/lib/libc/malloc.o
build-aboot-surf7k/lib/libc/rand.o
build-aboot-surf7k/lib/libc/eabi.o
build-aboot-surf7k/lib/libc/string/arch/arm/memcpy.o
build-aboot-surf7k/lib/libc/string/arch/arm/memset.o
build-aboot-surf7k/lib/libc/string/memchr.o
build-aboot-surf7k/lib/libc/string/memcmp.o
build-aboot-surf7k/lib/libc/string/strcat.o
build-aboot-surf7k/lib/libc/string/strchr.o
build-aboot-surf7k/lib/libc/string/strcmp.o
build-aboot-surf7k/lib/libc/string/strcoll.o
build-aboot-surf7k/lib/libc/string/strcpy.o
build-aboot-surf7k/lib/libc/string/strdup.o
build-aboot-surf7k/lib/libc/string/strerror.o
build-aboot-surf7k/lib/libc/string/strlcat.o
build-aboot-surf7k/lib/libc/string/strlcpy.o
build-aboot-surf7k/lib/libc/string/strlen.o
build-aboot-surf7k/lib/libc/string/strncat.o
build-aboot-surf7k/lib/libc/string/strncpy.o
build-aboot-surf7k/lib/libc/string/strncmp.o
build-aboot-surf7k/lib/libc/string/strnicmp.o
build-aboot-surf7k/lib/libc/string/strnlen.o
build-aboot-surf7k/lib/libc/string/strpbrk.o
build-aboot-surf7k/lib/libc/string/strrchr.o
build-aboot-surf7k/lib/libc/string/strspn.o
build-aboot-surf7k/lib/libc/string/strstr.o
build-aboot-surf7k/lib/libc/string/strtok.o
build-aboot-surf7k/lib/libc/string/strxfrm.o
build-aboot-surf7k/lib/ptable/ptable.o

Next
OBJS里各個目標的默認規(guī)則:
$(BUILDDIR)/%.o: %.c $(SRCDEPS)
Action
$(NOECHO)$(CC) $(CFLAGS) $(THUMBCFLAGS) --std=c99 $(INCLUDES) -c $< -MD -MT $@ -MF $(@:%o=%d) -o $@
Extension
THUMBCFLAGS := -mthumb -D__thumb__
INCLUDES := -I$(BUILDDIR) -Iinclude
INCLUDES +=
-I$(LOCAL_DIR)/include
INCLUDES += -I$(LOCAL_DIR)/include
SRCDEPS := $(CONFIGHEADER)
CONFIGHEADER := $(BUILDDIR)/config.h

最后編輯于
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末污桦,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子匙监,更是在濱河造成了極大的恐慌寡润,老刑警劉巖,帶你破解...
    沈念sama閱讀 206,311評論 6 481
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件舅柜,死亡現(xiàn)場離奇詭異梭纹,居然都是意外死亡,警方通過查閱死者的電腦和手機致份,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 88,339評論 2 382
  • 文/潘曉璐 我一進店門变抽,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人氮块,你說我怎么就攤上這事绍载。” “怎么了滔蝉?”我有些...
    開封第一講書人閱讀 152,671評論 0 342
  • 文/不壞的土叔 我叫張陵击儡,是天一觀的道長。 經(jīng)常有香客問我蝠引,道長阳谍,這世上最難降的妖魔是什么蛀柴? 我笑而不...
    開封第一講書人閱讀 55,252評論 1 279
  • 正文 為了忘掉前任,我火速辦了婚禮矫夯,結(jié)果婚禮上鸽疾,老公的妹妹穿的比我還像新娘。我一直安慰自己训貌,他們只是感情好制肮,可當我...
    茶點故事閱讀 64,253評論 5 371
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著递沪,像睡著了一般豺鼻。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上款慨,一...
    開封第一講書人閱讀 49,031評論 1 285
  • 那天儒飒,我揣著相機與錄音,去河邊找鬼樱调。 笑死约素,一個胖子當著我的面吹牛,可吹牛的內(nèi)容都是我干的笆凌。 我是一名探鬼主播圣猎,決...
    沈念sama閱讀 38,340評論 3 399
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼乞而!你這毒婦竟也來了送悔?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 36,973評論 0 259
  • 序言:老撾萬榮一對情侶失蹤爪模,失蹤者是張志新(化名)和其女友劉穎欠啤,沒想到半個月后,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體屋灌,經(jīng)...
    沈念sama閱讀 43,466評論 1 300
  • 正文 獨居荒郊野嶺守林人離奇死亡洁段,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 35,937評論 2 323
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了共郭。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片祠丝。...
    茶點故事閱讀 38,039評論 1 333
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖除嘹,靈堂內(nèi)的尸體忽然破棺而出写半,到底是詐尸還是另有隱情,我是刑警寧澤尉咕,帶...
    沈念sama閱讀 33,701評論 4 323
  • 正文 年R本政府宣布叠蝇,位于F島的核電站,受9級特大地震影響年缎,放射性物質(zhì)發(fā)生泄漏悔捶。R本人自食惡果不足惜铃慷,卻給世界環(huán)境...
    茶點故事閱讀 39,254評論 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望炎功。 院中可真熱鬧枚冗,春花似錦缓溅、人聲如沸蛇损。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,259評論 0 19
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽淤齐。三九已至,卻和暖如春袜匿,著一層夾襖步出監(jiān)牢的瞬間更啄,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 31,485評論 1 262
  • 我被黑心中介騙來泰國打工居灯, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留祭务,地道東北人。 一個月前我還...
    沈念sama閱讀 45,497評論 2 354
  • 正文 我出身青樓怪嫌,卻偏偏與公主長得像义锥,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子岩灭,可洞房花燭夜當晚...
    茶點故事閱讀 42,786評論 2 345

推薦閱讀更多精彩內(nèi)容