[07/10] configure: Check whether Windows Phone specific extra ldflags are needed

Message ID 1437904678-19444-7-git-send-email-martin@martin.st
State New
Headers show

Commit Message

Martin Storsjö July 26, 2015, 9:57 a.m.
---
After these patches, one can do a build for Windows Phone/ARM with
as little configure flags as this:
--toolchain=msvc --target-os=win32 --enable-cross-compile --arch=arm --cpu=armv7-a --extra-cflags='-DWINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP'
---
 configure | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Comments

Martin Storsjö July 26, 2015, 10 a.m. | #1
On Sun, 26 Jul 2015, Martin Storsjö wrote:

> ---
> After these patches, one can do a build for Windows Phone/ARM with
> as little configure flags as this:
> --toolchain=msvc --target-os=win32 --enable-cross-compile --arch=arm --cpu=armv7-a --extra-cflags='-DWINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP'
> ---
> configure | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)

Steve, hopefully these patches won't cause any issues when building with 
VLC's compiler wrapper script. The one that adds -MD might be a bit messy 
since it just checks what's in CFLAGS (and won't know if you have anything 
extra automatically added in the wrapper that configure doesn't know of), 
but other than that, most of these things should work seamlessly with 
existing setups (with lots of hardcoded flags) and allow removing a lot of 
the boilerplate flags.

// Martin
Steve Lhomme July 26, 2015, 2:44 p.m. | #2
On Sun, Jul 26, 2015 at 12:00 PM, Martin Storsjö <martin@martin.st> wrote:
> On Sun, 26 Jul 2015, Martin Storsjö wrote:
>
>> ---
>> After these patches, one can do a build for Windows Phone/ARM with
>> as little configure flags as this:
>> --toolchain=msvc --target-os=win32 --enable-cross-compile --arch=arm
>> --cpu=armv7-a --extra-cflags='-DWINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP'
>> ---
>> configure | 14 ++++++++++++++
>> 1 file changed, 14 insertions(+)
>
>
> Steve, hopefully these patches won't cause any issues when building with
> VLC's compiler wrapper script. The one that adds -MD might be a bit messy
> since it just checks what's in CFLAGS (and won't know if you have anything
> extra automatically added in the wrapper that configure doesn't know of),
> but other than that, most of these things should work seamlessly with
> existing setups (with lots of hardcoded flags) and allow removing a lot of
> the boilerplate flags.

No they shouldn't. Also your patch doesn't take in account WinRT which
is a little bit different.

Check https://github.com/robUx4/vlc-msvc/blob/master/wrappers/clwrap#L13

> // Martin
> _______________________________________________
> libav-devel mailing list
> libav-devel@libav.org
> https://lists.libav.org/mailman/listinfo/libav-devel
Martin Storsjö July 26, 2015, 4:51 p.m. | #3
On Sun, 26 Jul 2015, Steve Lhomme wrote:

> On Sun, Jul 26, 2015 at 12:00 PM, Martin Storsjö <martin@martin.st> wrote:
>> On Sun, 26 Jul 2015, Martin Storsjö wrote:
>>
>>> ---
>>> After these patches, one can do a build for Windows Phone/ARM with
>>> as little configure flags as this:
>>> --toolchain=msvc --target-os=win32 --enable-cross-compile --arch=arm
>>> --cpu=armv7-a --extra-cflags='-DWINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP'
>>> ---
>>> configure | 14 ++++++++++++++
>>> 1 file changed, 14 insertions(+)
>>
>>
>> Steve, hopefully these patches won't cause any issues when building with
>> VLC's compiler wrapper script. The one that adds -MD might be a bit messy
>> since it just checks what's in CFLAGS (and won't know if you have anything
>> extra automatically added in the wrapper that configure doesn't know of),
>> but other than that, most of these things should work seamlessly with
>> existing setups (with lots of hardcoded flags) and allow removing a lot of
>> the boilerplate flags.
>
> No they shouldn't. Also your patch doesn't take in account WinRT which
> is a little bit different.
>
> Check https://github.com/robUx4/vlc-msvc/blob/master/wrappers/clwrap#L13

Which ones of those are strictly necessary for libav? When targeting 
WinRT, building right now works just fine without adding any extra 
ldflags. As long as we don't call any such APIs, one doesn't need to add 
e.g. RuntimeObject.lib or any such. The only thing that would be useful is 
adding the nodefaultlib entries, but I don't really see why they'd be 
necessary here either.

(Also, it feels weird that you're first forcing both ole32.lib and 
kernel32.lib and then adding -nodefaultlib to exclude them again.)

Or am I missing anything? I haven't actually tried shipping any WinRT app.

// Martin

Patch

diff --git a/configure b/configure
index 541d6ce..814dfbd 100755
--- a/configure
+++ b/configure
@@ -3481,6 +3481,20 @@  EOF
             add_cflags -MD
         fi
     fi
+    if check_cpp<<EOF
+#include <winapifamily.h>
+#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE)
+#error not phone
+#endif
+EOF
+    then
+        # When building for Windows Phone 8.1 with MSVC 2013, one needs to manually add these ldflags.
+        # For Windows Phone 8.0 (MSVC 2012), they aren't needed (but don't hurt either).
+        # Check whether linking succeeds with the user provided flags, if not, try adding these.
+        check_ld <<EOF || check_ldflags -nodefaultlib:kernel32.lib -nodefaultlib:ole32.lib WindowsPhoneCore.lib
+int main(void){ return 0; }
+EOF
+    fi
 fi
 
 # compiler sanity check