support for building dynamic libraries on Mac OS X

based on a patch by Lina Pezzella <J4rg0n -- at -- gentoo -- dot -- org>

Originally committed as revision 4616 to svn://svn.ffmpeg.org/ffmpeg/trunk
pull/126/head
Diego Biurrun 20 years ago
parent 399d84012f
commit 4e159595b5
  1. 7
      configure
  2. 21
      libavcodec/Makefile
  3. 32
      libavcodec/libpostproc/Makefile
  4. 20
      libavformat/Makefile
  5. 19
      libavutil/Makefile
  6. 22
      vhook/Makefile

7
configure vendored

@ -329,11 +329,12 @@ v4l="no"
audio_oss="no" audio_oss="no"
dv1394="no" dv1394="no"
ffserver="no" ffserver="no"
SHFLAGS="-dynamiclib" SHFLAGS="-dynamiclib -Wl,-single_module,-undefined,dynamic_lookup"
extralibs="" extralibs=""
darwin="yes" darwin="yes"
strip="strip -x" strip="strip -x"
LDFLAGS="-Wl,-search_paths_first" LDFLAGS="-Wl,-dynamic,-search_paths_first"
SLIBSUF=".dylib"
FFSLDFLAGS=-Wl,-bind_at_load FFSLDFLAGS=-Wl,-bind_at_load
;; ;;
MINGW32*) MINGW32*)
@ -1428,6 +1429,8 @@ fi
if test "$lshared" = "yes" ; then if test "$lshared" = "yes" ; then
echo "BUILD_SHARED=yes" >> config.mak echo "BUILD_SHARED=yes" >> config.mak
echo "PIC=-fPIC -DPIC" >> config.mak echo "PIC=-fPIC -DPIC" >> config.mak
echo "SPPMAJOR=0" >> config.mak
echo "SPPVERSION=0.0.1" >> config.mak
fi fi
echo "EXTRALIBS=$extralibs" >> config.mak echo "EXTRALIBS=$extralibs" >> config.mak
version=`grep '#define FFMPEG_VERSION ' "$source_path/libavcodec/avcodec.h" | version=`grep '#define FFMPEG_VERSION ' "$source_path/libavcodec/avcodec.h" |

