Correctly handle empty frames
[libav.git] / common.mak
1 #
2 # common bits used by all libraries
3 #
4
5 LIBSRC = $(SRC_PATH_BARE)/lib$(NAME)
6
7 LIBVERSION = $(lib$(NAME)_VERSION)
8 LIBMAJOR = $(lib$(NAME)_VERSION_MAJOR)
9
10 vpath %.c $(LIBSRC)
11 vpath %.h $(LIBSRC)
12 vpath %.S $(LIBSRC)
13
14 SRC_DIR = "$(LIBSRC)"
15
16 ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale
17
18 CFLAGS += $(CFLAGS-yes)
19 OBJS += $(OBJS-yes)
20 ASM_OBJS += $(ASM_OBJS-yes)
21 CPP_OBJS += $(CPP_OBJS-yes)
22 FFLIBS += $(FFLIBS-yes)
23
24 CFLAGS += -DHAVE_AV_CONFIG_H -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \
25 -D_ISOC9X_SOURCE -I$(BUILD_ROOT) -I$(SRC_PATH) \
26 $(addprefix -I$(SRC_PATH)/lib,$(ALLFFLIBS)) $(OPTFLAGS)
27
28 EXTRALIBS := $(addprefix -l,$(addsuffix $(BUILDSUF),$(FFLIBS))) $(EXTRALIBS)
29 LDFLAGS := $(addprefix -L$(BUILD_ROOT)/lib,$(FFLIBS)) $(LDFLAGS)
30
31 SRCS := $(OBJS:.o=.c) $(ASM_OBJS:.o=.S) $(CPPOBJS:.o=.cpp)
32 OBJS := $(OBJS) $(ASM_OBJS) $(CPPOBJS)
33
34 all: $(LIBNAME) $(SLIBNAME)
35
36 $(LIBNAME): $(OBJS)
37 rm -f $@
38 $(AR) rc $@ $^ $(EXTRAOBJS)
39 $(RANLIB) $@
40
41 $(SLIBNAME): $(SLIBNAME_WITH_MAJOR)
42 $(LN_S) $^ $@
43
44 $(SLIBNAME_WITH_MAJOR): $(OBJS)
45 $(SLIB_CREATE_DEF_CMD)
46 $(CC) $(SHFLAGS) $(LDFLAGS) -o $@ $^ $(EXTRALIBS) $(EXTRAOBJS)
47 $(SLIB_EXTRA_CMD)
48
49 %.o: %.c
50 $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
51
52 %.o: %.S
53 $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
54
55 %: %.o $(LIBNAME)
56 $(CC) $(LDFLAGS) -o $@ $^ $(EXTRALIBS)
57
58 %.ho: %.h
59 $(CC) $(CFLAGS) $(LIBOBJFLAGS) -Wno-unused -c -o $@ -x c $<
60
61 ALLHEADERS = $(subst $(LIBSRC)/,,$(wildcard $(LIBSRC)/*.h))
62 checkheaders: $(filter-out %_template.ho,$(ALLHEADERS:.h=.ho))
63
64 depend dep: $(SRCS)
65 $(CC) -MM $(CFLAGS) $^ 1>.depend
66
67 clean::
68 rm -f *.o *~ *.a *.lib *.so *.so.* *.dylib *.dll \
69 *.def *.dll.a *.exp *.ho *.map $(TESTS)
70
71 distclean: clean
72 rm -f .depend
73
74 INSTALL_TARGETS-$(BUILD_SHARED) += install-lib-shared
75 INSTALL_TARGETS-$(BUILD_STATIC) += install-lib-static
76
77 install: install-libs install-headers
78
79 install-libs: $(INSTALL_TARGETS-yes)
80
81 install-lib-shared: $(SLIBNAME)
82 install -d "$(SHLIBDIR)"
83 install -m 755 $(SLIBNAME) "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
84 $(STRIP) "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
85 cd "$(SHLIBDIR)" && \
86 $(LN_S) $(SLIBNAME_WITH_VERSION) $(SLIBNAME_WITH_MAJOR)
87 cd "$(SHLIBDIR)" && \
88 $(LN_S) $(SLIBNAME_WITH_VERSION) $(SLIBNAME)
89 $(SLIB_INSTALL_EXTRA_CMD)
90
91 install-lib-static: $(LIBNAME)
92 install -d "$(LIBDIR)"
93 install -m 644 $(LIBNAME) "$(LIBDIR)"
94 $(LIB_INSTALL_EXTRA_CMD)
95
96 INCINSTDIR = $(INCDIR)/lib$(NAME)
97
98 install-headers:
99 install -d "$(INCINSTDIR)"
100 install -d "$(LIBDIR)/pkgconfig"
101 install -m 644 $(addprefix $(SRC_DIR)/,$(HEADERS)) "$(INCINSTDIR)"
102 install -m 644 $(BUILD_ROOT)/lib$(NAME).pc "$(LIBDIR)/pkgconfig"
103
104 uninstall: uninstall-libs uninstall-headers
105
106 uninstall-libs:
107 -rm -f "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR)" \
108 "$(SHLIBDIR)/$(SLIBNAME)" \
109 "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
110 -$(SLIB_UNINSTALL_EXTRA_CMD)
111 -rm -f "$(LIBDIR)/$(LIBNAME)"
112
113 uninstall-headers::
114 rm -f $(addprefix "$(INCINSTDIR)/",$(HEADERS))
115 rm -f "$(LIBDIR)/pkgconfig/lib$(NAME).pc"
116
117 tests: $(TESTS)
118
119 %-test$(EXESUF): %.c $(LIBNAME)
120 $(CC) $(CFLAGS) $(LDFLAGS) -DTEST -o $@ $^ $(EXTRALIBS)
121
122 .PHONY: all depend dep clean distclean install* uninstall* tests
123
124 -include .depend