common.mak 2.4 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 24

%.o: %.c
25
	$(CCDEP)
26
	$(CC) $(CPPFLAGS) $(CFLAGS) $(CC_DEPFLAGS) -c $(CC_O) $<
27 28

%.o: %.S
29
	$(ASDEP)
30
	$(AS) $(CPPFLAGS) $(ASFLAGS) $(AS_DEPFLAGS) -c -o $@ $<
31

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

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

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

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

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

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

50
.PHONY: all depend dep *clean install* uninstall examples testprogs
Måns Rullgård's avatar
Måns Rullgård committed
51
endif
52

53 54
OBJS-$(HAVE_MMX) +=  $(MMX-OBJS-yes)

Diego Biurrun's avatar
Diego Biurrun committed
55 56 57 58
CFLAGS    += $(CFLAGS-yes)
OBJS      += $(OBJS-yes)
FFLIBS    := $(FFLIBS-yes) $(FFLIBS)
TESTPROGS += $(TESTPROGS-yes)
59

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

63
EXAMPLES  := $(addprefix $(SUBDIR),$(addsuffix -example$(EXESUF),$(EXAMPLES)))
Diego Biurrun's avatar
Diego Biurrun committed
64
OBJS      := $(addprefix $(SUBDIR),$(OBJS))
65
TESTPROGS := $(addprefix $(SUBDIR),$(addsuffix -test$(EXESUF),$(TESTPROGS)))
66 67
HOSTOBJS  := $(addprefix $(SUBDIR),$(addsuffix .o,$(HOSTPROGS)))
HOSTPROGS := $(addprefix $(SUBDIR),$(addsuffix $(HOSTEXESUF),$(HOSTPROGS)))
68

69
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
70

71
ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h))
72 73
SKIPHEADERS = $(addprefix $(SUBDIR),$(SKIPHEADERS-))
checkheaders: $(filter-out $(SKIPHEADERS:.h=.ho),$(ALLHEADERS:.h=.ho))
74

75 76 77 78 79 80
$(HOSTOBJS): %.o: %.c
	$(HOSTCC) $(HOSTCFLAGS) -c -o $@ $<

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

81 82
DEPS := $(OBJS:.o=.d)
depend dep: $(DEPS)
83

84
CLEANSUFFIXES     = *.d *.o *~ *.ho *.map *.ver
85
DISTCLEANSUFFIXES = *.pc
86
LIBSUFFIXES       = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp
87

88
-include $(wildcard $(DEPS))