[FFmpeg-devel] [PATCH] Proper support for building MSVC import libraries
Måns Rullgård
mans
Fri Jul 20 00:18:58 CEST 2007
Ramiro Polla <ramiro at lisha.ufsc.br> writes:
> Hello,
>
> Currently, MSVC import libraries are created for dlls if the lib
> program exists on MinGW's PATH (with the wrong name, since BUILDSUF is
> not respected).
> IMO, Makefile commands don't belong in configure (such as
> SLIB_INSTALL_EXTRA_CMD).
>
> Attached patch adds an option to configure and puts Makefile commands
> in common.mak.
>
> Ramiro Polla
> Index: configure
> ===================================================================
> --- configure (revision 9765)
> +++ configure (working copy)
> @@ -65,6 +65,7 @@
> echo " --enable-static build static libraries [default=yes]"
> echo " --disable-static do not build static libraries [default=no]"
> echo " --enable-shared build shared libraries [default=no]"
> + echo " --enable-msvc-implib build MSVC import libs for dlls [default=no]"
Why this option?
> @@ -1157,9 +1159,10 @@
> EXESUF=".exe"
> SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
> SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME)-$(LIBMAJOR)$(SLIBSUF)'
> - SLIB_EXTRA_CMD="-lib /machine:i386 /def:\$(@:${SLIBSUF}=.def)"
> - SLIB_INSTALL_EXTRA_CMD="-install -m 644 \$(SLIBNAME_WITH_MAJOR:\$(SLIBSUF)=.lib) \"\$(shlibdir)/\$(SLIBNAME_WITH_MAJOR:\$(SLIBSUF)=.lib)\""
> - SHFLAGS="-shared -Wl,--output-def,\$(@:${SLIBSUF}=.def),--out-implib,lib\$(SLIBNAME:\$(SLIBSUF)=.dll.a) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base"
> + MSVC_IMPLIB='$(SLIBNAME_WITH_MAJOR:.dll=.lib)'
> + enabled msvc_implib &&
> + MSVC_IMPLIB_SHFLAGS='-Wl,--output-def,$(MSVC_IMPLIB:.lib=.def)'
> + SHFLAGS='-shared $(MSVC_IMPLIB_SHFLAGS) -Wl,--out-implib,lib$(SLIBNAME:$(SLIBSUF)=.dll.a) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base'
Is this really correct? That unconditional --out-imlib option looks a
little fishy to my untrained eye.
BTW, am I the only one who thinks that chunk is really ugly to look at?
> enabled network && add_extralibs -lws2_32
> ;;
> cygwin*)
> @@ -1930,8 +1933,10 @@
> echo "SLIBNAME=${SLIBNAME}" >> config.mak
> echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
> echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
> - echo "SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}" >> config.mak
> - echo "SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}" >> config.mak
> + enabled msvc_implib &&
> + echo "BUILD_MSVC_IMPLIB=yes" >> config.mak
Settings like this one should be done the generic way.
> + echo "MSVC_IMPLIB=${MSVC_IMPLIB}" >> config.mak
> + echo "MSVC_IMPLIB_SHFLAGS=${MSVC_IMPLIB_SHFLAGS}" >> config.mak
> fi
> echo "LIB_INSTALL_EXTRA_CMD=${LIB_INSTALL_EXTRA_CMD}" >> config.mak
> echo "EXTRALIBS=$extralibs" >> config.mak
> Index: common.mak
> ===================================================================
> --- common.mak (revision 9765)
> +++ common.mak (working copy)
> @@ -19,7 +19,7 @@
> STATIC_OBJS := $(OBJS) $(STATIC_OBJS)
> SHARED_OBJS := $(OBJS) $(SHARED_OBJS)
>
> -all: $(EXTRADEPS) $(LIB) $(SLIBNAME)
> +all: $(EXTRADEPS) $(LIB) $(SLIBNAME) $(MSVC_IMPLIB)
>
> $(LIB): $(STATIC_OBJS)
> rm -f $@
> @@ -31,8 +31,10 @@
>
> $(SLIBNAME_WITH_MAJOR): $(SHARED_OBJS)
> $(CC) $(SHFLAGS) $(LDFLAGS) -o $@ $^ $(EXTRALIBS) $(EXTRAOBJS)
> - $(SLIB_EXTRA_CMD)
>
> +$(MSVC_IMPLIB): $(SLIBNAME_WITH_MAJOR)
> + lib /machine:i386 /def:$(@:.lib=.def)
> +
> %.o: %.c
> $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
>
> @@ -64,6 +66,9 @@
> ifeq ($(BUILD_STATIC),yes)
> INSTLIBTARGETS += install-lib-static
> endif
> +ifeq ($(BUILD_MSVC_IMPLIB),yes)
> +INSTLIBTARGETS += install-lib-msvc-implib
> +endif
>
> install: install-libs install-headers
>
> @@ -77,13 +82,15 @@
> ln -sf $(SLIBNAME_WITH_VERSION) $(SLIBNAME_WITH_MAJOR)
> cd "$(shlibdir)" && \
> ln -sf $(SLIBNAME_WITH_VERSION) $(SLIBNAME)
> - $(SLIB_INSTALL_EXTRA_CMD)
>
> install-lib-static: $(LIB)
> install -d "$(libdir)"
> install -m 644 $(LIB) "$(libdir)"
> - $(LIB_INSTALL_EXTRA_CMD)
>
> +install-lib-msvc-implib: $(MSVC_IMPLIB)
> + install -d "$(libdir)"
> + install -m 644 $(MSVC_IMPLIB) "$(libdir)"
install-lib-static: $(LIB) $(MSVC_IMPLIB)
...
Or some variation thereof. I don't recall the exact semantics of
these targets.
--
M?ns Rullg?rd
mans at mansr.com
More information about the ffmpeg-devel
mailing list