ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • make
    bin/Linux 2008. 3. 6. 14:06
    영어 http://www.gnu.org/software/make/manual/make.html


    two flavors of variables

    = 재귀적 확장매크로(recursively expanded)
    장점: recursive 확장, 정의가 뒤에 있어도 됨.
    CFLAGS = $(include_dirs) -O
    include_dirs = -Ifoo -Ibar

    단점: 자기 자신을 assign 못함
    CFLAGS = $(CFLAGS) -O
    make 무한루프 에러


    := 단순확장매크로(simply expanded)
    장점: shell 함수와 := 를 결합해서 사용할 때 유용, 딱 한번 확장되고 끝
    ifeq (0,${MAKELEVEL})
    cur-dir := $(shell pwd)
    whoami := $(shell whoami)
    host-type := $(shell arch)
    MAKE := ${MAKE} host-type=${host-type} whoami=${whoami}
    endif

    단점: 공백문자를 변수값으로 사용할 수 있다.조심해서 써야한다.

    nullstring :=
    space := $(nullstring) # end of the line
    space 값은 하나의 스페이스이다

    dir := /foo/bar # directory to put the frobs in
    dir 변수의 값은 '/foo/bar ' 푸바와 4개 스페이스이다.

    += 기존 매크로에 추가

    ?= 정의안된 매크로일 때만 정의(conditional variable assignment operator)
    dmake
    http://network.hanb.co.kr/view.php?bi_id=385
    컴파일 과정을 병렬화합니다
    CPU 사용률을 높인다.

    리눅스의 make -j [thread_number]와 같다.



    장애 : make warning

    test -e include/linux/autoconf.h -a -e include/config/auto.conf || (           \
           echo;                                                           \
           echo "  ERROR: Kernel configuration is invalid.";               \
           echo "         include/linux/autoconf.h or include/config/auto.conf are missing.";      \
           echo "         Run 'make oldconfig && make prepare' on kernel src to fix it.";  \
           echo;                                                           \
           /bin/false)

    분석: /lib/modules/2.6.18-53.el5/build/Makefile
    cfm2 $ make -p > cfm2.make.p.
    V=1 : verbose
    C=1 : semantic parse
    M=$(PWD) : external module 디렉토리
    O=dir/to/store/output/files/: 아웃풋 파일을 갖다놓을 디렉토리
    http://kldp.org/node/83418



    # rpm -qf /usr/src/kernels/2.6.18-53.el5-x86_64/include/config/kernel.release
    kernel-devel-2.6.18-53.el5

    srctree         := $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR))

    3항 연산자다 (조건 ? then : else)
    KBUILD_SRC 가 empty 면 false 로 간주. CURDIR 값을 사용
    KBUILD_SRC 가 true 면 KBUILD_SRC 값을 사용

    http://www.gnu.org/software/make/manual/make.html


Designed by Tistory.