Linux kernel root directory Makefile annotation

  
 

## Makefile for linux.# If you don't have '-mstring-insns' in your gcc (and nobody but me has :-)# remove them from the CFLAGS defines.#

# #8086Assembler compiler and linker. -0 generates 8086 target program; -a generates code compatible with gas and gld parts #AS86 =as -0 -a CC86 =cc -0LD86 =ld -0

##GNUAssembly Compiler and Connector#AS =gasLD =gld

##GNU Connector gld runtime option #-s omits all symbol information in the output file #-x Delete all Local Symbol #-M Prints a link map on a standard output device (display). #Connection Image: A memory address map generated by the linker that lists the program loaded into memory. The location information has the following information: #Target file and symbol information mapped to the location in memory #How to place the public symbol #All the file members included in the connection and the symbols they reference #LDFLAGS =-s -x -M

##gcc is the GNU C program compiler. For UNIX-like scripts, #refer to the defined identifier, precede it with a $ sign and enclose the identifier in parentheses #CC = Gcc

##GCC Options.#-Wall Print all warning messages#-O Optimize code#-fstrength-reduce Optimization loop statement #CFLAGS =-Wall -O -fstrength-reduce -fomit- Frame-pointer -fcombine-regs

##CPP is a preprocessor for gcc#-nostdinc -Iinclude Do not search for files in the standard header file directory, instead use the directory specified by the -I option or Search the header file in the current directory #CPP =gcc -E -nostdinc -Iinclude

# # kernel directory, mm directory, object code file generated by the fs directory. # For ease of reference, use them here to represent ARCHIVES (archive file) identifier #ARCHIVES=kernel/kernel.o mm/mm.o fs/fs.o

## Generated from lib/directory General library file #LIBS =lib/lib.a

## make implicit suffix rule# Instructs make to compile all .c files with the following command to generate .s assembler # ':' indicates the following Is the command of the rule # Rule: refers to gcc to use the option specified by the previous CFLAGS and only use the header file in the include/directory, # stop (-S) without proper assembly after compilation, thus generating and inputting each The C file corresponds to the code file in assembly language form. # By default, the assembler file generated is the original C file name minus .c followed by the .s suffix. # -o indicates the form of the output file. # where $*.s (or $@) is the automatic target variable, and $< represents the first prerequisite, here is the file that meets the condition *.c. #.c.s:$(CC) $(CFLAGS) \\-nostdinc -Iinclude -S -o $*.s $<

## Compile all .s assembler files into .o object files. The next one is the specific command to achieve this operation # Use the gas compiler to compile the assembler into a .o object file. -c means compile or assemble only, but does not connect operation #.so:$(AS) -c -o $*.o $<

## Use gcc to compile c language into object file but Not connected #.co:$(CC) $(CFLAGS) \\-nostdinc -Iinclude -c -o $*.o $<

## all means to create the topmost target known to the Makefile. Here is the image file #all: Image

## First line description: The target file (Image file) is generated by the 3 elements after the semicolon. The following two lines are executed commands # First line Indicates that the boot, system files are assembled into a kernel image file using the build utility in the tools directory. Image# The second line of the sysn synchronization command forces the buffer block data to immediately write to the disk and update the superblock #Image: boot/boot tools/system Tools/buildtools/build boot/boot tools/system > Imagesync

#chmem -- Modify system memory data tools/build: tools/build.c$(CC) $(CFLAGS) \\-o tools/Build tools/build.cchmem +65000 tools/build

## Generate head.o files using the .so rules above #boot/head.o: boot/head.s

## The last >System.map indicates that gld needs to redirect the connection image in the System.map file #tools/system: boot/head.o init/main.o \\$(ARCHIVES) $(LIBS)$(LD $(LDFLAGS) boot/head.o init/main.o \\$(ARCHIVES) \\$(LIBS) \\-o tools/system > System.map

## Kernel target module kernel.o #kernel/kernel.o:(cd kernel; make)

## Kernel Management Module mm.o#mm/mm.o:(cd mm; make)

## File System Target Module fs.o#fs/fs.o:(cd fs; make)

## Library function lib.a#lib/lib.a:(cd lib; make)

## Add a line in the boot.s program opening for the system file length information # First generated with "SYSSIZE = The actual length of the file " a line of information in the tmp.s file, and then add the boot.s file after it. # Get the length of the system: # Use the ls command to display a long list of system files # Use the grep command to get the file byte number field information on the list, and save it in the tmp.s temporary file #cut command for cutting The string #tr is used to remove the carriage return # at the end of the line (actual length + 15)/16 to get the length information represented by 'section', 1 section = 16 bytes # with 8086 assembly and connector pair setup.s The file is compiled to generate the setup file # -s indicates that the symbol information in the target file is to be fetched #boot/boot: boot/boot.s tools/system(echo -n "SYSSIZE = (";ls -l tools/system

Copyright © Windows knowledge All Rights Reserved