Re: [libav-devel] [PATCH 2/2] Add support for building shared libraries with MSVC

2012-10-17 Thread Måns Rullgård
Martin Storsjö  writes:

> On Sat, 13 Oct 2012, Måns Rullgård wrote:
>
>> Martin Storsjö  writes:
>>
>>> @@ -2930,6 +2944,9 @@ build the shared libraries as well. To only build the 
>>> shared libraries specify
>>>  EOF
>>>  exit 1;
>>>  fi
>>> +if enabled_all msvc static shared; then
>>> +die "Cannot build shared and static libraries at the same time with 
>>> MSVC."
>>> +fi
>>
>> Another idea is to simply disable static if shared is enabled.  That way
>> users can simply configure --enable-shared and save some pointless typing.
>
> Sounds sane, changed locally into:
>
> +if enabled_all msvc shared; then
> +# Cannot build shared and static libraries at the same time with MSVC.
> +disable static
> +fi

That can actually go into the win32 OS section.  That is where the
restriction comes from after all.

-- 
Måns Rullgård
m...@mansr.com
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/2] Add support for building shared libraries with MSVC

2012-10-17 Thread Martin Storsjö

On Mon, 15 Oct 2012, Måns Rullgård wrote:


Martin Storsjö  writes:


On Sat, 13 Oct 2012, Måns Rullgård wrote:


Martin Storsjö  writes:


+#if CONFIG_SHARED && defined(_WIN32) && !defined(COMPILING_avcodec)
+#define avcodec_exportdata __declspec(dllimport)
+#else
+#define avcodec_exportdata
+#endif


I want to think about this some more.


Any further comments on this part?


Probably.  Do not push it yet.


Ping

// Martin___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/2] Add support for building shared libraries with MSVC

2012-10-14 Thread Måns Rullgård
Martin Storsjö  writes:

> On Sat, 13 Oct 2012, Måns Rullgård wrote:
>
>> Martin Storsjö  writes:
>>
>>> +#if CONFIG_SHARED && defined(_WIN32) && !defined(COMPILING_avcodec)
>>> +#define avcodec_exportdata __declspec(dllimport)
>>> +#else
>>> +#define avcodec_exportdata
>>> +#endif
>>
>> I want to think about this some more.
>
> Any further comments on this part?

Probably.  Do not push it yet.

-- 
Måns Rullgård
m...@mansr.com
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/2] Add support for building shared libraries with MSVC

2012-10-14 Thread Martin Storsjö

On Sat, 13 Oct 2012, Måns Rullgård wrote:


Martin Storsjö  writes:


+#if CONFIG_SHARED && defined(_WIN32) && !defined(COMPILING_avcodec)
+#define avcodec_exportdata __declspec(dllimport)
+#else
+#define avcodec_exportdata
+#endif


I want to think about this some more.


Any further comments on this part?

// Martin___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/2] Add support for building shared libraries with MSVC

2012-10-13 Thread Måns Rullgård
Martin Storsjö  writes:

> On Sat, 13 Oct 2012, Måns Rullgård wrote:
>
>> Martin Storsjö  writes:
>>
>>> @@ -2930,6 +2944,9 @@ build the shared libraries as well. To only build the 
>>> shared libraries specify
>>>  EOF
>>>  exit 1;
>>>  fi
>>> +if enabled_all msvc static shared; then
>>> +die "Cannot build shared and static libraries at the same time with 
>>> MSVC."
>>> +fi
>>
>> Another idea is to simply disable static if shared is enabled.  That way
>> users can simply configure --enable-shared and save some pointless typing.
>
> Sounds sane, changed locally into:
>
> +if enabled_all msvc shared; then
> +# Cannot build shared and static libraries at the same time with MSVC.
> +disable static
> +fi

That can be condensed to "enabled_all msvc shared && disable static"

Another way to do the same is by declaring static_deps_any="!msvc !shared"

-- 
Måns Rullgård
m...@mansr.com
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/2] Add support for building shared libraries with MSVC

2012-10-13 Thread Martin Storsjö

On Sat, 13 Oct 2012, Måns Rullgård wrote:


Martin Storsjö  writes:


@@ -2930,6 +2944,9 @@ build the shared libraries as well. To only build the 
shared libraries specify
 EOF
 exit 1;
 fi
