makefile快速入门

LIBDIR = -L /opt/kds/mobile-stock/3rd-soft/lib/
LIBSO = -lhiredis
HEAD = -I /opt/kds/mobile-stock/3rd-soft/include/hiredis/

#最终生成test才结束
all:test

#$^所有依赖 $@目标
test:test.o a.o 
    gcc -Wall -o $@ $^ $(LIBDIR) $(LIBSO)
    #gcc -o test test.o

#$<第一个依赖
#.c.o缺省:所有name.c生成name.o 相当于 %.o:%.c
.c.o:
    gcc -Wall -o $@ -c $< $(HEAD)

#test.o:test.c
#   gcc -o $@ -c $< $(HEAD)

#gcc -o test.o -c test.c -I ./3rd-soft/include/hiredis/ 只预编译 编译 不汇编 链接
#gcc -o test      test.o -L ./3rd-soft/lib/ -lhiredis 汇编 链接

clean:
    rm -rf *.o
    rm -f test

 

你可能感兴趣的:(makefile)