2010年12月31日 星期五

imx51 make clean

build/core/envsetup.mk

root下的Makefile
include build/core/main.mk
會展開main.mk位於build/core

build/core/main.mk
內有clean

下make clean 就會呼叫到這裡


.PHONY: clean
dirs_to_clean := \
        $(PRODUCT_OUT) \
        $(TARGET_COMMON_OUT_ROOT) \
        $(HOST_OUT) \
        $(HOST_COMMON_OUT_ROOT)
clean:
        @for dir in $(dirs_to_clean) ; do \
            echo "Cleaning $$dir..."; \
            rm -rf $$dir; \
        done
        @echo "Clean."; \

所以要知道會刪除哪些資料就要知道這些參數的定義

        $(PRODUCT_OUT) 
        $(TARGET_COMMON_OUT_ROOT) 
        $(HOST_OUT) 
        $(HOST_COMMON_OUT_ROOT)

可以從envsetup.mk知道

以下是結果
TARGET_COMMON_OUT_ROOT = out/target/common
PRODUCT_OUT := $(TARGET_PRODUCT_OUT_ROOT)/$(TARGET_DEVICE)  = out/target/product/imx51_bbg
HOST_OUT = out/host/linux-x86
HOST_COMMON_OUT_ROOT = out/host/common

怎麼知道envsetup.mk有跟main.mk有關系呢

main.mk會include config.mk
./main.mk:55:include $(BUILD_SYSTEM)/config.mk

config.mk會include envsetup.mk
./config.mk:122:include $(BUILD_SYSTEM)/envsetup.mk

而BUILD_SYSTEM就是build/core

透過Facebook分享

2010年12月30日 星期四

build e2fsprogs for mkfs under arm platform

download source : http://sourceforge.net/projects/e2fsprogs/

設定環境變數
執行arm-setupenv.sh
內容為

#!/bin/bash
export ARCH=arm
export CROSS_COMPILE=/home/nelsonchung/Develop/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-
export PATH=/home/nelsonchung/Develop/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/bin:$PATH

follow

mkfs.ext4 for ARM (Android)

LDFLAGS=-static ./configure --host=arm-none-linux-gnueabi

make

可以build成功

查看一下版本 - 4.1.2
nelsonchung@ubuntu:~/Develop$ arm-none-linux-gnueabi-gcc -v
Reading specs from /home/nelsonchung/Develop/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/bin/../lib/gcc/arm-none-linux-gnueabi/4.1.2/specs
Target: arm-none-linux-gnueabi
Configured with: /usr/src/redhat/BUILD/cross-mlib/source/gcc-4.1.2/configure --target=arm-none-linux-gnueabi --host=i686-host_pc-linux-gnu --prefix=/opt/freescale/usr/local/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi --with-sysroot=/opt/freescale/usr/local/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/arm-none-linux-gnueabi/sysroot --enable-threads --enable-shared --disable-libssp --disable-libgomp --disable-libmudflap --enable-languages=c,c++ --enable-__cxa_atexit --disable-nls
Thread model: posix
gcc version 4.1.2

可以在misc找到mke2fs

--
使用buildroot-2010.11產生出來的cross-compile

. arm-buildroot-setupenv.sh

內容為
#!/bin/bash
export ARCH=arm
export CROSS_COMPILE=/home/nelsonchung/Develop/buildroot-2010.11/output/staging/usr/bin/arm-linux-
export PATH=/home/nelsonchung/Develop/buildroot-2010.11/output/staging/usr/bin:$PATH

LDFLAGS=-static ./configure --host=arm-linux

make

產生以下error
CC llseek.c
llseek.c: In function '_llseek':
llseek.c:65: error: expected declaration specifiers or '...' before '_llseek'
llseek.c:65: error: expected declaration specifiers or '...' before 'fd'
llseek.c:65: error: expected declaration specifiers or '...' before 'offset_high'
llseek.c:66: error: expected declaration specifiers or '...' before 'offset_low'
llseek.c:66: error: expected declaration specifiers or '...' before 'result'
llseek.c:67: error: expected declaration specifiers or '...' before 'origin'
llseek.c:67: error: storage class specified for parameter '_syscall5'
llseek.c:71: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
llseek.c:91: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
llseek.c:138: error: old-style parameter declarations in prototyped function definition
llseek.c:62: error: parameter name omitted
llseek.c:62: error: parameter name omitted
llseek.c:63: error: parameter name omitted
llseek.c:63: error: parameter name omitted
llseek.c:63: error: parameter name omitted
llseek.c:114: error: expected '{' at end of input
make[2]: *** [llseek.o] Error 1
make[2]: Leaving directory `/home/nelsonchung/Develop/e2fsprogs-1.41.14/lib/ext2fs'
make[1]: *** [all-libs-recursive] Error 1
make[1]: Leaving directory `/home/nelsonchung/Develop/e2fsprogs-1.41.14'
make: *** [all] Error 2

