How to use Make

xiaoxiao2021-03-06  91

How to use Make

Blue forest http://www.lslnet.com, March 22, 2001 08:25

Under the shell's prompt symbol, if you type "make", it will find the Makefile file in the current directory. Then follow the steps recorded in the Makefile step by step. When we write, if you write the steps you need in advance in advance, you want the Compiler program, you want the Compiler program to enter the Make instruction. As long as the program is correct, you can get the required results! Makefile format: (1) Note: In Makefile, any text starting with "#" is annotated, and make it will ignore it when interpreting makefile. (2) Renew the down: In Makefile, if you are not enough to accommodate the order. The last addition of the line in the line () indicates that the next behavior is continued, and the two lines should be considered as a line. (3) Macro (Macro) The format is: string = value, for example: cflags = -o -systype BSD43 In fact, Make itself has many Default Macro, if you want to view these Macro, you can go to make -p command. (4) The rule format is as follows: : depend .... : depend .... (5) one Very simple Makefile assumes that we have a program to partially divided into parts: Menu.c The main program part of the Menu.h menu.c provides some Function Calls Utils for Menu.c Call. H utils.c's include file simultaneously this application is also used with ncurses' Function Calls. Menu.c and utils.c are placed under / usr / src / menu. But menu.h and utils.h are placed under / usr / src / menu / include. After the program is finished, the file is implemented as MENU and is put below / usr / bin.

# This is the makefile of menu cc = gcc cflags = -ddebug -c libs = -lncurses include = -i / us / usr / src / menu / include all: Clean Install Install: Menu Chmod 750 Menu CP MENU / USR / BIN MENU: Menu.o Utils.o $ (CC) -O $ @ $ (libs) menu.o: $ (cc) $ (cflags) -o $ @ menu.c $ (incline) Utils.o: $ (CC ) $ (Cflags) -O $ @ utils.c * .o -rm * ~ In the above Makefile, use a MACRO available in such a form of (macro_name). Make will automatically expand. $ @ Is the Rule Target, and $? Is the debnd of the rule. If you add one "-" in front of Command, it means that if this Command has an error, it will not pay, continue to execute. The relationship between the above Makefile can be represented as follows: All / Clean Install Menu / Menu.o Utils.o You can play make Clean if you only want to clear files other than SOURCE. If you just want to make MAKE Menu.o. If you want to finish all, you can play Make ALL or Make. Pay special attention to a Tab (ie Tab) before Command. Excerpted from: http://www.linuxaid.com.cn

转载请注明原文地址:https://www.9cbs.com/read-123204.html

New Post(0)