Makefile 范例,支持多程序

    技术2022-05-20  41

    #Author:cinience@gmail.com #edit "src" to your path,it include your c source file SRC_DIR =.

    #edit "inc" to your path,it include your c header file INC_DIR =.

    #edit your .o file OBJECTS01 = ftpclient.o OBJECTS02 = chklogin.o clientinfo.o ftpserver.o

    #edit your app name TARGETS01 = client TARGETS02 = server

    #edit your complie cc = gcc

    #edit CFLAGS = -Wall -O -g

    #VPATH = src:inc vpath %.c $(SRC_DIR) vpath %.h $(INC_DIR)

    all : $(TARGETS01)  $(TARGETS02)

    #edit "myapp" to your app name $(TARGETS01) : $(OBJECTS01)     $(cc) $^ $(CFLAGS) -o $@ $(OBJECTS) : %.o : %.c     $(cc) $(CFLAGS) -c $< -I$(INC_DIR)

    $(TARGETS02) : $(OBJECTS02)     $(cc)  $^ $(CFLAGS) -o $@ -lphread -lmysqlclient $(OBJECTS) : %.o : %.c     $(cc) $(CFLAGS) -c $< -I$(INC_DIR)

    .PHONY : clean clean :     -rm -f *.o $(TARGETS01) $(TARGETS02)

     

     

    如果不需要支持多程序编译,只需屏蔽相应的即可

    如果还需要支持更多程序,类似的添加即可


    最新回复(0)