2008年3月8日星期六

不错的Makefile 留个做参考

  prefix = /usr/local

  exec_prefix = ${prefix}

  BINDIR = ${exec_prefix}/bin

  MANDIR = ${prefix}/man/man1

  ETCDIR = /etc

  CC = gcc

  CFLAGS = -Wall -O2

  LIBS = -lgd -lpng -lz -lm

  DEFS = -DETCDIR="/etc" -DHAVE_GETOPT_H=1 -DHAVE_MATH_H=1

  LDFLAGS=

  INSTALL= /usr/bin/install -c

  INSTALL_PROGRAM=${INSTALL}

  INSTALL_DATA=${INSTALL} -m 644

  # where are the GD header files?

  GDLIB=/usr/include
# Shouldn't have to touch below here!

  all: webalizer

  webalizer: webalizer.o webalizer.h hashtab.o hashtab.h

  linklist.o linklist.h preserve.o preserve.h

  dns_resolv.o dns_resolv.h parser.o parser.h

  output.o output.h graphs.o graphs.h lang.h

  webalizer_lang.h

  $(CC) ${LDFLAGS} -o webalizer webalizer.o hashtab.o linklist.o preserv

  e.o parser.o output.o dns_resolv.o graphs.o ${LIBS}

  rm -f webazolver

  ln -s webalizer webazolver

  webalizer.o: webalizer.c webalizer.h parser.h output.h preserve.h

  graphs.h dns_resolv.h webalizer_lang.h

  $(CC) ${CFLAGS} ${DEFS} -c webalizer.c

  parser.o: parser.c parser.h webalizer.h lang.h

  $(CC) ${CFLAGS} ${DEFS} -c parser.c

  hashtab.o: hashtab.c hashtab.h dns_resolv.h webalizer.h lang.h

  $(CC) ${CFLAGS} ${DEFS} -c hashtab.c

  linklist.o: linklist.c linklist.h webalizer.h lang.h

  $(CC) ${CFLAGS} ${DEFS} -c linklist.c

  output.o: output.c output.h webalizer.h preserve.h

  hashtab.h graphs.h lang.h

  $(CC) ${CFLAGS} ${DEFS} -c output.c

  preserve.o: preserve.c preserve.h webalizer.h parser.h

  hashtab.h graphs.h lang.h

  $(CC) ${CFLAGS} ${DEFS} -c preserve.c

  dns_resolv.o: dns_resolv.c dns_resolv.h lang.h webalizer.h

  $(CC) ${CFLAGS} ${DEFS} -c dns_resolv.c

  graphs.o: graphs.c graphs.h webalizer.h lang.h

  $(CC) ${CFLAGS} ${DEFS} -I${GDLIB} -c graphs.c