common.mak 2.05 KB
Newer Older
1 2 3 4
#
# common bits used by all libraries
#

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

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

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

53
install: install-libs install-headers
54

55
uninstall: uninstall-libs uninstall-headers
56

57
.PHONY: all depend dep *clean install* uninstall* examples testprogs
58
endif
59

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

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

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
DEP_LIBS := $(foreach NAME,$(FFLIBS),$(BUILD_ROOT_REL)/lib$(NAME)/$($(BUILD_SHARED:yes=S)LIBNAME))
75

76
ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h))
77
checkheaders: $(filter-out %_template.ho,$(ALLHEADERS:.h=.ho))
78

79 80
DEPS := $(OBJS:.o=.d)
depend dep: $(DEPS)
81

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

86
-include $(DEPS)