我正在为移动设备(Windows Mobile 6和Android)开发跨平台2D引擎。我的Windows版本已经准备就绪,但我仍然需要确保在Android上提供相同的功能。
我想要的是项目根目录中的Makefile
和项目本身以及测试应用程序的几个Makefile
。
Makefile
---Engine
------Makefile
------src
------bin
------intermediate
---Tests
------TestOne
---------Makefile
---------src
---------bin
---------intermediate
------TestTwo
---------Makefile
---------src
---------bin
---------intermediate
我正在尝试以下Makefile
:
include ../makeinclude
PROGS = test1
SOURCES = $(wildcard *.cpp)
# first compile main.o and start.o, then compile the rest
OBJECTS = main.o start.o $(SOURCES:.cpp=.o)
all: $(PROGS)
clean:
rm -f *.o src
test1: $(OBJECTS)
$(LD) --entry=_start --dynamic-linker system/bin/linker -nostdlib -rpath system/lib -rpath $(LIBS) -L $(LIBS) -lm -lc -lui -lGLESv1_CM $^ -o ../$@
acpy ../$(PROGS)
.cpp.o:
$(CC) $(CFLAGS) -I $(GLES_INCLUDES) -c $*.cpp $(CLIBS)
然而,我对这些事情并不是很了解。我想要的是它取得src
文件夹中的.cpp,将它们编译成.o并将它们放在intermediate
文件夹中,最后将.o编译成编译的exe文件夹并将其放在bin
文件夹中。
我已经设法干净地工作了这样:
cd intermediate && rm -f *.o
但是,我无法检索.cpp,编译它们并将它们放在intermediate
文件夹中。
我看过其他几个Makefiles
,但没有人做我想做的事。
感谢任何帮助。
答案 0 :(得分:8)
有多种方法可以做到这一点,但最简单的方法是在TestOne中运行,使得中间/ foo.o不受Src / foo.cpp的影响,而test1则退出Intermediate / foo.o,如下所示:
# This makefile resides in TestOne, and should be run from there. include makeinclude # Adjust the path to makeinclude, if need be. PROG = bin/test1 SOURCES = $(wildcard Src/*.cpp) # Since main.cpp and start.cpp should be in Src/ with the rest of # the source code, there's no need to single them out OBJECTS = $(patsubst Src/%.cpp,Intermediate/%.o,$(SOURCES)) all: $(PROG) clean: rm -f Intermediate/*.o bin/* $(PROG): $(OBJECTS) $(LD) $(BLAH_BLAH_BLAH) $^ -o ../$@ $(OBJECTS): Intermediate/%.o : Src/%.cpp $(CC) $(CFLAGS) -I $(GLES_INCLUDES) -c $< $(CLIBS) -o $@