Statistics
| Branch: | Revision:

ffmpeg / common.mak @ 362b3bf7

History | View | Annotate | Download (3.12 KB)

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

    
5
SRC_DIR = $(SRC_PATH_BARE)/lib$(NAME)
6

    
7
LIBVERSION = $(lib$(NAME)_VERSION)
8
LIBMAJOR   = $(lib$(NAME)_VERSION_MAJOR)
9

    
10
vpath %.c $(SRC_DIR)
11
vpath %.h $(SRC_DIR)
12
vpath %.S $(SRC_DIR)
13

    
14
ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale
15

    
16
CFLAGS   += $(CFLAGS-yes)
17
OBJS     += $(OBJS-yes)
18
ASM_OBJS += $(ASM_OBJS-yes)
19
CPP_OBJS += $(CPP_OBJS-yes)
20
FFLIBS   += $(FFLIBS-yes)
21

    
22
CFLAGS += -DHAVE_AV_CONFIG_H -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \
23
          -D_ISOC9X_SOURCE -I$(BUILD_ROOT) -I$(SRC_PATH) \
24
          $(addprefix -I$(SRC_PATH)/lib,$(ALLFFLIBS)) $(OPTFLAGS)
25

    
26
EXTRALIBS := $(addprefix -l,$(addsuffix $(BUILDSUF),$(FFLIBS))) $(EXTRALIBS)
27
LDFLAGS   := $(addprefix -L$(BUILD_ROOT)/lib,$(FFLIBS)) $(LDFLAGS)
28

    
29
SRCS := $(OBJS:.o=.c) $(ASM_OBJS:.o=.S) $(CPPOBJS:.o=.cpp)
30
OBJS := $(OBJS) $(ASM_OBJS) $(CPPOBJS)
31

    
32
all: $(LIBNAME) $(SLIBNAME)
33

    
34
$(LIBNAME): $(OBJS)
35
	rm -f $@
36
	$(AR) rc $@ $^ $(EXTRAOBJS)
37
	$(RANLIB) $@
38

    
39
$(SLIBNAME): $(SLIBNAME_WITH_MAJOR)
40
	$(LN_S) $^ $@
41

    
42
$(SLIBNAME_WITH_MAJOR): $(OBJS)
43
	$(SLIB_CREATE_DEF_CMD)
44
	$(CC) $(SHFLAGS) $(LDFLAGS) -o $@ $^ $(EXTRALIBS) $(EXTRAOBJS)
45
	$(SLIB_EXTRA_CMD)
46

    
47
%.o: %.c
48
	$(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
49

    
50
%.o: %.S
51
	$(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
52

    
53
%: %.o $(LIBNAME)
54
	$(CC) $(LDFLAGS) -o $@ $^ $(EXTRALIBS)
55

    
56
%.ho: %.h
57
	$(CC) $(CFLAGS) $(LIBOBJFLAGS) -Wno-unused -c -o $@ -x c $<
58

    
59
ALLHEADERS = $(subst $(SRC_DIR)/,,$(wildcard $(SRC_DIR)/*.h))
60
checkheaders: $(filter-out %_template.ho,$(ALLHEADERS:.h=.ho))
61

    
62
depend dep: $(SRCS)
63
	$(DEPEND_CMD) > .depend
64

    
65
clean::
66
	rm -f *.o *~ *.a *.lib *.so *.so.* *.dylib *.dll \
67
	      *.def *.dll.a *.exp *.ho *.map $(TESTS)
68

    
69
distclean: clean
70
	rm -f .depend
71

    
72
INSTALL_TARGETS-$(BUILD_SHARED) += install-lib-shared
73
INSTALL_TARGETS-$(BUILD_STATIC) += install-lib-static
74

    
75
install: install-libs install-headers
76

    
77
install-libs: $(INSTALL_TARGETS-yes)
78

    
79
install-lib-shared: $(SLIBNAME)
80
	install -d "$(SHLIBDIR)"
81
	install -m 755 $(SLIBNAME) "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
82
	$(STRIP) "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
83
	cd "$(SHLIBDIR)" && \
84
		$(LN_S) $(SLIBNAME_WITH_VERSION) $(SLIBNAME_WITH_MAJOR)
85
	cd "$(SHLIBDIR)" && \
86
		$(LN_S) $(SLIBNAME_WITH_VERSION) $(SLIBNAME)
87
	$(SLIB_INSTALL_EXTRA_CMD)
88

    
89
install-lib-static: $(LIBNAME)
90
	install -d "$(LIBDIR)"
91
	install -m 644 $(LIBNAME) "$(LIBDIR)"
92
	$(LIB_INSTALL_EXTRA_CMD)
93

    
94
INCINSTDIR = $(INCDIR)/lib$(NAME)
95

    
96
install-headers:
97
	install -d "$(INCINSTDIR)"
98
	install -d "$(LIBDIR)/pkgconfig"
99
	install -m 644 $(addprefix "$(SRC_DIR)"/,$(HEADERS)) "$(INCINSTDIR)"
100
	install -m 644 $(BUILD_ROOT)/lib$(NAME).pc "$(LIBDIR)/pkgconfig"
101

    
102
uninstall: uninstall-libs uninstall-headers
103

    
104
uninstall-libs:
105
	-rm -f "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR)" \
106
	       "$(SHLIBDIR)/$(SLIBNAME)"            \
107
	       "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
108
	-$(SLIB_UNINSTALL_EXTRA_CMD)
109
	-rm -f "$(LIBDIR)/$(LIBNAME)"
110

    
111
uninstall-headers::
112
	rm -f $(addprefix "$(INCINSTDIR)/",$(HEADERS))
113
	rm -f "$(LIBDIR)/pkgconfig/lib$(NAME).pc"
114

    
115
tests: $(TESTS)
116

    
117
%-test$(EXESUF): %.c $(LIBNAME)
118
	$(CC) $(CFLAGS) $(LDFLAGS) -DTEST -o $@ $^ $(EXTRALIBS)
119

    
120
.PHONY: all depend dep clean distclean install* uninstall* tests
121

    
122
-include .depend