我正在开发适用于移动设备(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)
然而,我对这些事情不太擅长。我想要的是它采用 .cpp 中的src
文件夹,将它们编译为.o并放入intermediate
文件夹,最后将 .o 编译为已编译的 exe 并将其放入bin
folder.
我已经成功地像这样干净地工作了:
cd intermediate && rm -f *.o
但是,我无法让它检索 .cpp、编译它们并将它们放入intermediate
folder.
我看过其他几个Makefiles
,但没有人做我想做的事情。
任何帮助表示赞赏。
有不止一种方法可以做到这一点,但最简单的方法是在 TestOne 中运行,从 Src/foo.cpp 中生成 Intermediate/foo.o,并从 Intermediate/foo.o 中生成 test1,如下所示:
# 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 $@
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)