Move some make rules outside of eval'd block
[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)
a482e61b 12vpath %.v $(SRC_DIR)
8b2121e3 13
9e6165b5
MR
14ifeq ($(SRC_DIR),$(SRC_PATH_BARE))
15BUILD_ROOT_REL = .
16else
17BUILD_ROOT_REL = ..
18endif
19
63611f31
MR
20ifndef V
21Q = @
22ECHO = printf "$(1)\t%s\n" $(2)
23BRIEF = CC AS YASM AR LD HOSTCC RANLIB STRIP CP
a0ac9501 24SILENT = DEPCC YASMDEP RM
63611f31
MR
25MSG = $@
26$(foreach VAR,$(BRIEF), \
27 $(eval $(VAR) = @$$(call ECHO,$(VAR),$$(MSG)); $($(VAR))))
28$(foreach VAR,$(SILENT),$(eval $(VAR) = @$($(VAR))))
29$(eval INSTALL = @$(call ECHO,INSTALL,$$(^:$(SRC_DIR)/%=%)); $(INSTALL))
30endif
31
5671fc14
MR
32ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale
33
72c2bdeb 34CPPFLAGS := -I$(BUILD_ROOT_REL) -I$(SRC_PATH) $(CPPFLAGS)
8be0a5c3 35CFLAGS += $(ECFLAGS)
8b2121e3
MR
36
37%.o: %.c
07dec06e 38 $(CCDEP)
bce7b696 39 $(CC) $(CPPFLAGS) $(CFLAGS) $(CC_DEPFLAGS) -c $(CC_O) $<
8b2121e3
MR
40
41%.o: %.S
07dec06e 42 $(ASDEP)
bce7b696 43 $(AS) $(CPPFLAGS) $(ASFLAGS) $(AS_DEPFLAGS) -c -o $@ $<
8b2121e3 44
e4d86a57 45%.ho: %.h
bce7b696 46 $(CC) $(CPPFLAGS) $(CFLAGS) -Wno-unused -c -o $@ -x c $<
e4d86a57 47
bf237413
MR
48%$(EXESUF): %.c
49
a482e61b 50%.ver: %.v
63611f31 51 $(Q)sed 's/$$MAJOR/$($(basename $(@F))_VERSION_MAJOR)/' $^ > $@
a482e61b 52
9e6165b5
MR
53SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
54ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
55$(BUILD_ROOT_REL)/version.h: $(SVN_ENTRIES)
56endif
57
873b0923 58$(BUILD_ROOT_REL)/version.h: $(SRC_PATH_BARE)/version.sh config.mak
1db2c5c9 59 $< $(SRC_PATH) $@ $(EXTRA_VERSION)
9e6165b5 60
71c61f62 61install: install-libs install-headers
7716f7ff 62
d3cb93b3
RP
63uninstall: uninstall-libs uninstall-headers
64
65.PHONY: all depend dep *clean install* uninstall* examples testprogs
f3a572ca
MR
66
67# Disable suffix rules. Most of the builtin rules are suffix rules,
68# so this saves some time on slow systems.
69.SUFFIXES:
1d536203
MR
70
71# Do not delete intermediate files from chains of implicit rules
72.SECONDARY:
71c61f62 73endif
8b2121e3 74
c5662879
DB
75OBJS-$(HAVE_MMX) += $(MMX-OBJS-yes)
76
8be0a5c3 77CFLAGS += $(CFLAGS-yes)
6ccf540f
DB
78OBJS += $(OBJS-yes)
79FFLIBS := $(FFLIBS-yes) $(FFLIBS)
80TESTPROGS += $(TESTPROGS-yes)
8b2121e3 81
71c61f62 82FFEXTRALIBS := $(addprefix -l,$(addsuffix $(BUILDSUF),$(FFLIBS))) $(EXTRALIBS)
bdc2cc16 83FFLDFLAGS := $(addprefix -L$(BUILD_ROOT)/lib,$(ALLFFLIBS)) $(LDFLAGS)
8b2121e3 84
43a0cb7c 85EXAMPLES := $(addprefix $(SUBDIR),$(addsuffix -example$(EXESUF),$(EXAMPLES)))
7acc0104 86OBJS := $(addprefix $(SUBDIR),$(sort $(OBJS)))
2a5500b1 87TESTOBJS := $(addprefix $(SUBDIR),$(TESTOBJS))
7304c2c4 88TESTPROGS := $(addprefix $(SUBDIR),$(addsuffix -test$(EXESUF),$(TESTPROGS)))
de4070b5
MR
89HOSTOBJS := $(addprefix $(SUBDIR),$(addsuffix .o,$(HOSTPROGS)))
90HOSTPROGS := $(addprefix $(SUBDIR),$(addsuffix $(HOSTEXESUF),$(HOSTPROGS)))
8b2121e3 91
bea81a52 92DEP_LIBS := $(foreach NAME,$(FFLIBS),$(BUILD_ROOT_REL)/lib$(NAME)/$($(CONFIG_SHARED:yes=S)LIBNAME))
76ca42a8 93
7b5e8a27 94ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h))
f89c1402 95SKIPHEADERS += $(addprefix $(ARCH)/,$(ARCH_HEADERS))
9b55e2e7 96SKIPHEADERS := $(addprefix $(SUBDIR),$(SKIPHEADERS-) $(SKIPHEADERS))
95f2c769 97checkheaders: $(filter-out $(SKIPHEADERS:.h=.ho),$(ALLHEADERS:.h=.ho))
8b2121e3 98
de4070b5
MR
99$(HOSTOBJS): %.o: %.c
100 $(HOSTCC) $(HOSTCFLAGS) -c -o $@ $<
101
102$(HOSTPROGS): %$(HOSTEXESUF): %.o
103 $(HOSTCC) $(HOSTLDFLAGS) -o $@ $< $(HOSTLIBS)
104
caec74dd
MR
105DEPS := $(OBJS:.o=.d)
106depend dep: $(DEPS)
8b2121e3 107
a482e61b 108CLEANSUFFIXES = *.d *.o *~ *.ho *.map *.ver
79de9c83 109DISTCLEANSUFFIXES = *.pc
8e8a67fa 110LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp
76a448ed 111
c1c3933a 112-include $(wildcard $(DEPS))