X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=common.mak;h=343ca749b5f2272bfe173de6808730cbd3dd0898;hb=803d8488f27a9695cd9329c66b16a184392cfdc4;hp=78985d8b367bac1fa7f031277132e6f2571a0070;hpb=76808d6e7ef6d56440b6b773706d6254c9e161fe;p=ffmpeg diff --git a/common.mak b/common.mak index 78985d8b367..343ca749b5f 100644 --- a/common.mak +++ b/common.mak @@ -2,101 +2,77 @@ # common bits used by all libraries # -SRC_DIR = $(SRC_PATH)/lib$(NAME) -VPATH = $(SRC_DIR) - -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) - -EXTRALIBS := -L$(BUILD_ROOT)/libavutil -lavutil$(BUILDSUF) $(EXTRALIBS) - -all: $(EXTRADEPS) $(LIB) $(SLIBNAME) - -$(LIB): $(STATIC_OBJS) - rm -f $@ - $(AR) rc $@ $^ $(EXTRAOBJS) - $(RANLIB) $@ +all: # make "all" default target + +ifndef SUBDIR +vpath %.c $(SRC_DIR) +vpath %.h $(SRC_DIR) +vpath %.S $(SRC_DIR) +vpath %.asm $(SRC_DIR) + +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 $@ $< + $(CCDEP) + $(CC) $(CPPFLAGS) $(CFLAGS) $(CC_DEPFLAGS) -c $(CC_O) $< %.o: %.S - $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $< + $(ASDEP) + $(AS) $(CPPFLAGS) $(ASFLAGS) $(AS_DEPFLAGS) -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) -Wno-unused -c -o $@ -x c $< -%: %.o $(LIB) - $(CC) $(LDFLAGS) -o $@ $^ $(EXTRALIBS) +%$(EXESUF): %.c -depend dep: $(SRCS) - $(CC) -MM $(CFLAGS) $^ 1>.depend +SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries +ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES)) +$(BUILD_ROOT_REL)/version.h: $(SVN_ENTRIES) +endif -clean:: - rm -f *.o *.d *~ *.a *.lib *.so *.so.* *.dylib *.dll \ - *.lib *.def *.dll.a *.exp +$(BUILD_ROOT_REL)/version.h: $(SRC_PATH_BARE)/version.sh config.mak + $< $(SRC_PATH) $@ $(EXTRA_VERSION) -distclean: clean - rm -f .depend +install: install-libs install-headers -ifeq ($(BUILD_SHARED),yes) -INSTLIBTARGETS += install-lib-shared -endif -ifeq ($(BUILD_STATIC),yes) -INSTLIBTARGETS += install-lib-static -endif +uninstall: uninstall-libs uninstall-headers -install: install-libs install-headers +.PHONY: all depend dep *clean install* uninstall* examples testprogs +endif -install-libs: $(INSTLIBTARGETS) +OBJS-$(HAVE_MMX) += $(MMX-OBJS-yes) -install-lib-shared: $(SLIBNAME) - install -d "$(shlibdir)" - install $(INSTALLSTRIP) -m 755 $(SLIBNAME) \ - "$(shlibdir)/$(SLIBNAME_WITH_VERSION)" - cd "$(shlibdir)" && \ - ln -sf $(SLIBNAME_WITH_VERSION) $(SLIBNAME_WITH_MAJOR) - cd "$(shlibdir)" && \ - ln -sf $(SLIBNAME_WITH_VERSION) $(SLIBNAME) +CFLAGS += $(CFLAGS-yes) +OBJS += $(OBJS-yes) +FFLIBS := $(FFLIBS-yes) $(FFLIBS) +TESTPROGS += $(TESTPROGS-yes) -install-lib-static: $(LIB) - install -d "$(libdir)" - install -m 644 $(LIB) "$(libdir)" - $(LIB_INSTALL_EXTRA_CMD) +FFEXTRALIBS := $(addprefix -l,$(addsuffix $(BUILDSUF),$(FFLIBS))) $(EXTRALIBS) +FFLDFLAGS := $(addprefix -L$(BUILD_ROOT)/lib,$(ALLFFLIBS)) $(LDFLAGS) -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" +EXAMPLES := $(addprefix $(SUBDIR),$(addsuffix -example$(EXESUF),$(EXAMPLES))) +OBJS := $(addprefix $(SUBDIR),$(OBJS)) +TESTPROGS := $(addprefix $(SUBDIR),$(addsuffix -test$(EXESUF),$(TESTPROGS))) -uninstall: uninstall-libs uninstall-headers +DEP_LIBS := $(foreach NAME,$(FFLIBS),$(BUILD_ROOT_REL)/lib$(NAME)/$($(CONFIG_SHARED:yes=S)LIBNAME)) -uninstall-libs: - -rm -f "$(shlibdir)/$(SLIBNAME_WITH_MAJOR)" \ - "$(shlibdir)/$(SLIBNAME)" \ - "$(shlibdir)/$(SLIBNAME_WITH_VERSION)" - -rm -f "$(libdir)/$(LIB)" +ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h)) +SKIPHEADERS = $(addprefix $(SUBDIR),$(SKIPHEADERS-)) +checkheaders: $(filter-out $(SKIPHEADERS:.h=.ho),$(ALLHEADERS:.h=.ho)) -uninstall-headers: - rm -f $(addprefix "$(incdir)/",$(HEADERS)) - rm -f "$(libdir)/pkgconfig/lib$(NAME).pc" +DEPS := $(OBJS:.o=.d) +depend dep: $(DEPS) -.PHONY: all depend dep clean distclean install* uninstall* +CLEANSUFFIXES = *.o *~ *.ho *.map +DISTCLEANSUFFIXES = *.d *.pc +LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp -# -# include dependency files if they exist -# -ifneq ($(wildcard .depend),) -include .depend -endif +-include $(wildcard $(DEPS))