views:

177

answers:

1
+1  Q: 

Xcode and makefile

Hey all,

What I want to achieve: I'm porting an application to iPhone and I need to run some scripts on the generated assembly by the compiler (our optimization stuff) and then compile it to an executable. I always used a standard make file and did something like this

gcc -S -c my_source.c # compile and generate ASM
optimize.sh my_source.s # optimizations
gcc CCFLAGS my_source.s # compile

Unfortunately, there's no way to generate makefile from xcode projects (I tried some tools, but none of them actually works). I was wondering if any of you got a solution for my problem. I know I can write a makefile from scratch, but it's not a good idea. Any other solutions are welcomed too.

Thanks

A: 

You can do this by changing the default rules for your target in Xcode so that .c files are treated specially. You would then use a custom script for compiling .c files rather than the default behaviour.

Select your target, Get Info, then look at the Rules tab.

Paul R
It might help, but I'm not really sure how. I tried to add a simple rule for processing *.s files (the assembly files created during the compilation), but it didn't work. If I try to change the default rule for C files, it tells me that I can't because it's a system rule.Google shows mostly example for custom files, but none for C/*.S files. Got any example?
DreamMaker
There are several different ways of doing this. In my case I have .pl files which generate .c files, so it's a little different from your case. Easiest solution would probably be to use a different suffix for your .c files. Another approach is to define a new source type which still has a .c suffix with its own build script and then for your .c source files which you want to preprocess specially you change their type from `sourcecode.c.c` to your custom type.
Paul R