common.mak 2.59 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

20 21
ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale

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

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

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

38 39 40
%.ver: %.v
	sed 's/$$MAJOR/$($(basename $(@F))_VERSION_MAJOR)/' $^ > $@

41 42 43 44 45
SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
$(BUILD_ROOT_REL)/version.h: $(SVN_ENTRIES)
endif

46
$(BUILD_ROOT_REL)/version.h: $(SRC_PATH_BARE)/version.sh config.mak
47
	$< $(SRC_PATH) $@ $(EXTRA_VERSION)
48

Måns Rullgård's avatar
Måns Rullgård committed
49
install: install-libs install-headers
50

Ramiro Polla's avatar
Ramiro Polla committed
51 52 53
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
54 55 56 57

# Disable suffix rules.  Most of the builtin rules are suffix rules,
# so this saves some time on slow systems.
.SUFFIXES:
Måns Rullgård's avatar
Måns Rullgård committed
58
endif
59

60 61
OBJS-$(HAVE_MMX) +=  $(MMX-OBJS-yes)

62
CFLAGS    += $(CFLAGS-yes)
Diego Biurrun's avatar
Diego Biurrun committed
63 64 65
OBJS      += $(OBJS-yes)
FFLIBS    := $(FFLIBS-yes) $(FFLIBS)
TESTPROGS += $(TESTPROGS-yes)
66

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

70
EXAMPLES  := $(addprefix $(SUBDIR),$(addsuffix -example$(EXESUF),$(EXAMPLES)))
Diego Biurrun's avatar
Diego Biurrun committed
71
OBJS      := $(addprefix $(SUBDIR),$(OBJS))
72
TESTPROGS := $(addprefix $(SUBDIR),$(addsuffix -test$(EXESUF),$(TESTPROGS)))
73 74
HOSTOBJS  := $(addprefix $(SUBDIR),$(addsuffix .o,$(HOSTPROGS)))
HOSTPROGS := $(addprefix $(SUBDIR),$(addsuffix $(HOSTEXESUF),$(HOSTPROGS)))
75

76
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
77

78
ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h))
79 80
SKIPHEADERS = $(addprefix $(SUBDIR),$(SKIPHEADERS-))
checkheaders: $(filter-out $(SKIPHEADERS:.h=.ho),$(ALLHEADERS:.h=.ho))
81

82 83 84 85 86 87
$(HOSTOBJS): %.o: %.c
	$(HOSTCC) $(HOSTCFLAGS) -c -o $@ $<

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

88 89
DEPS := $(OBJS:.o=.d)
depend dep: $(DEPS)
90

91
CLEANSUFFIXES     = *.d *.o *~ *.ho *.map *.ver
92
DISTCLEANSUFFIXES = *.pc
93
LIBSUFFIXES       = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp
94

95
-include $(wildcard $(DEPS))