configure: add test_ldflags function
[libav.git] / common.mak
CommitLineData
8b2121e3
MR
1#
2# common bits used by all libraries
3#
4
71c61f62 5all: # make "all" default target
0e32c8c6 6
8e255b8b 7ifndef SUBDIR
6ccf540f
DB
8vpath %.c $(SRC_DIR)
9vpath %.h $(SRC_DIR)
10vpath %.S $(SRC_DIR)
304d586d 11vpath %.asm $(SRC_DIR)
8b2121e3 12
9e6165b5
MR
13ifeq ($(SRC_DIR),$(SRC_PATH_BARE))
14BUILD_ROOT_REL = .
15else
16BUILD_ROOT_REL = ..
17endif
18
5671fc14
MR
19ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale
20
04a803be 21CPPFLAGS := -DHAVE_AV_CONFIG_H -I$(BUILD_ROOT_REL) -I$(SRC_PATH) $(CPPFLAGS)
8b2121e3
MR
22
23%.o: %.c
07dec06e 24 $(CCDEP)
bce7b696 25 $(CC) $(CPPFLAGS) $(CFLAGS) $(CC_DEPFLAGS) -c $(CC_O) $<
8b2121e3
MR
26
27%.o: %.S
07dec06e 28 $(ASDEP)
bce7b696 29 $(AS) $(CPPFLAGS) $(ASFLAGS) $(AS_DEPFLAGS) -c -o $@ $<
8b2121e3 30
e4d86a57 31%.ho: %.h
bce7b696 32 $(CC) $(CPPFLAGS) $(CFLAGS) -Wno-unused -c -o $@ -x c $<
e4d86a57 33
bf237413
MR
34%$(EXESUF): %.c
35
9e6165b5
MR
36SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
37ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
38$(BUILD_ROOT_REL)/version.h: $(SVN_ENTRIES)
39endif
40
873b0923 41$(BUILD_ROOT_REL)/version.h: $(SRC_PATH_BARE)/version.sh config.mak
1db2c5c9 42 $< $(SRC_PATH) $@ $(EXTRA_VERSION)
9e6165b5 43
71c61f62 44install: install-libs install-headers
7716f7ff 45
93fe7eb6 46.PHONY: all depend dep *clean install* uninstall examples testprogs
71c61f62 47endif
8b2121e3 48
c5662879
DB
49OBJS-$(HAVE_MMX) += $(MMX-OBJS-yes)
50
6ccf540f
DB
51CFLAGS += $(CFLAGS-yes)
52OBJS += $(OBJS-yes)
53FFLIBS := $(FFLIBS-yes) $(FFLIBS)
54TESTPROGS += $(TESTPROGS-yes)
8b2121e3 55
71c61f62 56FFEXTRALIBS := $(addprefix -l,$(addsuffix $(BUILDSUF),$(FFLIBS))) $(EXTRALIBS)
bdc2cc16 57FFLDFLAGS := $(addprefix -L$(BUILD_ROOT)/lib,$(ALLFFLIBS)) $(LDFLAGS)
8b2121e3 58
43a0cb7c 59EXAMPLES := $(addprefix $(SUBDIR),$(addsuffix -example$(EXESUF),$(EXAMPLES)))
6ccf540f 60OBJS := $(addprefix $(SUBDIR),$(OBJS))
7304c2c4 61TESTPROGS := $(addprefix $(SUBDIR),$(addsuffix -test$(EXESUF),$(TESTPROGS)))
de4070b5
MR
62HOSTOBJS := $(addprefix $(SUBDIR),$(addsuffix .o,$(HOSTPROGS)))
63HOSTPROGS := $(addprefix $(SUBDIR),$(addsuffix $(HOSTEXESUF),$(HOSTPROGS)))
8b2121e3 64
bea81a52 65DEP_LIBS := $(foreach NAME,$(FFLIBS),$(BUILD_ROOT_REL)/lib$(NAME)/$($(CONFIG_SHARED:yes=S)LIBNAME))
76ca42a8 66
7b5e8a27 67ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h))
95f2c769
MR
68SKIPHEADERS = $(addprefix $(SUBDIR),$(SKIPHEADERS-))
69checkheaders: $(filter-out $(SKIPHEADERS:.h=.ho),$(ALLHEADERS:.h=.ho))
8b2121e3 70
de4070b5
MR
71$(HOSTOBJS): %.o: %.c
72 $(HOSTCC) $(HOSTCFLAGS) -c -o $@ $<
73
74$(HOSTPROGS): %$(HOSTEXESUF): %.o
75 $(HOSTCC) $(HOSTLDFLAGS) -o $@ $< $(HOSTLIBS)
76
caec74dd
MR
77DEPS := $(OBJS:.o=.d)
78depend dep: $(DEPS)
8b2121e3 79
79de9c83
MR
80CLEANSUFFIXES = *.d *.o *~ *.ho *.map
81DISTCLEANSUFFIXES = *.pc
8e8a67fa 82LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp
76a448ed 83
c1c3933a 84-include $(wildcard $(DEPS))