Skip to content

Commit 5657278

Browse files
jamrialmichaelni
authored andcommitted
Add Windows resource file support for shared libraries
Originally written by James Almer <[email protected]> With the following contributions by Timothy Gu <[email protected]> * Use descriptions of libraries from the pkg-config file generation function * Use "FFmpeg Project" as CompanyName (suggested by Alexander Strasser) * Use "FFmpeg" for ProductName as MSDN says "name of the product with which the file is distributed" [1]. * Use FFmpeg's version (N-xxxxx-gxxxxxxx) for ProductVersion per MSDN [1]. * Only build the .rc files when --enable-small is not enabled. [1] http://msdn.microsoft.com/en-us/library/windows/desktop/aa381058.aspx Signed-off-by: James Almer <[email protected]> Signed-off-by: Michael Niedermayer <[email protected]>
1 parent af7562a commit 5657278

File tree

23 files changed

+543
-5
lines changed

23 files changed

+543
-5
lines changed

Changelog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ version <next>
1111
- support for decoding through VDPAU in ffmpeg (the -hwaccel option)
1212
- complete Voxware MetaSound decoder
1313
- remove mp3_header_compress bitstream filters
14+
- Windows resource files for shared libraries
1415

1516

1617
version 2.1:

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ vpath %.cpp $(SRC_PATH)
66
vpath %.h $(SRC_PATH)
77
vpath %.S $(SRC_PATH)
88
vpath %.asm $(SRC_PATH)
9+
vpath %.rc $(SRC_PATH)
910
vpath %.v $(SRC_PATH)
1011
vpath %.texi $(SRC_PATH)
1112
vpath %/fate_config.sh.template $(SRC_PATH)
@@ -72,7 +73,7 @@ SUBDIR_VARS := CLEANFILES EXAMPLES FFLIBS HOSTPROGS TESTPROGS TOOLS \
7273
ALTIVEC-OBJS VIS-OBJS \
7374
MMX-OBJS YASM-OBJS \
7475
MIPSFPU-OBJS MIPSDSPR2-OBJS MIPSDSPR1-OBJS MIPS32R2-OBJS \
75-
OBJS HOSTOBJS TESTOBJS
76+
OBJS SLIBOBJS HOSTOBJS TESTOBJS
7677

7778
define RESET
7879
$(1) :=

common.mak

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ifndef SUBDIR
1010
ifndef V
1111
Q = @
1212
ECHO = printf "$(1)\t%s\n" $(2)
13-
BRIEF = CC CXX HOSTCC HOSTLD AS YASM AR LD STRIP CP
13+
BRIEF = CC CXX HOSTCC HOSTLD AS YASM AR LD STRIP CP WINDRES
1414
SILENT = DEPCC DEPHOSTCC DEPAS DEPYASM RANLIB RM
1515

1616
MSG = $@
@@ -60,6 +60,9 @@ COMPILE_HOSTC = $(call COMPILE,HOSTCC)
6060
%_host.o: %.c
6161
$(COMPILE_HOSTC)
6262

63+
%.o: %.rc
64+
$(WINDRES) $(IFLAGS) -o $@ $<
65+
6366
%.i: %.c
6467
$(CC) $(CCFLAGS) $(CC_E) $<
6568

@@ -86,6 +89,7 @@ endif
8689
include $(SRC_PATH)/arch.mak
8790

8891
OBJS += $(OBJS-yes)
92+
SLIBOBJS += $(SLIBOBJS-yes)
8993
FFLIBS := $(FFLIBS-yes) $(FFLIBS)
9094
TESTPROGS += $(TESTPROGS-yes)
9195

@@ -94,6 +98,7 @@ FFEXTRALIBS := $(LDLIBS:%=$(LD_LIB)) $(EXTRALIBS)
9498

9599
EXAMPLES := $(EXAMPLES:%=$(SUBDIR)%-example$(EXESUF))
96100
OBJS := $(sort $(OBJS:%=$(SUBDIR)%))
101+
SLIBOBJS := $(sort $(SLIBOBJS:%=$(SUBDIR)%))
97102
TESTOBJS := $(TESTOBJS:%=$(SUBDIR)%) $(TESTPROGS:%=$(SUBDIR)%-test.o)
98103
TESTPROGS := $(TESTPROGS:%=$(SUBDIR)%-test$(EXESUF))
99104
HOSTOBJS := $(HOSTPROGS:%=$(SUBDIR)%.o)
@@ -125,10 +130,11 @@ $(HOSTPROGS): %$(HOSTEXESUF): %.o
125130
$(OBJS): | $(sort $(dir $(OBJS)))
126131
$(HOBJS): | $(sort $(dir $(HOBJS)))
127132
$(HOSTOBJS): | $(sort $(dir $(HOSTOBJS)))
133+
$(SLIBOBJS): | $(sort $(dir $(SLIBOBJS)))
128134
$(TESTOBJS): | $(sort $(dir $(TESTOBJS)))
129135
$(TOOLOBJS): | tools
130136

