Statistics
| Branch: | Revision:

ffmpeg / common.mak @ 93bff1de

History | View | Annotate | Download (3.23 KB)

1
#
2
# common bits used by all libraries
3
#
4

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

    
8
ifndef SUBDIR
9
vpath %.c   $(SRC_DIR)
10
vpath %.h   $(SRC_DIR)
11
vpath %.S   $(SRC_DIR)
12
vpath %.asm $(SRC_DIR)
13
vpath %.v   $(SRC_DIR)
14

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

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

    
34
ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale
35

    
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

    
47
%.ho: %.h
48
	$(CC) $(CPPFLAGS) $(CFLAGS) -Wno-unused -c -o $@ -x c $<
49

    
50
%$(EXESUF): %.c
51

    
52
%.ver: %.v
53
	$(Q)sed 's/$$MAJOR/$($(basename $(@F))_VERSION_MAJOR)/' $^ > $@
54

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

    
57
SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
58
ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
59
$(BUILD_ROOT_REL)/version.h: $(SVN_ENTRIES)
60
endif
61

    
62
$(BUILD_ROOT_REL)/version.h: $(SRC_PATH_BARE)/version.sh config.mak
63
	$(M)$< $(SRC_PATH) $@ $(EXTRA_VERSION)
64

    
65
install: install-libs install-headers
66
install-libs: install-libs-yes
67

    
68
uninstall: uninstall-libs uninstall-headers
69

    
70
.PHONY: all depend dep *clean install* uninstall* examples testprogs
71

    
72
# Disable suffix rules.  Most of the builtin rules are suffix rules,
73
# so this saves some time on slow systems.
74
.SUFFIXES:
75

    
76
# Do not delete intermediate files from chains of implicit rules
77
.SECONDARY:
78
endif
79

    
80
OBJS-$(HAVE_MMX) +=  $(MMX-OBJS-yes)
81

    
82
CFLAGS    += $(CFLAGS-yes)
83
OBJS      += $(OBJS-yes)
84
FFLIBS    := $(FFLIBS-yes) $(FFLIBS)
85
TESTPROGS += $(TESTPROGS-yes)
86

    
87
FFEXTRALIBS := $(addprefix -l,$(addsuffix $(BUILDSUF),$(FFLIBS))) $(EXTRALIBS)
88
FFLDFLAGS   := $(addprefix -L$(BUILD_ROOT)/lib,$(ALLFFLIBS)) $(LDFLAGS)
89

    
90
EXAMPLES  := $(addprefix $(SUBDIR),$(addsuffix -example$(EXESUF),$(EXAMPLES)))
91
OBJS      := $(addprefix $(SUBDIR),$(sort $(OBJS)))
92
TESTOBJS  := $(addprefix $(SUBDIR),$(TESTOBJS))
93
TESTPROGS := $(addprefix $(SUBDIR),$(addsuffix -test$(EXESUF),$(TESTPROGS)))
94
HOSTOBJS  := $(addprefix $(SUBDIR),$(addsuffix .o,$(HOSTPROGS)))
95
HOSTPROGS := $(addprefix $(SUBDIR),$(addsuffix $(HOSTEXESUF),$(HOSTPROGS)))
96

    
97
DEP_LIBS := $(foreach NAME,$(FFLIBS),$(BUILD_ROOT_REL)/lib$(NAME)/$($(CONFIG_SHARED:yes=S)LIBNAME))
98

    
99
ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h))
100
SKIPHEADERS += $(addprefix $(ARCH)/,$(ARCH_HEADERS))
101
SKIPHEADERS := $(addprefix $(SUBDIR),$(SKIPHEADERS-) $(SKIPHEADERS))
102
checkheaders: $(filter-out $(SKIPHEADERS:.h=.ho),$(ALLHEADERS:.h=.ho))
103

    
104
$(HOSTOBJS): %.o: %.c
105
	$(HOSTCC) $(HOSTCFLAGS) -c -o $@ $<
106

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

    
110
DEPS := $(OBJS:.o=.d)
111
depend dep: $(DEPS)
112

    
113
CLEANSUFFIXES     = *.d *.o *~ *.ho *.map *.ver
114
DISTCLEANSUFFIXES = *.pc
115
LIBSUFFIXES       = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp
116

    
117
-include $(wildcard $(DEPS))