PJSIP for iOS (ARMv6 and ARMv7)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The new llvm compiler in Xcode 4 is able to create universal binaries 
(using lipo underneath, most certainly).

So I tried to patch the PJSIP build system to work with the llvm compiler 
and this is what I tried:

# 
CC="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-gcc-4.2" 
ARCH="-arch armv6 -arch armv7" ./configure-iphone
# make dep
# make

The compiler has some limitations, that need some patching:
1.) for some strange reason it seems to require a space after -o
2.) -M and -E don't work together with multiple arch arguments

So I came up with this hack (quick and dirty):

$ svn diff
Index: pjsip-apps/build/Samples.mak
===================================================================
--- pjsip-apps/build/Samples.mak        (revision 3557)
+++ pjsip-apps/build/Samples.mak        (working copy)
@@ -45,13 +45,13 @@
 all: $(BINDIR) $(OBJDIR) $(EXES)
 
 $(BINDIR)/%$(HOST_EXE): $(OBJDIR)/%$(OBJEXT) $(PJ_LIB_FILES)
-       $(LD) $(LDOUT)$(subst /,$(HOST_PSEP),$@) \
+       $(LD) $(LDOUT) $(subst /,$(HOST_PSEP),$@) \
            $(subst /,$(HOST_PSEP),$<) \
            $(_LDFLAGS)
 
 $(OBJDIR)/%$(OBJEXT): $(SRCDIR)/%.c
        $(CC) $(_CFLAGS) \
-         $(CC_OUT)$(subst /,$(HOST_PSEP),$@) \
+         $(CC_OUT) $(subst /,$(HOST_PSEP),$@) \
          $(subst /,$(HOST_PSEP),$<) 
 
 $(OBJDIR):
Index: configure-iphone
===================================================================
--- configure-iphone    (revision 3557)
+++ configure-iphone    (working copy)
@@ -106,7 +106,7 @@
 export RANLIB="echo ranlib"
 # Use gcc -E as preprocessor instead of cpp, since cpp will find the
 # header files in standard /usr/include instead of in isysroot
-export CPP="${CC} ${ARCH} -E -isysroot ${SDKPATH}"
+#export CPP="${CC} ${ARCH} -E -isysroot ${SDKPATH}"
 
 # Print settings
 if test "1" = "1"; then
Index: build/rules.mak
===================================================================
--- build/rules.mak     (revision 3557)
+++ build/rules.mak     (working copy)
@@ -45,7 +45,7 @@
 # When generating dependency (gcc -MM), ideally we use only either
 # CFLAGS or CXXFLAGS (not both). But I just couldn't make if/ifeq to 
work.
 #
-DEPFLAGS = $($(APP)_CXXFLAGS) $($(APP)_CFLAGS)
+DEPFLAGS = $(subst armv6,armv7,$($(APP)_CXXFLAGS) $($(APP)_CFLAGS))
 
 # Dependency file
 DEP_FILE := .$(app)-$(TARGET_NAME).depend
@@ -84,7 +84,7 @@
 
 $(EXE): $(OBJDIRS) $(OBJS) $($(APP)_EXTRA_DEP)
        if test ! -d $(BINDIR); then $(subst @@,$(subst 
/,$(HOST_PSEP),$(BINDIR)),$(HOST_MKDIR)); fi
-       $(LD) $(LDOUT)$(subst /,$(HOST_PSEP),$(EXE)) \
+       $(LD) $(LDOUT) $(subst /,$(HOST_PSEP),$(EXE)) \
            $(subst /,$(HOST_PSEP),$(OBJS)) $($(APP)_LDFLAGS)
 
 $(OBJDIR)/$(app).o: $(OBJDIRS) $(OBJS)
@@ -117,22 +117,22 @@
 
 $(OBJDIR)/%$(OBJEXT): $(SRCDIR)/%.m
        $(CC) $($(APP)_CFLAGS) \
-               $(CC_OUT)$(subst /,$(HOST_PSEP),$@) \
+               $(CC_OUT) $(subst /,$(HOST_PSEP),$@) \
                $(subst /,$(HOST_PSEP),$<) 
 
 $(OBJDIR)/%$(OBJEXT): $(SRCDIR)/%.c
        $(CC) $($(APP)_CFLAGS) \
-               $(CC_OUT)$(subst /,$(HOST_PSEP),$@) \
+               $(CC_OUT) $(subst /,$(HOST_PSEP),$@) \
                $(subst /,$(HOST_PSEP),$<) 
 
 $(OBJDIR)/%$(OBJEXT): $(SRCDIR)/%.S
        $(CC) $($(APP)_CFLAGS) \
-               $(CC_OUT)$(subst /,$(HOST_PSEP),$@) \
+               $(CC_OUT) $(subst /,$(HOST_PSEP),$@) \
                $(subst /,$(HOST_PSEP),$<) 
 
 $(OBJDIR)/%$(OBJEXT): $(SRCDIR)/%.cpp
        $(CC) $($(APP)_CXXFLAGS) \
-               $(CC_OUT)$(subst /,$(HOST_PSEP),$@) \
+               $(CC_OUT) $(subst /,$(HOST_PSEP),$@) \
                $(subst /,$(HOST_PSEP),$<)
 
 $(OBJDIRS):

That works for the moment, but is nothing to check in. I don't know what 
this -E line in configure-iphone is good for (is there any C++ in PJSIP?) 
and the $(subst) thing in rules.mak is, well, the definition of a hack in 
itself. $DEPFLAGS is used together with -M, which doesn't work with "-arch 
armv6 -arch armv7", but is happy with "-arch armv7 -arch armv7". ;)

Maybe someone is able to clear that up a bit and make something useful out 
of it?

Regards,
Sebastian.


pjsip-bounces at lists.pjsip.org schrieb am 24.06.2011 11:21:05:

| You should compile separately for both arch armv6 and armv7 and 
| combine libraries with tool lipo 




[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux