common.mak 2.98 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
ifndef SUBDIR
Diego Biurrun's avatar
Diego Biurrun committed
9 10 11
vpath %.c   $(SRC_DIR)
vpath %.h   $(SRC_DIR)
vpath %.S   $(SRC_DIR)
Loren Merritt's avatar
Loren Merritt committed
12
vpath %.asm $(SRC_DIR)
13
vpath %.v   $(SRC_DIR)
14

15 16 17 18 19 20
ifeq ($(SRC_DIR),$(SRC_PATH_BARE))
BUILD_ROOT_REL = .
else
BUILD_ROOT_REL = ..
endif

Måns Rullgård's avatar
Måns Rullgård committed
21 22 23 24
ifndef V
Q      = @
ECHO   = printf "$(1)\t%s\n" $(2)
BRIEF  = CC AS YASM AR LD HOSTCC RANLIB STRIP CP
25
SILENT = DEPCC YASMDEP RM
Måns Rullgård's avatar
Måns Rullgård committed
26
MSG    = $@
27
M      = @$(call ECHO,$(TAG),$@);
Måns Rullgård's avatar
Måns Rullgård committed
28 29 30 31 32 33
$(foreach VAR,$(BRIEF), \
    $(eval $(VAR) = @$$(call ECHO,$(VAR),$$(MSG)); $($(VAR))))
$(foreach VAR,$(SILENT),$(eval $(VAR) = @$($(VAR))))
$(eval INSTALL = @$(call ECHO,INSTALL,$$(^:$(SRC_DIR)/%=%)); $(INSTALL))
endif

34 35
ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale

36
CPPFLAGS := -I$(BUILD_ROOT_REL) -I$(SRC_PATH) $(CPPFLAGS)
37
CFLAGS   += $(ECFLAGS)
38 39

%.o: %.c
40
	$(CCDEP)
41
	$(CC) $(CPPFLAGS) $(CFLAGS) $(CC_DEPFLAGS) -c $(CC_O) $<
42 43

%.o: %.S
44
	$(ASDEP)
45
	$(AS) $(CPPFLAGS) $(ASFLAGS) $(AS_DEPFLAGS) -c -o $@ $<
46

Måns Rullgård's avatar
Måns Rullgård committed
47
%.ho: %.h
48
	$(CC) $(CPPFLAGS) $(CFLAGS) -Wno-unused -c -o $@ -x c $<
Måns Rullgård's avatar
Måns Rullgård committed
49

Måns Rullgård's avatar
Måns Rullgård committed
50 51
%$(EXESUF): %.c

52
%.ver: %.v
Måns Rullgård's avatar
Måns Rullgård committed
53
	$(Q)sed 's/$$MAJOR/$($(basename $(@F))_VERSION_MAJOR)/' $^ > $@
54

55
%.c %.h: TAG = GEN
56

Måns Rullgård's avatar
Måns Rullgård committed
57
install: install-libs install-headers
58
install-libs: install-libs-yes
59

Ramiro Polla's avatar
Ramiro Polla committed
60 61 62
uninstall: uninstall-libs uninstall-headers

.PHONY: all depend dep *clean install* uninstall* examples testprogs
Måns Rullgård's avatar
Måns Rullgård committed
63 64 65 66

# Disable suffix rules.  Most of the builtin rules are suffix rules,
# so this saves some time on slow systems.
.SUFFIXES:
67 68

# Do not delete intermediate files from chains of implicit rules
Måns Rullgård's avatar
Måns Rullgård committed
69
$(OBJS):
Måns Rullgård's avatar
Måns Rullgård committed
70
endif
71

72 73
OBJS-$(HAVE_MMX) +=  $(MMX-OBJS-yes)

74
CFLAGS    += $(CFLAGS-yes)
Diego Biurrun's avatar
Diego Biurrun committed
75 76 77
OBJS      += $(OBJS-yes)
FFLIBS    := $(FFLIBS-yes) $(FFLIBS)
TESTPROGS += $(TESTPROGS-yes)
78

Måns Rullgård's avatar
Måns Rullgård committed
79
FFEXTRALIBS := $(addprefix -l,$(addsuffix $(BUILDSUF),$(FFLIBS))) $(EXTRALIBS)
80
FFLDFLAGS   := $(addprefix -L$(BUILD_ROOT)/lib,$(ALLFFLIBS)) $(LDFLAGS)
81

82
EXAMPLES  := $(addprefix $(SUBDIR),$(addsuffix -example$(EXESUF),$(EXAMPLES)))
Måns Rullgård's avatar
Måns Rullgård committed
83
OBJS      := $(addprefix $(SUBDIR),$(sort $(OBJS)))
84
TESTOBJS  := $(addprefix $(SUBDIR),$(TESTOBJS))
85
TESTPROGS := $(addprefix $(SUBDIR),$(addsuffix -test$(EXESUF),$(TESTPROGS)))
86 87
HOSTOBJS  := $(addprefix $(SUBDIR),$(addsuffix .o,$(HOSTPROGS)))
HOSTPROGS := $(addprefix $(SUBDIR),$(addsuffix $(HOSTEXESUF),$(HOSTPROGS)))
88

89
DEP_LIBS := $(foreach NAME,$(FFLIBS),$(BUILD_ROOT_REL)/lib$(NAME)/$($(CONFIG_SHARED:yes=S)LIBNAME))
Måns Rullgård's avatar
Måns Rullgård committed
90

91
ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h))
92
SKIPHEADERS += $(addprefix $(ARCH)/,$(ARCH_HEADERS))
93
SKIPHEADERS := $(addprefix $(SUBDIR),$(SKIPHEADERS-) $(SKIPHEADERS))
94
checkheaders: $(filter-out $(SKIPHEADERS:.h=.ho),$(ALLHEADERS:.h=.ho))
95

96 97 98 99 100 101
$(HOSTOBJS): %.o: %.c
	$(HOSTCC) $(HOSTCFLAGS) -c -o $@ $<

$(HOSTPROGS): %$(HOSTEXESUF): %.o
	$(HOSTCC) $(HOSTLDFLAGS) -o $@ $< $(HOSTLIBS)

102 103
DEPS := $(OBJS:.o=.d)
depend dep: $(DEPS)
104

105
CLEANSUFFIXES     = *.d *.o *~ *.ho *.map *.ver
106
DISTCLEANSUFFIXES = *.pc
107
LIBSUFFIXES       = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp
108

109
-include $(wildcard $(DEPS))