avformat/output-example: Declare link dependency on libswscale in the Makefile
[libav.git] / common.mak
1 #
2 # common bits used by all libraries
3 #
4
5 # first so "all" becomes default target
6 all: all-yes
7
8 include $(SRC_PATH)/arch.mak
9
10 OBJS += $(OBJS-yes)
11 FFLIBS := $(FFLIBS-yes) $(FFLIBS)
12 TESTPROGS += $(TESTPROGS-yes)
13
14 LDLIBS = $(FFLIBS:%=%$(BUILDSUF))
15 FFEXTRALIBS := $(LDLIBS:%=$(LD_LIB)) $(EXTRALIBS)
16
17 EXAMPLES := $(EXAMPLES:%=$(SUBDIR)%-example$(EXESUF))
18 OBJS := $(sort $(OBJS:%=$(SUBDIR)%))
19 TESTOBJS := $(TESTOBJS:%=$(SUBDIR)%) $(TESTPROGS:%=$(SUBDIR)%-test.o)
20 TESTPROGS := $(TESTPROGS:%=$(SUBDIR)%-test$(EXESUF))
21 HOSTOBJS := $(HOSTPROGS:%=$(SUBDIR)%.o)
22 HOSTPROGS := $(HOSTPROGS:%=$(SUBDIR)%$(HOSTEXESUF))
23 TOOLS += $(TOOLS-yes)
24 TOOLOBJS := $(TOOLS:%=tools/%.o)
25 TOOLS := $(TOOLS:%=tools/%$(EXESUF))
26 HEADERS += $(HEADERS-yes)
27
28 PATH_LIBNAME = $(foreach NAME,$(1),lib$(NAME)/$($(CONFIG_SHARED:yes=S)LIBNAME))
29 DEP_LIBS := $(foreach lib,$(FFLIBS),$(call PATH_LIBNAME,$(lib)))
30
31 ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h))
32 SKIPHEADERS += $(ARCH_HEADERS:%=$(ARCH)/%) $(SKIPHEADERS-)
33 SKIPHEADERS := $(SKIPHEADERS:%=$(SUBDIR)%)
34 HOBJS = $(filter-out $(SKIPHEADERS:.h=.h.o),$(ALLHEADERS:.h=.h.o))
35 checkheaders: $(HOBJS)
36 .SECONDARY: $(HOBJS:.o=.c)
37
38 alltools: $(TOOLS)
39
40 $(HOSTOBJS): %.o: %.c
41 $(call COMPILE,HOSTCC)
42
43 $(HOSTPROGS): %$(HOSTEXESUF): %.o
44 $(HOSTLD) $(HOSTLDFLAGS) $(HOSTLD_O) $< $(HOSTLIBS)
45
46 $(OBJS): | $(sort $(dir $(OBJS)))
47 $(HOSTOBJS): | $(sort $(dir $(HOSTOBJS)))
48 $(TESTOBJS): | $(sort $(dir $(TESTOBJS)))
49 $(TOOLOBJS): | tools
50
51 OBJDIRS := $(OBJDIRS) $(dir $(OBJS) $(HOSTOBJS) $(TESTOBJS))
52
53 CLEANSUFFIXES = *.d *.o *~ *.h.c *.map *.ver
54 DISTCLEANSUFFIXES = *.pc
55 LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a
56
57 define RULES
58 clean::
59 $(RM) $(OBJS) $(OBJS:.o=.d)
60 $(RM) $(HOSTPROGS)
61 $(RM) $(TOOLS)
62 endef
63
64 $(eval $(RULES))
65
66 -include $(wildcard $(OBJS:.o=.d) $(HOSTOBJS:.o=.d) $(TESTOBJS:.o=.d) $(HOBJS:.o=.d))