X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=common.mak;h=5d5d3137a827dba755dc2a36037eaca5a0ef5d13;hb=63613fe615160671b394a232c1a3736319a6a8ec;hp=2748e5ed466b372caf2010e68cc4cf2bb5afe119;hpb=5cb854e1c68330f5dd0ca13cabb2a9a58b53b7eb;p=ffmpeg diff --git a/common.mak b/common.mak index 2748e5ed466..5d5d3137a82 100644 --- a/common.mak +++ b/common.mak @@ -2,103 +2,85 @@ # common bits used by all libraries # -SRC_DIR = $(SRC_PATH)/lib$(NAME) -VPATH = $(SRC_DIR) +all: # make "all" default target -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) +ifndef SUBDIR +vpath %.c $(SRC_DIR) +vpath %.h $(SRC_DIR) +vpath %.S $(SRC_DIR) +vpath %.asm $(SRC_DIR) -all: $(EXTRADEPS) $(LIB) $(SLIBNAME) - -$(LIB): $(STATIC_OBJS) - rm -f $@ - $(AR) rc $@ $^ $(EXTRAOBJS) - $(RANLIB) $@ +ifeq ($(SRC_DIR),$(SRC_PATH_BARE)) +BUILD_ROOT_REL = . +else +BUILD_ROOT_REL = .. +endif -$(SLIBNAME): $(SLIBNAME_WITH_MAJOR) - ln -sf $^ $@ +ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale -$(SLIBNAME_WITH_MAJOR): $(SHARED_OBJS) - $(CC) $(SHFLAGS) $(LDFLAGS) -o $@ $^ $(EXTRALIBS) $(EXTRAOBJS) - $(SLIB_EXTRA_CMD) +CPPFLAGS := -DHAVE_AV_CONFIG_H -I$(BUILD_ROOT_REL) -I$(SRC_PATH) $(CPPFLAGS) %.o: %.c - $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $< + $(CC) $(CPPFLAGS) $(CFLAGS) $(LIBOBJFLAGS) -c $(CC_O) $< %.o: %.S - $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $< + $(AS) $(CPPFLAGS) $(ASFLAGS) $(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) $(CPPFLAGS) $(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 *.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 "$(shlibdir)" -ifeq ($(CONFIG_MINGW),yes) - install $(INSTALLSTRIP) -m 755 $(SLIBNAME) "$(prefix)" -else - install $(INSTALLSTRIP) -m 755 $(SLIBNAME) \ - $(shlibdir)/$(SLIBNAME_WITH_VERSION) - ln -sf $(SLIBNAME_WITH_VERSION) \ - $(shlibdir)/$(SLIBNAME_WITH_MAJOR) - ln -sf $(SLIBNAME_WITH_VERSION) \ - $(shlibdir)/$(SLIBNAME) +.PHONY: all depend dep *clean install* uninstall* examples testprogs endif -install-lib-static: $(LIB) - install -d "$(libdir)" - install -m 644 $(LIB) "$(libdir)" +OBJS-$(HAVE_MMX) += $(MMX-OBJS-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" +CFLAGS += $(CFLAGS-yes) +OBJS += $(OBJS-yes) +FFLIBS := $(FFLIBS-yes) $(FFLIBS) +TESTPROGS += $(TESTPROGS-yes) -uninstall: uninstall-libs uninstall-headers +FFEXTRALIBS := $(addprefix -l,$(addsuffix $(BUILDSUF),$(FFLIBS))) $(EXTRALIBS) +FFLDFLAGS := $(addprefix -L$(BUILD_ROOT)/lib,$(ALLFFLIBS)) $(LDFLAGS) -uninstall-libs: -ifeq ($(CONFIG_MINGW),yes) - -rm -f $(prefix)/$(SLIBNAME) -else - -rm -f $(libdir)/$(SLIBNAME_WITH_MAJOR) \ - $(libdir)/$(SLIBNAME) \ - $(libdir)/$(SLIBNAME_WITH_VERSION) -endif - -rm -f $(libdir)/$(LIB) +EXAMPLES := $(addprefix $(SUBDIR),$(addsuffix -example$(EXESUF),$(EXAMPLES))) +OBJS := $(addprefix $(SUBDIR),$(OBJS)) +TESTPROGS := $(addprefix $(SUBDIR),$(addsuffix -test$(EXESUF),$(TESTPROGS))) -uninstall-headers: - rm -f $(addprefix $(incdir)/,$(HEADERS)) - rm -f $(libdir)/pkgconfig/lib$(NAME).pc +DEP_LIBS := $(foreach NAME,$(FFLIBS),$(BUILD_ROOT_REL)/lib$(NAME)/$($(BUILD_SHARED:yes=S)LIBNAME)) -# -# include dependency files if they exist -# -ifneq ($(wildcard .depend),) -include .depend -endif +ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h)) +checkheaders: $(filter-out %_template.ho,$(ALLHEADERS:.h=.ho)) + +DEPS := $(OBJS:.o=.d) +depend dep: $(DEPS) + +CLEANSUFFIXES = *.o *~ *.ho *.map +DISTCLEANSUFFIXES = *.d *.pc +LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp + +-include $(DEPS)