+if enabled_all msvc static shared; then
+die "Cannot build shared and static libraries at the same time with MSVC."
+fi


Another idea is to simply disable static if shared is enabled.  That way
users can simply configure --enable-shared and save some pointless typing.


Sounds sane, changed locally into:

+if enabled_all msvc shared; then
+# Cannot build shared and static libraries at the same time with MSVC.
+disable static
+fi


+#if CONFIG_SHARED && defined(_WIN32) && !defined(COMPILING_avcodec)
+#define avcodec_exportdata __declspec(dllimport)
+#else
+#define avcodec_exportdata
+#endif


I want to think about this some more.


Ok


diff --git a/library.mak b/library.mak
index b365935..56a4586 100644
--- a/library.mak
+++ b/library.mak
@@ -33,6 +33,7 @@ install-libs-$(CONFIG_STATIC): install-lib$(NAME)-static
 install-libs-$(CONFIG_SHARED): install-lib$(NAME)-shared

 define RULES
+$(OBJS): CPPFLAGS += -DCOMPILING_$(NAME)=1
 $(EXAMPLES) $(TOOLS): THISLIB = $(FULLNAME:%=$(LD_LIB))
 $(TESTPROGS): THISLIB = $(SUBDIR)$(LIBNAME)


This could use a blank line.


Done locally.

// Martin___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/2] Add support for building shared libraries with MSVC

2012-10-13 Thread Måns Rullgård
Martin Storsjö  writes:

> diff --git a/configure b/configure
> index b30d69b..b70b1ec 100755
> --- a/configure
> +++ b/configure
> @@ -2794,6 +2794,20 @@ case $target_os in
>  add_cppflags -U__STRICT_ANSI__
>  ;;
>  win32|win64)
> +# Link to the import library instead of the normal static library for
> +# shared libs.
> +enabled shared && LD_LIB='%.lib'
> +shlibdir_default="$bindir_default"
> +SLIBPREF=""
> +SLIBSUF=".dll"
> +
> SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
> +SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
> +SLIB_CREATE_DEF_CMD='makedef $(SUBDIR)lib$(NAME).ver $(OBJS) > 
> $$(@:$(SLIBSUF)=.def)'
> +SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
> +SLIB_INSTALL_LINKS=
> +SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'
> +SLIB_INSTALL_EXTRA_LIB='$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)'
> +SHFLAGS='-dll -def:$$(@:$(SLIBSUF)=.def) 
> -implib:$(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib)'
>  objformat="win32"
>  ranlib=:
>  enable dos_paths

This is looking reasonable.

> @@ -2930,6 +2944,9 @@ build the shared libraries as well. To only build the 
> shared libraries specify
>  EOF
>  exit 1;
>  fi
> +if enabled_all msvc static shared; then
> +die "Cannot build shared and static libraries at the same time with 
> MSVC."
> +fi

Another idea is to simply disable static if shared is enabled.  That way
users can simply configure --enable-shared and save some pointless typing.

> +#if CONFIG_SHARED && defined(_WIN32) && !defined(COMPILING_avcodec)
> +#define avcodec_exportdata __declspec(dllimport)
> +#else
> +#define avcodec_exportdata
> +#endif

I want to think about this some more.

> diff --git a/library.mak b/library.mak
> index b365935..56a4586 100644
> --- a/library.mak
> +++ b/library.mak
> @@ -33,6 +33,7 @@ install-libs-$(CONFIG_STATIC): install-lib$(NAME)-static
>  install-libs-$(CONFIG_SHARED): install-lib$(NAME)-shared
>
>  define RULES
> +$(OBJS): CPPFLAGS += -DCOMPILING_$(NAME)=1
>  $(EXAMPLES) $(TOOLS): THISLIB = $(FULLNAME:%=$(LD_LIB))
>  $(TESTPROGS): THISLIB = $(SUBDIR)$(LIBNAME)

This could use a blank line.

-- 
Måns Rullgård
m...@mansr.com
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/2] Add support for building shared libraries with MSVC

2012-10-13 Thread Martin Storsjö

On Sat, 13 Oct 2012, Dave Yeo wrote:


On 10/13/12 10:23 am, Martin Storsjö wrote:

This requires the makedef perl script by Derek, which probably will
go into the c99-to-c89 repo. That scripts produces a .def file,
listing the symbols to be exported, based on the gcc version
scripts and the built object files.