131-
OBJDIRS := $(OBJDIRS) $(dir $(OBJS) $(HOBJS) $(HOSTOBJS) $(TESTOBJS))
137+
OBJDIRS := $(OBJDIRS) $(dir $(OBJS) $(HOBJS) $(HOSTOBJS) $(SLIBOBJS) $(TESTOBJS))
132138

133139
CLEANSUFFIXES = *.d *.o *~ *.h.c *.map *.ver *.ho *.gcno *.gcda
134140
DISTCLEANSUFFIXES = *.pc

configure

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ Advanced options (experts only):
267267
--nm=NM use nm tool NM [$nm_default]
268268
--ar=AR use archive tool AR [$ar_default]
269269
--as=AS use assembler AS [$as_default]
270+
--windres=WINDRES use windows resource compiler WINDRES [$windres_default]
270271
--yasmexe=EXE use yasm-compatible assembler EXE [$yasmexe_default]
271272
--cc=CC use C compiler CC [$cc_default]
272273
--cxx=CXX use C compiler CXX [$cxx_default]
@@ -1509,6 +1510,7 @@ HAVE_LIST="
15091510
gettimeofday
15101511
glob
15111512
gnu_as
1513+
gnu_windres
15121514
gsm_h
15131515
ibm_asm
15141516
inet_aton
@@ -2367,6 +2369,7 @@ pkg_config_default=pkg-config
23672369
ranlib="ranlib"
23682370
strip_default="strip"
23692371
yasmexe_default="yasm"
2372+
windres_default="windres"
23702373

23712374
nogas=":"
23722375

@@ -2637,6 +2640,7 @@ nm_default="${cross_prefix}${nm_default}"
26372640
pkg_config_default="${cross_prefix}${pkg_config_default}"
26382641
ranlib="${cross_prefix}${ranlib}"
26392642
strip_default="${cross_prefix}${strip_default}"
2643+
windres_default="${cross_prefix}${windres_default}"
26402644

26412645
sysinclude_default="${sysroot}/usr/include"
26422646

@@ -3155,7 +3159,7 @@ test -n "$cc_type" && enable $cc_type ||
31553159
: ${dep_cc_default:=$cc}
31563160
: ${ld_default:=$cc}
31573161
: ${host_ld_default:=$host_cc}
3158-
set_default ar as dep_cc ld host_ld
3162+
set_default ar as dep_cc ld host_ld windres
31593163

31603164
probe_cc as "$as"
31613165
asflags_filter=$_flags_filter
@@ -3637,6 +3641,7 @@ case $target_os in
36373641
elif enabled arm; then
36383642
LIBTARGET=arm-wince
36393643
fi
3644+
enabled shared && ! enabled small && check_cmd $windres --version && enable gnu_windres
36403645
check_ldflags -Wl,--nxcompat
36413646
check_ldflags -Wl,--dynamicbase
36423647
shlibdir_default="$bindir_default"
@@ -3699,6 +3704,7 @@ case $target_os in
36993704
SHFLAGS='-shared -Wl,--out-implib,$(SUBDIR)lib$(FULLNAME).dll.a'
37003705
objformat="win32"
37013706
enable dos_paths
3707+
enabled shared && ! enabled small && check_cmd $windres --version && enable gnu_windres
37023708
;;
37033709
*-dos|freedos|opendos)
37043710
network_extralibs="-lsocket"
@@ -4882,6 +4888,7 @@ LD_O=$LD_O
48824888
LD_LIB=$LD_LIB
48834889
LD_PATH=$LD_PATH
48844890
DLLTOOL=$dlltool
4891+
WINDRES=$windres
48854892
LDFLAGS=$LDFLAGS
48864893
SHFLAGS=$(echo $($ldflags_filter $SHFLAGS))
48874894
ASMSTRIPFLAGS=$ASMSTRIPFLAGS
@@ -4969,6 +4976,7 @@ cat > $TMPH <<EOF
49694976
#define av_restrict $_restrict
49704977
#define EXTERN_PREFIX "${extern_prefix}"
49714978
#define EXTERN_ASM ${extern_prefix}
4979+
#define BUILDSUF "$build_suffix"
49724980
#define SLIBSUF "$SLIBSUF"
49734981
#define HAVE_MMX2 HAVE_MMXEXT
49744982
EOF

libavcodec/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,9 @@ OBJS-$(HAVE_OS2THREADS) += pthread.o pthread_slice.o pthread_fram
814814

