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

13 14 15 16 17 18
ifeq ($(SRC_DIR),$(SRC_PATH_BARE))
BUILD_ROOT_REL = .
else
BUILD_ROOT_REL = ..
endif

19 20
ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale

21
CFLAGS := -DHAVE_AV_CONFIG_H -I$(BUILD_ROOT_REL) -I$(SRC_PATH) $(OPTFLAGS)
22 23 24 25 26

%.o: %.c
	$(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<

%.o: %.S
27
	$(AS) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
28

Måns Rullgård's avatar
Måns Rullgård committed
29 30 31
%.ho: %.h
	$(CC) $(CFLAGS) $(LIBOBJFLAGS) -Wno-unused -c -o $@ -x c $<

32 33 34 35 36 37 38 39 40
%.d: %.c
	$(DEPEND_CMD) > $@

%.d: %.S
	$(DEPEND_CMD) > $@

%.d: %.cpp
	$(DEPEND_CMD) > $@

41 42
%.o: %.d

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

45 46 47 48 49
SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
$(BUILD_ROOT_REL)/version.h: $(SVN_ENTRIES)
endif

50
$(BUILD_ROOT_REL)/version.h: $(SRC_PATH_BARE)/version.sh config.mak
51
	$< $(SRC_PATH) $@ $(EXTRA_VERSION)
52

Måns Rullgård's avatar
Måns Rullgård committed
53
install: install-libs install-headers
54

Måns Rullgård's avatar
Måns Rullgård committed
55
uninstall: uninstall-libs uninstall-headers
56

57
.PHONY: all depend dep *clean install* uninstall* examples testprogs
Måns Rullgård's avatar
Måns Rullgård committed
58
endif
59

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

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

68
EXAMPLES  := $(addprefix $(SUBDIR),$(addsuffix -example$(EXESUF),$(EXAMPLES)))
Diego Biurrun's avatar
Diego Biurrun committed
69
OBJS      := $(addprefix $(SUBDIR),$(OBJS))
70
TESTPROGS := $(addprefix $(SUBDIR),$(addsuffix -test$(EXESUF),$(TESTPROGS)))
71

Diego Biurrun's avatar
Diego Biurrun committed
72
DEP_LIBS := $(foreach NAME,$(FFLIBS),lib$(NAME)/$($(BUILD_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))
Måns Rullgård's avatar
Måns Rullgård committed
75
checkheaders: $(filter-out %_template.ho,$(ALLHEADERS:.h=.ho))
76

77 78
DEPS := $(OBJS:.o=.d)
depend dep: $(DEPS)
79

Diego Biurrun's avatar
Diego Biurrun committed
80
CLEANSUFFIXES     = *.o *~ *.ho
81
DISTCLEANSUFFIXES = *.d *.pc
Diego Biurrun's avatar
Diego Biurrun committed
82
LIBSUFFIXES       = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp *.map
83

84
-include $(DEPS)