common.mak 2.7 KB
Newer Older
1 2 3 4
#
# common bits used by all libraries
#

5 6
VPATH = $(SRC_PATH_BARE)/lib$(NAME)
SRC_DIR = "$(VPATH)"
7

8 9 10
CFLAGS   += $(CFLAGS-yes)
OBJS     += $(OBJS-yes)
ASM_OBJS += $(ASM_OBJS-yes)
11
CPP_OBJS += $(CPP_OBJS-yes)
12

13 14 15
CFLAGS += -DHAVE_AV_CONFIG_H -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \
          -D_ISOC9X_SOURCE -I$(BUILD_ROOT) -I$(SRC_PATH) \
          -I$(SRC_PATH)/libavutil $(OPTFLAGS)
Diego Biurrun's avatar
Diego Biurrun committed
16

17
SRCS := $(OBJS:.o=.c) $(ASM_OBJS:.o=.S) $(CPPOBJS:.o=.cpp)
18 19
OBJS := $(OBJS) $(ASM_OBJS) $(CPPOBJS)

20
all: $(LIBNAME) $(SLIBNAME)
21

22
$(LIBNAME): $(OBJS)
23 24 25 26
	rm -f $@
	$(AR) rc $@ $^ $(EXTRAOBJS)
	$(RANLIB) $@

27
$(SLIBNAME): $(SLIBNAME_WITH_MAJOR)
28
	$(LN_S) $^ $@
29

30
$(SLIBNAME_WITH_MAJOR): $(OBJS)
31
	$(SLIB_CREATE_DEF_CMD)
32
	$(CC) $(SHFLAGS) $(LDFLAGS) -o $@ $^ $(EXTRALIBS) $(EXTRAOBJS)
33
	$(SLIB_EXTRA_CMD)
34 35 36 37 38 39 40

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

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

41
%: %.o $(LIBNAME)
Diego Biurrun's avatar
Diego Biurrun committed
42 43
	$(CC) $(LDFLAGS) -o $@ $^ $(EXTRALIBS)

Måns Rullgård's avatar
Måns Rullgård committed
44 45 46 47 48 49
%.ho: %.h
	$(CC) $(CFLAGS) $(LIBOBJFLAGS) -Wno-unused -c -o $@ -x c $<

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

50
depend dep: $(SRCS)
51 52 53
	$(CC) -MM $(CFLAGS) $^ 1>.depend

clean::
54
	rm -f *.o *~ *.a *.lib *.so *.so.* *.dylib *.dll \
55
	      *.def *.dll.a *.exp *.ho *.map $(TESTS)
56 57 58 59

distclean: clean
	rm -f .depend

60 61
INSTALL_TARGETS-$(BUILD_SHARED) += install-lib-shared
INSTALL_TARGETS-$(BUILD_STATIC) += install-lib-static
62 63 64

install: install-libs install-headers

65
install-libs: $(INSTALL_TARGETS-yes)
66 67

install-lib-shared: $(SLIBNAME)
68 69 70 71
	install -d "$(SHLIBDIR)"
	install -m 755 $(SLIBNAME) "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
	$(STRIP) "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
	cd "$(SHLIBDIR)" && \
72
		$(LN_S) $(SLIBNAME_WITH_VERSION) $(SLIBNAME_WITH_MAJOR)
73
	cd "$(SHLIBDIR)" && \
74
		$(LN_S) $(SLIBNAME_WITH_VERSION) $(SLIBNAME)
75
	$(SLIB_INSTALL_EXTRA_CMD)
76

77
install-lib-static: $(LIBNAME)
78
	install -d "$(LIBDIR)"
79
	install -m 644 $(LIBNAME) "$(LIBDIR)"
80
	$(LIB_INSTALL_EXTRA_CMD)
81 82

install-headers:
83 84 85 86
	install -d "$(INCDIR)"
	install -d "$(LIBDIR)/pkgconfig"
	install -m 644 $(addprefix $(SRC_DIR)/,$(HEADERS)) "$(INCDIR)"
	install -m 644 $(BUILD_ROOT)/lib$(NAME).pc "$(LIBDIR)/pkgconfig"
87

Diego Biurrun's avatar
Diego Biurrun committed
88 89 90
uninstall: uninstall-libs uninstall-headers

uninstall-libs:
91 92 93
	-rm -f "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR)" \
	       "$(SHLIBDIR)/$(SLIBNAME)"            \
	       "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
94
	-$(SLIB_UNINSTALL_EXTRA_CMD)
95
	-rm -f "$(LIBDIR)/$(LIBNAME)"
Diego Biurrun's avatar
Diego Biurrun committed
96

97
uninstall-headers::
98 99
	rm -f $(addprefix "$(INCDIR)/",$(HEADERS))
	rm -f "$(LIBDIR)/pkgconfig/lib$(NAME).pc"
Diego Biurrun's avatar
Diego Biurrun committed
100

101 102 103 104 105 106
tests: $(TESTS)

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

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

108
-include .depend