Statistics
| Branch: | Revision:

ffmpeg / common.mak @ 43a0cb7c

History | View | Annotate | Download (2.88 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

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

    
19
ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale
20

    
21
CFLAGS := -DHAVE_AV_CONFIG_H -I$(BUILD_ROOT_REL) -I$(SRC_PATH) $(OPTFLAGS)
22

    
23
%.o: %.c
24
	$(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
25

    
26
%.o: %.S
27
	$(AS) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
28

    
29
%.ho: %.h
30
	$(CC) $(CFLAGS) $(LIBOBJFLAGS) -Wno-unused -c -o $@ -x c $<
31

    
32
%.d: %.c
33
	$(DEPEND_CMD) > $@
34

    
35
%.d: %.S
36
	$(DEPEND_CMD) > $@
37

    
38
%.d: %.cpp
39
	$(DEPEND_CMD) > $@
40

    
41
%.o: %.d
42

    
43
%$(EXESUF): %.c
44

    
45
SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
46
ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
47
$(BUILD_ROOT_REL)/version.h: $(SVN_ENTRIES)
48
endif
49

    
50
$(BUILD_ROOT_REL)/version.h: $(SRC_PATH_BARE)/version.sh config.mak
51
	$< $(SRC_PATH) $@ $(EXTRA_VERSION)
52

    
53
install: install-libs install-headers
54

    
55
uninstall: uninstall-libs uninstall-headers
56

    
57
.PHONY: all depend dep *clean install* uninstall* examples testprogs
58
endif
59

    
60
CFLAGS    += $(CFLAGS-yes)
61
OBJS      += $(OBJS-yes)
62
FFLIBS    := $(FFLIBS-yes) $(FFLIBS)
63
TESTPROGS += $(TESTPROGS-yes)
64

    
65
FFEXTRALIBS := $(addprefix -l,$(addsuffix $(BUILDSUF),$(FFLIBS))) $(EXTRALIBS)
66
FFLDFLAGS   := $(addprefix -L$(BUILD_ROOT)/lib,$(FFLIBS)) $(LDFLAGS)
67

    
68
EXAMPLES  := $(addprefix $(SUBDIR),$(addsuffix -example$(EXESUF),$(EXAMPLES)))
69
OBJS      := $(addprefix $(SUBDIR),$(OBJS))
70
TESTPROGS := $(addprefix $(SUBDIR),$(addsuffix -test$(EXESUF),$(TESTPROGS)))
71

    
72
DEP_LIBS := $(foreach NAME,$(FFLIBS),lib$(NAME)/$($(BUILD_SHARED:yes=S)LIBNAME))
73

    
74
ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h))
75
checkheaders: $(filter-out %_template.ho,$(ALLHEADERS:.h=.ho))
76

    
77
DEPS := $(OBJS:.o=.d)
78
depend dep: $(DEPS)
79

    
80
CLEANSUFFIXES     = *.o *~ *.ho
81
DISTCLEANSUFFIXES = *.d *.pc
82
LIBSUFFIXES       = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp *.map
83

    
84
define RULES
85
$(SUBDIR)%$(EXESUF): $(SUBDIR)%.o
86
	$(CC) $(FFLDFLAGS) -o $$@ $$^ $(SUBDIR)$(LIBNAME) $(FFEXTRALIBS)
87

    
88
$(SUBDIR)%-test.o: $(SUBDIR)%.c
89
	$(CC) $(CFLAGS) -DTEST -c -o $$@ $$^
90

    
91
$(SUBDIR)%-test.o: $(SUBDIR)%-test.c
92
	$(CC) $(CFLAGS) -DTEST -c -o $$@ $$^
93

    
94
$(SUBDIR)x86/%.o: $(SUBDIR)x86/%.asm
95
	$(YASM) $(YASMFLAGS) -I $$(<D)/ -o $$@ $$<
96

    
97
$(SUBDIR)x86/%.d: $(SUBDIR)x86/%.asm
98
	$(YASM) $(YASMFLAGS) -I $$(<D)/ -M -o $$(@:%.d=%.o) $$< > $$@
99

    
100
clean::
101
	rm -f $(EXAMPLES) $(addprefix $(SUBDIR),*-test$(EXESUF) $(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \
102
	    $(addprefix $(SUBDIR), $(foreach suffix,$(CLEANSUFFIXES),$(addsuffix /$(suffix),$(DIRS))))
103

    
104
distclean:: clean
105
	rm -f  $(addprefix $(SUBDIR),$(DISTCLEANSUFFIXES)) \
106
            $(addprefix $(SUBDIR), $(foreach suffix,$(DISTCLEANSUFFIXES),$(addsuffix /$(suffix),$(DIRS))))
107
endef
108

    
109
$(eval $(RULES))
110

    
111
examples: $(EXAMPLES)
112
testprogs: $(TESTPROGS)
113

    
114
-include $(DEPS)