查一下版本-4.3.5
nelsonchung@ubuntu:~/Develop/buildroot-2010.11/output/staging/usr/bin$ arm-linux-gcc -v
Using built-in specs.
Target: arm-unknown-linux-uclibcgnueabi
Configured with: /home/nelsonchung/Develop/buildroot-2010.11/output/toolchain/gcc-4.3.5/configure --prefix=/home/nelsonchung/Develop/buildroot-2010.11/output/staging/usr --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --target=arm-unknown-linux-uclibcgnueabi --enable-languages=c --with-sysroot=/home/nelsonchung/Develop/buildroot-2010.11/output/staging --with-build-time-tools=/home/nelsonchung/Develop/buildroot-2010.11/output/staging/usr/arm-unknown-linux-uclibcgnueabi/bin --disable-__cxa_atexit --enable-target-optspace --with-gnu-ld --disable-libssp --disable-multilib --disable-tls --enable-shared --with-gmp=/home/nelsonchung/Develop/buildroot-2010.11/output/toolchain/gmp --with-mpfr=/home/nelsonchung/Develop/buildroot-2010.11/output/toolchain/mpfr --disable-nls --enable-threads --disable-decimal-float --with-float=soft --with-abi=aapcs-linux --with-arch=armv4t --with-tune=arm920t --disable-largefile --with-pkgversion='Buildroot 2010.11' --with-bugurl=http://bugs.buildroot.net/
Thread model: posix
gcc version 4.3.5 (Buildroot 2010.11)


修改位於
./lib/blkid/llseek.c
./lib/ext2fs/llseek.c

(改天寫完記得要出patch)

make

error message

