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) $(CXXFLAGS)
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"' >$@
86 %.c %.h %.ver: TAG = GEN
88 # Dummy rule to stop make trying to rebuild removed or renamed headers
92 # Disable suffix rules. Most of the builtin rules are suffix rules,
93 # so this saves some time on slow systems.
96 # Do not delete intermediate files from chains of implicit rules
100 include $(SRC_PATH)/arch.mak
103 SLIBOBJS += $(SLIBOBJS-yes)
104 FFLIBS := $($(NAME)_FFLIBS) $(FFLIBS-yes) $(FFLIBS)
105 TESTPROGS += $(TESTPROGS-yes)
107 LDLIBS = $(FFLIBS:%=%$(BUILDSUF))
108 FFEXTRALIBS := $(LDLIBS:%=$(LD_LIB)) $(EXTRALIBS)
110 OBJS := $(sort $(OBJS:%=$(SUBDIR)%))
111 SLIBOBJS := $(sort $(SLIBOBJS:%=$(SUBDIR)%))
112 TESTOBJS := $(TESTOBJS:%=$(SUBDIR)tests/%) $(TESTPROGS:%=$(SUBDIR)tests/%.o)
113 TESTPROGS := $(TESTPROGS:%=$(SUBDIR)tests/%$(EXESUF))
114 HOSTOBJS := $(HOSTPROGS:%=$(SUBDIR)%.o)
115 HOSTPROGS := $(HOSTPROGS:%=$(SUBDIR)%$(HOSTEXESUF))
116 TOOLS += $(TOOLS-yes)
117 TOOLOBJS := $(TOOLS:%=tools/%.o)
118 TOOLS := $(TOOLS:%=tools/%$(EXESUF))
119 HEADERS += $(HEADERS-yes)
121 PATH_LIBNAME = $(foreach NAME,$(1),lib$(NAME)/$($(2)LIBNAME))
122 DEP_LIBS := $(foreach lib,$(FFLIBS),$(call PATH_LIBNAME,$(lib),$(CONFIG_SHARED:yes=S)))
123 STATIC_DEP_LIBS := $(foreach lib,$(FFLIBS),$(call PATH_LIBNAME,$(lib)))
125 SRC_DIR := $(SRC_PATH)/lib$(NAME)
126 ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h))
127 SKIPHEADERS += $(ARCH_HEADERS:%=$(ARCH)/%) $(SKIPHEADERS-)
128 SKIPHEADERS := $(SKIPHEADERS:%=$(SUBDIR)%)
129 HOBJS = $(filter-out $(SKIPHEADERS:.h=.h.o),$(ALLHEADERS:.h=.h.o))
130 checkheaders: $(HOBJS)
131 .SECONDARY: $(HOBJS:.o=.c)
135 $(HOSTOBJS): %.o: %.c
138 $(HOSTPROGS): %$(HOSTEXESUF): %.o
139 $(HOSTLD) $(HOSTLDFLAGS) $(HOSTLD_O) $^ $(HOSTLIBS)
141 $(OBJS): | $(sort $(dir $(OBJS)))
142 $(HOBJS): | $(sort $(dir $(HOBJS)))
143 $(HOSTOBJS): | $(sort $(dir $(HOSTOBJS)))
144 $(SLIBOBJS): | $(sort $(dir $(SLIBOBJS)))
145 $(TESTOBJS): | $(sort $(dir $(TESTOBJS)))
148 OBJDIRS := $(OBJDIRS) $(dir $(OBJS) $(HOBJS) $(HOSTOBJS) $(SLIBOBJS) $(TESTOBJS))
150 CLEANSUFFIXES = *.d *.o *~ *.h.c *.gcda *.gcno *.map *.ver *.ho *$(DEFAULT_YASMD).asm
151 DISTCLEANSUFFIXES = *.pc
152 LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a
156 $(RM) $(HOSTPROGS) $(TESTPROGS) $(TOOLS)
161 -include $(wildcard $(OBJS:.o=.d) $(HOSTOBJS:.o=.d) $(TESTOBJS:.o=.d) $(HOBJS:.o=.d) $(SLIBOBJS:.o=.d)) $(OBJS:.o=$(DEFAULT_YASMD).d)