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 WINDRES
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)
46 COMPILE_HOSTC = $(call COMPILE,HOSTCC)
58 $(CC) $(CPPFLAGS) $(CFLAGS) -S -o $@ $<
67 $(WINDRES) $(IFLAGS) --preprocessor "$(DEPWINDRES) -E -xc-header -DRC_INVOKED $(CC_DEPFLAGS)" -o $@ $<
70 $(CC) $(CCFLAGS) $(CC_E) $<
73 $(Q)echo '#include "$*.h"' >$@
76 $(Q)sed 's/$$MAJOR/$($(basename $(@F))_VERSION_MAJOR)/' $^ > $@
80 # Dummy rule to stop make trying to rebuild removed or renamed headers
84 # Disable suffix rules. Most of the builtin rules are suffix rules,
85 # so this saves some time on slow systems.
88 # Do not delete intermediate files from chains of implicit rules
92 include $(SRC_PATH)/arch.mak
95 SLIBOBJS += $(SLIBOBJS-yes)
96 FFLIBS := $($(NAME)_FFLIBS) $(FFLIBS-yes) $(FFLIBS)
97 TESTPROGS += $(TESTPROGS-yes)
99 LDLIBS = $(FFLIBS:%=%$(BUILDSUF))
100 FFEXTRALIBS := $(LDLIBS:%=$(LD_LIB)) $(EXTRALIBS)
102 OBJS := $(sort $(OBJS:%=$(SUBDIR)%))
103 SLIBOBJS := $(sort $(SLIBOBJS:%=$(SUBDIR)%))
104 TESTOBJS := $(TESTOBJS:%=$(SUBDIR)%) $(TESTPROGS:%=$(SUBDIR)%-test.o)
105 TESTPROGS := $(TESTPROGS:%=$(SUBDIR)%-test$(EXESUF))
106 HOSTOBJS := $(HOSTPROGS:%=$(SUBDIR)%.o)
107 HOSTPROGS := $(HOSTPROGS:%=$(SUBDIR)%$(HOSTEXESUF))
108 TOOLS += $(TOOLS-yes)
109 TOOLOBJS := $(TOOLS:%=tools/%.o)
110 TOOLS := $(TOOLS:%=tools/%$(EXESUF))
111 HEADERS += $(HEADERS-yes)
113 PATH_LIBNAME = $(foreach NAME,$(1),lib$(NAME)/$($(CONFIG_SHARED:yes=S)LIBNAME))
114 DEP_LIBS := $(foreach lib,$(FFLIBS),$(call PATH_LIBNAME,$(lib)))
116 SRC_DIR := $(SRC_PATH)/lib$(NAME)
117 ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h))
118 SKIPHEADERS += $(ARCH_HEADERS:%=$(ARCH)/%) $(SKIPHEADERS-)
119 SKIPHEADERS := $(SKIPHEADERS:%=$(SUBDIR)%)
120 HOBJS = $(filter-out $(SKIPHEADERS:.h=.h.o),$(ALLHEADERS:.h=.h.o))
121 checkheaders: $(HOBJS)
122 .SECONDARY: $(HOBJS:.o=.c)
126 $(HOSTOBJS): %.o: %.c
129 $(HOSTPROGS): %$(HOSTEXESUF): %.o
130 $(HOSTLD) $(HOSTLDFLAGS) $(HOSTLD_O) $^ $(HOSTLIBS)
132 $(OBJS): | $(sort $(dir $(OBJS)))
133 $(HOBJS): | $(sort $(dir $(HOBJS)))
134 $(HOSTOBJS): | $(sort $(dir $(HOSTOBJS)))
135 $(SLIBOBJS): | $(sort $(dir $(SLIBOBJS)))
136 $(TESTOBJS): | $(sort $(dir $(TESTOBJS)))
139 OBJDIRS := $(OBJDIRS) $(dir $(OBJS) $(HOBJS) $(HOSTOBJS) $(SLIBOBJS) $(TESTOBJS))
141 CLEANSUFFIXES = *.d *.o *~ *.h.c *.map *.ver *.ho *.gcno *.gcda
142 DISTCLEANSUFFIXES = *.pc
143 LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a
147 $(RM) $(OBJS) $(OBJS:.o=.d)
154 -include $(wildcard $(OBJS:.o=.d) $(HOSTOBJS:.o=.d) $(TESTOBJS:.o=.d) $(HOBJS:.o=.d) $(SLIBOBJS:.o=.d))