[FFmpeg-devel] Adding .rc files for win32

Ramiro Polla ramiro
Thu May 15 22:00:14 CEST 2008


Hello,

>>>>> I want to add a .rc file for the av* dlls on windows.  This would 
>>>>> allow the embedding of versioning information in the dll that 
>>>>> windows explorer can read (think right clicking on the dll and 
>>>>> choosing version, you get legal notices, credits, version numbers 
>>>>> etc).
[...]
>>>> Great. I tried that a long time ago [0]. It should be easier now 
>>>> with non-recursive Makefile. That patch has to be updated to current 
>>>> FFmpeg SVN, and split out in a few patches (like setting the license 
>>>> variable is a separate thing).
[...]
>> The patch helps imensely.  I think I have it mostly working except for 
>> the dependency on version.h.  Wherever I put $(SLIB_EXTRA_DEP) it 
>> can't find the rule to make 'version.h'.  Where's the correct place to 
>> put it?
[...]
> Here's my version so far.  It's based mostly on the patch that you 
> linked me to.  It doesn't work yet as I'm not sure where SLIB_EXTRA_DEP 
> and SLIB_EXTRA_OBJS goes in the makefiles.

> Index: configure
> ===================================================================
> --- configure	(revision 13158)
> +++ configure	(working copy)
> @@ -919,6 +919,9 @@
>  # libraries
>  enable zlib
>  
> +# dll information
> +dllinfo="no"
> +

You don't need to initialize values to "no". Just remove this.

>  # configurable options
>  enable debug
>  enable ffmpeg
> @@ -1076,6 +1079,7 @@
>  TMPE="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}${EXESUF}"
>  TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
>  TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
> +TMPRC="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.rc"
>  TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
>  TMPSH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.sh"
>  
> @@ -1228,12 +1232,17 @@
>              VHOOKLIBS="$VHOOKLIBS -lswscale\$(BUILDSUF)"
>          fi
>          disable ffserver
> +        if enabled shared; then
> +            dllinfo="yes"
> +        fi

You can use a simpler construct like:
enabled shared && enable dllinfo
Or maybe even use the dependency checked.

>          SLIBPREF=""
>          SLIBSUF=".dll"
>          EXESUF=".exe"
>          SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
>          SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
>          SLIB_EXTRA_CMD='-lib /machine:$(LIBTARGET) /def:$$(@:$(SLIBSUF)=.def) /out:$(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)'
> +        SLIB_EXTRA_OBJS="dllinfo.rco"
> +        SLIB_EXTRA_DEP="version.h"
>          SLIB_INSTALL_EXTRA_CMD='-install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"; \
>              install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)"'
>          SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
> @@ -1973,12 +1982,15 @@
>      echo
>  done
>  
> -enabled nonfree &&
> -    echo "License: unredistributable" ||
> -    (enabled gpl &&
> -        echo "License: GPL" ||
> -        echo "License: LGPL")
> +license="LGPL"
> +if enabled nonfree; then
> +    license="unredistributable"
> +elif enabled gpl; then
> +    license="GPL"
> +fi
>  
> +echo "License: $license"
> +

This is what I was telling you that has to be split. The patches must be 
minimal, so you'd have to send at least 2. One for this license variable 
change and another for the dllinfo.rc stuff.

