一个makefile调用多个makefile 文件示例

长平狐 发布于 2012/09/03 12:56
阅读 2K+
收藏 0

项目1makefile:

LIBDIR = /root

INCDIR = . ./Include

 

TARGET = x

MAKEFILE = makefile

LIBS = dl pthread rt

TXLIB = aes

 

#CC = gcc -ggdb

CC = gcc

CPPFLAGS = -MD

# add -D_INTERRUPT to CFLAGS to switch to interrupt mode.

CFLAGS := -O -Wall -D_REENTRANT -fPIC $(addprefix -I, $(INCDIR)) -g

LDFLAGS = -Wl,-Bsymbolic -rdynamic

 

SOURCE := $(wildcard *.c) $(wildcard *.cpp)

OBJS := $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCE)))

DEPS := $(patsubst %.o,%.d,$(OBJS))

 

all : $(TARGET)

 

clean :

        -rm -f  ../$(TARGET) $(OBJS) $(DEPS) *~ core*

 

-include $(DEPS)

 

$(TARGET) : $(OBJS) $(MAKEFILE)

        $(CC) -o ../$(TARGET) $(LDFLAGS) $(OBJS) $(addprefix -l,$(LIBS)) -laes -L/usr/lib/mysql -lmysqlclient -lm -lz -lstdc++ 

 

项目2makefile:

TARGET=moni_x

CC=gcc

CFLAGS=-Wall -O -g

SOURCE=$(wildcard *.c)

OBJS=${SOURCE:.c=.o}

 

all: $(TARGET)

$(TARGET):$(OBJS)

        $(CC) $(CFLAGS)  $^ -o ../$@

#       $(CC) $(CFLAGS) $(OBJS) -o ../$(TARGET)

 

.PHONY: clean

clean:

        rm -rf  ../$(TARGET) $(OBJS) *~ core*

总makefile:

SUBDIRS = Clean-with-com4  moni_x

 

all:

        @list='$(SUBDIRS)'; for subdir in $$list; do /

                echo "Making all in $$list"; /

                (cd $$subdir && make all); /

        done;

 

.PHONY: clean

 

clean:

        @list='$(SUBDIRS)'; for subdir in $$list; do /

                echo "Clean in $$subdir"; /

                (cd $$subdir && make clean); /

        done

 


原文链接:http://blog.csdn.net/hanchaoman/article/details/5697699
加载中
返回顶部
顶部