source

리눅스 커널 Makefile에서 obj-y += something/의 의미는?

ittop 2023. 10. 29. 19:59
반응형

리눅스 커널 Makefile에서 obj-y += something/의 의미는?

나는 그 의미를 이해합니다.

obj-$(CONFIG_USB)       += usb.o

CONFIG_USB가 y이면 usb.o가 컴파일됩니다.그럼 이제 이걸 어떻게 이해해야 할까요?

obj-y               += something/

Kernel Make files는 의 일부입니다.kbuildhttp://lwn.net/Articles/21835/ 와 같이 웹상의 다양한 장소에서 문서화된 시스템.관련 발췌문은 다음과 같습니다.

--- 3.1 Goal definitions

목표 정의는 kbuild Make 파일의 주요 부분(하트)입니다.이러한 행은 빌드할 파일, 특수 컴파일 옵션 및 재귀적으로 입력할 하위 디렉토리를 정의합니다.

가장 간단한 kbuild makefile은 한 줄로 구성되어 있습니다.

예: obj-y += foo.o

이 kbuild는 foo.o.o.o.o라는 이름의 디렉터리에 하나의 개체가 있다는 것을 알려줍니다. foo.o.o는 foo.c 또는 foo.o에서 빌드됩니다.s.

foo.o를 모듈로 구축해야 하는 경우 obj-m 변수를 사용합니다.따라서 종종 다음 패턴이 사용됩니다.

예: obj-$(CONFIG_FOO) += foo.o

$(CONFIG_FOO)는 (내장된 경우) y 또는 m(모듈) 중 하나로 평가합니다.CONFIG_FOO가 y 또는 y가 아니면 파일을 컴파일하거나 링크하지 않습니다.

그렇게m평균 모듈,y는 내장(커널 구성 프로세스에서 yes를 나타냄)을 의미하며, $(CONFIG_FOO)는 일반 구성 프로세스에서 정답을 가져옵니다.

obj-y += 뭔가/

이것은 kbuild가 "something" 디렉토리에 들어가야 한다는 것을 의미합니다.이 디렉터리로 이동하면 "something"에서 Makefile을 보고 빌드할 개체를 결정합니다.

디렉토리 "something"으로 이동하여 "make"를 실행하는 것과 유사합니다.

전체 디렉토리를 목표로 추가하는 이유가 궁금하신 것 같습니다. KConfig 설명서의 관련 부분은 다음과 같습니다.

--- 3.6 Descending down in directories

    A Makefile is only responsible for building objects in its own
    directory. Files in subdirectories should be taken care of by
    Makefiles in these subdirs. The build system will automatically
    invoke make recursively in subdirectories, provided you let it know of
    them.

    To do so obj-y and obj-m are used.
    ext2 lives in a separate directory, and the Makefile present in fs/
    tells kbuild to descend down using the following assignment.

    Example:
        #fs/Makefile
        obj-$(CONfIG_EXT2_FS) += ext2/

    If CONFIG_EXT2_FS is set to either 'y' (built-in) or 'm' (modular)
    the corresponding obj- variable will be set, and kbuild will descend
    down in the ext2 directory.
    Kbuild only uses this information to decide that it needs to visit
    the directory, it is the Makefile in the subdirectory that
    specifies what is modules and what is built-in.

    It is good practice to use a CONFIG_ variable when assigning directory
    names. This allows kbuild to totally skip the directory if the
    corresponding CONFIG_ option is neither 'y' nor 'm'.

언급URL : https://stackoverflow.com/questions/10949986/whats-meaning-of-obj-y-something-in-linux-kernel-makefile

반응형