nginx原始碼分析
阿新 • • 發佈:2019-02-03
生成的Makefile分析
變數賦值
CC,CFLAGS,CPP,LINK($CC),ALL_INCS(-I...),CORE_DEPS, CORE_INCS, HTTP_DEPS, HTTP_INCS
目標
build: binary modules manpage
binary: objs/nginx
objs/nginx: objs/src/core/nginx.o ... objs/src/http/ngx_http.o
$(LINK) -o objs/nginx (...o)-ldl -lpthread -lcrypt -lpcre -lz -Wl,-E
下面是每個.o檔案的編譯規則
objs/ngx_modules.o: $(CORE_DEPS) objs/ngx_modules.c
(CC) -c $(CFLAGS) $(CORE_INCS) -o objs/ngx_modules.o objs/ngx_modules.c
...
objs/src/http/ngx_http.o: $(CORE_DEPS) $(HTTP_DEPS) src/http/ngx_http.c
$(CC) -c $(CFLAGS) $(CORE_INCS) $(HTTP_INCS) -o objs/src/http/ngx_http.o src/http/ngx_http.c
...
manpage:objs/nginx.8
objs/nginx.8: docs/man/nginx.8 objs/ngx_auto_config.h
sed -e ...替換現有檔案內容
install: build
建立目錄,拷貝objs/nginx,/usr/local/nginx/sbin/nginx
conf/... /usr/local/nginx/conf/...
建立目錄/usr/local/nginx/logs
...
變數賦值
CC,CFLAGS,CPP,LINK($CC),ALL_INCS(-I...),CORE_DEPS, CORE_INCS, HTTP_DEPS, HTTP_INCS
目標
build: binary modules manpage
binary: objs/nginx
objs/nginx: objs/src/core/nginx.o ... objs/src/http/ngx_http.o
$(LINK) -o objs/nginx (...o)-ldl -lpthread -lcrypt -lpcre -lz -Wl,-E
下面是每個.o檔案的編譯規則
objs/ngx_modules.o: $(CORE_DEPS) objs/ngx_modules.c
(CC) -c $(CFLAGS) $(CORE_INCS) -o objs/ngx_modules.o objs/ngx_modules.c
...
objs/src/http/ngx_http.o: $(CORE_DEPS) $(HTTP_DEPS) src/http/ngx_http.c
$(CC) -c $(CFLAGS) $(CORE_INCS) $(HTTP_INCS) -o objs/src/http/ngx_http.o src/http/ngx_http.c
...
manpage:objs/nginx.8
objs/nginx.8: docs/man/nginx.8 objs/ngx_auto_config.h
sed -e ...替換現有檔案內容
install: build
建立目錄,拷貝objs/nginx,/usr/local/nginx/sbin/nginx
conf/... /usr/local/nginx/conf/...
建立目錄/usr/local/nginx/logs
...