2 # common bits used by all libraries
5 # first so "all" becomes default target
11 YASMD=$(DEFAULT_YASMD)
20 ECHO = printf "$(1)\t%s\n" $(2)
21 BRIEF = CC CXX OBJCC HOSTCC HOSTLD AS YASM AR LD STRIP CP WINDRES
22 SILENT = DEPCC DEPHOSTCC DEPAS DEPYASM RANLIB RM
25 M = @$(call ECHO,$(TAG),$@);
26 $(foreach VAR,$(BRIEF), \
27 $(eval override $(VAR) = @$$(call ECHO,$(VAR),$$(MSG)); $($(VAR))))
28 $(foreach VAR,$(SILENT),$(eval override $(VAR) = @$($(VAR))))
29 $(eval INSTALL = @$(call ECHO,INSTALL,$$(^:$(SRC_DIR)/%=%)); $(INSTALL))
32 ALLFFLIBS = avcodec avdevice avfilter avformat avresample avutil postproc swscale swresample
34 # NASM requires -I path terminated with /
35 IFLAGS := -I. -I$(SRC_LINK)/
36 CPPFLAGS := $(IFLAGS) $(CPPFLAGS)
38 CCFLAGS = $(CPPFLAGS) $(CFLAGS)
39 OBJCFLAGS += $(EOBJCFLAGS)
40 OBJCCFLAGS = $(CPPFLAGS) $(CFLAGS) $(OBJCFLAGS)
41 ASFLAGS := $(CPPFLAGS) $(ASFLAGS)
42 CXXFLAGS += $(CPPFLAGS) $(CFLAGS)
43 YASMFLAGS += $(IFLAGS:%=%/) -Pconfig.asm
45 HOSTCCFLAGS = $(IFLAGS) $(HOSTCPPFLAGS) $(HOSTCFLAGS)
46 LDFLAGS := $(ALLFFLIBS:%=$(LD_PATH)lib%) $(LDFLAGS)
50 $($(1)) $($(1)FLAGS) $($(1)_DEPFLAGS) $($(1)_C) $($(1)_O) $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<)
53 COMPILE_C = $(call COMPILE,CC)
54 COMPILE_CXX = $(call COMPILE,CXX)
55 COMPILE_S = $(call COMPILE,AS)
56 COMPILE_M = $(call COMPILE,OBJCC)
57 COMPILE_HOSTC = $(call COMPILE,HOSTCC)
69 $(CC) $(CCFLAGS) -S -o $@ $<
78 $(WINDRES) $(IFLAGS) --preprocessor "$(DEPWINDRES) -E -xc-header -DRC_INVOKED $(CC_DEPFLAGS)" -o $@ $<
81 $(CC) $(CCFLAGS) $(CC_E) $<
84 $(Q)echo '#include "$*.h"' >$@
87 $(Q)sed 's/$$MAJOR/$($(basename $(@F))_VERSION_MAJOR)/' $^ | sed -e 's/:/:\
93 # Dummy rule to stop make trying to rebuild removed or renamed headers
97 # Disable suffix rules. Most of the builtin rules are suffix rules,
98 # so this saves some time on slow systems.
101 # Do not delete intermediate files from chains of implicit rules
105 include $(SRC_PATH)/arch.mak
108 SLIBOBJS += $(SLIBOBJS-yes)
109 FFLIBS := $($(NAME)_FFLIBS) $(FFLIBS-yes) $(FFLIBS)
110 TESTPROGS += $(TESTPROGS-yes)
112 LDLIBS = $(FFLIBS:%=%$(BUILDSUF))
113 FFEXTRALIBS := $(LDLIBS:%=$(LD_LIB)) $(EXTRALIBS)
115 OBJS := $(sort $(OBJS:%=$(SUBDIR)%))
116 SLIBOBJS := $(sort $(SLIBOBJS:%=$(SUBDIR)%))
117 TESTOBJS := $(TESTOBJS:%=$(SUBDIR)%) $(TESTPROGS:%=$(SUBDIR)%-test.o)
118 TESTPROGS := $(TESTPROGS:%=$(SUBDIR)%-test$(EXESUF))
119 HOSTOBJS := $(HOSTPROGS:%=$(SUBDIR)%.o)
120 HOSTPROGS := $(HOSTPROGS:%=$(SUBDIR)%$(HOSTEXESUF))
121 TOOLS += $(TOOLS-yes)
122 TOOLOBJS := $(TOOLS:%=tools/%.o)
123 TOOLS := $(TOOLS:%=tools/%$(EXESUF))
124 HEADERS += $(HEADERS-yes)
126 PATH_LIBNAME = $(foreach NAME,$(1),lib$(NAME)/$($(2)LIBNAME))
127 DEP_LIBS := $(foreach lib,$(FFLIBS),$(call PATH_LIBNAME,$(lib),$(CONFIG_SHARED:yes=S)))
128 STATIC_DEP_LIBS := $(foreach lib,$(FFLIBS),$(call PATH_LIBNAME,$(lib)))
130 SRC_DIR := $(SRC_PATH)/lib$(NAME)
131 ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h))
132 SKIPHEADERS += $(ARCH_HEADERS:%=$(ARCH)/%) $(SKIPHEADERS-)
133 SKIPHEADERS := $(SKIPHEADERS:%=$(SUBDIR)%)
134 HOBJS = $(filter-out $(SKIPHEADERS:.h=.h.o),$(ALLHEADERS:.h=.h.o))
135 checkheaders: $(HOBJS)
136 .SECONDARY: $(HOBJS:.o=.c)
140 $(HOSTOBJS): %.o: %.c
143 $(HOSTPROGS): %$(HOSTEXESUF): %.o
144 $(HOSTLD) $(HOSTLDFLAGS) $(HOSTLD_O) $^ $(HOSTLIBS)
146 $(OBJS): | $(sort $(dir $(OBJS)))
147 $(HOBJS): | $(sort $(dir $(HOBJS)))
148 $(HOSTOBJS): | $(sort $(dir $(HOSTOBJS)))
149 $(SLIBOBJS): | $(sort $(dir $(SLIBOBJS)))
150 $(TESTOBJS): | $(sort $(dir $(TESTOBJS)))
153 OBJDIRS := $(OBJDIRS) $(dir $(OBJS) $(HOBJS) $(HOSTOBJS) $(SLIBOBJS) $(TESTOBJS))
155 CLEANSUFFIXES = *.d *.o *~ *.h.c *.map *.ver *.ver-sol2 *.ho *.gcno *.gcda *$(DEFAULT_YASMD).asm
156 DISTCLEANSUFFIXES = *.pc
157 LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a
161 $(RM) $(OBJS) $(OBJS:.o=.d) $(OBJS:.o=$(DEFAULT_YASMD).d)
168 -include $(wildcard $(OBJS:.o=.d) $(HOSTOBJS:.o=.d) $(TESTOBJS:.o=.d) $(HOBJS:.o=.d) $(SLIBOBJS:.o=.d)) $(OBJS:.o=$(DEFAULT_YASMD).d)