Makefile 사용 인스턴스

1041 단어
[tab]는 탭입니다.
#      
CC = gcc

# CFLAG       
CFLAGS = -g -Wall

#        
INC = -Iport -I../../modbus/rtu \
  -I../../modbus/ascii -I../../modbus/include -I../../modbus/tcp

#      
LDFLAGS = 
LDLIBS = -lpthread
#   
TARGET = tcpmodbus
#    
SRC = demo.c port/portother.c \
 port/portevent.c port/porttcp.c \
 ../../modbus/mb.c ../../modbus/tcp/mbtcp.c \
 ../../modbus/functions/mbfunccoils.c \
 ../../modbus/functions/mbfuncdiag.c \
 ../../modbus/functions/mbfuncholding.c \
 ../../modbus/functions/mbfuncinput.c \
 ../../modbus/functions/mbfuncother.c \
 ../../modbus/functions/mbfuncdisc.c \
 ../../modbus/functions/mbutils.c

#           
OBJS = $(SRC:.c=.o)

#           $^          
$(TARGET): $(OBJS)
[tab]$(CC) $^ -o $@ $(LDFLAGS) $(LDLIBS)

#             
clean:
[tab]rm -f $(OBJS)
[tab]rm -f $(TARGET)

#            $@       $<          
%.o:%.c
[tab]$(CC) $(CFLAGS) $(INC) -o $@ -c $<

#   【1】             。
#   【2】         。

#【1】LDIBS     ,     -l    。
#【2】LDFLAGS         ,    -L    。

좋은 웹페이지 즐겨찾기