g723.1: drop unnecessary variable buf_ptr in formant_postfilter()
[ffmpeg.git] / common.mak
index e93ded0..f94a43d 100644 (file)
 # common bits used by all libraries
 #
 
-VPATH = $(SRC_PATH_BARE)/lib$(NAME)
-SRC_DIR = "$(VPATH)"
+# first so "all" becomes default target
+all: all-yes
 
-CFLAGS   += $(CFLAGS-yes)
-OBJS     += $(OBJS-yes)
-ASM_OBJS += $(ASM_OBJS-yes)
-CPP_OBJS += $(CPP_OBJS-yes)
+include $(SRC_PATH)/arch.mak
 
-CFLAGS += -DHAVE_AV_CONFIG_H -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \
-          -D_ISOC9X_SOURCE -I$(BUILD_ROOT) -I$(SRC_PATH) \
-          -I$(SRC_PATH)/libavutil $(OPTFLAGS)
+OBJS      += $(OBJS-yes)
+FFLIBS    := $(FFLIBS-yes) $(FFLIBS)
+TESTPROGS += $(TESTPROGS-yes)
 
-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)
+FFEXTRALIBS := $(FFLIBS:%=-l%$(BUILDSUF)) $(EXTRALIBS)
 
-all: $(LIB) $(SLIBNAME)
+EXAMPLES  := $(EXAMPLES:%=$(SUBDIR)%-example$(EXESUF))
+OBJS      := $(sort $(OBJS:%=$(SUBDIR)%))
+TESTOBJS  := $(TESTOBJS:%=$(SUBDIR)%) $(TESTPROGS:%=$(SUBDIR)%-test.o)
+TESTPROGS := $(TESTPROGS:%=$(SUBDIR)%-test$(EXESUF))
+HOSTOBJS  := $(HOSTPROGS:%=$(SUBDIR)%.o)
+HOSTPROGS := $(HOSTPROGS:%=$(SUBDIR)%$(HOSTEXESUF))
+TOOLS     += $(TOOLS-yes)
+TOOLOBJS  := $(TOOLS:%=tools/%.o)
+TOOLS     := $(TOOLS:%=tools/%$(EXESUF))
 
-$(LIB): $(STATIC_OBJS)
-       rm -f $@
-       $(AR) rc $@ $^ $(EXTRAOBJS)
-       $(RANLIB) $@
+DEP_LIBS := $(foreach NAME,$(FFLIBS),lib$(NAME)/$($(CONFIG_SHARED:yes=S)LIBNAME))
 
-$(SLIBNAME): $(SLIBNAME_WITH_MAJOR)
-       $(LN_S) $^ $@
+ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h))
+SKIPHEADERS += $(ARCH_HEADERS:%=$(ARCH)/%) $(SKIPHEADERS-)
+SKIPHEADERS := $(SKIPHEADERS:%=$(SUBDIR)%)
+HOBJS        = $(filter-out $(SKIPHEADERS:.h=.h.o),$(ALLHEADERS:.h=.h.o))
+checkheaders: $(HOBJS)
+.SECONDARY:   $(HOBJS:.o=.c)
 
-$(SLIBNAME_WITH_MAJOR): $(SHARED_OBJS)
-       $(CC) $(SHFLAGS) $(LDFLAGS) -o $@ $^ $(EXTRALIBS) $(EXTRAOBJS)
-       $(SLIB_EXTRA_CMD)
+alltools: $(TOOLS)
 
-%.o: %.c
-       $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
+$(HOSTOBJS): %.o: %.c
+       $(call COMPILE,HOSTCC)
 
-%.o: %.S
-       $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
+$(HOSTPROGS): %$(HOSTEXESUF): %.o
+       $(HOSTCC) $(HOSTLDFLAGS) -o $@ $< $(HOSTLIBS)
 
-%: %.o $(LIB)
-       $(CC) $(LDFLAGS) -o $@ $^ $(EXTRALIBS)
+$(OBJS):     | $(sort $(dir $(OBJS)))
+$(HOSTOBJS): | $(sort $(dir $(HOSTOBJS)))
+$(TESTOBJS): | $(sort $(dir $(TESTOBJS)))
+$(TOOLOBJS): | tools
 
-%.ho: %.h
-       $(CC) $(CFLAGS) $(LIBOBJFLAGS) -Wno-unused -c -o $@ -x c $<
+OBJDIRS := $(OBJDIRS) $(dir $(OBJS) $(HOSTOBJS) $(TESTOBJS))
 
-ALLHEADERS = $(subst $(VPATH)/,,$(wildcard $(VPATH)/*.h))
-checkheaders: $(filter-out %_template.ho,$(ALLHEADERS:.h=.ho))
+CLEANSUFFIXES     = *.d *.o *~ *.h.c *.map *.ver
+DISTCLEANSUFFIXES = *.pc
+LIBSUFFIXES       = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a
 
-depend dep: $(SRCS)
-       $(CC) -MM $(CFLAGS) $^ 1>.depend
-
-clean::
-       rm -f *.o *~ *.a *.lib *.so *.so.* *.dylib *.dll \
-             *.def *.dll.a *.exp *.ho
-
-distclean: clean
-       rm -f .depend
-
-ifeq ($(BUILD_SHARED),yes)
-INSTLIBTARGETS += install-lib-shared
-endif
-ifeq ($(BUILD_STATIC),yes)
-INSTLIBTARGETS += install-lib-static
-endif
-
-install: install-libs install-headers
-
-install-libs: $(INSTLIBTARGETS)
-
-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)
-
-install-lib-static: $(LIB)
-       install -d "$(LIBDIR)"
-       install -m 644 $(LIB) "$(LIBDIR)"
-       $(LIB_INSTALL_EXTRA_CMD)
-
-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"
-
-uninstall: uninstall-libs uninstall-headers
-
-uninstall-libs:
-       -rm -f "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR)" \
-              "$(SHLIBDIR)/$(SLIBNAME)"            \
-              "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
-       -$(SLIB_UNINSTALL_EXTRA_CMD)
-       -rm -f "$(LIBDIR)/$(LIB)"
-
-uninstall-headers::
-       rm -f $(addprefix "$(INCDIR)/",$(HEADERS))
-       rm -f "$(LIBDIR)/pkgconfig/lib$(NAME).pc"
-
-.PHONY: all depend dep clean distclean install* uninstall*
-
--include .depend
+-include $(wildcard $(OBJS:.o=.d) $(HOSTOBJS:.o=.d) $(TESTOBJS:.o=.d) $(HOBJS:.o=.d))