make[2]: Entering directory `/home/nelsonchung/Develop/e2fsprogs-1.41.14/e2fsck'
LD e2fsck
../lib/libext2fs.a(tdb.o): In function `ext2fs_tdb_transaction_commit':
/home/nelsonchung/Develop/e2fsprogs-1.41.14/lib/ext2fs/tdb.c:2119: warning: the use of OBSOLESCENT `utime' is discouraged, use `utimes'
profile.o: In function `profile_create_node':
/home/nelsonchung/Develop/e2fsprogs-1.41.14/e2fsck/profile.c:1088: undefined reference to `__strdup'
/home/nelsonchung/Develop/e2fsprogs-1.41.14/e2fsck/profile.c:1094: undefined reference to `__strdup'
profile.o: In function `skip_over_nonblanks':
/home/nelsonchung/Develop/e2fsprogs-1.41.14/e2fsck/profile.c:639: undefined reference to `__ctype_b_loc'
profile.o: In function `skip_over_blanks':
/home/nelsonchung/Develop/e2fsprogs-1.41.14/e2fsck/profile.c:626: undefined reference to `__ctype_b_loc'
profile.o: In function `parse_line':
/home/nelsonchung/Develop/e2fsprogs-1.41.14/e2fsck/profile.c:681: undefined reference to `__ctype_b_loc'
profile.o: In function `strtoul':
/home/nelsonchung/Develop/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/bin/../arm-none-linux-gnueabi/sysroot/usr/include/stdlib.h:342: undefined reference to `__strtoul_internal'
profile.o: In function `strtol':
/home/nelsonchung/Develop/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/bin/../arm-none-linux-gnueabi/sysroot/usr/include/stdlib.h:336: undefined reference to `__strtol_internal'
profile.o: In function `get_dirlist':
/home/nelsonchung/Develop/e2fsprogs-1.41.14/e2fsck/profile.c:300: undefined reference to `__ctype_b_loc'
profile.o: In function `stat':
/home/nelsonchung/Develop/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/bin/../arm-none-linux-gnueabi/sysroot/usr/include/sys/stat.h:436: undefined reference to `__xstat'
collect2: ld returned 1 exit status
make[2]: *** [e2fsck] Error 1
make[2]: Leaving directory `/home/nelsonchung/Develop/e2fsprogs-1.41.14/e2fsck'
make[1]: *** [all-progs-recursive] Error 1
make[1]: Leaving directory `/home/nelsonchung/Develop/e2fsprogs-1.41.14'
make: *** [all] Error 2


透過Facebook分享

找尋含有A字串在B檔案的目錄路徑並顯示出來

  • 找尋當目錄下所有Android.mk含有BOARD_HAVE_BLUETOOTH字串


find . -type f -name "Android.mk" -print0 | xargs -0 grep "BOARD_HAVE_BLUETOOTH"


./system/netd/Android.mk:ifeq ($(BOARD_HAVE_BLUETOOTH),true)
./system/bluetooth/brcm_patchram_plus/Android.mk:ifeq ($(BOARD_HAVE_BLUETOOTH_BCM),true)
./system/bluetooth/Android.mk:ifeq ($(BOARD_HAVE_BLUETOOTH),true)
./frameworks/base/libs/audioflinger/Android.mk:ifeq ($(BOARD_HAVE_BLUETOOTH),true)
./frameworks/base/libs/audioflinger/Android.mk:ifeq ($(BOARD_HAVE_BLUETOOTH),true)
./frameworks/base/libs/audioflinger/Android.mk:ifeq ($(BOARD_HAVE_BLUETOOTH),true)
./frameworks/base/core/jni/Android.mk:ifeq ($(BOARD_HAVE_BLUETOOTH),true)
./hardware/msm7k/libaudio-qsd8k/Android.mk:ifeq ($(BOARD_HAVE_BLUETOOTH),true)
./hardware/msm7k/libaudio-qsd8k/Android.mk:ifeq ($(BOARD_HAVE_BLUETOOTH),true)
./hardware/msm7k/libaudio/Android.mk:ifeq ($(BOARD_HAVE_BLUETOOTH),true)
./hardware/msm7k/libaudio/Android.mk:ifeq ($(BOARD_HAVE_BLUETOOTH),true)
./hardware/alsa_sound/Android.mk:ifeq ($(BOARD_HAVE_BLUETOOTH),true)
./hardware/alsa_sound/Android.mk:ifeq ($(BOARD_HAVE_BLUETOOTH),true)
./external/bluetooth/glib/Android.mk:ifeq ($(BOARD_HAVE_BLUETOOTH),true)
./external/bluetooth/hcidump/Android.mk:ifeq ($(BOARD_HAVE_BLUETOOTH),true)
./external/bluetooth/bluez/Android.mk:ifeq ($(BOARD_HAVE_BLUETOOTH),true)
./external/bluetooth/bluez/common/Android.mk:ifeq ($(BOARD_HAVE_BLUETOOTH_BCM),true)
./external/bluetooth/bluez/common/Android.mk: -DBOARD_HAVE_BLUETOOTH_BCM


  • 找尋當目錄下所有Android.mk含有BOARD_HAVE_BLUETOOTH字串的目錄路徑



find . -type f -name "Android.mk" -print0 | xargs -0 grep "BOARD_HAVE_BLUETOOTH" | sed -e 's/\/[^/]*$//'


./system/netd
./system/bluetooth/brcm_patchram_plus
./system/bluetooth
./frameworks/base/libs/audioflinger
./frameworks/base/libs/audioflinger
./frameworks/base/libs/audioflinger
./frameworks/base/core/jni
./hardware/msm7k/libaudio-qsd8k
./hardware/msm7k/libaudio-qsd8k
./hardware/msm7k/libaudio
./hardware/msm7k/libaudio
./hardware/alsa_sound
./hardware/alsa_sound
./external/bluetooth/glib
./external/bluetooth/hcidump
./external/bluetooth/bluez
./external/bluetooth/bluez/common
./external/bluetooth/bluez/common


  • 找尋當目錄下所有Android.mk含有BOARD_HAVE_BLUETOOTH字串的目錄路徑



find . -type f -name "Android.mk" -print0 | xargs -0 grep "BOARD_HAVE_BLUETOOTH" | sed -e 's/\/[^/]*$//' | uniq


./system/netd
./system/bluetooth/brcm_patchram_plus
./system/bluetooth
./frameworks/base/libs/audioflinger
./frameworks/base/core/jni
./hardware/msm7k/libaudio-qsd8k
./hardware/msm7k/libaudio
./hardware/alsa_sound
./external/bluetooth/glib
./external/bluetooth/hcidump
./external/bluetooth/bluez
./external/bluetooth/bluez/common


透過Facebook分享

Gnu make: $< and $@的用法

Follow 

4.12.1 Syntax of Static Pattern Rules

我們可以簡化makefile的內容

一個makefile的內容如下

objects = main.o Eye.o Nose.o Ear.o Mouse.o Face.o

all: $(objects)
gcc $(objects) -o main

$(objects): %.o: %.c
gcc -c $< -o $@

clean:
rm main.o Eye.o Nose.o Ear.o Mouse.o Face.o main

藍色部份第一行中, %稱為stem
gnu make會替我們match出符合的.o檔的file name
然後交給gcc去作compile
$<: 能夠找出prerequisites的name
$@: 則能夠找出target的name

make之後你可以得到以下結果
gcc -c main.c -o main.o
gcc -c Eye.c -o Eye.o
gcc -c Nose.c -o Nose.o
gcc -c Ear.c -o Ear.o
gcc -c Mouse.c -o Mouse.o
gcc -c Face.c -o Face.o
gcc main.o Eye.o Nose.o Ear.o Mouse.o Face.o -o main


是使用git作source control
你也可以使用git log -p來查看差異


透過Facebook分享

2010年12月29日 星期三

刪除由git建出的branch

請使用git branch -D branchname

ex.
git branch
列出有三個分支A, B, C
假設你位於A要刪除C
git branch -D C

如果你位於A又要刪掉A呢
git branch -D A
這時候會出現error message
error: Cannot delete the branch 'C' which you are currently on.
所以你需要先切換到B
git checkout B
在刪除A
git branch -D A

透過Facebook分享