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

5 6
# first so "all" becomes default target
all: all-yes
7

8
ifndef SUBDIR
Diego Biurrun's avatar
Diego Biurrun committed
9 10 11
vpath %.c   $(SRC_DIR)
vpath %.h   $(SRC_DIR)
vpath %.S   $(SRC_DIR)
Loren Merritt's avatar
Loren Merritt 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

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

Stefano Sabatini's avatar
Stefano Sabatini committed
34
ALLFFLIBS = avcodec avcore avdevice avfilter avformat avutil postproc swscale
35

Måns Rullgård's avatar
Måns Rullgård committed
36 37
IFLAGS   := -I$(BUILD_ROOT_REL) -I$(SRC_PATH)
CPPFLAGS := $(IFLAGS) $(CPPFLAGS)
38
CFLAGS   += $(ECFLAGS)
39

Måns Rullgård's avatar
Måns Rullgård committed
40 41
HOSTCFLAGS += $(IFLAGS)

42
%.o: %.c
43
	$(CCDEP)
44
	$(CC) $(CPPFLAGS) $(CFLAGS) $(CC_DEPFLAGS) -c $(CC_O) $<
45 46

%.o: %.S
47
	$(ASDEP)
48
	$(AS) $(CPPFLAGS) $(ASFLAGS) $(AS_DEPFLAGS) -c -o $@ $<
49

Måns Rullgård's avatar
Måns Rullgård committed
50
%.ho: %.h
51
	$(CC) $(CPPFLAGS) $(CFLAGS) -Wno-unused -c -o $@ -x c $<
Måns Rullgård's avatar
Måns Rullgård committed
52

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

55
%.ver: %.v
Måns Rullgård's avatar
Måns Rullgård committed
56
	$(Q)sed 's/$$MAJOR/$($(basename $(@F))_VERSION_MAJOR)/' $^ > $@
57

58
%.c %.h: TAG = GEN
59

60 61 62 63
# Dummy rule to stop make trying to rebuild removed or renamed headers
%.h:
	@:

Måns Rullgård's avatar
Måns Rullgård committed
64
install: install-libs install-headers
65
install-libs: install-libs-yes
66

Ramiro Polla's avatar
Ramiro Polla committed
67 68 69
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
70 71 72 73

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

# Do not delete intermediate files from chains of implicit rules
Måns Rullgård's avatar
Måns Rullgård committed
76
$(OBJS):
Måns Rullgård's avatar
Måns Rullgård committed
77
endif
78

79 80
OBJS-$(HAVE_MMX) +=  $(MMX-OBJS-yes)

81
CFLAGS    += $(CFLAGS-yes)
Diego Biurrun's avatar
Diego Biurrun committed
82 83 84
OBJS      += $(OBJS-yes)
FFLIBS    := $(FFLIBS-yes) $(FFLIBS)
TESTPROGS += $(TESTPROGS-yes)
85

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

89
EXAMPLES  := $(addprefix $(SUBDIR),$(addsuffix -example$(EXESUF),$(EXAMPLES)))
Måns Rullgård's avatar
Måns Rullgård committed
90
OBJS      := $(addprefix $(SUBDIR),$(sort $(OBJS)))
91
TESTOBJS  := $(addprefix $(SUBDIR),$(TESTOBJS))
92
TESTPROGS := $(addprefix $(SUBDIR),$(addsuffix -test$(EXESUF),$(TESTPROGS)))
93 94
HOSTOBJS  := $(addprefix $(SUBDIR),$(addsuffix .o,$(HOSTPROGS)))
HOSTPROGS := $(addprefix $(SUBDIR),$(addsuffix $(HOSTEXESUF),$(HOSTPROGS)))
95

96
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
97

98
ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h))
99
SKIPHEADERS += $(addprefix $(ARCH)/,$(ARCH_HEADERS))
100
SKIPHEADERS := $(addprefix $(SUBDIR),$(SKIPHEADERS-) $(SKIPHEADERS))
101
checkheaders: $(filter-out $(SKIPHEADERS:.h=.ho),$(ALLHEADERS:.h=.ho))
102

103 104 105 106 107 108
$(HOSTOBJS): %.o: %.c
	$(HOSTCC) $(HOSTCFLAGS) -c -o $@ $<

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

109 110
DEPS := $(OBJS:.o=.d)
depend dep: $(DEPS)
111

112
CLEANSUFFIXES     = *.d *.o *~ *.ho *.map *.ver
113
DISTCLEANSUFFIXES = *.pc
114
LIBSUFFIXES       = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp
115

116
-include $(wildcard $(DEPS))