common.mak 1.97 KB
Newer Older
1 2 3 4
#
# common bits used by all libraries
#

5 6
# first so "all" becomes default target
all: all-yes
7

8
include $(SRC_PATH)/arch.mak
9

Diego Biurrun's avatar
Diego Biurrun committed
10 11 12
OBJS      += $(OBJS-yes)
FFLIBS    := $(FFLIBS-yes) $(FFLIBS)
TESTPROGS += $(TESTPROGS-yes)
13

14 15
LDLIBS       = $(FFLIBS:%=%$(BUILDSUF))
FFEXTRALIBS := $(LDLIBS:%=$(LD_LIB)) $(EXTRALIBS)
16

17 18 19 20 21 22
EXAMPLES  := $(EXAMPLES:%=$(SUBDIR)%-example$(EXESUF))
OBJS      := $(sort $(OBJS:%=$(SUBDIR)%))
TESTOBJS  := $(TESTOBJS:%=$(SUBDIR)%) $(TESTPROGS:%=$(SUBDIR)%-test.o)
TESTPROGS := $(TESTPROGS:%=$(SUBDIR)%-test$(EXESUF))
HOSTOBJS  := $(HOSTPROGS:%=$(SUBDIR)%.o)
HOSTPROGS := $(HOSTPROGS:%=$(SUBDIR)%$(HOSTEXESUF))
23 24 25
TOOLS     += $(TOOLS-yes)
TOOLOBJS  := $(TOOLS:%=tools/%.o)
TOOLS     := $(TOOLS:%=tools/%$(EXESUF))
26
HEADERS   += $(HEADERS-yes)
27

28 29
PATH_LIBNAME = $(foreach NAME,$(1),lib$(NAME)/$($(CONFIG_SHARED:yes=S)LIBNAME))
DEP_LIBS := $(foreach lib,$(FFLIBS),$(call PATH_LIBNAME,$(lib)))
Måns Rullgård's avatar
Måns Rullgård committed
30

31
SRC_DIR    := $(SRC_PATH)/lib$(NAME)
32
ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h))
33 34
SKIPHEADERS += $(ARCH_HEADERS:%=$(ARCH)/%) $(SKIPHEADERS-)
SKIPHEADERS := $(SKIPHEADERS:%=$(SUBDIR)%)
35 36 37
HOBJS        = $(filter-out $(SKIPHEADERS:.h=.h.o),$(ALLHEADERS:.h=.h.o))
checkheaders: $(HOBJS)
.SECONDARY:   $(HOBJS:.o=.c)
38

39 40
alltools: $(TOOLS)

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 50
$(HOSTOBJS): | $(sort $(dir $(HOSTOBJS)))
$(TESTOBJS): | $(sort $(dir $(TESTOBJS)))
51
$(TOOLOBJS): | tools
52

53
OBJDIRS := $(OBJDIRS) $(dir $(OBJS) $(HOBJS) $(HOSTOBJS) $(TESTOBJS))
54

55
CLEANSUFFIXES     = *.d *.o *~ *.h.c *.map *.ver *.gcno *.gcda
56
DISTCLEANSUFFIXES = *.pc
57
LIBSUFFIXES       = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a
58

Mans Rullgard's avatar
Mans Rullgard committed
59
define RULES
60 61
clean::
	$(RM) $(OBJS) $(OBJS:.o=.d)
Mans Rullgard's avatar
Mans Rullgard committed
62 63 64 65 66
	$(RM) $(HOSTPROGS)
	$(RM) $(TOOLS)
endef

$(eval $(RULES))
67

68
-include $(wildcard $(OBJS:.o=.d) $(HOSTOBJS:.o=.d) $(TESTOBJS:.o=.d) $(HOBJS:.o=.d))