【发布时间】:2010-04-14 20:44:17
【问题描述】:
我的项目(一种解释性语言)有一个由多个文件组成的标准库,每个文件都将内置到一个 .so 动态库中,解释器将根据用户请求加载(使用导入指令)。 每个源文件都位于代表其“命名空间”的子目录中,例如:
构建过程必须创建一个“构建”目录,然后在每个文件编译时都必须在“构建”目录中创建其命名空间目录,例如在编译时
std/io/network/tcp.cc
他使用
运行 mkdir 命令mkdir -p build/std/io/network
Makefile sn-p 是:
STDSRC=stdlib/std/hashing/md5.cc \
stdlib/std/hashing/crc32.cc \
stdlib/std/hashing/sha1.cc \
stdlib/std/hashing/sha2.cc \
stdlib/std/io/network/http.cc \
stdlib/std/io/network/tcp.cc \
stdlib/std/io/network/smtp.cc \
stdlib/std/io/file.cc \
stdlib/std/io/console.cc \
stdlib/std/io/xml.cc \
stdlib/std/type/reflection.cc \
stdlib/std/type/string.cc \
stdlib/std/type/matrix.cc \
stdlib/std/type/array.cc \
stdlib/std/type/map.cc \
stdlib/std/type/type.cc \
stdlib/std/type/binary.cc \
stdlib/std/encoding.cc \
stdlib/std/os/dll.cc \
stdlib/std/os/time.cc \
stdlib/std/os/threads.cc \
stdlib/std/os/process.cc \
stdlib/std/pcre.cc \
stdlib/std/math.cc
STDOBJ=$(STDSRC:.cc=.so)
all: stdlib
stdlib: $(STDOBJ)
.cc.so:
mkdir -p `dirname $< | sed -e 's/stdlib/stdlib\/build/'`
$(CXX) $< -o `dirname $< | sed -e 's/stdlib/stdlib\/build/'`/`basename $< .cc`.so $(CFLAGS) $(LDFLAGS)
我有两个问题:
1 - 问题是 make 命令,我真的不知道为什么,不检查文件是否被修改,无论如何都不会在所有文件上启动构建过程,所以如果我只需要构建一个文件,我必须全部构建它们或使用命令:
make path/to/single/file.so
有没有办法解决这个问题?
2 - 有什么方法可以以“更清洁”的方式做到这一点,而不必将所有构建目录与源代码一起分发?
谢谢
【问题讨论】:
标签: makefile