2020年4月16日木曜日

FreeBSD kernel build

まずは、FreeBSD Handbookの8.5. Building and Installing a Custom Kernelを読む

#cd /usr/src
#make buildkernel KERNCONF=MYKERNE

詳しく知るには、
/usr/src/Makefileを読む。

その前に、Developers' HandbookのChapter 9. Building and Installing a FreeBSD Kernelを読む

#/usr/sbin/config MYKERNEL

続いて、config(8)を読む
man config

SYNOPSIS
     config [-CVgp] [-I path] [-d destdir] [-s srcdir] SYSTEM_NAME
     config [-x kernel]

     SYSTEM_NAME      Specify the name of the system configuration file
                      containing device specifications, configuration options
                      and other system parameters for one system
                      configuration.

MYKERNELは、SYSTEM_NAMEのことでシステムの構成を記述したファイル、
通常は、/sys/ARCH/confに存在する。(ARCHは、amd64)
configは、Makefileなどビルドに必要なファイルを作成する。
テンプレートが/sys/ARCH/confにある。テンプレートを修正してはいけない。
コピーして使う。
書き方は、config(5)に書かれている。

FILES
     /sys/conf/files                                         list of common files system is built from
     /sys/conf/Makefile.ARCH                                 generic makefile for the ARCH
     /sys/conf/files.ARCH                                    list of ARCH specific files
     /sys/ARCH/compile/SYSTEM_NAME   
                       default kernel  build directory for system  SYSTEM_NAME on ARCH

時間があれば、Building 4.4BSD Kernels with Configを読む。

config(5)によると
     device name [, name [...]]
     devices name [, name [...]]
             Configures the specified devices for inclusion into the kernel
             image.  Devices that are common to all architectures are defined
             in the file sys/conf/files.  Devices that are specific to
             architecture arch are defined in the file sys/conf/files.<arch>.


2020年4月5日日曜日

GNU Make 4.1 (1)

$ make --version
GNU Make 4.1
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

makeは、versionが異なると細かい部分で異なるので注意が必要

make [OPTION]... [TARGET]...

makeは、makefileと呼ばれるファイルを読み込み、makefileに従い処理を行う。
makefileには、ビルドに必要な情報が書かれている。

makeを引数なしで実行すると
GNUmakefile, makefile, Makefileの順でファイルを探していく。
最初に見つかったファイルをmakefileとして処理する。

.dependがあれば読み込む。

$ make
make: *** No targets specified and no makefile found.  Stop.

$ touch GNUmakefile
$ make
make: *** No targets.  Stop.

$ echo hello: > makefile
$ make
make: *** No targets.  Stop.       # makefile でなくGNUmakefileが読み込まれる
$ cp makefile GNUmakefile 
$ make
make: Nothing to be done for 'hello'.

通常は、Makefileを使うことが推奨されている。
GNUmakefileは、GNU makeに限定される場合だけに使用する。

makeが上手く動作しない場合は、-dを付けて実行すると、原因がわかるかもしれない

概要   https://www.gnu.org/software/make/
マニュアルhttps://www.gnu.org/software/make/manual/
開発   http://savannah.gnu.org/projects/make/