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

Ramiro Polla's avatar
Ramiro Polla committed
50 51 52
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
53
endif
54

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

Måns Rullgård's avatar
Måns Rullgård committed
57
CFLAGS    += $(CFLAGS-yes) $(ECFLAGS)
Diego Biurrun's avatar
Diego Biurrun committed
58 59 60
OBJS      += $(OBJS-yes)
FFLIBS    := $(FFLIBS-yes) $(FFLIBS)
TESTPROGS += $(TESTPROGS-yes)
61

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

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

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

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

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

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

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

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

90
-include $(wildcard $(DEPS))