Statistics
| Branch: | Revision:

ffmpeg / common.mak @ f89c1402

History | View | Annotate | Download (3.12 KB)

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

    
5
all: # make "all" default target
6

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

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

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

    
32
ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale
33

    
34
CPPFLAGS := -I$(BUILD_ROOT_REL) -I$(SRC_PATH) $(CPPFLAGS)
35
CFLAGS   += $(ECFLAGS)
36

    
37
%.o: %.c
38
	$(CCDEP)
39
	$(CC) $(CPPFLAGS) $(CFLAGS) $(CC_DEPFLAGS) -c $(CC_O) $<
40

    
41
%.o: %.S
42
	$(ASDEP)
43
	$(AS) $(CPPFLAGS) $(ASFLAGS) $(AS_DEPFLAGS) -c -o $@ $<
44

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

    
48
%$(EXESUF): %.c
49

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

    
53
SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
54
ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
55
$(BUILD_ROOT_REL)/version.h: $(SVN_ENTRIES)
56
endif
57

    
58
$(BUILD_ROOT_REL)/version.h: $(SRC_PATH_BARE)/version.sh config.mak
59
	$< $(SRC_PATH) $@ $(EXTRA_VERSION)
60

    
61
install: install-libs install-headers
62

    
63
uninstall: uninstall-libs uninstall-headers
64

    
65
.PHONY: all depend dep *clean install* uninstall* examples testprogs
66

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

    
71
# Do not delete intermediate files from chains of implicit rules
72
.SECONDARY:
73
endif
74

    
75
OBJS-$(HAVE_MMX) +=  $(MMX-OBJS-yes)
76

    
77
CFLAGS    += $(CFLAGS-yes)
78
OBJS      += $(OBJS-yes)
79
FFLIBS    := $(FFLIBS-yes) $(FFLIBS)
80
TESTPROGS += $(TESTPROGS-yes)
81

    
82
FFEXTRALIBS := $(addprefix -l,$(addsuffix $(BUILDSUF),$(FFLIBS))) $(EXTRALIBS)
83
FFLDFLAGS   := $(addprefix -L$(BUILD_ROOT)/lib,$(ALLFFLIBS)) $(LDFLAGS)
84

    
85
EXAMPLES  := $(addprefix $(SUBDIR),$(addsuffix -example$(EXESUF),$(EXAMPLES)))
86
OBJS      := $(addprefix $(SUBDIR),$(OBJS))
87
TESTOBJS  := $(addprefix $(SUBDIR),$(TESTOBJS))
88
TESTPROGS := $(addprefix $(SUBDIR),$(addsuffix -test$(EXESUF),$(TESTPROGS)))
89
HOSTOBJS  := $(addprefix $(SUBDIR),$(addsuffix .o,$(HOSTPROGS)))
90
HOSTPROGS := $(addprefix $(SUBDIR),$(addsuffix $(HOSTEXESUF),$(HOSTPROGS)))
91

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

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

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

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

    
105
DEPS := $(OBJS:.o=.d)
106
depend dep: $(DEPS)
107

    
108
CLEANSUFFIXES     = *.d *.o *~ *.ho *.map *.ver
109
DISTCLEANSUFFIXES = *.pc
110
LIBSUFFIXES       = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp
111

    
112
-include $(wildcard $(DEPS))