815815
OBJS-$(CONFIG_FRAME_THREAD_ENCODER) += frame_thread_encoder.o
816816

817+
# Windows resource file
818+
SLIBOBJS-$(HAVE_GNU_WINDRES) += avcodecres.o
819+
817820
SKIPHEADERS += %_tablegen.h \
818821
%_tables.h \
819822
aac_tablegen_decl.h \

libavcodec/avcodecres.rc

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Windows resource file for libavcodec
3+
*
4+
* Copyright (C) 2012 James Almer
5+
* Copyright (C) 2013 Tiancheng "Timothy" Gu
6+
*
7+
* This file is part of FFmpeg.
8+
*
9+
* FFmpeg is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation; either
12+
* version 2.1 of the License, or (at your option) any later version.
13+
*
14+
* FFmpeg is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with FFmpeg; if not, write to the Free Software
21+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22+
*/
23+
24+
#include <windows.h>
25+
#include "libavcodec/version.h"
26+
#include "libavutil/ffversion.h"
27+
#include "config.h"
28+
29+
1 VERSIONINFO
30+
FILEVERSION LIBAVCODEC_VERSION_MAJOR, LIBAVCODEC_VERSION_MINOR, LIBAVCODEC_VERSION_MICRO, 0
31+
PRODUCTVERSION LIBAVCODEC_VERSION_MAJOR, LIBAVCODEC_VERSION_MINOR, LIBAVCODEC_VERSION_MICRO, 0
32+
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
33+
FILEOS VOS_NT_WINDOWS32
34+
FILETYPE VFT_DLL
35+
{
36+
BLOCK "StringFileInfo"
37+
{
38+
BLOCK "040904B0"
39+
{
40+
VALUE "CompanyName", "FFmpeg Project"
41+
VALUE "FileDescription", "FFmpeg codec library"
42+
VALUE "FileVersion", AV_STRINGIFY(LIBAVCODEC_VERSION)
43+
VALUE "InternalName", "libavcodec"
44+
VALUE "LegalCopyright", "Copyright (C) 2000-" AV_STRINGIFY(CONFIG_THIS_YEAR) " FFmpeg Project"
45+
VALUE "OriginalFilename", "avcodec" BUILDSUF "-" AV_STRINGIFY(LIBAVCODEC_VERSION_MAJOR) SLIBSUF
46+
VALUE "ProductName", "FFmpeg"
47+
VALUE "ProductVersion", FFMPEG_VERSION
48+
}
49+
}
50+
51+
BLOCK "VarFileInfo"
52+
{
53+
VALUE "Translation", 0x0409, 0x04B0
54+
}
55+
}

libavdevice/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ OBJS-$(CONFIG_XV_OUTDEV) += xv.o
5151
OBJS-$(CONFIG_LIBCDIO_INDEV) += libcdio.o
5252
OBJS-$(CONFIG_LIBDC1394_INDEV) += libdc1394.o
5353

54+
# Windows resource file
55+
SLIBOBJS-$(HAVE_GNU_WINDRES) += avdeviceres.o
56+
5457
SKIPHEADERS-$(CONFIG_DSHOW_INDEV) += dshow_capture.h
5558
SKIPHEADERS-$(CONFIG_LIBPULSE) += pulse_audio_common.h
5659
SKIPHEADERS-$(CONFIG_V4L2_INDEV) += v4l2-common.h

libavdevice/avdeviceres.rc

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Windows resource file for libavdevice
3+
*
4+
* Copyright (C) 2012 James Almer
5+
* Copyright (C) 2013 Tiancheng "Timothy" Gu
6+
*
7+
* This file is part of FFmpeg.
8+
*
9+
* FFmpeg is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation; either
12+
* version 2.1 of the License, or (at your option) any later version.
13+
*
14+
* FFmpeg is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with FFmpeg; if not, write to the Free Software
21+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22+
*/
23+
24+
#include <windows.h>
25+
#include "libavdevice/version.h"
26+
#include "libavutil/ffversion.h"
27+
#include "config.h"
28+
29+
1 VERSIONINFO
30+
FILEVERSION LIBAVDEVICE_VERSION_MAJOR, LIBAVDEVICE_VERSION_MINOR, LIBAVDEVICE_VERSION_MICRO, 0
31+
PRODUCTVERSION LIBAVDEVICE_VERSION_MAJOR, LIBAVDEVICE_VERSION_MINOR, LIBAVDEVICE_VERSION_MICRO, 0
32+
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
33+
FILEOS VOS_NT_WINDOWS32
34+
FILETYPE VFT_DLL
35+
{
36+
BLOCK "StringFileInfo"
37+
{
38+
BLOCK "040904B0"
39+
{
40+
VALUE "CompanyName", "FFmpeg Project"
41+
VALUE "FileDescription", "FFmpeg device handling library"
42+
VALUE "FileVersion", AV_STRINGIFY(LIBAVDEVICE_VERSION)
43+
VALUE "InternalName", "libavdevice"
44+
VALUE "LegalCopyright", "Copyright (C) 2000-" AV_STRINGIFY(CONFIG_THIS_YEAR) " FFmpeg Project"
45+
VALUE "OriginalFilename", "avdevice" BUILDSUF "-" AV_STRINGIFY(LIBAVDEVICE_VERSION_MAJOR) SLIBSUF
46+
VALUE "ProductName", "FFmpeg"
47+
VALUE "ProductVersion", FFMPEG_VERSION
48+
}
49+
}
50+
51+
BLOCK "VarFileInfo"
52+
{
53+
VALUE "Translation", 0x0409, 0x04B0
54+
}
55+
}

