这个Makefile是生成二进制程序的。参考前一篇文章
PREFIX=/usr/local
BIN=my
LIBPATH=-L$(PREFIX)/lib
MY_LIBS=-L../lib -lspider
MY_CFLAGS=-I../include
LIBS:=$(MY_LIBS)
INCLUDE=$(MY_CFLAGS)
CFLAGS=-g -Wall -O3 $(INCLUDE)
INSTALL=/usr/bin/install -c
LDFLAGS= -Wl,-R$(PREFIX)/lib
CC=gcc
SOURCE=main.c
OBJS:=$(patsubst %.c, %.o, $(SOURCE))
DEPS:=$(patsubst %.o, %.d, $(OBJS))
CPPFLAGS += -MMD
.PHONY: all deps objs clean
all: $(BIN)
deps: $(DEPS)
objs: $(OJBS)
-include $(DEPS)
$(BIN): $(OBJS)
$(CC) $(LDFLAGS) -o $(BIN) $(OBJS) $(LIBS)
clean:
@$(RM) $(OBJS) $(DEPS) $(BIN)
install:
if test ! -d $(PREFIX)/bin;then mkdir -p $(PREFIX)/bin;fi
$(INSTALL) $(BIN) $(PREFIX)/bin/