@ -377,17 +377,22 @@ ifeq ($(TARGET_ARCH_SPARC64),yes)
CFLAGS+= -mcpu=ultrasparc -mtune=ultrasparc CFLAGS+= -mcpu=ultrasparc -mtune=ultrasparc
endif endif
# Darwin specific stuff
ifeq ($(CONFIG_DARWIN),yes)
SHFLAGS += -Wl,-install_name,$(libdir)/$(SLIBPREF)avcodec$(SLIBSUF),-current_version,$(SPPVERSION),-compatibility_version,$(SPPVERSION)
endif
SRCS := $(OBJS:.o=.c) $(ASM_OBJS:.o=.S) SRCS := $(OBJS:.o=.c) $(ASM_OBJS:.o=.S)
OBJS := $(OBJS) $(ASM_OBJS) OBJS := $(OBJS) $(ASM_OBJS)
LIB= $(LIBPREF)avcodec$(LIBSUF) LIB= $(LIBPREF)avcodec$(LIBSUF)
LIBAVUTIL= $(SRC_PATH)/libavutil/$(LIBPREF)avutil$(LIBSUF) LIBAVUTIL= $(SRC_PATH)/libavutil/$(LIBPREF)avutil$(LIBSUF)
ifeq ($(BUILD_SHARED),yes) ifeq ($(BUILD_SHARED),yes)
SLIB= $(SLIBPREF)avcodec$(SLIBSUF) SLIBNAME= $(SLIBPREF)avcodec$(SLIBSUF)
endif endif
TESTS= imgresample-test dct-test motion-test fft-test TESTS= imgresample-test dct-test motion-test fft-test
all: $(LIB) $(SLIB) all: $(LIB) $(SLIBNAME)
amrlibs: amrlibs:
$(MAKE) -C amr spclib fipoplib $(MAKE) -C amr spclib fipoplib
@ -399,7 +404,7 @@ $(LIB): $(OBJS) $(AMRLIBS)
$(AR) rc $@ $(OBJS) $(AMREXTRALIBS) $(AR) rc $@ $(OBJS) $(AMREXTRALIBS)
$(RANLIB) $@ $(RANLIB) $@
$(SLIB): $(OBJS) $(SLIBNAME): $(OBJS)
ifeq ($(CONFIG_PP),yes) ifeq ($(CONFIG_PP),yes)
$(MAKE) -C libpostproc $(MAKE) -C libpostproc
endif endif
@ -407,7 +412,7 @@ ifeq ($(CONFIG_WIN32),yes)
$(CC) $(SHFLAGS) -Wl,--output-def,$(@:.dll=.def) -o $@ $(OBJS) $(EXTRALIBS) $(AMREXTRALIBS) $(CC) $(SHFLAGS) -Wl,--output-def,$(@:.dll=.def) -o $@ $(OBJS) $(EXTRALIBS) $(AMREXTRALIBS)
-lib /machine:i386 /def:$(@:.dll=.def) -lib /machine:i386 /def:$(@:.dll=.def)
else else
$(CC) $(SHFLAGS) -o $@ $(OBJS) $(EXTRALIBS) $(AMREXTRALIBS) $(LDFLAGS) $(CC) $(SHFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(EXTRALIBS) $(AMREXTRALIBS)
endif endif
dsputil.o: dsputil.c dsputil.h dsputil.o: dsputil.c dsputil.h
@ -427,7 +432,7 @@ depend: $(SRCS)
dep: depend dep: depend
clean: $(CLEANAMR) clean: $(CLEANAMR)
rm -f *.o *.d *~ .depend $(LIB) $(SLIB) *.so i386/*.o i386/*~ \ rm -f *.o *.d *~ .depend $(LIB) $(SLIBNAME) *$(SLIBSUF) i386/*.o i386/*~ \
armv4l/*.o armv4l/*~ \ armv4l/*.o armv4l/*~ \
mlib/*.o mlib/*~ \ mlib/*.o mlib/*~ \
alpha/*.o alpha/*~ \ alpha/*.o alpha/*~ \
@ -476,11 +481,11 @@ fft-test: fft-test.o $(LIB)
ifeq ($(BUILD_SHARED),yes) ifeq ($(BUILD_SHARED),yes)
install: all install-headers install: all install-headers
ifeq ($(CONFIG_WIN32),yes) ifeq ($(CONFIG_WIN32),yes)
install $(INSTALLSTRIP) -m 755 $(SLIB) "$(prefix)" install $(INSTALLSTRIP) -m 755 $(SLIBNAME) "$(prefix)"
else else
install -d $(libdir) install -d $(libdir)
install $(INSTALLSTRIP) -m 755 $(SLIB) $(libdir)/libavcodec-$(VERSION).so install $(INSTALLSTRIP) -m 755 $(SLIBNAME) $(libdir)/libavcodec-$(VERSION)$(SLIBSUF)
ln -sf libavcodec-$(VERSION).so $(libdir)/libavcodec.so ln -sf libavcodec-$(VERSION)$(SLIBSUF) $(libdir)/libavcodec$(SLIBSUF)
$(LDCONFIG) || true $(LDCONFIG) || true
endif endif
ifeq ($(CONFIG_PP),yes) ifeq ($(CONFIG_PP),yes)

@ -4,9 +4,16 @@ include ../../config.mak
VPATH=$(SRC_PATH)/libavcodec/libpostproc VPATH=$(SRC_PATH)/libavcodec/libpostproc
ifeq ($(SHARED_PP),yes) ifeq ($(SHARED_PP),yes)
SPPLIB = $(SLIBPREF)postproc$(SLIBSUF) SPPLIBNAME = $(SLIBPREF)postproc$(SLIBSUF)
SPPMAJOR = 0 ifeq ($(CONFIG_DARWIN),yes)
SPPVERSION = $(SPPMAJOR).0.1 SPPLIBMAJOR = $(SLIBPREF)postproc.$(SPPMAJOR)$(SLIBSUF)
SPPLIB = $(SLIBPREF)postproc.$(SPPVERSION)$(SLIBSUF)
SHFLAGS += -Wl,-install_name,$(libdir)/$(SPPLIBNAME),-current_version,$(SPPVERSION),-compatibility_version,$(SPPVERSION)
else
SPPLIBMAJOR = $(SPPLIBNAME).$(SPPMAJOR)
SPPLIB = $(SPPLIBNAME).$(SPPVERSION)
SHFLAGS = -shared -Wl,-soname,$(SPPLIB)
endif
endif endif
PPLIB = $(LIBPREF)postproc$(LIBSUF) PPLIB = $(LIBPREF)postproc$(LIBSUF)
@ -23,13 +30,13 @@ CFLAGS = $(OPTFLAGS) $(MLIB_INC) -I. -I.. $(EXTRA_INC)
.c.o: .c.o:
$(CC) -c $(CFLAGS) $(LIBOBJFLAGS) -I$(SRC_PATH)/libavcodec -I../.. -o $@ $< $(CC) -c $(CFLAGS) $(LIBOBJFLAGS) -I$(SRC_PATH)/libavcodec -I../.. -o $@ $<
all: $(SWSLIB) $(PPLIB) $(SPPLIB) all: $(SWSLIB) $(PPLIB) $(SPPLIBNAME)
clean: clean:
rm -f *.o *.a *~ *.so $(PPLIB) $(SPPLIB) rm -f *.o *.a *~ *$(SLIBSUF) $(PPLIB) $(SPPLIBNAME)
distclean: distclean:
rm -f Makefile.bak *.o *.a *~ *.so .depend rm -f Makefile.bak *.o *.a *~ *$(SLIBSUF) .depend
dep: depend dep: depend
@ -40,9 +47,8 @@ ifeq ($(SHARED_PP),yes)
postprocess_pic.o: postprocess.c postprocess_pic.o: postprocess.c
$(CC) -c $(CFLAGS) -fomit-frame-pointer -fPIC -DPIC -I.. -I../.. -o $@ $< $(CC) -c $(CFLAGS) -fomit-frame-pointer -fPIC -DPIC -I.. -I../.. -o $@ $<
$(SPPLIB): $(SPPOBJS) $(SPPLIBNAME): $(SPPOBJS)
$(CC) -shared -Wl,-soname,$(SPPLIB).$(SPPMAJOR) \ $(CC) $(SHFLAGS) -o $(SPPLIBNAME) $(SPPOBJS)
-o $(SPPLIB) $(SPPOBJS)
endif endif
$(PPLIB): $(PPOBJS) $(PPLIB): $(PPOBJS)
@ -53,12 +59,12 @@ $(PPLIB): $(PPOBJS)
install: all install: all
ifeq ($(SHARED_PP),yes) ifeq ($(SHARED_PP),yes)
ifeq ($(CONFIG_WIN32),yes) ifeq ($(CONFIG_WIN32),yes)
install $(INSTALLSTRIP) -m 755 $(SPPLIB) "$(prefix)" install $(INSTALLSTRIP) -m 755 $(SPPLIBNAME) "$(prefix)"
else else
install -d $(libdir) install -d $(libdir)
install $(INSTALLSTRIP) -m 755 $(SPPLIB) $(libdir)/$(SPPLIB).$(SPPVERSION) install $(INSTALLSTRIP) -m 755 $(SPPLIBNAME) $(libdir)/$(SPPLIB)
ln -sf $(SPPLIB).$(SPPVERSION) $(libdir)/$(SPPLIB) ln -sf $(SPPLIB) $(libdir)/$(SPPLIBNAME)
ln -sf $(SPPLIB).$(SPPVERSION) $(libdir)/$(SPPLIB).$(SPPMAJOR) ln -sf $(SPPLIB) $(libdir)/$(SPPLIBMAJOR)
install -d $(libdir)/pkgconfig install -d $(libdir)/pkgconfig
install -m 644 ../../libpostproc.pc $(libdir)/pkgconfig install -m 644 ../../libpostproc.pc $(libdir)/pkgconfig
$(LDCONFIG) || true $(LDCONFIG) || true

@ -81,9 +81,11 @@ endif
LIB= $(LIBPREF)avformat$(LIBSUF) LIB= $(LIBPREF)avformat$(LIBSUF)
ifeq ($(BUILD_SHARED),yes) ifeq ($(BUILD_SHARED),yes)
SLIB= $(SLIBPREF)avformat$(SLIBSUF) SLIBNAME= $(SLIBPREF)avformat$(SLIBSUF)
AVCLIBS+=-lavcodec$(BUILDSUF) -L../libavcodec -lavutil$(BUILDSUF) -L../libavutil
AVCLIBS+=-lavcodec$(BUILDSUF) -L../libavcodec ifeq ($(CONFIG_DARWIN),yes)
SHFLAGS += -Wl,-install_name,$(libdir)/$(SLIBNAME),-current_version,$(SPPVERSION),-compatibility_version,$(SPPVERSION)
endif
ifeq ($(CONFIG_MP3LAME),yes) ifeq ($(CONFIG_MP3LAME),yes)
AVCLIBS+=-lmp3lame AVCLIBS+=-lmp3lame
endif endif
@ -91,14 +93,14 @@ endif
SRCS := $(OBJS:.o=.c) $(PPOBJS:.o=.cpp) SRCS := $(OBJS:.o=.c) $(PPOBJS:.o=.cpp)
all: $(LIB) $(SLIB) all: $(LIB) $(SLIBNAME)
$(LIB): $(OBJS) $(PPOBJS) $(LIB): $(OBJS) $(PPOBJS)
rm -f $@ rm -f $@
$(AR) rc $@ $(OBJS) $(PPOBJS) $(AR) rc $@ $(OBJS) $(PPOBJS)
$(RANLIB) $@ $(RANLIB) $@
$(SLIB): $(OBJS) $(SLIBNAME): $(OBJS)
ifeq ($(CONFIG_WIN32),yes) ifeq ($(CONFIG_WIN32),yes)
$(CC) $(SHFLAGS) -Wl,--output-def,$(@:.dll=.def) -o $@ $(OBJS) $(PPOBJS) $(AVCLIBS) $(EXTRALIBS) $(CC) $(SHFLAGS) -Wl,--output-def,$(@:.dll=.def) -o $@ $(OBJS) $(PPOBJS) $(AVCLIBS) $(EXTRALIBS)
-lib /machine:i386 /def:$(@:.dll=.def) -lib /machine:i386 /def:$(@:.dll=.def)
@ -112,11 +114,11 @@ depend: $(SRCS)
ifeq ($(BUILD_SHARED),yes) ifeq ($(BUILD_SHARED),yes)
install: all install-headers install: all install-headers
ifeq ($(CONFIG_WIN32),yes) ifeq ($(CONFIG_WIN32),yes)
install $(INSTALLSTRIP) -m 755 $(SLIB) "$(prefix)" install $(INSTALLSTRIP) -m 755 $(SLIBNAME) "$(prefix)"
else else
install -d $(libdir) install -d $(libdir)
install $(INSTALLSTRIP) -m 755 $(SLIB) $(libdir)/libavformat-$(VERSION).so install $(INSTALLSTRIP) -m 755 $(SLIBNAME) $(libdir)/$(SLIBPREF)avformat-$(VERSION)$(SLIBSUF)
ln -sf libavformat-$(VERSION).so $(libdir)/libavformat.so ln -sf $(SLIBPREF)avformat-$(VERSION)$(SLIBSUF) $(libdir)/$(SLIBNAME)
$(LDCONFIG) || true $(LDCONFIG) || true
endif endif
else else
@ -143,7 +145,7 @@ install-headers:
g++ $(subst -Wall,,$(CFLAGS)) -c -o $@ $< g++ $(subst -Wall,,$(CFLAGS)) -c -o $@ $<
distclean clean: distclean clean:
rm -f *.o *.d .depend *~ *.a *.so $(LIB) rm -f *.o *.d .depend *~ *.a *$(SLIBSUF) $(LIB)
# #
# include dependency files if they exist # include dependency files if they exist

@ -22,22 +22,25 @@ SRCS := $(OBJS:.o=.c)
LIB= $(LIBPREF)avutil$(LIBSUF) LIB= $(LIBPREF)avutil$(LIBSUF)
ifeq ($(BUILD_SHARED),yes) ifeq ($(BUILD_SHARED),yes)
SLIB= $(SLIBPREF)avutil$(SLIBSUF) SLIBNAME= $(SLIBPREF)avutil$(SLIBSUF)
ifeq ($(CONFIG_DARWIN),yes)
SHFLAGS += -Wl,-install_name,$(libdir)/$(SLIBNAME),-current_version,$(SPPVERSION),-compatibility_version,$(SPPVERSION)
endif
endif endif
all: $(LIB) $(SLIB) all: $(LIB) $(SLIBNAME)
$(LIB): $(OBJS) $(LIB): $(OBJS)
rm -f $@ rm -f $@
$(AR) rc $@ $(OBJS) $(AR) rc $@ $(OBJS)
$(RANLIB) $@ $(RANLIB) $@
$(SLIB): $(OBJS) $(SLIBNAME): $(OBJS)
ifeq ($(CONFIG_WIN32),yes) ifeq ($(CONFIG_WIN32),yes)
$(CC) $(SHFLAGS) -Wl,--output-def,$(@:.dll=.def) -o $@ $(OBJS) $(EXTRALIBS) $(AMREXTRALIBS) $(CC) $(SHFLAGS) -Wl,--output-def,$(@:.dll=.def) -o $@ $(OBJS) $(EXTRALIBS) $(AMREXTRALIBS)
-lib /machine:i386 /def:$(@:.dll=.def) -lib /machine:i386 /def:$(@:.dll=.def)
else else
$(CC) $(SHFLAGS) -o $@ $(OBJS) $(EXTRALIBS) $(AMREXTRALIBS) $(LDFLAGS) $(CC) $(SHFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(EXTRALIBS) $(AMREXTRALIBS)
endif endif
%.o: %.c %.o: %.c
@ -49,7 +52,7 @@ depend: $(SRCS)
dep: depend dep: depend
clean: clean:
rm -f *.o *.d *~ .depend $(LIB) $(SLIB) *.so rm -f *.o *.d *~ .depend $(LIB) $(SLIBNAME) *$(SLIBSUF)
distclean: clean distclean: clean
rm -f Makefile.bak .depend rm -f Makefile.bak .depend
@ -58,11 +61,11 @@ distclean: clean
ifeq ($(BUILD_SHARED),yes) ifeq ($(BUILD_SHARED),yes)
install: all install-headers install: all install-headers
ifeq ($(CONFIG_WIN32),yes) ifeq ($(CONFIG_WIN32),yes)
install $(INSTALLSTRIP) -m 755 $(SLIB) "$(prefix)" install $(INSTALLSTRIP) -m 755 $(SLIBNAME) "$(prefix)"
else else
install -d $(libdir) install -d $(libdir)
install $(INSTALLSTRIP) -m 755 $(SLIB) $(libdir)/libavutil-$(VERSION).so install $(INSTALLSTRIP) -m 755 $(SLIBNAME) $(libdir)/libavutil-$(VERSION)$(SLIBSUF)
ln -sf libavutil-$(VERSION).so $(libdir)/libavutil.so ln -sf libavutil-$(VERSION)$(SLIBSUF) $(libdir)/$(SLIBNAME)
$(LDCONFIG) || true $(LDCONFIG) || true
endif endif
else else

@ -5,22 +5,22 @@ VPATH=$(SRC_PATH)/vhook
CFLAGS=-fPIC $(SHCFLAGS) -I.. -I$(SRC_PATH) -I$(SRC_PATH)/libavformat -I$(SRC_PATH)/libavcodec -I$(SRC_PATH)/libavutil -DHAVE_AV_CONFIG_H CFLAGS=-fPIC $(SHCFLAGS) -I.. -I$(SRC_PATH) -I$(SRC_PATH)/libavformat -I$(SRC_PATH)/libavcodec -I$(SRC_PATH)/libavutil -DHAVE_AV_CONFIG_H
ifeq ($(CONFIG_DARWIN),yes) ifeq ($(CONFIG_DARWIN),yes)
SHFLAGS+=-flat_namespace -undefined suppress SHFLAGS += -flat_namespace
endif endif
HOOKS=null.so fish.so ppm.so watermark.so HOOKS=null$(SLIBSUF) fish$(SLIBSUF) ppm$(SLIBSUF) watermark$(SLIBSUF)
ifeq ($(HAVE_IMLIB2),yes) ifeq ($(HAVE_IMLIB2),yes)
HOOKS += imlib2.so HOOKS += imlib2$(SLIBSUF)
endif endif
ifeq ($(HAVE_FREETYPE2),yes) ifeq ($(HAVE_FREETYPE2),yes)
HOOKS += drawtext.so HOOKS += drawtext$(SLIBSUF)
CFLAGS += `freetype-config --cflags` CFLAGS += `freetype-config --cflags`
endif endif
all: $(HOOKS) all: $(HOOKS)
SRCS := $(HOOKS:.so=.c) SRCS := $(HOOKS:$(SLIBSUF)=.c)
depend: $(SRCS) depend: $(SRCS)
$(CC) -MM $(CFLAGS) $^ 1>.depend $(CC) -MM $(CFLAGS) $^ 1>.depend
@ -29,17 +29,21 @@ install:
install -d "$(libdir)/vhook" install -d "$(libdir)/vhook"
install -m 755 $(HOOKS) "$(libdir)/vhook" install -m 755 $(HOOKS) "$(libdir)/vhook"
imlib2.so: imlib2.o imlib2$(SLIBSUF): imlib2.o
$(CC) $(LDFLAGS) -g -o $@ $(SHFLAGS) $< -lImlib2 $(CC) $(LDFLAGS) -g -o $@ $(SHFLAGS) $< -lImlib2
drawtext.so: drawtext.o drawtext$(SLIBSUF): drawtext.o
$(CC) $(LDFLAGS) -g -o $@ $(SHFLAGS) $< `freetype-config --libs` $(CC) $(LDFLAGS) -g -o $@ $(SHFLAGS) $< `freetype-config --libs`
%.so: %.o %$(SLIBSUF): %.o
ifeq ($(CONFIG_DARWIN),yes)
$(CC) $(LDFLAGS) $(SHFLAGS) -Wl,-install_name,$(libdir)/vhoook/$@ -g -o $@ $<
else
$(CC) $(LDFLAGS) -g -o $@ $(SHFLAGS) $< $(CC) $(LDFLAGS) -g -o $@ $(SHFLAGS) $<
endif
clean: clean:
rm -f *.o *.d .depend *.so *~ rm -f *.o *.d .depend *$(SLIBSUF) *~
ifneq ($(wildcard .depend),) ifneq ($(wildcard .depend),)
include .depend include .depend

Loading…
Cancel
Save