当前位置: 技术问答>linux和unix
多目录源文件makefile编写
来源: 互联网 发布时间:2016-03-16
本文导语: 我新建一个目录叫fse,里面有个头文件和一个main文件,然后还有其他目录文件,名为file1,....file5.里面放着头文件以及源文件,我想使用autoconfig和automake建立一个makefile,基本步骤已经编写完毕,到了写makefile.am这个...
我新建一个目录叫fse,里面有个头文件和一个main文件,然后还有其他目录文件,名为file1,....file5.里面放着头文件以及源文件,我想使用autoconfig和automake建立一个makefile,基本步骤已经编写完毕,到了写makefile.am这个步骤,不知道makefile.am如何编写,有一些材料都是非常简单的 makfile.am的编写,没有多目录下makefile.am的编写,请高人指教,最好一些makefile.am的规则介绍。谢谢。
|
在父目录的Makefile.am加入
SUBDIRS = 子目录1 子目录2
automake手册不能不看,最好的例子是开源软件源代码。
SUBDIRS = 子目录1 子目录2
automake手册不能不看,最好的例子是开源软件源代码。
|
bin_PROGRAMS= xx.o
xx_SOURCES= 1.cc 2.cc
|
给你一个示例:
针对 include 目录,写一个makefile, 我这里命名为common.mk
# Add inputs and outputs from these tool invocations to the build variables
CPP_SRCS +=
../common/Condition.cpp
../common/Mutex.cpp
../common/Thread.cpp
../common/ThreadPool.cpp
../common/WorkThread.cpp
../common/WorkThreadOfPool.cpp
OBJS +=
./Condition.o
./Mutex.o
./Thread.o
./ThreadPool.o
./WorkThread.o
./WorkThreadOfPool.o
CPP_DEPS +=
./Condition.d
./Mutex.d
./Thread.d
./ThreadPool.d
./WorkThread.d
./WorkThreadOfPool.d
# Each subdirectory must supply rules for building sources it contributes
%.o: ../common/%.cpp
@echo 'Building file: $
针对 include 目录,写一个makefile, 我这里命名为common.mk
# Add inputs and outputs from these tool invocations to the build variables
CPP_SRCS +=
../common/Condition.cpp
../common/Mutex.cpp
../common/Thread.cpp
../common/ThreadPool.cpp
../common/WorkThread.cpp
../common/WorkThreadOfPool.cpp
OBJS +=
./Condition.o
./Mutex.o
./Thread.o
./ThreadPool.o
./WorkThread.o
./WorkThreadOfPool.o
CPP_DEPS +=
./Condition.d
./Mutex.d
./Thread.d
./ThreadPool.d
./WorkThread.d
./WorkThreadOfPool.d
# Each subdirectory must supply rules for building sources it contributes
%.o: ../common/%.cpp
@echo 'Building file: $