Split install-headers target and simplify rules
[libav.git] / common.mak
1 #
2 # common bits used by all libraries
3 #
4
5 all: # make "all" default target
6
7 ifndef SUBDIR
8 vpath %.c $(SRC_DIR)
9 vpath %.h $(SRC_DIR)
10 vpath %.S $(SRC_DIR)
11 vpath %.asm $(SRC_DIR)
12 vpath %.v $(SRC_DIR)
13
14 ifeq ($(SRC_DIR),$(SRC_PATH_BARE))
15 BUILD_ROOT_REL = .
16 else
17 BUILD_ROOT_REL = ..
18 endif
19
20 ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale
21
22 CPPFLAGS := -DHAVE_AV_CONFIG_H -I$(BUILD_ROOT_REL) -I$(SRC_PATH) $(CPPFLAGS)
23 CFLAGS += $(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
41 SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
42 ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
43 $(BUILD_ROOT_REL)/version.h: $(SVN_ENTRIES)
44 endif
45
46 $(BUILD_ROOT_REL)/version.h: $(SRC_PATH_BARE)/version.sh config.mak
47 $< $(SRC_PATH) $@ $(EXTRA_VERSION)
48
49 install: install-libs install-headers
50
51 uninstall: 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:
61 endif
62
63 OBJS-$(HAVE_MMX) += $(MMX-OBJS-yes)
64
65 CFLAGS += $(CFLAGS-yes)
66 OBJS += $(OBJS-yes)
67 FFLIBS := $(FFLIBS-yes) $(FFLIBS)
68 TESTPROGS += $(TESTPROGS-yes)
69
70 FFEXTRALIBS := $(addprefix -l,$(addsuffix $(BUILDSUF),$(FFLIBS))) $(EXTRALIBS)
71 FFLDFLAGS := $(addprefix -L$(BUILD_ROOT)/lib,$(ALLFFLIBS)) $(LDFLAGS)
72
73 EXAMPLES := $(addprefix $(SUBDIR),$(addsuffix -example$(EXESUF),$(EXAMPLES)))
74 OBJS := $(addprefix $(SUBDIR),$(OBJS))
75 TESTPROGS := $(addprefix $(SUBDIR),$(addsuffix -test$(EXESUF),$(TESTPROGS)))
76 HOSTOBJS := $(addprefix $(SUBDIR),$(addsuffix .o,$(HOSTPROGS)))
77 HOSTPROGS := $(addprefix $(SUBDIR),$(addsuffix $(HOSTEXESUF),$(HOSTPROGS)))
78
79 DEP_LIBS := $(foreach NAME,$(FFLIBS),$(BUILD_ROOT_REL)/lib$(NAME)/$($(CONFIG_SHARED:yes=S)LIBNAME))
80
81 ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h))
82 SKIPHEADERS = $(addprefix $(SUBDIR),$(SKIPHEADERS-))
83 checkheaders: $(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
91 DEPS := $(OBJS:.o=.d)
92 depend dep: $(DEPS)
93
94 CLEANSUFFIXES = *.d *.o *~ *.ho *.map *.ver
95 DISTCLEANSUFFIXES = *.pc
96 LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp
97
98 -include $(wildcard $(DEPS))