xcb: Add all the libraries to the link line explicitly
[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 := $($(NAME)_FFLIBS) $(FFLIBS-yes) $(FFLIBS)
12 TESTPROGS += $(TESTPROGS-yes)
13
14 LDLIBS = $(FFLIBS:%=%$(BUILDSUF))
15 FFEXTRALIBS := $(LDLIBS:%=$(LD_LIB)) $(EXTRALIBS)
16
17 OBJS := $(sort $(OBJS:%=$(SUBDIR)%))
18 TESTOBJS := $(TESTOBJS:%=$(SUBDIR)tests/%) $(TESTPROGS:%=$(SUBDIR)tests/%.o)
19 TESTPROGS := $(TESTPROGS:%=$(SUBDIR)tests/%$(EXESUF))
20 HOSTOBJS := $(HOSTPROGS:%=$(SUBDIR)%.o)
21 HOSTPROGS := $(HOSTPROGS:%=$(SUBDIR)%$(HOSTEXESUF))
22 TOOLS += $(TOOLS-yes)
23 TOOLOBJS := $(TOOLS:%=tools/%.o)
24 TOOLS := $(TOOLS:%=tools/%$(EXESUF))
25 HEADERS += $(HEADERS-yes)
26
27 PATH_LIBNAME = $(foreach NAME,$(1),lib$(NAME)/$($(2)LIBNAME))
28 DEP_LIBS := $(foreach lib,$(FFLIBS),$(call PATH_LIBNAME,$(lib),$(CONFIG_SHARED:yes=S)))
29 STATIC_DEP_LIBS := $(foreach lib,$(FFLIBS),$(call PATH_LIBNAME,$(lib)))
30
31 SRC_DIR := $(SRC_PATH)/lib$(NAME)
32 ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h))
33 SKIPHEADERS += $(ARCH_HEADERS:%=$(ARCH)/%) $(SKIPHEADERS-)
34 SKIPHEADERS := $(SKIPHEADERS:%=$(SUBDIR)%)
35 HOBJS = $(filter-out $(SKIPHEADERS:.h=.h.o),$(ALLHEADERS:.h=.h.o))
36 checkheaders: $(HOBJS)
37 .SECONDARY: $(HOBJS:.o=.c)
38
39 alltools: $(TOOLS)
40
41 $(HOSTOBJS): %.o: %.c
42 $(COMPILE_HOSTC)
43
44 $(HOSTPROGS): %$(HOSTEXESUF): %.o
45 $(HOSTLD) $(HOSTLDFLAGS) $(HOSTLD_O) $^ $(HOSTLIBS)
46
47 $(OBJS): | $(sort $(dir $(OBJS)))
48 $(HOBJS): | $(sort $(dir $(HOBJS)))
49 $(HOSTOBJS): | $(sort $(dir $(HOSTOBJS)))
50 $(TESTOBJS): | $(sort $(dir $(TESTOBJS)))
51 $(TOOLOBJS): | tools
52
53 OBJDIRS := $(OBJDIRS) $(dir $(OBJS) $(HOBJS) $(HOSTOBJS) $(TESTOBJS))
54
55 CLEANSUFFIXES = *.d *.o *~ *.h.c *.gcda *.gcno *.map *.ver
56 DISTCLEANSUFFIXES = *.pc
57 LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a
58
59 define RULES
60 clean::
61 $(RM) $(HOSTPROGS) $(TESTPROGS) $(TOOLS)
62 endef
63
64 $(eval $(RULES))
65
66 -include $(wildcard $(OBJS:.o=.d) $(HOSTOBJS:.o=.d) $(TESTOBJS:.o=.d) $(HOBJS:.o=.d))