代码:
bash-3.2$ cat test_first.m
#import <Foundation/Foundation.h>
int main(int argc, char ** argv) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSLog(@"headfile file is OK \n");
[pool release];
return 0;
}
makefile:
TARGET_NAME:=test_first
AUTO_SRC_FILE=$(join $(TARGET_NAME),.m)
AUTO_OBJ_FILE=$(join $(TARGET_NAME),.o)
INCLUDE_DIR:=
LIBRARY_DIR:=
OPTIONS:=-fconstant-stirng-class=NSConstantString -lobjc
.phony:all
all:$(TARGET_NAME)
$(TARGET_NAME):$(AUTO_OBJ_FILE)
gcc $^ -o $@ $(OPTIONS) -framework Foundation -framework CoreFoundation
%.o:%.m
gcc -c -o $@ $^
运行结果:
bash-3.2$ ./test_first
2011-09-19 23:45:02.097 test_first[709:903] headfile file is OK