Implicit rules:
C Compilation:. c changes to. o $ (CC)-c $ (CPPFLAGS) $ (CFLAGS)
C ++ Compilation: Change. cc or. c to. o $ (CXX)-c $ (CPPFLAGS) $ (CXXFLAGS)
Pascal Compilation: Change. p to. o $ (PC)-c $ (PFLAGS)
Fortran Compilation: Change. r to-o $ (FC)-c $ (FFLAGS)
Example:
OBJS = kang. o yul. o
CC = gcc
CFLAGS =-Wall-O-g
Usage: $ (OBJS)
$ (CC) $ ^-o $ @
Kang. o: kang. c kang. h
$ (CC) $ (CFLAGS)-c $ <-o $ @
Yul. o: yul. c yul. h
$ (CC) $ (CFLAGS)-c $ <-o $ @
Use implicit rules
OBJS = kang. o yul. o
CC = gcc
CFLAGS =-Wall-O-g
Usage: $ (OBJS)
$ (CC) $ ^-o $ @
Mode rules:
Implicit rules can only be operated using the default make variables, while pattern rules can also introduce User-Defined variables to create the same rules for multiple files, thus simplifying the preparation of Makefile. The format of a pattern rule is similar to that of a common rule. "%" must be used before the relevant files in the rule. Example of using a Pattern Rule:
OBJS = kang. o yul. o
CC = gcc
CFLAGS =-Wall-O-g
Usage: $ (OBJS)
$ (Cc) $ ^-o $ @
%. O: %. c
$ (Cc) $ (CFLAGS)-c $ <-o $ @