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

Måns Rullgård's avatar
Måns Rullgård committed
5
all: # make "all" default target
6

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

14 15 16 17 18 19
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
20 21 22 23
ifndef V
Q      = @
ECHO   = printf "$(1)\t%s\n" $(2)
BRIEF  = CC AS YASM AR LD HOSTCC RANLIB STRIP CP
24
SILENT = DEPCC YASMDEP RM
Måns Rullgård's avatar
Måns Rullgård committed
25 26 27 28 29 30 31
MSG    = $@
$(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

32 33
ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale

34
CPPFLAGS := -I$(BUILD_ROOT_REL) -I$(SRC_PATH) $(CPPFLAGS)
35
CFLAGS   += $(ECFLAGS)
36 37

%.o: %.c
38
	$(CCDEP)
39
	$(CC) $(CPPFLAGS) $(CFLAGS) $(CC_DEPFLAGS) -c $(CC_O) $<
40 41

%.o: %.S
42
	$(ASDEP)
43
	$(AS) $(CPPFLAGS) $(ASFLAGS) $(AS_DEPFLAGS) -c -o $@ $<
44

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

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

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

53 54 55 56 57
SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
$(BUILD_ROOT_REL)/version.h: $(SVN_ENTRIES)
endif

58
$(BUILD_ROOT_REL)/version.h: $(SRC_PATH_BARE)/version.sh config.mak
59
	$< $(SRC_PATH) $@ $(EXTRA_VERSION)
60

Måns Rullgård's avatar
Måns Rullgård committed
61
install: install-libs install-headers
62

Ramiro Polla's avatar
Ramiro Polla committed
63 64 65
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
66 67 68 69

# Disable suffix rules.  Most of the builtin rules are suffix rules,
# so this saves some time on slow systems.
.SUFFIXES:
70 71 72

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

75 76
OBJS-$(HAVE_MMX) +=  $(MMX-OBJS-yes)

77
CFLAGS    += $(CFLAGS-yes)
Diego Biurrun's avatar
Diego Biurrun committed
78 79 80
OBJS      += $(OBJS-yes)
FFLIBS    := $(FFLIBS-yes) $(FFLIBS)
TESTPROGS += $(TESTPROGS-yes)
81

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

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

92
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
93

94
ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h))
95
SKIPHEADERS += $(addprefix $(ARCH)/,$(ARCH_HEADERS))
96
SKIPHEADERS := $(addprefix $(SUBDIR),$(SKIPHEADERS-) $(SKIPHEADERS))
97
checkheaders: $(filter-out $(SKIPHEADERS:.h=.ho),$(ALLHEADERS:.h=.ho))
98

99 100 101 102 103 104
$(HOSTOBJS): %.o: %.c
	$(HOSTCC) $(HOSTCFLAGS) -c -o $@ $<

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

105 106
DEPS := $(OBJS:.o=.d)
depend dep: $(DEPS)
107

108
CLEANSUFFIXES     = *.d *.o *~ *.ho *.map *.ver
109
DISTCLEANSUFFIXES = *.pc
110
LIBSUFFIXES       = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp
111

112
-include $(wildcard $(DEPS))