build: remove BUILD_ROOT variable
[libav.git] / common.mak
CommitLineData
8b2121e3
MR
1#
2# common bits used by all libraries
3#
4
451db983
MR
5# first so "all" becomes default target
6all: all-yes
0e32c8c6 7
8e255b8b 8ifndef SUBDIR
6ccf540f
DB
9vpath %.c $(SRC_DIR)
10vpath %.h $(SRC_DIR)
11vpath %.S $(SRC_DIR)
304d586d 12vpath %.asm $(SRC_DIR)
a482e61b 13vpath %.v $(SRC_DIR)
8b2121e3 14
63611f31
MR
15ifndef V
16Q = @
17ECHO = printf "$(1)\t%s\n" $(2)
e0be794a 18BRIEF = CC AS YASM AR LD HOSTCC
de5aba8c 19SILENT = DEPCC YASMDEP RM RANLIB
63611f31 20MSG = $@
7732f641 21M = @$(call ECHO,$(TAG),$@);
63611f31 22$(foreach VAR,$(BRIEF), \
bf9aa44b
MR
23 $(eval override $(VAR) = @$$(call ECHO,$(VAR),$$(MSG)); $($(VAR))))
24$(foreach VAR,$(SILENT),$(eval override $(VAR) = @$($(VAR))))
63611f31
MR
25$(eval INSTALL = @$(call ECHO,INSTALL,$$(^:$(SRC_DIR)/%=%)); $(INSTALL))
26endif
27
737eb597 28ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale
5671fc14 29
798b2646 30IFLAGS := -I. -I$(SRC_PATH)
7f02d357 31CPPFLAGS := $(IFLAGS) $(CPPFLAGS)
8be0a5c3 32CFLAGS += $(ECFLAGS)
55127e7b 33YASMFLAGS += $(IFLAGS) -Pconfig.asm
8b2121e3 34
7f02d357
MR
35HOSTCFLAGS += $(IFLAGS)
36
8b2121e3 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
7732f641 53%.c %.h: TAG = GEN
93bff1de 54
11d788ca
MR
55# Dummy rule to stop make trying to rebuild removed or renamed headers
56%.h:
57 @:
58
71c61f62 59install: install-libs install-headers
451db983 60install-libs: install-libs-yes
7716f7ff 61
d3cb93b3
RP
62uninstall: uninstall-libs uninstall-headers
63
64.PHONY: all depend dep *clean install* uninstall* examples testprogs
f3a572ca
MR
65
66# Disable suffix rules. Most of the builtin rules are suffix rules,
67# so this saves some time on slow systems.
68.SUFFIXES:
1d536203
MR
69
70# Do not delete intermediate files from chains of implicit rules
0680c40a 71$(OBJS):
71c61f62 72endif
8b2121e3 73
c5662879
DB
74OBJS-$(HAVE_MMX) += $(MMX-OBJS-yes)
75
8be0a5c3 76CFLAGS += $(CFLAGS-yes)
6ccf540f
DB
77OBJS += $(OBJS-yes)
78FFLIBS := $(FFLIBS-yes) $(FFLIBS)
79TESTPROGS += $(TESTPROGS-yes)
8b2121e3 80
71c61f62 81FFEXTRALIBS := $(addprefix -l,$(addsuffix $(BUILDSUF),$(FFLIBS))) $(EXTRALIBS)
798b2646 82FFLDFLAGS := $(addprefix -Llib,$(ALLFFLIBS)) $(LDFLAGS)
8b2121e3 83
43a0cb7c 84EXAMPLES := $(addprefix $(SUBDIR),$(addsuffix -example$(EXESUF),$(EXAMPLES)))
7acc0104 85OBJS := $(addprefix $(SUBDIR),$(sort $(OBJS)))
2f97b12e 86TESTOBJS := $(addprefix $(SUBDIR),$(TESTOBJS) $(TESTPROGS:%=%-test.o))
7304c2c4 87TESTPROGS := $(addprefix $(SUBDIR),$(addsuffix -test$(EXESUF),$(TESTPROGS)))
de4070b5
MR
88HOSTOBJS := $(addprefix $(SUBDIR),$(addsuffix .o,$(HOSTPROGS)))
89HOSTPROGS := $(addprefix $(SUBDIR),$(addsuffix $(HOSTEXESUF),$(HOSTPROGS)))
8b2121e3 90
798b2646 91DEP_LIBS := $(foreach NAME,$(FFLIBS),lib$(NAME)/$($(CONFIG_SHARED:yes=S)LIBNAME))
76ca42a8 92
7b5e8a27 93ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h))
f89c1402 94SKIPHEADERS += $(addprefix $(ARCH)/,$(ARCH_HEADERS))
9b55e2e7 95SKIPHEADERS := $(addprefix $(SUBDIR),$(SKIPHEADERS-) $(SKIPHEADERS))
95f2c769 96checkheaders: $(filter-out $(SKIPHEADERS:.h=.ho),$(ALLHEADERS:.h=.ho))
8b2121e3 97
de4070b5
MR
98$(HOSTOBJS): %.o: %.c
99 $(HOSTCC) $(HOSTCFLAGS) -c -o $@ $<
100
101$(HOSTPROGS): %$(HOSTEXESUF): %.o
102 $(HOSTCC) $(HOSTLDFLAGS) -o $@ $< $(HOSTLIBS)
103
a482e61b 104CLEANSUFFIXES = *.d *.o *~ *.ho *.map *.ver
79de9c83 105DISTCLEANSUFFIXES = *.pc
8e8a67fa 106LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp
76a448ed 107
2f97b12e 108-include $(wildcard $(OBJS:.o=.d) $(TESTOBJS:.o=.d))