aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMåns Rullgård <mans@mansr.com>2008-04-07 21:16:31 +0000
committerMåns Rullgård <mans@mansr.com>2008-04-07 21:16:31 +0000
commit71c61f62a3ca855062c832ec2ed27e331221af45 (patch)
tree8345f97e1bc07033d6d183fe33c65c3f6e1b0814
parentc09ed33e186ea0ba4ab96599bd69aea462aabeda (diff)
downloadffmpeg-71c61f62a3ca855062c832ec2ed27e331221af45.tar.gz
non-recursive makefiles
Originally committed as revision 12760 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--Makefile128
-rw-r--r--common.mak127
-rwxr-xr-xconfigure31
-rw-r--r--libavcodec/Makefile43
-rw-r--r--libavdevice/Makefile4
-rw-r--r--libavfilter/Makefile4
-rw-r--r--libavformat/Makefile4
-rw-r--r--libavutil/Makefile9
-rw-r--r--libpostproc/Makefile4
-rw-r--r--subdir.mak75
10 files changed, 198 insertions, 231 deletions
diff --git a/Makefile b/Makefile
index acc2015886..43b5c14f4b 100644
--- a/Makefile
+++ b/Makefile
@@ -6,8 +6,6 @@ include config.mak
SRC_DIR = $(SRC_PATH_BARE)
-vpath %.c $(SRC_PATH_BARE)
-vpath %.h $(SRC_PATH_BARE)
vpath %.texi $(SRC_PATH_BARE)
PROGS-$(CONFIG_FFMPEG) += ffmpeg
@@ -30,6 +28,14 @@ FFLIBS-$(CONFIG_SWSCALE) += swscale
FFLIBS := avdevice avformat avcodec avutil
+include common.mak
+
+FF_LDFLAGS := $(FFLDFLAGS)
+FF_EXTRALIBS := $(FFEXTRALIBS)
+
+S := $(BUILD_SHARED:yes=S)
+DEP_LIBS := $(foreach L,$(FFLIBS),lib$(L)/$($(S)LIBPREF)$(L)$($(S)LIBSUF))
+
ALL_TARGETS-$(CONFIG_VHOOK) += videohook
ALL_TARGETS-$(BUILD_DOC) += documentation
@@ -40,7 +46,7 @@ INSTALL_TARGETS-$(BUILD_DOC) += install-man
endif
INSTALL_PROGS_TARGETS-$(BUILD_SHARED) = install-libs
-main: lib $(PROGS) $(ALL_TARGETS-yes)
+all: $(DEP_LIBS) $(PROGS) $(ALL_TARGETS-yes)
$(PROGS): %$(EXESUF): %_g$(EXESUF)
cp -p $< $@
@@ -48,13 +54,20 @@ $(PROGS): %$(EXESUF): %_g$(EXESUF)
.depend: version.h $(PROGS_SRCS)
-# bandaid to disable triggering shared library installation routines
-DISABLE=yes
+SUBDIR_VARS := OBJS ASM_OBJS CPP_OBJS FFLIBS CLEANFILES
-include common.mak
+define RESET
+$(1) :=
+$(1)-yes :=
+endef
-S := $(BUILD_SHARED:yes=S)
-DEP_LIBS := $(foreach L,$(FFLIBS),lib$(L)/$($(S)LIBPREF)$(L)$($(S)LIBSUF))
+define DOSUBDIR
+$(foreach V,$(SUBDIR_VARS),$(eval $(call RESET,$(V))))
+SUBDIR := $(1)/
+include $(1)/Makefile
+endef
+
+$(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D))))
VHOOKCFLAGS += $(filter-out -mdynamic-no-pic,$(CFLAGS))
@@ -78,23 +91,11 @@ VHOOKCFLAGS += $(VHOOKCFLAGS-yes)
vhook/%.o: CFLAGS:=$(VHOOKCFLAGS)
-MAKE-yes = $(MAKE)
-MAKE- = : $(MAKE)
-
-lib:
- $(MAKE) -C libavutil all
- $(MAKE) -C libavcodec all
- $(MAKE) -C libavformat all
- $(MAKE) -C libavdevice all
- $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc all
- $(MAKE-$(CONFIG_SWSCALE)) -C libswscale all
- $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter all
-
-ffplay_g$(EXESUF): EXTRALIBS += $(SDL_LIBS)
-ffserver_g$(EXESUF): LDFLAGS += $(FFSERVERLDFLAGS)
+ffplay_g$(EXESUF): FF_EXTRALIBS += $(SDL_LIBS)
+ffserver_g$(EXESUF): FF_LDFLAGS += $(FFSERVERLDFLAGS)
-%_g$(EXESUF): %.o cmdutils.o .libs
- $(CC) $(LDFLAGS) -o $@ $< cmdutils.o $(EXTRALIBS)
+%_g$(EXESUF): %.o cmdutils.o $(DEP_LIBS)
+ $(CC) $(FF_LDFLAGS) -o $@ $< cmdutils.o $(FF_EXTRALIBS)
SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
@@ -104,18 +105,18 @@ endif
version.h:
$(SRC_PATH)/version.sh $(SRC_PATH)
-output_example$(EXESUF): output_example.o .libs
- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(EXTRALIBS)
+output_example$(EXESUF): output_example.o $(DEP_LIBS)
+ $(CC) $(CFLAGS) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)
tools/%$(EXESUF): tools/%.c
- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(EXTRALIBS)
+ $(CC) $(CFLAGS) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)
ffplay.o .depend: CFLAGS += $(SDL_CFLAGS)
ffmpeg.o ffplay.o ffserver.o: version.h
# vhooks compile fine without libav*, but need them nonetheless.
-videohook: .libs $(HOOKS)
+videohook: $(DEP_LIBS) $(HOOKS)
vhook/%$(SLIBSUF): vhook/%.o
$(CC) $(LDFLAGS) -o $@ $(VHOOKSHFLAGS) $< $(VHOOKLIBS) $(LIBS_$(@F))
@@ -148,24 +149,6 @@ install-vhook: videohook
install -d "$(SHLIBDIR)/vhook"
install -m 755 $(HOOKS) "$(SHLIBDIR)/vhook"
-install-libs:
- $(MAKE) -C libavutil install-libs
- $(MAKE) -C libavcodec install-libs
- $(MAKE) -C libavformat install-libs
- $(MAKE) -C libavdevice install-libs
- $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc install-libs
- $(MAKE-$(CONFIG_SWSCALE)) -C libswscale install-libs
- $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter install-libs
-
-install-headers::
- $(MAKE) -C libavutil install-headers
- $(MAKE) -C libavcodec install-headers
- $(MAKE) -C libavformat install-headers
- $(MAKE) -C libavdevice install-headers
- $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc install-headers
- $(MAKE) -C libswscale install-headers
- $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter install-headers
-
uninstall: uninstall-progs uninstall-man uninstall-vhook
uninstall-progs:
@@ -178,51 +161,13 @@ uninstall-vhook:
rm -f $(addprefix "$(SHLIBDIR)/",$(ALLHOOKS_SRCS:.c=$(SLIBSUF)))
-rmdir "$(SHLIBDIR)/vhook/"
-uninstall-libs::
- $(MAKE) -C libavutil uninstall-libs
- $(MAKE) -C libavcodec uninstall-libs
- $(MAKE) -C libavformat uninstall-libs
- $(MAKE) -C libavdevice uninstall-libs
- $(MAKE) -C libpostproc uninstall-libs
- $(MAKE) -C libswscale uninstall-libs
- $(MAKE) -C libavfilter uninstall-libs
-
-uninstall-headers::
- $(MAKE) -C libavutil uninstall-headers
- $(MAKE) -C libavcodec uninstall-headers
- $(MAKE) -C libavformat uninstall-headers
- $(MAKE) -C libavdevice uninstall-headers
- $(MAKE) -C libpostproc uninstall-headers
- $(MAKE) -C libswscale uninstall-headers
- $(MAKE) -C libavfilter uninstall-headers
- -rmdir "$(INCDIR)"
-
depend dep: .vhookdep
- $(MAKE) -C libavutil depend
- $(MAKE) -C libavcodec depend
- $(MAKE) -C libavformat depend
- $(MAKE) -C libavdevice depend
- $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc depend
- $(MAKE-$(CONFIG_SWSCALE)) -C libswscale depend
- $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter depend
.vhookdep: $(ALLHOOKS_SRCS) version.h
$(VHOOK_DEPEND_CMD) > $@
-$(DEP_LIBS): lib
-
-.libs: $(DEP_LIBS)
- touch $@
-
clean::
- $(MAKE) -C libavutil clean
- $(MAKE) -C libavcodec clean
- $(MAKE) -C libavformat clean
- $(MAKE) -C libavdevice clean
- $(MAKE) -C libpostproc clean
- $(MAKE) -C libswscale clean
- $(MAKE) -C libavfilter clean
- rm -f .libs gmon.out TAGS $(ALLPROGS) $(ALLPROGS_G) \
+ rm -f gmon.out TAGS $(ALLPROGS) $(ALLPROGS_G) \
output_example$(EXESUF)
rm -f doc/*.html doc/*.pod doc/*.1
rm -rf tests/vsynth1 tests/vsynth2 tests/data tests/asynth1.sw tests/*~
@@ -231,13 +176,6 @@ clean::
rm -f vhook/*.o vhook/*~ vhook/*.so vhook/*.dylib vhook/*.dll
distclean::
- $(MAKE) -C libavutil distclean
- $(MAKE) -C libavcodec distclean
- $(MAKE) -C libavformat distclean
- $(MAKE) -C libavdevice distclean
- $(MAKE) -C libpostproc distclean
- $(MAKE) -C libswscale distclean
- $(MAKE) -C libavfilter distclean
rm -f .vhookdep version.h config.* *.pc
# regression tests
@@ -404,10 +342,10 @@ tests/asynth1.sw: tests/audiogen$(EXESUF)
$(BUILD_ROOT)/$< $@
%$(EXESUF): %.c
- $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $<
+ $(CC) $(FF_LDFLAGS) $(CFLAGS) -o $@ $<
-tests/seek_test$(EXESUF): tests/seek_test.c .libs
- $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $< $(EXTRALIBS)
+tests/seek_test$(EXESUF): tests/seek_test.c $(DEP_LIBS)
+ $(CC) $(FF_LDFLAGS) $(CFLAGS) -o $@ $< $(FF_EXTRALIBS)
.PHONY: lib videohook documentation TAGS
diff --git a/common.mak b/common.mak
index 2dc181bcb1..c405430308 100644
--- a/common.mak
+++ b/common.mak
@@ -2,47 +2,18 @@
# common bits used by all libraries
#
-SRC_DIR = $(SRC_PATH_BARE)/lib$(NAME)
-
-LIBVERSION = $(lib$(NAME)_VERSION)
-LIBMAJOR = $(lib$(NAME)_VERSION_MAJOR)
+all: # make "all" default target
+ifeq ($(SUBDIR),)
vpath %.c $(SRC_DIR)
vpath %.h $(SRC_DIR)
vpath %.S $(SRC_DIR)
ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale
-CFLAGS += $(CFLAGS-yes)
-OBJS += $(OBJS-yes)
-ASM_OBJS += $(ASM_OBJS-yes)
-CPP_OBJS += $(CPP_OBJS-yes)
-FFLIBS += $(FFLIBS-yes)
-
-CFLAGS += -DHAVE_AV_CONFIG_H -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \
- -D_ISOC9X_SOURCE -I$(BUILD_ROOT) -I$(SRC_PATH) \
- $(addprefix -I$(SRC_PATH)/lib,$(ALLFFLIBS)) $(OPTFLAGS)
-
-EXTRALIBS := $(addprefix -l,$(addsuffix $(BUILDSUF),$(FFLIBS))) $(EXTRALIBS)
-LDFLAGS := $(addprefix -L$(BUILD_ROOT)/lib,$(FFLIBS)) $(LDFLAGS)
-
-SRCS := $(OBJS:.o=.c) $(ASM_OBJS:.o=.S) $(CPP_OBJS:.o=.cpp)
-OBJS := $(OBJS) $(ASM_OBJS) $(CPP_OBJS)
-
-all: $(LIBNAME) $(SLIBNAME)
-
-$(LIBNAME)$(DISABLE): $(OBJS)
- rm -f $@
- $(AR) rc $@ $^ $(EXTRAOBJS)
- $(RANLIB) $@
-
-$(SLIBNAME)$(DISABLE): $(SLIBNAME_WITH_MAJOR)
- $(LN_S) $^ $@
-
-$(SLIBNAME_WITH_MAJOR): $(OBJS)
- $(SLIB_CREATE_DEF_CMD)
- $(CC) $(SHFLAGS) $(LDFLAGS) -o $@ $^ $(EXTRALIBS) $(EXTRAOBJS)
- $(SLIB_EXTRA_CMD)
+CFLAGS = -DHAVE_AV_CONFIG_H -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \
+ -D_ISOC9X_SOURCE -I$(BUILD_ROOT) -I$(SRC_PATH) \
+ $(addprefix -I$(SRC_PATH)/lib,$(ALLFFLIBS)) $(OPTFLAGS)
%.o: %.c
$(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
@@ -50,75 +21,59 @@ $(SLIBNAME_WITH_MAJOR): $(OBJS)
%.o: %.S
$(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
-%: %.o $(LIBNAME)
- $(CC) $(LDFLAGS) -o $@ $^ $(EXTRALIBS)
-
%.ho: %.h
$(CC) $(CFLAGS) $(LIBOBJFLAGS) -Wno-unused -c -o $@ -x c $<
-ALLHEADERS = $(subst $(SRC_DIR)/,,$(wildcard $(SRC_DIR)/*.h))
-checkheaders: $(filter-out %_template.ho,$(ALLHEADERS:.h=.ho))
-
-depend dep: .depend
+install: install-libs install-headers
-.depend: $(SRCS)
- $(DEPEND_CMD) > .depend
+uninstall: uninstall-libs uninstall-headers
-clean::
- rm -f *.o *~ *.a *.lib *.so *.so.* *.dylib *.dll \
- *.def *.dll.a *.exp *.ho *.map $(TESTS)
+.PHONY: all depend dep clean distclean install* uninstall* tests
+endif
-distclean:: clean
- rm -f .depend
+CFLAGS += $(CFLAGS-yes)
+OBJS += $(OBJS-yes)
+ASM_OBJS += $(ASM_OBJS-yes)
+CPP_OBJS += $(CPP_OBJS-yes)
+FFLIBS := $(FFLIBS-yes) $(FFLIBS)
-INSTALL_LIB_TARGETS-$(BUILD_SHARED) += install-lib-shared
-INSTALL_LIB_TARGETS-$(BUILD_STATIC) += install-lib-static
+FFEXTRALIBS := $(addprefix -l,$(addsuffix $(BUILDSUF),$(FFLIBS))) $(EXTRALIBS)
+FFLDFLAGS := $(addprefix -L$(BUILD_ROOT)/lib,$(FFLIBS)) $(LDFLAGS)
-install: install-libs install-headers
+SRCS := $(OBJS:.o=.c) $(ASM_OBJS:.o=.S) $(CPP_OBJS:.o=.cpp)
+OBJS := $(OBJS) $(ASM_OBJS) $(CPP_OBJS)
-install-libs$(DISABLE): $(INSTALL_LIB_TARGETS-yes)
+SRCS := $(addprefix $(SUBDIR),$(SRCS))
+OBJS := $(addprefix $(SUBDIR),$(OBJS))
+TESTS := $(addprefix $(SUBDIR),$(TESTS))
-install-lib-shared: $(SLIBNAME)
- install -d "$(SHLIBDIR)"
- install -m 755 $(SLIBNAME) "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
- $(STRIP) "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
- cd "$(SHLIBDIR)" && \
- $(LN_S) $(SLIBNAME_WITH_VERSION) $(SLIBNAME_WITH_MAJOR)
- cd "$(SHLIBDIR)" && \
- $(LN_S) $(SLIBNAME_WITH_VERSION) $(SLIBNAME)
- $(SLIB_INSTALL_EXTRA_CMD)
+ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h))
+checkheaders: $(filter-out %_template.ho,$(ALLHEADERS:.h=.ho))
-install-lib-static: $(LIBNAME)
- install -d "$(LIBDIR)"
- install -m 644 $(LIBNAME) "$(LIBDIR)"
- $(LIB_INSTALL_EXTRA_CMD)
+depend dep: $(SUBDIR).depend
-INCINSTDIR = $(INCDIR)/lib$(NAME)
+CLEANFILES += *.o *~ *.a *.lib *.so *.so.* *.dylib *.dll \
+ *.def *.dll.a *.exp *.ho *.map
-install-headers$(DISABLE)::
- install -d "$(INCINSTDIR)"
- install -d "$(LIBDIR)/pkgconfig"
- install -m 644 $(addprefix "$(SRC_DIR)"/,$(HEADERS)) "$(INCINSTDIR)"
- install -m 644 $(BUILD_ROOT)/lib$(NAME).pc "$(LIBDIR)/pkgconfig"
+define RULES
+$(SUBDIR)%: $(SUBDIR)%.o $(LIBNAME)
+ $(CC) $(FFLDFLAGS) -o $$@ $$^ $(FFEXTRALIBS)
-uninstall: uninstall-libs uninstall-headers
+$(SUBDIR)%-test$(EXESUF): $(SUBDIR)%.c $(LIBNAME)
+ $(CC) $(CFLAGS) $(FFLDFLAGS) -DTEST -o $$@ $$^ $(FFEXTRALIBS)
-uninstall-libs::
- -rm -f "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR)" \
- "$(SHLIBDIR)/$(SLIBNAME)" \
- "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
- -$(SLIB_UNINSTALL_EXTRA_CMD)
- -rm -f "$(LIBDIR)/$(LIBNAME)"
+$(SUBDIR).depend: $(SRCS)
+ $(DEPEND_CMD) > $$@
-uninstall-headers::
- rm -f $(addprefix "$(INCINSTDIR)/",$(HEADERS))
- rm -f "$(LIBDIR)/pkgconfig/lib$(NAME).pc"
+clean::
+ rm -f $(TESTS) $(addprefix $(SUBDIR),$(CLEANFILES))
-tests: $(TESTS)
+distclean:: clean
+ rm -f $(SUBDIR).depend
+endef
-%-test$(EXESUF): %.c $(LIBNAME)
- $(CC) $(CFLAGS) $(LDFLAGS) -DTEST -o $@ $^ $(EXTRALIBS)
+$(eval $(RULES))
-.PHONY: all depend dep clean distclean install* uninstall* tests
+tests: $(TESTS)
--include .depend
+-include $(SUBDIR).depend
diff --git a/configure b/configure
index cefa343dbd..3822ebe7d1 100755
--- a/configure
+++ b/configure
@@ -940,7 +940,7 @@ SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
LIB_INSTALL_EXTRA_CMD='$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
# gcc stupidly only outputs the basename of targets with -MM
-DEPEND_CMD='$(CC) -MM $(CFLAGS) $(filter-out %.h,$^) | sed "s,[0-9a-z._-]*: \($(SRC_DIR)/\)*\([a-z0-9]*/\)[^/]* ,\\2&,"'
+DEPEND_CMD='$(CC) -MM $(CFLAGS) $(filter-out %.h,$$^) | sed "s,[0-9a-z._-]*: \($(SRC_DIR)/\)*\([a-z0-9]*/\)[^/]* ,\\2&,;s,^.*:,\$$$$(SUBDIR)&,"'
VHOOK_DEPEND_CMD='$(CC) -MM $(VHOOKCFLAGS) $(filter-out %.h,$^) | sed "s,^\([a-z]\),vhook/\\1,"'
# find source path
@@ -1105,7 +1105,7 @@ case $target_os in
darwin)
disable need_memalign
SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR) -Wl,-read_only_relocs,suppress'
- VHOOKSHFLAGS='-dynamiclib -Wl,-single_module -flat_namespace -undefined suppress -Wl,-install_name,$(SHLIBDIR)/vhook/$@'
+ VHOOKSHFLAGS='-dynamiclib -Wl,-single_module -flat_namespace -undefined suppress -Wl,-install_name,$(SHLIBDIR)/vhook/$$@'
strip="strip -x"
FFLDFLAGS="-Wl,-dynamic,-search_paths_first"
SLIBSUF=".dylib"
@@ -1128,10 +1128,10 @@ case $target_os in
EXESUF=".exe"
SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(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:$(SLIBSUF)=.lib)"'
+ SLIB_EXTRA_CMD='-lib /machine:i386 /def:$$(@:$(SLIBSUF)=.def)'
+ SLIB_INSTALL_EXTRA_CMD='-install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
- SHFLAGS='-shared -Wl,--output-def,$(@:$(SLIBSUF)=.def) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base'
+ SHFLAGS='-shared -Wl,--output-def,$$(@:$(SLIBSUF)=.def) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base'
;;
cygwin*)
target_os=cygwin
@@ -1168,22 +1168,22 @@ case $target_os in
ln_s="cp -f"
EXESUF=".exe"
FFLDFLAGS="-Zomf -Zbin-files -Zargs-wild -Zmap"
- SHFLAGS='$(NAME).def -Zdll -Zomf'
+ SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
FFSERVERLDFLAGS=""
LIBSUF="_s.a"
SLIBPREF=""
SLIBSUF=".dll"
SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
- SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(NAME).def; \
- echo PROTMODE >> $(NAME).def; \
- echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(NAME).def; \
- echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(NAME).def; \
- echo EXPORTS >> $(NAME).def; \
- emxexp -o $(OBJS) >> $(NAME).def'
- SLIB_EXTRA_CMD='emximp -o $(LIBPREF)$(NAME)_dll.a $(NAME).def; \
- emximp -o $(LIBPREF)$(NAME)_dll.lib $(NAME).def;'
- SLIB_INSTALL_EXTRA_CMD='install -m 644 $(LIBPREF)$(NAME)_dll.a $(LIBPREF)$(NAME)_dll.lib "$(LIBDIR)"'
+ SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
+ echo PROTMODE >> $(SUBDIR)$(NAME).def; \
+ echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
+ echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
+ echo EXPORTS >> $(SUBDIR)$(NAME).def; \
+ emxexp -o $(OBJS) >> $(SUBDIR)$(NAME).def'
+ SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
+ emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
+ SLIB_INSTALL_EXTRA_CMD='install -m 644 $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib "$(LIBDIR)"'
SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.a "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.lib'
disable vhook
;;
@@ -2096,6 +2096,7 @@ if enabled source_path_used; then
FILES="\
Makefile \
common.mak \
+ subdir.mak \
doc/texi2pod.pl \
libavcodec/Makefile \
libavdevice/Makefile \
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 0ec1548cd4..124fc8d025 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -2,7 +2,7 @@
# libavcodec Makefile
# (c) 2000-2005 Fabrice Bellard
#
-include ../config.mak
+include $(SUBDIR)../config.mak
NAME = avcodec
FFLIBS = avutil
@@ -449,7 +449,7 @@ ALTIVEC-OBJS-$(CONFIG_VC1_DECODER) += ppc/vc1dsp_altivec.o
ALTIVEC-OBJS-$(CONFIG_WMV3_DECODER) += ppc/vc1dsp_altivec.o
# -maltivec is needed in order to build AltiVec code.
-$(ALTIVEC-OBJS-yes): CFLAGS += -maltivec -mabi=altivec
+$(addprefix $(SUBDIR),$(ALTIVEC-OBJS-yes)): CFLAGS += -maltivec -mabi=altivec
# check_altivec must be built without -maltivec
OBJS-$(HAVE_ALTIVEC) += $(ALTIVEC-OBJS-yes) \
@@ -469,23 +469,22 @@ ifeq ($(ARCH_X86),yes)
TESTS += cpuid-test$(EXESUF) motion-test$(EXESUF)
endif
-include ../common.mak
-
-clean::
- rm -f \
- alpha/*.o alpha/*~ \
- armv4l/*.o armv4l/*~ \
- bfin/*.o bfin/*~ \
- i386/*.o i386/*~ \
- mlib/*.o mlib/*~ \
- ppc/*.o ppc/*~ \
- ps2/*.o ps2/*~ \
- sh4/*.o sh4/*~ \
- sparc/*.o sparc/*~ \
- apiexample$(EXESUF)
-
-cpuid-test$(EXESUF): i386/cputest.c
-apiexample$(EXESUF): apiexample.o $(LIBNAME)
-dct-test$(EXESUF): dct-test.o fdctref.o $(LIBNAME)
-fft-test$(EXESUF): fft-test.o $(LIBNAME)
-motion-test$(EXESUF): motion-test.o $(LIBNAME)
+CLEANFILES = \
+ alpha/*.o alpha/*~ \
+ armv4l/*.o armv4l/*~ \
+ bfin/*.o bfin/*~ \
+ i386/*.o i386/*~ \
+ mlib/*.o mlib/*~ \
+ ppc/*.o ppc/*~ \
+ ps2/*.o ps2/*~ \
+ sh4/*.o sh4/*~ \
+ sparc/*.o sparc/*~ \
+ apiexample$(EXESUF)
+
+include $(SUBDIR)../subdir.mak
+
+$(SUBDIR)cpuid-test$(EXESUF): $(SUBDIR)i386/cputest.c
+$(SUBDIR)apiexample$(EXESUF): $(SUBDIR)apiexample.o $(SUBDIR)$(LIBNAME)
+$(SUBDIR)dct-test$(EXESUF): $(SUBDIR)dct-test.o fdctref.o $(SUBDIR)$(LIBNAME)
+$(SUBDIR)fft-test$(EXESUF): $(SUBDIR)fft-test.o $(SUBDIR)$(LIBNAME)
+$(SUBDIR)motion-test$(EXESUF): $(SUBDIR)motion-test.o $(SUBDIR)$(LIBNAME)
diff --git a/libavdevice/Makefile b/libavdevice/Makefile
index ddb0113c79..5bdf38ff2d 100644
--- a/libavdevice/Makefile
+++ b/libavdevice/Makefile
@@ -1,4 +1,4 @@
-include ../config.mak
+include $(SUBDIR)../config.mak
NAME = avdevice
FFLIBS = avformat avcodec avutil
@@ -23,4 +23,4 @@ OBJS-$(CONFIG_LIBDC1394_DEMUXER) += libdc1394.o
CPP_OBJS-$(CONFIG_AUDIO_BEOS_DEMUXER) += beosaudio.o
CPP_OBJS-$(CONFIG_AUDIO_BEOS_MUXER) += beosaudio.o
-include ../common.mak
+include $(SUBDIR)../subdir.mak
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 923f91c696..2357aeea44 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -1,4 +1,4 @@
-include ../config.mak
+include $(SUBDIR)../config.mak
NAME = avfilter
FFLIBS = avcodec avutil
@@ -14,4 +14,4 @@ OBJS = allfilters.o \
HEADERS = avfilter.h
-include ../common.mak
+include $(SUBDIR)../subdir.mak
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 5ac7ea1c57..6dd2c4e1e9 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -2,7 +2,7 @@
# libavformat Makefile
# (c) 2000-2003 Fabrice Bellard
#
-include ../config.mak
+include $(SUBDIR)../config.mak
NAME = avformat
FFLIBS = avcodec avutil
@@ -198,4 +198,4 @@ OBJS-$(CONFIG_RTP_PROTOCOL) += rtpproto.o
OBJS-$(CONFIG_TCP_PROTOCOL) += tcp.o
OBJS-$(CONFIG_UDP_PROTOCOL) += udp.o
-include ../common.mak
+include $(SUBDIR)../subdir.mak
diff --git a/libavutil/Makefile b/libavutil/Makefile
index 2ff0a9764f..c0dfa95f56 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -1,4 +1,4 @@
-include ../config.mak
+include $(SUBDIR)../config.mak
NAME = avutil
@@ -41,9 +41,8 @@ HEADERS = adler32.h \
TESTS = $(addsuffix -test$(EXESUF), adler32 aes crc des lls md5 sha1 softfloat tree)
-include ../common.mak
+include $(SUBDIR)../subdir.mak
-lzo-test$(EXESUF): EXTRALIBS += -llzo2
+$(SUBDIR)lzo-test$(EXESUF): EXTRALIBS += -llzo2
-clean::
- rm -f lzo-test$(EXESUF)
+CLEANFILES = lzo-test$(EXESUF)
diff --git a/libpostproc/Makefile b/libpostproc/Makefile
index 555b47252e..bd0b71e3d4 100644
--- a/libpostproc/Makefile
+++ b/libpostproc/Makefile
@@ -1,4 +1,4 @@
-include ../config.mak
+include $(SUBDIR)../config.mak
NAME = postproc
FFLIBS = avutil
@@ -7,4 +7,4 @@ HEADERS = postprocess.h
OBJS = postprocess.o
-include ../common.mak
+include $(SUBDIR)../subdir.mak
diff --git a/subdir.mak b/subdir.mak
new file mode 100644
index 0000000000..6384d8baf8
--- /dev/null
+++ b/subdir.mak
@@ -0,0 +1,75 @@
+SRC_DIR := $(SRC_PATH_BARE)/lib$(NAME)
+
+include $(SUBDIR)../common.mak
+
+LIBVERSION := $(lib$(NAME)_VERSION)
+LIBMAJOR := $(lib$(NAME)_VERSION_MAJOR)
+
+ifeq ($(BUILD_STATIC),yes)
+all: $(SUBDIR)$(LIBNAME)
+
+install-libs: install-lib$(NAME)-static
+
+$(SUBDIR)$(LIBNAME): $(OBJS)
+ rm -f $@
+ $(AR) rc $@ $^ $(EXTRAOBJS)
+ $(RANLIB) $@
+endif
+
+INCINSTDIR := $(INCDIR)/lib$(NAME)
+
+define RULES
+ifeq ($(BUILD_SHARED),yes)
+all: $(SUBDIR)$(SLIBNAME)
+
+install-libs: install-lib$(NAME)-shared
+
+$(SUBDIR)$(SLIBNAME): $(SUBDIR)$(SLIBNAME_WITH_MAJOR)
+ cd ./$(SUBDIR) && $(LN_S) $(SLIBNAME_WITH_MAJOR) $(SLIBNAME)
+
+$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS)
+ $(SLIB_CREATE_DEF_CMD)
+ $(CC) $(SHFLAGS) $(FFLDFLAGS) -o $$@ $$^ $(FFEXTRALIBS) $(EXTRAOBJS)
+ $(SLIB_EXTRA_CMD)
+
+ifneq ($(SUBDIR),)
+$(SUBDIR)$(SLIBNAME_WITH_MAJOR): \
+ $(foreach L,$(FFLIBS),lib$(L)/$(SLIBPREF)$(L)$(SLIBSUF))
+endif
+endif
+
+install-lib$(NAME)-shared: $(SUBDIR)$(SLIBNAME)
+ install -d "$(SHLIBDIR)"
+ install -m 755 $(SUBDIR)$(SLIBNAME) "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
+ $(STRIP) "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
+ cd "$(SHLIBDIR)" && \
+ $(LN_S) $(SLIBNAME_WITH_VERSION) $(SLIBNAME_WITH_MAJOR)
+ cd "$(SHLIBDIR)" && \
+ $(LN_S) $(SLIBNAME_WITH_VERSION) $(SLIBNAME)
+ $(SLIB_INSTALL_EXTRA_CMD)
+
+install-lib$(NAME)-static: $(SUBDIR)$(LIBNAME)
+ install -d "$(LIBDIR)"
+ install -m 644 $(SUBDIR)$(LIBNAME) "$(LIBDIR)"
+ $(LIB_INSTALL_EXTRA_CMD)
+
+install-headers::
+ install -d "$(INCINSTDIR)"
+ install -d "$(LIBDIR)/pkgconfig"
+ install -m 644 $(addprefix "$(SRC_DIR)"/,$(HEADERS)) "$(INCINSTDIR)"
+ install -m 644 $(BUILD_ROOT)/lib$(NAME).pc "$(LIBDIR)/pkgconfig"
+
+uninstall-libs::
+ -rm -f "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR)" \
+ "$(SHLIBDIR)/$(SLIBNAME)" \
+ "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
+ -$(SLIB_UNINSTALL_EXTRA_CMD)
+ -rm -f "$(LIBDIR)/$(LIBNAME)"
+
+uninstall-headers::
+ rm -f $(addprefix "$(INCINSTDIR)/",$(HEADERS))
+ rm -f "$(LIBDIR)/pkgconfig/lib$(NAME).pc"
+ -rmdir "$(INCDIR)"
+endef
+
+$(eval $(RULES))