我正在为移动设备(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
Run Code Online (Sandbox Code Playgroud)
我正在尝试以下方面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)
Run Code Online (Sandbox Code Playgroud)
但是,我对这些事情不是很了解.我想要的是它获取src文件夹中的.cpp ,将它们编译为.o并将它们放在intermediate文件夹中,最后将.o编译成编译的exe并将其放入bin文件夹中.
我已经设法干净地工作了这样:
cd intermediate && rm -f *.o
Run Code Online (Sandbox Code Playgroud)
但是,我无法检索.cpp,编译它们并将它们放在intermediate文件夹中.
我看过其他几个Makefiles,但没有做我想做的事情.
任何帮助表示赞赏.
有多种方法可以做到这一点,但最简单的方法是在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 $@