common.mak 2.46 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
endif
55

56 57
OBJS-$(HAVE_MMX) +=  $(MMX-OBJS-yes)

58
CFLAGS    += $(CFLAGS-yes)
Diego Biurrun's avatar
Diego Biurrun committed
59 60 61
OBJS      += $(OBJS-yes)
FFLIBS    := $(FFLIBS-yes) $(FFLIBS)
TESTPROGS += $(TESTPROGS-yes)
62

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

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

72
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
73

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

78 79 80 81 82 83
$(HOSTOBJS): %.o: %.c
	$(HOSTCC) $(HOSTCFLAGS) -c -o $@ $<

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

84 85
DEPS := $(OBJS:.o=.d)
depend dep: $(DEPS)
86

87
CLEANSUFFIXES     = *.d *.o *~ *.ho *.map *.ver
88
DISTCLEANSUFFIXES = *.pc
89
LIBSUFFIXES       = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp
90

91
-include $(wildcard $(DEPS))