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

Måns Rullgård's avatar
Måns Rullgård committed
15 16 17
ifndef V
Q      = @
ECHO   = printf "$(1)\t%s\n" $(2)
18
BRIEF  = CC AS YASM AR LD HOSTCC
19
SILENT = DEPCC YASMDEP RM RANLIB
Måns Rullgård's avatar
Måns Rullgård committed
20
MSG    = $@
21
M      = @$(call ECHO,$(TAG),$@);
Måns Rullgård's avatar
Måns Rullgård committed
22
$(foreach VAR,$(BRIEF), \
23 24
    $(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
25 26 27
$(eval INSTALL = @$(call ECHO,INSTALL,$$(^:$(SRC_DIR)/%=%)); $(INSTALL))
endif

28
ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale
29

30
IFLAGS   := -I. -I$(SRC_PATH)
Måns Rullgård's avatar
Måns Rullgård committed
31
CPPFLAGS := $(IFLAGS) $(CPPFLAGS)
32
CFLAGS   += $(ECFLAGS)
33
YASMFLAGS += $(IFLAGS) -Pconfig.asm
34

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

37
%.o: %.c
38
	$(CCDEP)
39
	$(CC) $(CPPFLAGS) $(CFLAGS) $(CC_DEPFLAGS) -c $(CC_O) $<
40 41

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

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

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

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

53
%.c %.h: TAG = GEN
54

55 56 57 58
# Dummy rule to stop make trying to rebuild removed or renamed headers
%.h:
	@:

Måns Rullgård's avatar
Måns Rullgård committed
59
install: install-libs install-headers
60
install-libs: install-libs-yes
61

Ramiro Polla's avatar
Ramiro Polla committed
62 63 64
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
65 66 67 68

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

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

74 75
OBJS-$(HAVE_MMX) +=  $(MMX-OBJS-yes)

76
CFLAGS    += $(CFLAGS-yes)
Diego Biurrun's avatar
Diego Biurrun committed
77 78 79
OBJS      += $(OBJS-yes)
FFLIBS    := $(FFLIBS-yes) $(FFLIBS)
TESTPROGS += $(TESTPROGS-yes)
80

Måns Rullgård's avatar
Måns Rullgård committed
81
FFEXTRALIBS := $(addprefix -l,$(addsuffix $(BUILDSUF),$(FFLIBS))) $(EXTRALIBS)
82
FFLDFLAGS   := $(addprefix -Llib,$(ALLFFLIBS)) $(LDFLAGS)
83

84
EXAMPLES  := $(addprefix $(SUBDIR),$(addsuffix -example$(EXESUF),$(EXAMPLES)))
Måns Rullgård's avatar
Måns Rullgård committed
85
OBJS      := $(addprefix $(SUBDIR),$(sort $(OBJS)))
86
TESTOBJS  := $(addprefix $(SUBDIR),$(TESTOBJS) $(TESTPROGS:%=%-test.o))
87
TESTPROGS := $(addprefix $(SUBDIR),$(addsuffix -test$(EXESUF),$(TESTPROGS)))
88 89
HOSTOBJS  := $(addprefix $(SUBDIR),$(addsuffix .o,$(HOSTPROGS)))
HOSTPROGS := $(addprefix $(SUBDIR),$(addsuffix $(HOSTEXESUF),$(HOSTPROGS)))
90

91
DEP_LIBS := $(foreach NAME,$(FFLIBS),lib$(NAME)/$($(CONFIG_SHARED:yes=S)LIBNAME))
Måns Rullgård's avatar
Måns Rullgård committed
92

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

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

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

104
CLEANSUFFIXES     = *.d *.o *~ *.ho *.map *.ver
105
DISTCLEANSUFFIXES = *.pc
106
LIBSUFFIXES       = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp
107

108
-include $(wildcard $(OBJS:.o=.d) $(TESTOBJS:.o=.d))