## If you want the Ram-disk device, define the# Size in blocks.# If you want to use RAM to define the size of the block (commented out), this is a compile-time parameter, if defined below will be used. RAMDISK=#-dramdisk=512AS86=as86-0-a #8006汇编的编译器和连接器. The following parameters are:LD86=ld86-0 # 0 generates 8086 target programs,-a generates code that is partially compatible with gas and GLD. as=Gas #GNU assembler and connectors. LD=GLDLdflags=-s-x-M # GLD parameter, the-s output file omits all symbol information,-X removes all local symbols,-m prints the connection image on the standard output device #连接映像是指由连接程序程序产生的一种内存地址映像, lists the location information that the program segment is loaded into memory. Specific means: #1. destination file and symbol information mapped to a location in memory #2. How the Bulletin symbol is placed #3. All the files contained in the connection and their referenced symbols# gcc GNU compiler, when referencing a defined symbol, you need to precede the $ symbol with parentheses to enclose the defined identifier. CC=GCC$(RAMDISK)#-wall Print all warning messages,-O to optimize code "-F Flag" specifies machine-independent compilation flags# 1.-fstrength-reduce for Optimizing loop statements# 2.-fomit-frame-pointer indicates that a function that does not require frame pointers (frame pointer) does not leave the frame pointer in the register, which avoids manipulation and maintenance of the frame pointer. # 3.-fcombine-regs indicates that the compiler combines the instructions for copying one register to another register during the composite compilation phase. # 4.-mstring-insns Linus is an option for GCC when learning gcc, which can be removed by using 386CPU string instructions for gcc-1.40 operations such as copying structures. CFLAGS=-wall-o-fstrength-reduce-fomit-frame-pointer\-fcombine-regs-mstring-insns#-nostdinc-iinclude do not search for files in the standard header files directory, that is, without the header files in the/usr/include/directory,# Instead, use the "-i" option to specify the directory or search for the header file in the current directory. CPP=Cpp-nostdinc-iinclude## ROOT_DEV Specifies the default root-device when making the image.# This can is either floppy,/dev/xxxx or empty, in which case the# Default OF/DEV/HD6 is used by ' build '.# # ROOT_DEV Specifies the device on which the default root file system is used when creating the kernel image file, which can be a floppy disk,#/dev/xxx or empty, use default value when empty/dev/hd6#Root_dev=/dev/hd6# kernel directory, mm directory, and FS directory generated by the target code file, in order to facilitate the reference, with the Archives (archive) identifier bidARCHIVES=KERNEL/KERNEL.O MM/MM.O FS/FS.O# block and character device library files. '. A ' means that the file is an archive file that contains many executable binaries#子程序集合的库文件, usually generated by the GNU AR Program, AR is the GNU binary file handler for creating, modifying, and extracting files from an archive file. DRIVERS=KERNEL/BLK_DRV/BLK_DRV.A KERNEL/CHR_DRV/CHR_DRV.AMATH=kernel/math/math.a # Math library fileLIBS=LIB/LIB.A # The library files generated by the files in the lib/directory are compiled. #1. Make an old-fashioned implicit suffix rule that instructs made to use the following command to compile the desired '. C ' file to generate '. s ' assembler. #2. Using the header file in the include/directory,#3.-S indicates compilation only and produces assembly files corresponding to each C file. The file name generated by default is the source file minus '. C ' after adding '. s ' suffix. #4.-O is followed by the format of the output file, where ' $*.s ' (or ' [email protected] ') is an automatic target variable. #5. ' $< ' represents the first prerequisite, here is the qualifying ' *.c ' file#下面有三个规则:#1. If the destination file is a '. s ' file, the source file is a '. C ' file, then the first rule is used. #2. If the destination file is a '. O ' file, the source file is a '. s ' file, then the second rule is used. #3. If the destination file is a '. O ' file, the source file is a '. C ' file, then a third rule is used. . C.S: $(CC) $(CFLAGS) \ -nostdinc-iinclude-s-O$*. S$<. S.O: $( as)-c-o$*. o$<. C.O: $(CC) $(CFLAGS) \ -nostdinc-iinclude-c-O$*. O$<# All represents the topmost target known to makefile, here is the image file, here is the boot disk image file bootimage. All :Image# The file following the colon is the 4 files that generate image file dependencies, and the next line is the Execute command that generates the imageImage:boot/bootsect boot/setup Tools/system tools/buildTools/build Boot/bootsect Boot/setup Tools/system$(Root_dev)> Image#生成Image文件的命令Sync#使用同步命令迫使缓冲块数据立即写盘并更新超级块. # Disk destination file is generated by image. DD Command: Copies a file and formats the conversion according to the options. # bs= Indicates the number of bytes read/written for the first time. if= represents the input file. The of= represents the output to a file. Disk:ImageDD bs=8192 if=image OF=/DEV/PS0#使用dd命令把Image文件写入/DEV/PS0 (first floppy drive)# Compile Build tools/build fileTools/build:TOOLS/BUILD.C $(CC) $(CFLAGS) \ -o tools/build tools/build.c# Use the. S.O rule given above to generate the HEAD.O fileBOOT/HEAD.O:Boot/head.s# Compile Build tools/system fileTools/system:BOOT/HEAD.O INIT/MAIN.O\ $(ARCHIVES) $(DRIVERS) $(MATH) $(LIBS) $(LD) $(Ldflags)BOOT/HEAD.O INIT/MAIN.O\ $(ARCHIVES) \ $(DRIVERS) \ $(MATH) \ $(LIBS) \ -o tools/system > System.map# Generate the Math co-processing file, MATH.A, enter the Kernel/math directory, run makefile under that directory. Here are a few commands like this. KERNEL/MATH/MATH.A:(CD Kernel/math; make)#生成块设备库文件 blk_drv.a, which contains relocatable target files. KERNEL/BLK_DRV/BLK_DRV.A:(CD kernel/blk_drv; make)#生成字符设备函数文件 CHR_DRV.AKERNEL/CHR_DRV/CHR_DRV.A:(CD kernel/chr_drv; make)#生成内核目标模块 KERNEL.OKERNEL/KERNEL.O:(CD kernel; make)#生成内存管理模块 MM.OMM/MM.O:(cd mm; make)#生成文件系统目标模块fs. OFS/FS.O:(CD FS; make)#生成库函数liba. ALIB/LIB.A:(CD lib; make)Boot/setup:Boot/setup.s#这里三行使用8086汇编器和连接器对 $(AS86)-O BOOT/SETUP.O Boot/setup.scompiling the setup file #setup. s files $(LD86)-s-o Boot/setup BOOT/SETUP.O#-S To remove symbolic information from the target file# ibid., generating bootsect disk boot blocksBoot/bootsect:Boot/bootsect.s $(AS86)-O BOOT/BOOTSECT.O Boot/bootsect.s$(LD86)-s-o Boot/bootsect BOOT/BOOTSECT.O# Add a line at the beginning of the Bootsect.s text program about the system module file length information in the system module# used to indicate the length of the system module during loading into memory. By using commands to get the size of the system module and saving# in the Tmp.s file. The Cut command is used to cut strings, and the TR is used to remove carriage returns at the end of a line. (actual length +15)/16 for# Get the length information represented by "section", section 1 = 16 bytes. This is the old version (0.01-0.10) in use, the new version has not been used# The new version indicates the size of the system directly in the file. TMP.S:Boot/bootsect.s Tools/system(Echo-n"syssize = ("; Ls-l Tools/system | grep system\| cut-c25-31 | Tr' \012 ' "'; Echo"+"/+)) > Tmp.s cat boot/bootsect.s >> TMP.S# Execute the following command when doing clean, delete the compiled link generated file# RM is a file Delete command, and-f means that nonexistent files are ignored and deletion information is not displayed. Clean :Rm-f Image system.map tmp_make core boot/bootsect boot/setup rm-f init/*.o tools/system tools/build boot/*.o (cd m M;make Clean)#进入 The mm/directory, execute the clean rule in the makefile file under that directory, similar to the following. (CD Fs;make Clean) (CD Kernel;make Clean) (CD Lib;make Clean)#该规则先执行上面的clean规则, and then compress the linux/directory to generate backup. Z compressed files. # CD: Back to the top-level directory of Linux, tar cf-linux indicates that the TAR directory is compressed. # |compress means that the compressed file is passed through the pipeline operation to the compressor compres, and the output of the program is saved as backup. Z file. Backup: Clean(CD.; Tar cf-linux | compress-> backup. Z) Sync#使用同步命令迫使缓冲块数据立即写盘并更新超级块. # The target or rule is used to generate dependencies between files, and these dependencies are created so that the make directory is used to determine whether a target object needs to be rebuilt. # If a header file is altered, make will be able to recompile all the *.c files associated with that head file through the generated dependency. # The process is as follows:# using the SED string editor to process the makefile, the output is to delete all rows after ' # # # Dependencies ' in makefile,# and generate a temporary file Tmp_make, and then perform a GCC preprocessing operation on each C file of the specified directory (init/). #-M tells the preprocessor CPP to output rules that describe the relevance of the target file, and these rules conform to make syntax for each source file, preprocessor# will output a rule whose resulting form is the target file of the corresponding source file plus its dependency, which is the list of all header files contained in the source file. # Then add the pre-processing results to the temporary file Tmp_make, and then copy the temporary file into the new makefile file. # "$ $i" is actually ' $ ($i) 'DEP:Sed'/\#\#\# dependencies/q '< Makefile > Tmp_make (For i in Init/*.c;do echo-n"init/";$(CPP)-M$$I;done) >> tmp_make CP tmp_make Makefile (CD fs; make DEP)#对fs目录下的makefile也做同样处理, similar to the following. (CD kernel; make Dep.) (cd mm; make DEP)# MAIN.O Dependent files# # # Dependencies:INIT/MAIN.O:init/main.c include/unistd.h include/sys/stat.h\include/sys/types.h include/sys/times.h include/sys/utsname.h\include/utime.h include/time.h include/linux/tty.h include/termios.h\include/linux/sched.h include/linux/head.h include/linux/fs.h\include/linux/mm.h include/signal.h include/asm/system.h include/asm/io.h\include/stddef.h include/stdarg.h include/fcntl.h
Linux kernel 0.11 makefile file description