2 # common bits used by all libraries
5 # first so "all" becomes default target
12 ECHO = printf "$(1)\t%s\n" $(2)
13 BRIEF = CC CXX HOSTCC HOSTLD AS YASM AR LD STRIP CP
14 SILENT = DEPCC DEPHOSTCC DEPAS DEPYASM RANLIB RM
17 M = @$(call ECHO,$(TAG),$@);
18 $(foreach VAR,$(BRIEF), \
19 $(eval override $(VAR) = @$$(call ECHO,$(VAR),$$(MSG)); $($(VAR))))
20 $(foreach VAR,$(SILENT),$(eval override $(VAR) = @$($(VAR))))
21 $(eval INSTALL = @$(call ECHO,INSTALL,$$(^:$(SRC_DIR)/%=%)); $(INSTALL))
24 ALLFFLIBS = avcodec avdevice avfilter avformat avresample avutil postproc swscale swresample
26 # NASM requires -I path terminated with /
27 IFLAGS := -I. -I$(SRC_PATH)/
28 CPPFLAGS := $(IFLAGS) $(CPPFLAGS)
30 CCFLAGS = $(CPPFLAGS) $(CFLAGS)
31 ASFLAGS := $(CPPFLAGS) $(ASFLAGS)
32 CXXFLAGS += $(CPPFLAGS) $(CFLAGS)
33 YASMFLAGS += $(IFLAGS:%=%/) -Pconfig.asm
35 HOSTCCFLAGS = $(IFLAGS) $(HOSTCPPFLAGS) $(HOSTCFLAGS)
36 LDFLAGS := $(ALLFFLIBS:%=$(LD_PATH)lib%) $(LDFLAGS)
40 $($(1)) $($(1)FLAGS) $($(1)_DEPFLAGS) $($(1)_C) $($(1)_O) $<
43 COMPILE_C = $(call COMPILE,CC)
44 COMPILE_CXX = $(call COMPILE,CXX)
45 COMPILE_S = $(call COMPILE,AS)
54 $(CC) $(CPPFLAGS) $(CFLAGS) -S -o $@ $<
60 $(CC) $(CCFLAGS) $(CC_E) $<
63 $(Q)echo '#include "$*.h"' >$@
66 $(Q)sed 's/$$MAJOR/$($(basename $(@F))_VERSION_MAJOR)/' $^ > $@
70 # Dummy rule to stop make trying to rebuild removed or renamed headers
74 # Disable suffix rules. Most of the builtin rules are suffix rules,
75 # so this saves some time on slow systems.
78 # Do not delete intermediate files from chains of implicit rules
82 include $(SRC_PATH)/arch.mak
85 FFLIBS := $(FFLIBS-yes) $(FFLIBS)
86 TESTPROGS += $(TESTPROGS-yes)
88 LDLIBS = $(FFLIBS:%=%$(BUILDSUF))
89 FFEXTRALIBS := $(LDLIBS:%=$(LD_LIB)) $(EXTRALIBS)
91 EXAMPLES := $(EXAMPLES:%=$(SUBDIR)%-example$(EXESUF))
92 OBJS := $(sort $(OBJS:%=$(SUBDIR)%))
93 TESTOBJS := $(TESTOBJS:%=$(SUBDIR)%) $(TESTPROGS:%=$(SUBDIR)%-test.o)
94 TESTPROGS := $(TESTPROGS:%=$(SUBDIR)%-test$(EXESUF))
95 HOSTOBJS := $(HOSTPROGS:%=$(SUBDIR)%.o)
96 HOSTPROGS := $(HOSTPROGS:%=$(SUBDIR)%$(HOSTEXESUF))
98 TOOLOBJS := $(TOOLS:%=tools/%.o)
99 TOOLS := $(TOOLS:%=tools/%$(EXESUF))
100 HEADERS += $(HEADERS-yes)
102 DEP_LIBS := $(foreach NAME,$(FFLIBS),lib$(NAME)/$($(CONFIG_SHARED:yes=S)LIBNAME))
104 SRC_DIR := $(SRC_PATH)/lib$(NAME)
105 ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h))
106 SKIPHEADERS += $(ARCH_HEADERS:%=$(ARCH)/%) $(SKIPHEADERS-)
107 SKIPHEADERS := $(SKIPHEADERS:%=$(SUBDIR)%)
108 HOBJS = $(filter-out $(SKIPHEADERS:.h=.h.o),$(ALLHEADERS:.h=.h.o))
109 checkheaders: $(HOBJS)
110 .SECONDARY: $(HOBJS:.o=.c)
114 $(HOSTOBJS): %.o: %.c
115 $(call COMPILE,HOSTCC)
117 $(HOSTPROGS): %$(HOSTEXESUF): %.o
118 $(HOSTLD) $(HOSTLDFLAGS) $(HOSTLD_O) $< $(HOSTLIBS)
120 $(OBJS): | $(sort $(dir $(OBJS)))
121 $(HOBJS): | $(sort $(dir $(HOBJS)))
122 $(HOSTOBJS): | $(sort $(dir $(HOSTOBJS)))
123 $(TESTOBJS): | $(sort $(dir $(TESTOBJS)))
126 OBJDIRS := $(OBJDIRS) $(dir $(OBJS) $(HOBJS) $(HOSTOBJS) $(TESTOBJS))
128 CLEANSUFFIXES = *.d *.o *~ *.h.c *.map *.ver *.ho *.gcno *.gcda
129 DISTCLEANSUFFIXES = *.pc
130 LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a
134 $(RM) $(OBJS) $(OBJS:.o=.d)
141 -include $(wildcard $(OBJS:.o=.d) $(HOSTOBJS:.o=.d) $(TESTOBJS:.o=.d) $(HOBJS:.o=.d))