Where is the makedef script currently?


You can grab a copy of it from http://albin.abo.fi/~mstorsjo/makedef right 
now, I'll push it to the c99-to-c89 repo once the rest of this is settled.



Perhaps it should be named makedef.pl?


Hmm, not sure I agree - the fact that it's a perl script isn't of much 
significance, you could swap it out for anything else with the same syntax 
implemented in a different language if you'd want.


// Martin___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/2] Add support for building shared libraries with MSVC

2012-10-13 Thread Dave Yeo

On 10/13/12 10:23 am, Martin Storsjö wrote:

This requires the makedef perl script by Derek, which probably will
go into the c99-to-c89 repo. That scripts produces a .def file,
listing the symbols to be exported, based on the gcc version
scripts and the built object files.


Where is the makedef script currently?
Perhaps it should be named makedef.pl?
Dave
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/2] Add support for building shared libraries with MSVC

2012-10-13 Thread Diego Biurrun
On Sat, Oct 13, 2012 at 10:43:19PM +0300, Martin Storsjö wrote:
> ---
>  configure  |   17 +
>  libavcodec/ac3tab.h|3 ++-
>  libavcodec/dca.h   |3 ++-
>  libavcodec/internal.h  |7 +++
>  libavcodec/mjpeg.h |   15 ---
>  libavcodec/mpeg12data.h|3 ++-
>  libavcodec/mpeg4audio.h|3 ++-
>  libavcodec/mpegaudiodata.h |6 --
>  library.mak|1 +
>  9 files changed, 45 insertions(+), 13 deletions(-)

LGTM, but wait for more opinions.

Diego
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/2] Add support for building shared libraries with MSVC

2012-10-13 Thread Derek Buitenhuis
On 13/10/2012 3:29 PM, Hendrik Leppkes wrote:
> ICL on windows mimics MSVCs behaviour rather strictly so it can be
> used as a more-or-less drop-in replacement, fwiw.

With the exception of supporting C99, which I think is being addressed
in Adam's patch anyway.

- Derek
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/2] Add support for building shared libraries with MSVC

2012-10-13 Thread Hendrik Leppkes
On Sat, Oct 13, 2012 at 9:21 PM, Diego Biurrun  wrote:
>
>> >>+#if CONFIG_SHARED && defined(_MSC_VER) && !defined(COMPILING_avcodec)
>> >
>> >This condition seems a bit too specific.  There are other compilers.
>>
>> That might be good for consistency, even if mingw can do without it.
>> So something like this then:
>>
>> #if CONFIG_SHARED && defined(_WIN32) && !defined(COMPILING_avcodec)
>
> Careful, we might soon get support for ICL, which might or might not
> need this.  _WIN32 seems too greedy to me.
>

ICL on windows mimics MSVCs behaviour rather strictly so it can be
used as a more-or-less drop-in replacement, fwiw.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/2] Add support for building shared libraries with MSVC

2012-10-13 Thread Diego Biurrun
On Sat, Oct 13, 2012 at 09:50:59PM +0300, Martin Storsjö wrote:
> On Sat, 13 Oct 2012, Måns Rullgård wrote:
> >Martin Storsjö  writes:
> >>--- a/configure
> >>+++ b/configure
> >>@@ -2794,6 +2794,29 @@ case $target_os in
> >> add_cppflags -U__STRICT_ANSI__
> >> ;;
> >> msvc)
> >>+if enabled shared; then
> >>+# Link to the import library instead of the
> >>+# normal static library.
> >>+LD_LIB='%.lib'
> >>+enabled static &&
> >>+die "Cannot build shared and static libraries at the same 
> >>time with MSVC."
> >>+fi
> >
> >The static+shared error feels misplaced here.
> 
> Yeah, it's a bit weird here. What section would be a better match?

Maybe around line 2931 with the check that at least one library type
is built.

> >>--- /dev/null
> >>+++ b/libavcodec/symbols.h
> >
> >As nondescriptive filenames go, this one ranks pretty darn high.
> 
> Indeed. Since this doesn't need to be installed, perhaps we could
> just put it into internal.h instead?

Sounds like a good place to me, we have other attributes in there.