>  echo "Creating config.mak and config.h..."
>  
>  echo "# Automatically generated by configure - do not modify!" > config.mak
> @@ -2061,6 +2073,8 @@
>      echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
>      echo "SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}" >> config.mak
>      echo "SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}" >> config.mak
> +    echo "SLIB_EXTRA_OBJS=${SLIB_EXTRA_OBJS}" >> config.mak
> +    echo "SLIB_EXTRA_DEP=${SLIB_EXTRA_DEP}" >> config.mak
>      echo "SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}" >> config.mak
>      echo "SLIB_UNINSTALL_EXTRA_CMD=${SLIB_UNINSTALL_EXTRA_CMD}" >> config.mak
>  fi
> @@ -2207,3 +2221,67 @@
>      pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "$pkg_requires libavcodec = $LIBAVCODEC_VERSION"
>      apply libswscale.pc sed s/^Libs:.*$/Libs:/
>  fi
> +
> +# build dll configuration for windows.
> +
> +if test "$dllinfo" = "yes"; then
> +
> +    dllinfo_generate() {
> +        name=$1
> +        description=$2
> +        version=$3
> +        major=${version%%.*}
> +        version_commas=`echo $version | sed s/\\\\./,/g`,0

Read Mans' reply in that thread. Use tr instead of this sed command. (Or 
  can sh do this change somehow?)

> +        dllname=`echo $name | sed s/lib//`
> +
> +        cat <<EOF >$TMPRC
> +#include <WinVer.h>
> +#include "version.h"
> +VS_VERSION_INFO VERSIONINFO
> + FILEVERSION $version_commas
> + PRODUCTVERSION $version_commas
> + FILEFLAGSMASK 0x17L
> + FILEFLAGS 0x0L
> + FILEOS VOS__WINDOWS32
> + FILETYPE VFT_DLL
> + FILESUBTYPE 0x0L
> +BEGIN
> +    BLOCK "StringFileInfo"
> +    BEGIN
> +        BLOCK "040904b0"
> +        BEGIN
> +            VALUE "Comments",            "FFmpeg is distributed under the terms "
> +                                         "of the GNU $license.\r\n"
> +                                         "Source code is available at "
> +                                         "http://ffmpeg.mplayerhq.hu"
> +            VALUE "CompanyName",         "FFmpeg"
> +            VALUE "FileDescription",     "$description"
> +            VALUE "FileVersion",         "$version"
> +            VALUE "InternalName",        "$name"
> +            VALUE "LegalCopyright",      "(C) 2000-2006 Fabrice Bellard, et al."

All this information could be rewritten. But I'm sure Diego will reply 
with the proper text.

> +            VALUE "LegalTrademarks",     "FFmpeg"
> +            VALUE "OriginalFilename",    "$dllname-$major.dll"
> +            VALUE "ProductName",         "$name"
> +            VALUE "ProductVersion",      FFMPEG_VERSION
> +        END
> +    END
> +    BLOCK "VarFileInfo"
> +    BEGIN
> +        VALUE "Translation", 0x409, 1200
> +    END
> +END
> +EOF
> +        if ! cmp -s $TMPRC $name/dllinfo.rc; then
> +            mv -f $TMPRC $name/dllinfo.rc
> +        fi
> +        rm -f $TMPRC
> +    }
> +
> +    dllinfo_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION"
> +    dllinfo_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION"
> +    dllinfo_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION"
> +    dllinfo_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION"
> +    dllinfo_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION"
> +    dllinfo_generate libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION"
> +    dllinfo_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION"
> +fi
> \ No newline at end of file
> Index: subdir.mak
> ===================================================================
> --- subdir.mak	(revision 13158)
> +++ subdir.mak	(working copy)
> @@ -27,7 +27,7 @@
>  $(SUBDIR)$(SLIBNAME): $(SUBDIR)$(SLIBNAME_WITH_MAJOR)
>  	cd ./$(SUBDIR) && $(LN_S) $(SLIBNAME_WITH_MAJOR) $(SLIBNAME)
>  
> -$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS)
> +$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS) $(SLIB_EXTRA_DEP) $(SLIB_EXTRA_OBJS)

I think what will have to be done is add only $(SLIB_EXTRA_OBJS) here, 
and make a rule for $(SLIB_EXTRA_OBJS) that depends on 
$(SLIB_EXTRA_DEP). I'm still confused with the new build system, so I'll 
leave it to you to figure out.

Ramiro Polla




More information about the ffmpeg-devel mailing list