Fix previously broken x86_64 check, simplifying it in the process.
[libav.git] / common.mak
CommitLineData
8b2121e3
MR
1#
2# common bits used by all libraries
3#
4
c415857d 5SRC_DIR = $(SRC_PATH_BARE)/lib$(NAME)
de2f77d8 6
0e32c8c6
MR
7LIBVERSION = $(lib$(NAME)_VERSION)
8LIBMAJOR = $(lib$(NAME)_VERSION_MAJOR)
9
c415857d
MR
10vpath %.c $(SRC_DIR)
11vpath %.h $(SRC_DIR)
12vpath %.S $(SRC_DIR)
8b2121e3 13
5671fc14
MR
14ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale
15
722dabcc
DB
16CFLAGS += $(CFLAGS-yes)
17OBJS += $(OBJS-yes)
18ASM_OBJS += $(ASM_OBJS-yes)
2d93bcc7 19CPP_OBJS += $(CPP_OBJS-yes)
5671fc14 20FFLIBS += $(FFLIBS-yes)
722dabcc 21
dadb850a
DB
22CFLAGS += -DHAVE_AV_CONFIG_H -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \
23 -D_ISOC9X_SOURCE -I$(BUILD_ROOT) -I$(SRC_PATH) \
5671fc14
MR
24 $(addprefix -I$(SRC_PATH)/lib,$(ALLFFLIBS)) $(OPTFLAGS)
25
26EXTRALIBS := $(addprefix -l,$(addsuffix $(BUILDSUF),$(FFLIBS))) $(EXTRALIBS)
27LDFLAGS := $(addprefix -L$(BUILD_ROOT)/lib,$(FFLIBS)) $(LDFLAGS)
1963f5e3 28
1540cfdc 29SRCS := $(OBJS:.o=.c) $(ASM_OBJS:.o=.S) $(CPPOBJS:.o=.cpp)
8b2121e3 30OBJS := $(OBJS) $(ASM_OBJS) $(CPPOBJS)
8b2121e3 31
24743a76 32all: $(LIBNAME) $(SLIBNAME)
8b2121e3 33
582c1c47 34$(LIBNAME): $(OBJS)
8b2121e3
MR
35 rm -f $@
36 $(AR) rc $@ $^ $(EXTRAOBJS)
37 $(RANLIB) $@
38
baa3a937 39$(SLIBNAME): $(SLIBNAME_WITH_MAJOR)
20369773 40 $(LN_S) $^ $@
baa3a937 41
582c1c47 42$(SLIBNAME_WITH_MAJOR): $(OBJS)
d22e8442 43 $(SLIB_CREATE_DEF_CMD)
8b2121e3 44 $(CC) $(SHFLAGS) $(LDFLAGS) -o $@ $^ $(EXTRALIBS) $(EXTRAOBJS)
5cb854e1 45 $(SLIB_EXTRA_CMD)
8b2121e3
MR
46
47%.o: %.c
48 $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
49
50%.o: %.S
51 $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
52
24743a76 53%: %.o $(LIBNAME)
c6c46511
DB
54 $(CC) $(LDFLAGS) -o $@ $^ $(EXTRALIBS)
55
e4d86a57
MR
56%.ho: %.h
57 $(CC) $(CFLAGS) $(LIBOBJFLAGS) -Wno-unused -c -o $@ -x c $<
58
c415857d 59ALLHEADERS = $(subst $(SRC_DIR)/,,$(wildcard $(SRC_DIR)/*.h))
e4d86a57
MR
60checkheaders: $(filter-out %_template.ho,$(ALLHEADERS:.h=.ho))
61
9d0199f4 62depend dep: $(SRCS)
315c741d 63 $(DEPEND_CMD) > .depend
8b2121e3 64
8b2121e3 65clean::
b8d40825 66 rm -f *.o *~ *.a *.lib *.so *.so.* *.dylib *.dll \
bca9e0bc 67 *.def *.dll.a *.exp *.ho *.map $(TESTS)
8b2121e3
MR
68
69distclean: clean
70 rm -f .depend
71
71fa13e8
DB
72INSTALL_TARGETS-$(BUILD_SHARED) += install-lib-shared
73INSTALL_TARGETS-$(BUILD_STATIC) += install-lib-static
8b2121e3
MR
74
75install: install-libs install-headers
76
71fa13e8 77install-libs: $(INSTALL_TARGETS-yes)
8b2121e3
MR
78
79install-lib-shared: $(SLIBNAME)
22a324da
DB
80 install -d "$(SHLIBDIR)"
81 install -m 755 $(SLIBNAME) "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
82 $(STRIP) "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
83 cd "$(SHLIBDIR)" && \
20369773 84 $(LN_S) $(SLIBNAME_WITH_VERSION) $(SLIBNAME_WITH_MAJOR)
22a324da 85 cd "$(SHLIBDIR)" && \
20369773 86 $(LN_S) $(SLIBNAME_WITH_VERSION) $(SLIBNAME)
8fbec4f4 87 $(SLIB_INSTALL_EXTRA_CMD)
8b2121e3 88
24743a76 89install-lib-static: $(LIBNAME)
22a324da 90 install -d "$(LIBDIR)"
24743a76 91 install -m 644 $(LIBNAME) "$(LIBDIR)"
d7e27559 92 $(LIB_INSTALL_EXTRA_CMD)
8b2121e3 93
76a448ed
MR
94INCINSTDIR = $(INCDIR)/lib$(NAME)
95
8b2121e3 96install-headers:
76a448ed 97 install -d "$(INCINSTDIR)"
22a324da 98 install -d "$(LIBDIR)/pkgconfig"
c415857d 99 install -m 644 $(addprefix "$(SRC_DIR)"/,$(HEADERS)) "$(INCINSTDIR)"
22a324da 100 install -m 644 $(BUILD_ROOT)/lib$(NAME).pc "$(LIBDIR)/pkgconfig"
8b2121e3 101
f9edb717
DB
102uninstall: uninstall-libs uninstall-headers
103
104uninstall-libs:
22a324da
DB
105 -rm -f "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR)" \
106 "$(SHLIBDIR)/$(SLIBNAME)" \
107 "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
5b5d0491 108 -$(SLIB_UNINSTALL_EXTRA_CMD)
24743a76 109 -rm -f "$(LIBDIR)/$(LIBNAME)"
f9edb717 110
fa62bdb8 111uninstall-headers::
76a448ed 112 rm -f $(addprefix "$(INCINSTDIR)/",$(HEADERS))
22a324da 113 rm -f "$(LIBDIR)/pkgconfig/lib$(NAME).pc"
f9edb717 114
bca9e0bc
DB
115tests: $(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
3263626f 121
6ca0c110 122-include .depend