Split install-headers target and simplify rules
[libav.git] / common.mak
... / ...
CommitLineData
1#
2# common bits used by all libraries
3#
4
5all: # make "all" default target
6
7ifndef SUBDIR
8vpath %.c $(SRC_DIR)
9vpath %.h $(SRC_DIR)
10vpath %.S $(SRC_DIR)
11vpath %.asm $(SRC_DIR)
12vpath %.v $(SRC_DIR)
13
14ifeq ($(SRC_DIR),$(SRC_PATH_BARE))
15BUILD_ROOT_REL = .
16else
17BUILD_ROOT_REL = ..
18endif
19
20ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale
21
22CPPFLAGS := -DHAVE_AV_CONFIG_H -I$(BUILD_ROOT_REL) -I$(SRC_PATH) $(CPPFLAGS)
23CFLAGS += $(ECFLAGS)
24
25%.o: %.c
26 $(CCDEP)
27 $(CC) $(CPPFLAGS) $(CFLAGS) $(CC_DEPFLAGS) -c $(CC_O) $<
28
29%.o: %.S
30 $(ASDEP)
31 $(AS) $(CPPFLAGS) $(ASFLAGS) $(AS_DEPFLAGS) -c -o $@ $<
32
33%.ho: %.h
34 $(CC) $(CPPFLAGS) $(CFLAGS) -Wno-unused -c -o $@ -x c $<
35
36%$(EXESUF): %.c
37
38%.ver: %.v
39 sed 's/$$MAJOR/$($(basename $(@F))_VERSION_MAJOR)/' $^ > $@
40
41SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
42ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
43$(BUILD_ROOT_REL)/version.h: $(SVN_ENTRIES)
44endif
45
46$(BUILD_ROOT_REL)/version.h: $(SRC_PATH_BARE)/version.sh config.mak
47 $< $(SRC_PATH) $@ $(EXTRA_VERSION)
48
49install: install-libs install-headers
50
51uninstall: uninstall-libs uninstall-headers
52
53.PHONY: all depend dep *clean install* uninstall* examples testprogs
54
55# Disable suffix rules. Most of the builtin rules are suffix rules,
56# so this saves some time on slow systems.
57.SUFFIXES:
58
59# Do not delete intermediate files from chains of implicit rules
60.SECONDARY:
61endif
62
63OBJS-$(HAVE_MMX) += $(MMX-OBJS-yes)
64
65CFLAGS += $(CFLAGS-yes)
66OBJS += $(OBJS-yes)
67FFLIBS := $(FFLIBS-yes) $(FFLIBS)
68TESTPROGS += $(TESTPROGS-yes)
69
70FFEXTRALIBS := $(addprefix -l,$(addsuffix $(BUILDSUF),$(FFLIBS))) $(EXTRALIBS)
71FFLDFLAGS := $(addprefix -L$(BUILD_ROOT)/lib,$(ALLFFLIBS)) $(LDFLAGS)
72
73EXAMPLES := $(addprefix $(SUBDIR),$(addsuffix -example$(EXESUF),$(EXAMPLES)))
74OBJS := $(addprefix $(SUBDIR),$(OBJS))
75TESTPROGS := $(addprefix $(SUBDIR),$(addsuffix -test$(EXESUF),$(TESTPROGS)))
76HOSTOBJS := $(addprefix $(SUBDIR),$(addsuffix .o,$(HOSTPROGS)))
77HOSTPROGS := $(addprefix $(SUBDIR),$(addsuffix $(HOSTEXESUF),$(HOSTPROGS)))
78
79DEP_LIBS := $(foreach NAME,$(FFLIBS),$(BUILD_ROOT_REL)/lib$(NAME)/$($(CONFIG_SHARED:yes=S)LIBNAME))
80
81ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h))
82SKIPHEADERS = $(addprefix $(SUBDIR),$(SKIPHEADERS-))
83checkheaders: $(filter-out $(SKIPHEADERS:.h=.ho),$(ALLHEADERS:.h=.ho))
84
85$(HOSTOBJS): %.o: %.c
86 $(HOSTCC) $(HOSTCFLAGS) -c -o $@ $<
87
88$(HOSTPROGS): %$(HOSTEXESUF): %.o
89 $(HOSTCC) $(HOSTLDFLAGS) -o $@ $< $(HOSTLIBS)
90
91DEPS := $(OBJS:.o=.d)
92depend dep: $(DEPS)
93
94CLEANSUFFIXES = *.d *.o *~ *.ho *.map *.ver
95DISTCLEANSUFFIXES = *.pc
96LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp
97
98-include $(wildcard $(DEPS))