Statistics
| Branch: | Revision:

ffmpeg / common.mak @ f07fd8c0

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

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

    
18
ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale
19

    
20
CFLAGS := -DHAVE_AV_CONFIG_H -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \
21
          -D_ISOC9X_SOURCE -I$(BUILD_ROOT_REL) -I$(SRC_PATH) $(OPTFLAGS)
22

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

    
26
%.o: %.S
27
	$(CC) $(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:
51
	$(SRC_PATH)/version.sh $(SRC_PATH) $@
52

    
53
install: install-libs install-headers
54

    
55
uninstall: uninstall-libs uninstall-headers
56

    
57
.PHONY: all depend dep clean distclean install* uninstall* tests
58
endif
59

    
60
CFLAGS   += $(CFLAGS-yes)
61
OBJS     += $(OBJS-yes)
62
ASM_OBJS += $(ASM_OBJS-yes)
63
CPP_OBJS += $(CPP_OBJS-yes)
64
FFLIBS   := $(FFLIBS-yes) $(FFLIBS)
65
TESTS    += $(TESTS-yes)
66

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

    
70
SRCS := $(OBJS:.o=.c) $(ASM_OBJS:.o=.S) $(CPP_OBJS:.o=.cpp)
71
OBJS := $(OBJS) $(ASM_OBJS) $(CPP_OBJS)
72

    
73
SRCS  := $(addprefix $(SUBDIR),$(SRCS))
74
OBJS  := $(addprefix $(SUBDIR),$(OBJS))
75
TESTS := $(addprefix $(SUBDIR),$(TESTS))
76

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

    
79
ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h))
80
checkheaders: $(filter-out %_template.ho,$(ALLHEADERS:.h=.ho))
81

    
82
DEPS := $(OBJS:.o=.d)
83
depend dep: $(DEPS)
84

    
85
CLEANSUFFIXES = *.o *~ *.ho
86
LIBSUFFIXES   = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp *.map
87
DISTCLEANSUFFIXES = *.d *.pc
88

    
89
define RULES
90
$(SUBDIR)%$(EXESUF): $(SUBDIR)%.o
91
	$(CC) $(FFLDFLAGS) -o $$@ $$^ $(SUBDIR)$(LIBNAME) $(FFEXTRALIBS)
92

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

    
96
$(SUBDIR)%-test.o: $(SUBDIR)%-test.c
97
	$(CC) $(CFLAGS) -DTEST -c -o $$@ $$^
98

    
99
clean::
100
	rm -f $(TESTS) $(addprefix $(SUBDIR),$(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \
101
	    $(addprefix $(SUBDIR), $(foreach suffix,$(CLEANSUFFIXES),$(addsuffix /$(suffix),$(DIRS))))
102

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

    
108
$(eval $(RULES))
109

    
110
tests: $(TESTS)
111

    
112
-include $(DEPS)