I never built the official script but i think the patch is easy, on the download part, it is necessary to download the gcc objc component and on the build script enable it by:
This builds but it won't link, I had to change my script with something like:
CFLAGS="-G0" \
../../gcc-4.3.2/configure \
--enable-languages="c,c++,objc" \
... and all the other flags...
Then I added the sample code to the SDK:
Code: Select all
Index: pspsdk/src/base/build.mak
===================================================================
--- pspsdk/src/base/build.mak (revision 2432)
+++ pspsdk/src/base/build.mak (working copy)
@@ -45,6 +45,11 @@
CFLAGS += -D_PSP_FW_VERSION=$(PSP_FW_VERSION)
CXXFLAGS += -D_PSP_FW_VERSION=$(PSP_FW_VERSION)
+# Objective-C selection. All Objective C code must be linked against libobjc.a
+ifeq ($(USE_OBJC),1)
+LIBS := $(LIBS) -lobjc
+endif
+
ifeq ($(BUILD_PRX),1)
LDFLAGS := $(addprefix -L,$(LIBDIR)) -specs=$(PSPSDK)/lib/prxspecs -Wl,-q,-T$(PSPSDK)/lib/linkfile.prx $(LDFLAGS)
EXTRA_CLEAN += $(TARGET).elf
@@ -198,6 +203,9 @@
%.c: %.exp
psp-build-exports -b $< > $@
+%.o: %.m
+ $(CC) $(CFLAGS) -c -o $@ $<
+
clean:
-rm -f $(FINAL_TARGET) $(EXTRA_CLEAN) $(OBJS) $(PSP_EBOOT_SFO) $(PSP_EBOOT) $(EXTRA_TARGETS)
Index: pspsdk/src/base/build_prx.mak
===================================================================
--- pspsdk/src/base/build_prx.mak (revision 2432)
+++ pspsdk/src/base/build_prx.mak (working copy)
@@ -37,6 +37,11 @@
CFLAGS += -D_PSP_FW_VERSION=$(PSP_FW_VERSION)
+# Objective-C selection. All Objective C code must be linked against libobjc.a
+ifeq ($(USE_OBJC),1)
+LIBS := $(LIBS) -lobjc
+endif
+
# Library selection. By default we link with Newlib's libc. Allow the
# user to link with PSPSDK's libc if USE_PSPSDK_LIBC is set to 1.
@@ -80,6 +85,9 @@
%.c: %.exp
psp-build-exports -b $< > $@
+%.o: %.m
+ $(CC) $(CFLAGS) -c -o $@ $<
+
clean: $(EXTRA_CLEAN)
-rm -f $(FINAL_TARGET) $(TARGET).elf $(OBJS)
Index: pspsdk/src/samples/Makefile.am
===================================================================
--- pspsdk/src/samples/Makefile.am (revision 2432)
+++ pspsdk/src/samples/Makefile.am (working copy)
@@ -81,7 +81,8 @@
utility/systemparam \
utility/osk \
me/basic \
- wlan
+ wlan \
+ obj-c
all:
Index: pspsdk/src/samples/obj-c/main.m
===================================================================
--- pspsdk/src/samples/obj-c/main.m (revision 0)
+++ pspsdk/src/samples/obj-c/main.m (revision 0)
@@ -0,0 +1,61 @@
+#include <objc/Object.h>
+
+@interface Greeter:Object
+{
+ /* This is left empty on purpose:
+ ** Normally instance variables would be declared here,
+ ** but these are not used in our example.
+ */
+}
+
+- (void)greet;
+
+@end
+
+
+#include <pspkernel.h>
+#include <pspdebug.h>
+#include <pspctrl.h>
+
+/* Define printf, just to make typing easier */
+#define printf pspDebugScreenPrintf
+
+@implementation Greeter
+
+- (void)greet
+{
+ printf("Hello, World from Obj-C!\n");
+}
+
+@end
+
+/* Define the module info section */
+PSP_MODULE_INFO("template", 0, 1, 1);
+
+/* Define the main thread's attribute value (optional) */
+PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
+
+int main(void)
+{
+ id myGreeter;
+ myGreeter=[Greeter new];
+
+ [myGreeter greet];
+
+ [myGreeter free];
+
+ /* Non Objective-C code to allow the app to end */
+ SceCtrlData pad;
+
+ printf("\nPress X to quit.\n");
+ for (;;)
+ {
+ sceCtrlReadBufferPositive(&pad, 1);
+ if (pad.Buttons & PSP_CTRL_CROSS)
+ break;
+ sceDisplayWaitVblankStart();
+ }
+ sceKernelExitGame();
+
+ return 0;
+}
Index: pspsdk/src/samples/obj-c/Makefile.sample
===================================================================
--- pspsdk/src/samples/obj-c/Makefile.sample (revision 0)
+++ pspsdk/src/samples/obj-c/Makefile.sample (revision 0)
@@ -0,0 +1,19 @@
+TARGET = ObjC
+OBJS = main.o
+
+USE_OBJC=1
+
+INCDIR =
+CFLAGS = -G0 -Wall -O2
+CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
+ASFLAGS = $(CFLAGS)
+
+LIBDIR =
+LDFLAGS =
+
+EXTRA_TARGETS = EBOOT.PBP
+PSP_EBOOT_TITLE = ObjC Sample
+
+PSPSDK=$(shell psp-config --pspsdk-path)
+include $(PSPSDK)/lib/build.mak
+