makefile

一剑行天下 posted @ 2008年11月01日 23:19 in 学习 , 1334 阅读

传统的makefile文件,内容如下:

INCLUDE=./
main: main.o insert.so creat.so delet.so print.so
    gcc -o main -g main.o ./insert.so ./creat.so ./delet.so ./print.so
main.o: main.c tou.h
    gcc -c -o main.o main.c -g -std=c99

insert.so: insert.c
    gcc -fpic -shared -I $(INCLUDE) -g -o ./insert.so insert.c -std=c99
creat.so: creat.c
    gcc -fpic -shared -I $(INCLUDE) -g -o ./creat.so creat.c -std=c99
delet.so: delet.c
    gcc -fpic -shared -I $(INCLUDE) -g -o ./delet.so delet.c -std=c99

print.so: print.c
    gcc -fpic -shared -I $(INCLUDE) -g -o ./print.so print.c -std=c99
clean:
    rm *.so main.o main

或者用目前已总结的最简介的makefile文件,内容如下:

VPATH =./src
CFLAGS = -g -std=c99 `pkg-config --cflags glib-2.0`
LIBS = `pkg-config --libs glib-2.0`
MLIBS = -lgsl -lm -lgslcblas
OBJ=main.o  point_generation.o m2.o m2list.o vector_sort.o  m2vector.o m2ptset.o m2box.o m2boxtree.o m2ntree.o m2coord.o   m2pt.o  each_bezier.o

//只需填写依赖文件

main : $(OBJ)
    $(CC) $(LIBS) $(MLIBS) $(OBJ) -o main
%.o : %.c
    $(CC) -c $(CFLAGS) -I$(VPATH)  $< -o $@
clean:
    rm -f $(OBJ) main *.o nc.asc  NC.asc point_vector.asc nc1.asc tool.NC


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter