2 # common bits used by all libraries
8 X86ASMD=$(DEFAULT_X86ASMD)
17 ECHO = printf "$(1)\t%s\n" $(2)
18 BRIEF = CC CXX OBJCC HOSTCC HOSTLD AS X86ASM AR LD STRIP CP WINDRES NVCC
19 SILENT = DEPCC DEPHOSTCC DEPAS DEPX86ASM RANLIB RM
22 M = @$(call ECHO,$(TAG),$@);
23 $(foreach VAR,$(BRIEF), \
24 $(eval override $(VAR) = @$$(call ECHO,$(VAR),$$(MSG)); $($(VAR))))
25 $(foreach VAR,$(SILENT),$(eval override $(VAR) = @$($(VAR))))
26 $(eval INSTALL = @$(call ECHO,INSTALL,$$(^:$(SRC_DIR)/%=%)); $(INSTALL))
29 ALLFFLIBS = avcodec avdevice avfilter avformat avresample avutil postproc swscale swresample
31 # NASM requires -I path terminated with /
32 IFLAGS := -I. -I$(SRC_LINK)/
33 CPPFLAGS := $(IFLAGS) $(CPPFLAGS)
35 CCFLAGS = $(CPPFLAGS) $(CFLAGS)
36 OBJCFLAGS += $(EOBJCFLAGS)
37 OBJCCFLAGS = $(CPPFLAGS) $(CFLAGS) $(OBJCFLAGS)
38 ASFLAGS := $(CPPFLAGS) $(ASFLAGS)
39 CXXFLAGS := $(CPPFLAGS) $(CFLAGS) $(CXXFLAGS)
40 X86ASMFLAGS += $(IFLAGS:%=%/) -I$(<D)/ -Pconfig.asm
43 HOSTCCFLAGS = $(IFLAGS) $(HOSTCPPFLAGS) $(HOSTCFLAGS)
44 LDFLAGS := $(ALLFFLIBS:%=$(LD_PATH)lib%) $(LDFLAGS)
48 $($(1)) $($(1)FLAGS) $($(1)_DEPFLAGS) $($(1)_C) $($(1)_O) $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<)
51 COMPILE_C = $(call COMPILE,CC)
52 COMPILE_CXX = $(call COMPILE,CXX)
53 COMPILE_S = $(call COMPILE,AS)
54 COMPILE_M = $(call COMPILE,OBJCC)
55 COMPILE_X86ASM = $(call COMPILE,X86ASM)
56 COMPILE_HOSTC = $(call COMPILE,HOSTCC)
57 COMPILE_NVCC = $(call COMPILE,NVCC)
69 $(CC) $(CCFLAGS) -S -o $@ $<
77 %$(DEFAULT_X86ASMD).asm: %.asm
78 $(DEPX86ASM) $(X86ASMFLAGS) -M -o $@ $< > $(@:.asm=.d)
79 $(X86ASM) $(X86ASMFLAGS) -e $< | sed '/^%/d;/^$$/d;' > $@
83 -$(if $(ASMSTRIPFLAGS), $(STRIP) $(ASMSTRIPFLAGS) $@)
86 $(WINDRES) $(IFLAGS) --preprocessor "$(DEPWINDRES) -E -xc-header -DRC_INVOKED $(CC_DEPFLAGS)" -o $@ $<
89 $(CC) $(CCFLAGS) $(CC_E) $<
92 $(Q)echo '#include "$*.h"' >$@
98 $(Q)sh $(SRC_PATH)/compat/cuda/ptx2c.sh $@ $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<)
100 %.c %.h %.pc %.ver %.version: TAG = GEN
102 # Dummy rule to stop make trying to rebuild removed or renamed headers
106 # Disable suffix rules. Most of the builtin rules are suffix rules,
107 # so this saves some time on slow systems.
110 # Do not delete intermediate files from chains of implicit rules
114 include $(SRC_PATH)/ffbuild/arch.mak
117 SLIBOBJS += $(SLIBOBJS-yes)
118 FFLIBS := $($(NAME)_FFLIBS) $(FFLIBS-yes) $(FFLIBS)
119 TESTPROGS += $(TESTPROGS-yes)
121 LDLIBS = $(FFLIBS:%=%$(BUILDSUF))
122 FFEXTRALIBS := $(LDLIBS:%=$(LD_LIB)) $(foreach lib,EXTRALIBS-$(NAME) $(FFLIBS:%=EXTRALIBS-%),$($(lib))) $(EXTRALIBS)
124 OBJS := $(sort $(OBJS:%=$(SUBDIR)%))
125 SLIBOBJS := $(sort $(SLIBOBJS:%=$(SUBDIR)%))
126 TESTOBJS := $(TESTOBJS:%=$(SUBDIR)tests/%) $(TESTPROGS:%=$(SUBDIR)tests/%.o)
127 TESTPROGS := $(TESTPROGS:%=$(SUBDIR)tests/%$(EXESUF))
128 HOSTOBJS := $(HOSTPROGS:%=$(SUBDIR)%.o)
129 HOSTPROGS := $(HOSTPROGS:%=$(SUBDIR)%$(HOSTEXESUF))
130 TOOLS += $(TOOLS-yes)
131 TOOLOBJS := $(TOOLS:%=tools/%.o)
132 TOOLS := $(TOOLS:%=tools/%$(EXESUF))
133 HEADERS += $(HEADERS-yes)
135 PATH_LIBNAME = $(foreach NAME,$(1),lib$(NAME)/$($(2)LIBNAME))
136 DEP_LIBS := $(foreach lib,$(FFLIBS),$(call PATH_LIBNAME,$(lib),$(CONFIG_SHARED:yes=S)))
137 STATIC_DEP_LIBS := $(foreach lib,$(FFLIBS),$(call PATH_LIBNAME,$(lib)))
139 SRC_DIR := $(SRC_PATH)/lib$(NAME)
140 ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h))
141 SKIPHEADERS += $(ARCH_HEADERS:%=$(ARCH)/%) $(SKIPHEADERS-)
142 SKIPHEADERS := $(SKIPHEADERS:%=$(SUBDIR)%)
143 HOBJS = $(filter-out $(SKIPHEADERS:.h=.h.o),$(ALLHEADERS:.h=.h.o))
144 PTXOBJS = $(filter %.ptx.o,$(OBJS))
145 $(HOBJS): CCFLAGS += $(CFLAGS_HEADERS)
146 checkheaders: $(HOBJS)
147 .SECONDARY: $(HOBJS:.o=.c) $(PTXOBJS:.o=.c) $(PTXOBJS:.o=)
151 $(HOSTOBJS): %.o: %.c
154 $(HOSTPROGS): %$(HOSTEXESUF): %.o
155 $(HOSTLD) $(HOSTLDFLAGS) $(HOSTLD_O) $^ $(HOSTEXTRALIBS)
157 $(OBJS): | $(sort $(dir $(OBJS)))
158 $(HOBJS): | $(sort $(dir $(HOBJS)))
159 $(HOSTOBJS): | $(sort $(dir $(HOSTOBJS)))
160 $(SLIBOBJS): | $(sort $(dir $(SLIBOBJS)))
161 $(TESTOBJS): | $(sort $(dir $(TESTOBJS)))
164 OBJDIRS := $(OBJDIRS) $(dir $(OBJS) $(HOBJS) $(HOSTOBJS) $(SLIBOBJS) $(TESTOBJS))
166 CLEANSUFFIXES = *.d *.gcda *.gcno *.h.c *.ho *.map *.o *.pc *.ptx *.ptx.c *.ver *.version *$(DEFAULT_X86ASMD).asm *~
167 LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a
171 $(RM) $(HOSTPROGS) $(TESTPROGS) $(TOOLS)
176 -include $(wildcard $(OBJS:.o=.d) $(HOSTOBJS:.o=.d) $(TESTOBJS:.o=.d) $(HOBJS:.o=.d) $(SLIBOBJS:.o=.d)) $(OBJS:.o=$(DEFAULT_X86ASMD).d)