common.mak 3.24 KB
Newer Older
1 2 3 4
#
# common bits used by all libraries
#

5 6
# first so "all" becomes default target
all: all-yes
7

8
ifndef SUBDIR
Diego Biurrun's avatar
Diego Biurrun committed
9 10 11
vpath %.c   $(SRC_DIR)
vpath %.h   $(SRC_DIR)
vpath %.S   $(SRC_DIR)
Loren Merritt's avatar
Loren Merritt committed
12
vpath %.asm $(SRC_DIR)
13
vpath %.v   $(SRC_DIR)
14

15 16 17 18 19 20
ifeq ($(SRC_DIR),$(SRC_PATH_BARE))
BUILD_ROOT_REL = .
else
BUILD_ROOT_REL = ..
endif

Måns Rullgård's avatar
Måns Rullgård committed
21 22 23 24
ifndef V
Q      = @
ECHO   = printf "$(1)\t%s\n" $(2)
BRIEF  = CC AS YASM AR LD HOSTCC RANLIB STRIP CP
25
SILENT = DEPCC YASMDEP RM
Måns Rullgård's avatar
Måns Rullgård committed
26
MSG    = $@
27
G      = @$(call ECHO,GEN,$@);
28
M      = @$(call ECHO,$(MSG),$@);
Måns Rullgård's avatar
Måns Rullgård committed
29 30 31 32 33 34
$(foreach VAR,$(BRIEF), \
    $(eval $(VAR) = @$$(call ECHO,$(VAR),$$(MSG)); $($(VAR))))
$(foreach VAR,$(SILENT),$(eval $(VAR) = @$($(VAR))))
$(eval INSTALL = @$(call ECHO,INSTALL,$$(^:$(SRC_DIR)/%=%)); $(INSTALL))
endif

35 36
ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale

37
CPPFLAGS := -I$(BUILD_ROOT_REL) -I$(SRC_PATH) $(CPPFLAGS)
38
CFLAGS   += $(ECFLAGS)
39 40

%.o: %.c
41
	$(CCDEP)
42
	$(CC) $(CPPFLAGS) $(CFLAGS) $(CC_DEPFLAGS) -c $(CC_O) $<
43 44

%.o: %.S
45
	$(ASDEP)
46
	$(AS) $(CPPFLAGS) $(ASFLAGS) $(AS_DEPFLAGS) -c -o $@ $<
47

Måns Rullgård's avatar
Måns Rullgård committed
48
%.ho: %.h
49
	$(CC) $(CPPFLAGS) $(CFLAGS) -Wno-unused -c -o $@ -x c $<
Måns Rullgård's avatar
Måns Rullgård committed
50

Måns Rullgård's avatar
Måns Rullgård committed
51 52
%$(EXESUF): %.c

53
%.ver: %.v
Måns Rullgård's avatar
Måns Rullgård committed
54
	$(Q)sed 's/$$MAJOR/$($(basename $(@F))_VERSION_MAJOR)/' $^ > $@
55

56 57 58 59 60
SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
$(BUILD_ROOT_REL)/version.h: $(SVN_ENTRIES)
endif

61
$(BUILD_ROOT_REL)/version.h: $(SRC_PATH_BARE)/version.sh config.mak
62
	$(G)$< $(SRC_PATH) $@ $(EXTRA_VERSION)
63

Måns Rullgård's avatar
Måns Rullgård committed
64
install: install-libs install-headers
65
install-libs: install-libs-yes
66

Ramiro Polla's avatar
Ramiro Polla committed
67 68 69
uninstall: uninstall-libs uninstall-headers

.PHONY: all depend dep *clean install* uninstall* examples testprogs
Måns Rullgård's avatar
Måns Rullgård committed
70 71 72 73

# Disable suffix rules.  Most of the builtin rules are suffix rules,
# so this saves some time on slow systems.
.SUFFIXES:
74 75 76

# Do not delete intermediate files from chains of implicit rules
.SECONDARY:
Måns Rullgård's avatar
Måns Rullgård committed
77
endif
78

79 80
OBJS-$(HAVE_MMX) +=  $(MMX-OBJS-yes)

81
CFLAGS    += $(CFLAGS-yes)
Diego Biurrun's avatar
Diego Biurrun committed
82 83 84
OBJS      += $(OBJS-yes)
FFLIBS    := $(FFLIBS-yes) $(FFLIBS)
TESTPROGS += $(TESTPROGS-yes)
85

Måns Rullgård's avatar
Måns Rullgård committed
86
FFEXTRALIBS := $(addprefix -l,$(addsuffix $(BUILDSUF),$(FFLIBS))) $(EXTRALIBS)
87
FFLDFLAGS   := $(addprefix -L$(BUILD_ROOT)/lib,$(ALLFFLIBS)) $(LDFLAGS)
88

89
EXAMPLES  := $(addprefix $(SUBDIR),$(addsuffix -example$(EXESUF),$(EXAMPLES)))
Måns Rullgård's avatar
Måns Rullgård committed
90
OBJS      := $(addprefix $(SUBDIR),$(sort $(OBJS)))
91
TESTOBJS  := $(addprefix $(SUBDIR),$(TESTOBJS))
92
TESTPROGS := $(addprefix $(SUBDIR),$(addsuffix -test$(EXESUF),$(TESTPROGS)))
93 94
HOSTOBJS  := $(addprefix $(SUBDIR),$(addsuffix .o,$(HOSTPROGS)))
HOSTPROGS := $(addprefix $(SUBDIR),$(addsuffix $(HOSTEXESUF),$(HOSTPROGS)))
95

96
DEP_LIBS := $(foreach NAME,$(FFLIBS),$(BUILD_ROOT_REL)/lib$(NAME)/$($(CONFIG_SHARED:yes=S)LIBNAME))
Måns Rullgård's avatar
Måns Rullgård committed
97

98
ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h))
99
SKIPHEADERS += $(addprefix $(ARCH)/,$(ARCH_HEADERS))
100
SKIPHEADERS := $(addprefix $(SUBDIR),$(SKIPHEADERS-) $(SKIPHEADERS))
101
checkheaders: $(filter-out $(SKIPHEADERS:.h=.ho),$(ALLHEADERS:.h=.ho))
102

103 104 105 106 107 108
$(HOSTOBJS): %.o: %.c
	$(HOSTCC) $(HOSTCFLAGS) -c -o $@ $<

$(HOSTPROGS): %$(HOSTEXESUF): %.o
	$(HOSTCC) $(HOSTLDFLAGS) -o $@ $< $(HOSTLIBS)

109 110
DEPS := $(OBJS:.o=.d)
depend dep: $(DEPS)
111

112
CLEANSUFFIXES     = *.d *.o *~ *.ho *.map *.ver
113
DISTCLEANSUFFIXES = *.pc
114
LIBSUFFIXES       = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp
115

116
-include $(wildcard $(DEPS))