tags:

views:

466

answers:

1

Hi.

I'm working on a cross-platform 2D engine for mobile devices (Windows Mobile 6 and Android). My Windows version is pretty much ready, but I still need to make sure the same functionality is available on Android.

What I want is one Makefile in the root of the project and several Makefile's for the project itself and the test applications.

Makefile
---Engine
------Makefile
------src
------bin
------intermediate
---Tests
------TestOne
---------Makefile
---------src
---------bin
---------intermediate
------TestTwo
---------Makefile
---------src
---------bin
---------intermediate

I'm basing my attempts on the following 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)

However, I'm not very good with these things. What I want is for it to take the .cpp's that are in the src folder, compile them to .o and put them in the intermediate folder and, finally, compile the .o's to the compiled exe and put it in the bin folder.

I've managed to get clean to work like this:

cd intermediate && rm -f *.o

However, I can't get it to retrieve the .cpp's, compile them and put them in the intermediate folder.

I've looked at several other Makefiles, but none do the things I want to do.

Any help is appreciated.

+3  A: 
Beta
Thank you! :DThis was exactly what I needed. I love makefile's (much more than Visual Studio's vcproj), but they can be so difficult to set up. :(
knight666
I like them too, but they have some serious shortcomings and a long learning curve... and since I didn't actually test this, there's a bug. Hang on a sec...
Beta