> >>+#if CONFIG_SHARED && defined(_MSC_VER) && !defined(COMPILING_avcodec)
> >
> >This condition seems a bit too specific.  There are other compilers.
> 
> That might be good for consistency, even if mingw can do without it.
> So something like this then:
> 
> #if CONFIG_SHARED && defined(_WIN32) && !defined(COMPILING_avcodec)

Careful, we might soon get support for ICL, which might or might not
need this.  _WIN32 seems too greedy to me.

> >>--- a/library.mak
> >>+++ b/library.mak
> >>@@ -19,6 +19,7 @@ $(SUBDIR)x86/%.o: $(SUBDIR)x86/%.asm
> >>$(DEPYASM) $(YASMFLAGS) -I $( $(@:.o=.d)
> >>$(YASM) $(YASMFLAGS) -I $( >>
> >>+$(OBJS): CPPFLAGS := -DCOMPILING_$(NAME)=1 $(CPPFLAGS)
> >
> >This should use +=
> 
> Ok, will change.

That line is mine and I think I initially used +=, but at that point in
time it did not work for some reason.  There have been changes to that
area since, so it might well work now, but doublecheck to be sure.

Diego
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/2] Add support for building shared libraries with MSVC

2012-10-13 Thread Måns Rullgård
Martin Storsjö  writes:

> On Sat, 13 Oct 2012, Martin Storsjö wrote:
>
 diff --git a/library.mak b/library.mak
 index b365935..318fe86 100644
 --- a/library.mak
 +++ b/library.mak
 @@ -19,6 +19,7 @@ $(SUBDIR)x86/%.o: $(SUBDIR)x86/%.asm
$(DEPYASM) $(YASMFLAGS) -I $( $(@:.o=.d)
$(YASM) $(YASMFLAGS) -I $(>>>
 +$(OBJS): CPPFLAGS := -DCOMPILING_$(NAME)=1 $(CPPFLAGS)
>>>
>>> This should use +=
>>
>> Ok, will change.
>
> Actually, there seems to be some subtlety here I don't understand
> off-hand - when I change this to use +=, it ends up defining
> -DCOMPILING_avutil while building avcodec (probably while building all
> of them).

Ah, that's because evaluation of $(NAME) is deferred.  If you stick that
line inside the RULES macro it should work.

-- 
Måns Rullgård
m...@mansr.com
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/2] Add support for building shared libraries with MSVC

2012-10-13 Thread Martin Storsjö

On Sat, 13 Oct 2012, Martin Storsjö wrote:


diff --git a/library.mak b/library.mak
index b365935..318fe86 100644
--- a/library.mak
+++ b/library.mak
@@ -19,6 +19,7 @@ $(SUBDIR)x86/%.o: $(SUBDIR)x86/%.asm
$(DEPYASM) $(YASMFLAGS) -I $( $(@:.o=.d)
$(YASM) $(YASMFLAGS) -I $(

This should use +=


Ok, will change.


Actually, there seems to be some subtlety here I don't understand off-hand 
- when I change this to use +=, it ends up defining -DCOMPILING_avutil 
while building avcodec (probably while building all of them).


// Martin___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/2] Add support for building shared libraries with MSVC

2012-10-13 Thread Martin Storsjö

On Sat, 13 Oct 2012, Måns Rullgård wrote:


Martin Storsjö  writes:


diff --git a/configure b/configure
index 667089b..362f8d1 100755
--- a/configure
+++ b/configure
@@ -2794,6 +2794,29 @@ case $target_os in
 add_cppflags -U__STRICT_ANSI__
 ;;
 msvc)
+if enabled shared; then
+# Link to the import library instead of the
+# normal static library.
+LD_LIB='%.lib'
+enabled static &&
+die "Cannot build shared and static libraries at the same time with 
MSVC."
+fi


The static+shared error feels misplaced here.


Yeah, it's a bit weird here. What section would be a better match?


+LIBTARGET=i386
+if enabled x86_64; then
+LIBTARGET=x64
+fi


enabled x86_64 && LIBTARGET=i386 || LIBTARGET=x64


+shlibdir_default="$bindir_default"
+SLIBPREF=""
+SLIBSUF=".dll"
+SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
+SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
+SLIB_CREATE_DEF_CMD='makedef $(SUBDIR)lib$(NAME).ver $(OBJS) > 
$$(@:$(SLIBSUF)=.def)'


Is makedef a friend of c99wrap?


Yeah, we'll put it into the same repo.


+SLIB_EXTRA_CMD='-lib.exe -machine:$(LIBTARGET) 
-def:$$(@:$(SLIBSUF)=.def) -out:$(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib)'
+SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
+SLIB_INSTALL_LINKS=
+SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'


Should the .lib file really end up in $bindir?  That doesn't feel right
at all.


It's pretty weird, but this is the convention - we do it the same way for 
mingw.



+SLIB_INSTALL_EXTRA_LIB='$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)'
+SHFLAGS='-dll -def:$$(@:$(SLIBSUF)=.def) 
-implib:$(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a)'


The mentino of .dll.a there is confusing.  Can you please tell me which
command produce/consume what files?  I have the distinct feeling all
this can be cleaned up considerably.


Indeed, this turned out to have some duplication I missed before. link.exe 
creates one import library, then we created a separate one using lib.exe. 
I'll change this to not use lib.exe at all and make link.exe produce the 
.lib named import library straight away.


After my local changes, link.exe produces e.g. avutil.lib, which is used 
by LD_LIB when linking the avcodec DLL and all other DLLs/executables.



+extern AVCODEC_SYMBOL const uint16_t avpriv_ac3_channel_layout_tab[8];


If this annotation is really required, please do two things:

1. Call it something at least halfway descriptive.
2. Make it less of an eyesore (i.e. not uppercase).


Right, like avcodec_exportdata or so? It needs to have the lib name 
included, since it should be enabled/disabled per library.



diff --git a/libavcodec/symbols.h b/libavcodec/symbols.h
new file mode 100644
index 000..3c98d46
--- /dev/null
+++ b/libavcodec/symbols.h


As nondescriptive filenames go, this one ranks pretty darn high.


Indeed. Since this doesn't need to be installed, perhaps we could just put 
it into internal.h instead?



[...]


+#if CONFIG_SHARED && defined(_MSC_VER) && !defined(COMPILING_avcodec)


This condition seems a bit too specific.  There are other compilers.


That might be good for consistency, even if mingw can do without it. So 
something like this then:


#if CONFIG_SHARED && defined(_WIN32) && !defined(COMPILING_avcodec)


+#define AVCODEC_SYMBOL __declspec(dllimport)
+#else
+#define AVCODEC_SYMBOL
+#endif
+
+#endif /* AVCODEC_SYMBOLS_H */
diff --git a/library.mak b/library.mak
index b365935..318fe86 100644
--- a/library.mak
+++ b/library.mak
@@ -19,6 +19,7 @@ $(SUBDIR)x86/%.o: $(SUBDIR)x86/%.asm
$(DEPYASM) $(YASMFLAGS) -I $( $(@:.o=.d)
$(YASM) $(YASMFLAGS) -I $(

This should use +=


Ok, will change.

// Martin___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/2] Add support for building shared libraries with MSVC

2012-10-13 Thread Måns Rullgård
Martin Storsjö  writes:

> diff --git a/configure b/configure
> index 667089b..362f8d1 100755
> --- a/configure
> +++ b/configure
> @@ -2794,6 +2794,29 @@ case $target_os in
>  add_cppflags -U__STRICT_ANSI__
>  ;;
>  msvc)
> +if enabled shared; then
> +# Link to the import library instead of the
> +# normal static library.
> +LD_LIB='%.lib'
> +enabled static &&
> +die "Cannot build shared and static libraries at the same 
> time with MSVC."
> +fi

The static+shared error feels misplaced here.

> +LIBTARGET=i386
> +if enabled x86_64; then
> +LIBTARGET=x64
> +fi

enabled x86_64 && LIBTARGET=i386 || LIBTARGET=x64

> +shlibdir_default="$bindir_default"
> +SLIBPREF=""
> +SLIBSUF=".dll"
> +
> SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
> +SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
> +SLIB_CREATE_DEF_CMD='makedef $(SUBDIR)lib$(NAME).ver $(OBJS) > 
> $$(@:$(SLIBSUF)=.def)'

Is makedef a friend of c99wrap?

> +SLIB_EXTRA_CMD='-lib.exe -machine:$(LIBTARGET) 
> -def:$$(@:$(SLIBSUF)=.def) -out:$(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib)'
> +SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
> +SLIB_INSTALL_LINKS=
> +SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'

Should the .lib file really end up in $bindir?  That doesn't feel right
at all.

> +SLIB_INSTALL_EXTRA_LIB='$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)'
> +SHFLAGS='-dll -def:$$(@:$(SLIBSUF)=.def) 
> -implib:$(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a)'

The mentino of .dll.a there is confusing.  Can you please tell me which
command produce/consume what files?  I have the distinct feeling all
this can be cleaned up considerably.

> +extern AVCODEC_SYMBOL const uint16_t avpriv_ac3_channel_layout_tab[8];

If this annotation is really required, please do two things:

1. Call it something at least halfway descriptive.
2. Make it less of an eyesore (i.e. not uppercase).

> diff --git a/libavcodec/symbols.h b/libavcodec/symbols.h
> new file mode 100644
> index 000..3c98d46
> --- /dev/null
> +++ b/libavcodec/symbols.h

As nondescriptive filenames go, this one ranks pretty darn high.

[...]

> +#if CONFIG_SHARED && defined(_MSC_VER) && !defined(COMPILING_avcodec)

This condition seems a bit too specific.  There are other compilers.

> +#define AVCODEC_SYMBOL __declspec(dllimport)
> +#else
> +#define AVCODEC_SYMBOL
> +#endif
> +
> +#endif /* AVCODEC_SYMBOLS_H */
> diff --git a/library.mak b/library.mak
> index b365935..318fe86 100644
> --- a/library.mak
> +++ b/library.mak
> @@ -19,6 +19,7 @@ $(SUBDIR)x86/%.o: $(SUBDIR)x86/%.asm
>   $(DEPYASM) $(YASMFLAGS) -I $( $(@:.o=.d)
>   $(YASM) $(YASMFLAGS) -I $(
> +$(OBJS): CPPFLAGS := -DCOMPILING_$(NAME)=1 $(CPPFLAGS)

This should use +=

>  $(OBJS) $(SUBDIR)%.h.o $(TESTOBJS): CPPFLAGS += -DHAVE_AV_CONFIG_H
>  $(TESTOBJS): CPPFLAGS += -DTEST

-- 
Måns Rullgård
m...@mansr.com
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/2] Add support for building shared libraries with MSVC

2012-10-13 Thread Diego Biurrun
On Sat, Oct 13, 2012 at 08:23:26PM +0300, Martin Storsjö wrote:
> From: "Ronald S. Bultje" 
> 
> This requires the makedef perl script by Derek, which probably will
> go into the c99-to-c89 repo. That scripts produces a .def file,
> listing the symbols to be exported, based on the gcc version
> scripts and the built object files.

This part of the commit message reads a bit ad-hoc.  It describes the
status of the development process at some point in time, but it does
not really explain the commit itself.

Not that this information would not be helpful, but it should instead
be part of a documentation update that describes building shared libs
with MSVC.

> The __declspec(dllimport) attribute is added via a macro. Since
> it has to be present when building code that refer to these symbols,

referS

> but not be present while building the library that exports the symbols
> themselves, the makefile is modified to add a define like

Makefile

> Also, linking to DLLs is slightly different from linking to shared
> libraries on other platforms. DLLs use a thing called import
> libraries, which is basically a stub library allowing the linker
> know which symbols exist in the DLL and what name the DLL will
> have at runtime.

to know

> In mingw/gcc, the import library is usually named libfoo.dll.a,
> which goes next to a static library named libfoo.a. This allows gcc
> to pick the dynamic one, if available, from the normal -lfoo switches,
> just as it does for libfoo.a vs libfoo.so on unix. On MSVC however,

Unix

> --- a/configure
> +++ b/configure
> @@ -2794,6 +2794,29 @@ case $target_os in
>  add_cppflags -U__STRICT_ANSI__
>  ;;
>  msvc)
> +if enabled shared; then
> +# Link to the import library instead of the
> +# normal static library.

Merge those two lines, they are not too long.

> +LD_LIB='%.lib'
> +enabled static &&
> +die "Cannot build shared and static libraries at the same 
> time with MSVC."
> +fi
> +LIBTARGET=i386
> +if enabled x86_64; then
> +LIBTARGET=x64
> +fi

enabled x86_64 &&

In general this does LGTM, but wait for more voices; it sure made enormous
progress since the initial version...

Diego
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel