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

mru's avatar
mru committed
5 6
# first so "all" becomes default target
all: all-yes
mru's avatar
mru committed
7

mru's avatar
mru committed
8
ifndef SUBDIR
diego's avatar
diego committed
9 10 11
vpath %.c   $(SRC_DIR)
vpath %.h   $(SRC_DIR)
vpath %.S   $(SRC_DIR)
lorenm's avatar
lorenm committed
12
vpath %.asm $(SRC_DIR)
13
vpath %.v   $(SRC_DIR)
14

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

mru's avatar
mru committed
21 22 23 24
ifndef V
Q      = @
ECHO   = printf "$(1)\t%s\n" $(2)
BRIEF  = CC AS YASM AR LD HOSTCC RANLIB STRIP CP
25
SILENT = DEPCC YASMDEP RM
mru's avatar
mru committed
26
MSG    = $@
27
M      = @$(call ECHO,$(TAG),$@);
mru's avatar
mru committed
28 29 30 31 32 33
$(foreach VAR,$(BRIEF), \
    $(eval $(VAR) = @$$(call ECHO,$(VAR),$$(MSG)); $($(VAR))))
$(foreach VAR,$(SILENT),$(eval $(VAR) = @$($(VAR))))
$(eval INSTALL = @$(call ECHO,INSTALL,$$(^:$(SRC_DIR)/%=%)); $(INSTALL))
endif

34 35
ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale

36
CPPFLAGS := -I$(BUILD_ROOT_REL) -I$(SRC_PATH) $(CPPFLAGS)
37
CFLAGS   += $(ECFLAGS)
38 39

%.o: %.c
40
	$(CCDEP)
41
	$(CC) $(CPPFLAGS) $(CFLAGS) $(CC_DEPFLAGS) -c $(CC_O) $<
42 43

%.o: %.S
44
	$(ASDEP)
45
	$(AS) $(CPPFLAGS) $(ASFLAGS) $(AS_DEPFLAGS) -c -o $@ $<
46

mru's avatar
mru committed
47
%.ho: %.h
48
	$(CC) $(CPPFLAGS) $(CFLAGS) -Wno-unused -c -o $@ -x c $<
mru's avatar
mru committed
49

mru's avatar
mru committed
50 51
%$(EXESUF): %.c

52
%.ver: %.v
mru's avatar
mru committed
53
	$(Q)sed 's/$$MAJOR/$($(basename $(@F))_VERSION_MAJOR)/' $^ > $@
54

55
%.c %.h: TAG = GEN
56

mru's avatar
mru committed
57
install: install-libs install-headers
mru's avatar
mru committed
58
install-libs: install-libs-yes
59

ramiro's avatar
ramiro committed
60 61 62
uninstall: uninstall-libs uninstall-headers

.PHONY: all depend dep *clean install* uninstall* examples testprogs
mru's avatar
mru committed
63 64 65 66

# Disable suffix rules.  Most of the builtin rules are suffix rules,
# so this saves some time on slow systems.
.SUFFIXES:
67 68

# Do not delete intermediate files from chains of implicit rules
mru's avatar
mru committed
69
$(OBJS):
mru's avatar
mru committed
70
endif
71

72 73
OBJS-$(HAVE_MMX) +=  $(MMX-OBJS-yes)

74
CFLAGS    += $(CFLAGS-yes)
diego's avatar
diego committed
75 76 77
OBJS      += $(OBJS-yes)
FFLIBS    := $(FFLIBS-yes) $(FFLIBS)
TESTPROGS += $(TESTPROGS-yes)
78

mru's avatar
mru committed
79
FFEXTRALIBS := $(addprefix -l,$(addsuffix $(BUILDSUF),$(FFLIBS))) $(EXTRALIBS)
mru's avatar
mru committed
80
FFLDFLAGS   := $(addprefix -L$(BUILD_ROOT)/lib,$(ALLFFLIBS)) $(LDFLAGS)
81

82
EXAMPLES  := $(addprefix $(SUBDIR),$(addsuffix -example$(EXESUF),$(EXAMPLES)))
mru's avatar
mru committed
83
OBJS      := $(addprefix $(SUBDIR),$(sort $(OBJS)))
84
TESTOBJS  := $(addprefix $(SUBDIR),$(TESTOBJS))
85
TESTPROGS := $(addprefix $(SUBDIR),$(addsuffix -test$(EXESUF),$(TESTPROGS)))
86 87
HOSTOBJS  := $(addprefix $(SUBDIR),$(addsuffix .o,$(HOSTPROGS)))
HOSTPROGS := $(addprefix $(SUBDIR),$(addsuffix $(HOSTEXESUF),$(HOSTPROGS)))
88

89
DEP_LIBS := $(foreach NAME,$(FFLIBS),$(BUILD_ROOT_REL)/lib$(NAME)/$($(CONFIG_SHARED:yes=S)LIBNAME))
mru's avatar
mru committed
90

91
ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h))
92
SKIPHEADERS += $(addprefix $(ARCH)/,$(ARCH_HEADERS))
93
SKIPHEADERS := $(addprefix $(SUBDIR),$(SKIPHEADERS-) $(SKIPHEADERS))
94
checkheaders: $(filter-out $(SKIPHEADERS:.h=.ho),$(ALLHEADERS:.h=.ho))
95

96 97 98 99 100 101
$(HOSTOBJS): %.o: %.c
	$(HOSTCC) $(HOSTCFLAGS) -c -o $@ $<

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

102 103
DEPS := $(OBJS:.o=.d)
depend dep: $(DEPS)
104

105
CLEANSUFFIXES     = *.d *.o *~ *.ho *.map *.ver
mru's avatar
mru committed
106
DISTCLEANSUFFIXES = *.pc
107
LIBSUFFIXES       = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp
108

109
-include $(wildcard $(DEPS))