libavfilter/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,9 @@ OBJS-$(CONFIG_SHOWWAVES_FILTER) += avf_showwaves.o
247247
OBJS-$(CONFIG_AMOVIE_FILTER) += src_movie.o
248248
OBJS-$(CONFIG_MOVIE_FILTER) += src_movie.o
249249

250+
# Windows resource file
251+
SLIBOBJS-$(HAVE_GNU_WINDRES) += avfilterres.o
252+
250253
SKIPHEADERS-$(CONFIG_LIBVIDSTAB) += vidstabutils.h
251254
SKIPHEADERS-$(CONFIG_OPENCL) += opencl_internal.h deshake_opencl_kernel.h unsharp_opencl_kernel.h
252255

libavfilter/avfilterres.rc

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Windows resource file for libavfilter
3+
*
4+
* Copyright (C) 2012 James Almer
5+
* Copyright (C) 2013 Tiancheng "Timothy" Gu
6+
*
7+
* This file is part of FFmpeg.
8+
*
9+
* FFmpeg is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation; either
12+
* version 2.1 of the License, or (at your option) any later version.
13+
*
14+
* FFmpeg is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with FFmpeg; if not, write to the Free Software
21+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22+
*/
23+
24+
#include <windows.h>
25+
#include "libavfilter/version.h"
26+
#include "libavutil/ffversion.h"
27+
#include "config.h"
28+
29+
1 VERSIONINFO
30+
FILEVERSION LIBAVFILTER_VERSION_MAJOR, LIBAVFILTER_VERSION_MINOR, LIBAVFILTER_VERSION_MICRO, 0
31+
PRODUCTVERSION LIBAVFILTER_VERSION_MAJOR, LIBAVFILTER_VERSION_MINOR, LIBAVFILTER_VERSION_MICRO, 0
32+
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
33+
FILEOS VOS_NT_WINDOWS32
34+
FILETYPE VFT_DLL
35+
{
36+
BLOCK "StringFileInfo"
37+
{
38+
BLOCK "040904B0"
39+
{
40+
VALUE "CompanyName", "FFmpeg Project"
41+
VALUE "FileDescription", "FFmpeg audio/video filtering library"
42+
VALUE "FileVersion", AV_STRINGIFY(LIBAVFILTER_VERSION)
43+
VALUE "InternalName", "libavfilter"
44+
VALUE "LegalCopyright", "Copyright (C) 2000-" AV_STRINGIFY(CONFIG_THIS_YEAR) " FFmpeg Project"
45+
VALUE "OriginalFilename", "avfilter" BUILDSUF "-" AV_STRINGIFY(LIBAVFILTER_VERSION_MAJOR) SLIBSUF
46+
VALUE "ProductName", "FFmpeg"
47+
VALUE "ProductVersion", FFMPEG_VERSION
48+
}
49+
}
50+
51+
BLOCK "VarFileInfo"
52+
{
53+
VALUE "Translation", 0x0409, 0x04B0
54+
}
55+
}

libavformat/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,9 @@ OBJS-$(CONFIG_TLS_PROTOCOL) += tls.o
467467
OBJS-$(CONFIG_UDP_PROTOCOL) += udp.o
468468
OBJS-$(CONFIG_UNIX_PROTOCOL) += unix.o
469469

470+
# Windows resource file
471+
SLIBOBJS-$(HAVE_GNU_WINDRES) += avformatres.o
472+
470473
SKIPHEADERS-$(CONFIG_FFRTMPCRYPT_PROTOCOL) += rtmpdh.h
471474
SKIPHEADERS-$(CONFIG_NETWORK) += network.h rtsp.h
472475
TESTPROGS = seek \

0 commit comments

Comments
 (0)