# common bits used by all libraries
#
-SRC_DIR = $(SRC_PATH)/$(SUBDIR)
-VPATH = $(SRC_DIR)
+all: # make "all" default target
-#FIXME: This should be in configure/config.mak
-ifeq ($(CONFIG_WIN32),yes)
-LDFLAGS = -Wl,--output-def,$(@:.dll=.def),--out-implib,lib$(SLIBNAME:$(SLIBSUF)=.dll.a)
-endif
-
-ifeq ($(TARGET_GPROF),yes)
-CFLAGS+=-p
-LDFLAGS+=-p
-endif
+ifndef SUBDIR
+vpath %.c $(SRC_DIR)
+vpath %.h $(SRC_DIR)
+vpath %.S $(SRC_DIR)
+vpath %.asm $(SRC_DIR)
-ifeq ($(TARGET_ARCH_SPARC64),yes)
-CFLAGS+= -mcpu=ultrasparc -mtune=ultrasparc
+ifeq ($(SRC_DIR),$(SRC_PATH_BARE))
+BUILD_ROOT_REL = .
+else
+BUILD_ROOT_REL = ..
endif
-SRCS := $(OBJS:.o=.c) $(ASM_OBJS:.o=.S) $(CPPOBJS:.o=.cpp)
-OBJS := $(OBJS) $(ASM_OBJS) $(CPPOBJS)
-STATIC_OBJS := $(OBJS) $(STATIC_OBJS)
-SHARED_OBJS := $(OBJS) $(SHARED_OBJS)
-
-all: $(EXTRADEPS) $(LIB) $(SLIBNAME)
-
-$(LIB): $(STATIC_OBJS)
- rm -f $@
- $(AR) rc $@ $^ $(EXTRAOBJS)
- $(RANLIB) $@
+ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale
-$(SLIBNAME): $(SLIBNAME_WITH_MAJOR)
- ln -sf $^ $@
-
-$(SLIBNAME_WITH_MAJOR): $(SHARED_OBJS)
- $(CC) $(SHFLAGS) $(LDFLAGS) -o $@ $^ $(EXTRALIBS) $(EXTRAOBJS)
-ifeq ($(CONFIG_WIN32),yes)
- -lib /machine:i386 /def:$(@:.dll=.def)
-endif
+CFLAGS := -DHAVE_AV_CONFIG_H -I$(BUILD_ROOT_REL) -I$(SRC_PATH) $(OPTFLAGS)
%.o: %.c
$(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
%.o: %.S
- $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
+ $(AS) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
-# BeOS: remove -Wall to get rid of all the "multibyte constant" warnings
-%.o: %.cpp
- g++ $(subst -Wall,,$(CFLAGS)) -c -o $@ $<
+%.ho: %.h
+ $(CC) $(CFLAGS) $(LIBOBJFLAGS) -Wno-unused -c -o $@ -x c $<
-depend: $(SRCS)
- $(CC) -MM $(CFLAGS) $^ 1>.depend
+%.d: %.c
+ $(DEPEND_CMD) > $@
-dep: depend
+%.d: %.S
+ $(DEPEND_CMD) > $@
-clean::
- rm -f *.o *.d *~ *.a *.lib *.so *.dylib *.dll \
- *.lib *.def *.dll.a *.exp
+%.d: %.cpp
+ $(DEPEND_CMD) > $@
-distclean: clean
- rm -f .depend
+%.o: %.d
-ifeq ($(BUILD_SHARED),yes)
-INSTLIBTARGETS += install-lib-shared
-endif
-ifeq ($(BUILD_STATIC),yes)
-INSTLIBTARGETS += install-lib-static
+%$(EXESUF): %.c
+
+SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
+ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
+$(BUILD_ROOT_REL)/version.h: $(SVN_ENTRIES)
endif
+$(BUILD_ROOT_REL)/version.h: $(SRC_PATH_BARE)/version.sh config.mak
+ $< $(SRC_PATH) $@ $(EXTRA_VERSION)
+
install: install-libs install-headers
-install-libs: $(INSTLIBTARGETS)
+uninstall: uninstall-libs uninstall-headers
-install-lib-shared: $(SLIBNAME)
- install -d "$(libdir)"
-ifeq ($(CONFIG_WIN32),yes)
- install $(INSTALLSTRIP) -m 755 $(SLIBNAME) "$(prefix)"
-else
- install $(INSTALLSTRIP) -m 755 $(SLIBNAME) \
- $(libdir)/$(SLIBNAME_WITH_VERSION)
- ln -sf $(SLIBNAME_WITH_VERSION) \
- $(libdir)/$(SLIBNAME_WITH_MAJOR)
- ln -sf $(SLIBNAME_WITH_VERSION) \
- $(libdir)/$(SLIBNAME)
+.PHONY: all depend dep *clean install* uninstall* examples testprogs
endif
-install-lib-static: $(LIB)
- install -d "$(libdir)"
- install -m 644 $(LIB) "$(libdir)"
+CFLAGS += $(CFLAGS-yes)
+OBJS += $(OBJS-yes)
+FFLIBS := $(FFLIBS-yes) $(FFLIBS)
+TESTPROGS += $(TESTPROGS-yes)
-install-headers:
- install -d "$(incdir)"
- install -d "$(libdir)/pkgconfig"
- install -m 644 $(addprefix "$(SRC_DIR)"/,$(HEADERS)) "$(incdir)"
- install -m 644 $(BUILD_ROOT)/lib$(NAME).pc "$(libdir)/pkgconfig"
+FFEXTRALIBS := $(addprefix -l,$(addsuffix $(BUILDSUF),$(FFLIBS))) $(EXTRALIBS)
+FFLDFLAGS := $(addprefix -L$(BUILD_ROOT)/lib,$(ALLFFLIBS)) $(LDFLAGS)
-uninstall: uninstall-libs uninstall-headers
+EXAMPLES := $(addprefix $(SUBDIR),$(addsuffix -example$(EXESUF),$(EXAMPLES)))
+OBJS := $(addprefix $(SUBDIR),$(OBJS))
+TESTPROGS := $(addprefix $(SUBDIR),$(addsuffix -test$(EXESUF),$(TESTPROGS)))
-uninstall-libs:
-ifeq ($(CONFIG_WIN32),yes)
- -rm -f $(prefix)/$(SLIBNAME)
-else
- -rm -f $(libdir)/$(SLIBNAME_WITH_MAJOR) \
- $(libdir)/$(SLIBNAME) \
- $(libdir)/$(SLIBNAME_WITH_VERSION)
-endif
- -rm -f $(libdir)/$(LIB)
+DEP_LIBS := $(foreach NAME,$(FFLIBS),lib$(NAME)/$($(BUILD_SHARED:yes=S)LIBNAME))
-uninstall-headers:
- rm -f $(addprefix $(incdir)/,$(HEADERS))
- rm -f $(libdir)/pkgconfig/lib$(NAME).pc
+ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h))
+checkheaders: $(filter-out %_template.ho,$(ALLHEADERS:.h=.ho))
-#
-# include dependency files if they exist
-#
-ifneq ($(wildcard .depend),)
-include .depend
-endif
+DEPS := $(OBJS:.o=.d)
+depend dep: $(DEPS)
+
+CLEANSUFFIXES = *.o *~ *.ho
+DISTCLEANSUFFIXES = *.d *.pc
+LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp *.map
+
+-include $(DEPS)