2006-02-13 14:53:25 +02:00
|
|
|
#
|
|
|
|
# common bits used by all libraries
|
|
|
|
#
|
|
|
|
|
2010-03-09 16:58:18 +02:00
|
|
|
# first so "all" becomes default target
|
|
|
|
all: all-yes
|
2008-03-07 21:27:17 +02:00
|
|
|
|
2011-06-24 10:02:57 +03:00
|
|
|
ifndef SUBDIR
|
|
|
|
|
|
|
|
ifndef V
|
|
|
|
Q = @
|
|
|
|
ECHO = printf "$(1)\t%s\n" $(2)
|
2012-08-29 19:13:00 +03:00
|
|
|
BRIEF = CC CXX HOSTCC HOSTLD AS YASM AR LD STRIP CP
|
2012-08-09 01:26:38 +03:00
|
|
|
SILENT = DEPCC DEPHOSTCC DEPAS DEPYASM RANLIB RM
|
|
|
|
|
2011-06-24 10:02:57 +03:00
|
|
|
MSG = $@
|
|
|
|
M = @$(call ECHO,$(TAG),$@);
|
|
|
|
$(foreach VAR,$(BRIEF), \
|
|
|
|
$(eval override $(VAR) = @$$(call ECHO,$(VAR),$$(MSG)); $($(VAR))))
|
|
|
|
$(foreach VAR,$(SILENT),$(eval override $(VAR) = @$($(VAR))))
|
|
|
|
$(eval INSTALL = @$(call ECHO,INSTALL,$$(^:$(SRC_DIR)/%=%)); $(INSTALL))
|
|
|
|
endif
|
|
|
|
|
2012-04-25 23:01:59 +03:00
|
|
|
ALLFFLIBS = avcodec avdevice avfilter avformat avresample avutil postproc swscale swresample
|
2011-07-21 17:27:55 +03:00
|
|
|
|
2011-06-24 11:04:22 +03:00
|
|
|
# NASM requires -I path terminated with /
|
2011-06-27 04:32:45 +03:00
|
|
|
IFLAGS := -I. -I$(SRC_PATH)/
|
|
|
|
CPPFLAGS := $(IFLAGS) $(CPPFLAGS)
|
|
|
|
CFLAGS += $(ECFLAGS)
|
2012-07-28 00:42:19 +03:00
|
|
|
CCFLAGS = $(CPPFLAGS) $(CFLAGS)
|
|
|
|
ASFLAGS := $(CPPFLAGS) $(ASFLAGS)
|
2012-07-30 18:44:56 +03:00
|
|
|
CXXFLAGS += $(CPPFLAGS) $(CFLAGS)
|
2012-08-08 00:04:55 +03:00
|
|
|
YASMFLAGS += $(IFLAGS:%=%/) -I$(SRC_PATH)/libavutil/x86/ -Pconfig.asm
|
|
|
|
|
2012-07-28 00:42:19 +03:00
|
|
|
HOSTCCFLAGS = $(IFLAGS) $(HOSTCFLAGS)
|
2012-08-30 18:28:21 +03:00
|
|
|
LDFLAGS := $(ALLFFLIBS:%=$(LD_PATH)lib%) $(LDFLAGS)
|
2011-06-24 10:02:57 +03:00
|
|
|
|
2011-06-27 04:32:45 +03:00
|
|
|
define COMPILE
|
2012-07-28 00:42:19 +03:00
|
|
|
$(call $(1)DEP,$(1))
|
2012-07-29 02:56:31 +03:00
|
|
|
$($(1)) $($(1)FLAGS) $($(1)_DEPFLAGS) $($(1)_C) $($(1)_O) $<
|
2011-06-27 04:32:45 +03:00
|
|
|
endef
|
|
|
|
|
|
|
|
COMPILE_C = $(call COMPILE,CC)
|
2011-09-14 02:23:16 +03:00
|
|
|
COMPILE_CXX = $(call COMPILE,CXX)
|
2011-06-27 04:32:45 +03:00
|
|
|
COMPILE_S = $(call COMPILE,AS)
|
|
|
|
|
2011-06-24 10:02:57 +03:00
|
|
|
%.o: %.c
|
2011-06-27 04:32:45 +03:00
|
|
|
$(COMPILE_C)
|
2011-06-24 10:02:57 +03:00
|
|
|
|
2011-09-14 02:23:16 +03:00
|
|
|
%.o: %.cpp
|
|
|
|
$(COMPILE_CXX)
|
|
|
|
|
2011-03-04 21:41:33 +02:00
|
|
|
%.s: %.c
|
|
|
|
$(CC) $(CPPFLAGS) $(CFLAGS) -S -o $@ $<
|
|
|
|
|
2011-06-24 10:02:57 +03:00
|
|
|
%.o: %.S
|
2011-06-27 04:32:45 +03:00
|
|
|
$(COMPILE_S)
|
2011-06-24 10:02:57 +03:00
|
|
|
|
2012-08-09 04:46:43 +03:00
|
|
|
%.h.c:
|
|
|
|
$(Q)echo '#include "$*.h"' >$@
|
2011-06-24 10:02:57 +03:00
|
|
|
|
|
|
|
%.ver: %.v
|
|
|
|
$(Q)sed 's/$$MAJOR/$($(basename $(@F))_VERSION_MAJOR)/' $^ > $@
|
|
|
|
|
|
|
|
%.c %.h: TAG = GEN
|
|
|
|
|
2011-06-24 20:53:28 +03:00
|
|
|
# Dummy rule to stop make trying to rebuild removed or renamed headers
|
|
|
|
%.h:
|
|
|
|
@:
|
|
|
|
|
|
|
|
# Disable suffix rules. Most of the builtin rules are suffix rules,
|
|
|
|
# so this saves some time on slow systems.
|
|
|
|
.SUFFIXES:
|
|
|
|
|
|
|
|
# Do not delete intermediate files from chains of implicit rules
|
|
|
|
$(OBJS):
|
2011-06-24 10:02:57 +03:00
|
|
|
endif
|
|
|
|
|
2012-03-28 00:10:02 +03:00
|
|
|
include $(SRC_PATH)/arch.mak
|
2009-04-13 01:48:44 +03:00
|
|
|
|
2009-03-25 20:14:28 +02:00
|
|
|
OBJS += $(OBJS-yes)
|
|
|
|
FFLIBS := $(FFLIBS-yes) $(FFLIBS)
|
|
|
|
TESTPROGS += $(TESTPROGS-yes)
|
2006-02-13 14:53:25 +02:00
|
|
|
|
2012-08-28 18:06:56 +03:00
|
|
|
LDLIBS = $(FFLIBS:%=%$(BUILDSUF))
|
|
|
|
FFEXTRALIBS := $(LDLIBS:%=$(LD_LIB)) $(EXTRALIBS)
|
2006-02-13 14:53:25 +02:00
|
|
|
|
2011-06-28 16:45:57 +03:00
|
|
|
EXAMPLES := $(EXAMPLES:%=$(SUBDIR)%-example$(EXESUF))
|
|
|
|
OBJS := $(sort $(OBJS:%=$(SUBDIR)%))
|
|
|
|
TESTOBJS := $(TESTOBJS:%=$(SUBDIR)%) $(TESTPROGS:%=$(SUBDIR)%-test.o)
|
|
|
|
TESTPROGS := $(TESTPROGS:%=$(SUBDIR)%-test$(EXESUF))
|
|
|
|
HOSTOBJS := $(HOSTPROGS:%=$(SUBDIR)%.o)
|
|
|
|
HOSTPROGS := $(HOSTPROGS:%=$(SUBDIR)%$(HOSTEXESUF))
|
2011-07-10 22:26:25 +03:00
|
|
|
TOOLS += $(TOOLS-yes)
|
|
|
|
TOOLOBJS := $(TOOLS:%=tools/%.o)
|
|
|
|
TOOLS := $(TOOLS:%=tools/%$(EXESUF))
|
2006-02-13 14:53:25 +02:00
|
|
|
|
2011-05-28 15:10:01 +03:00
|
|
|
DEP_LIBS := $(foreach NAME,$(FFLIBS),lib$(NAME)/$($(CONFIG_SHARED:yes=S)LIBNAME))
|
2008-04-10 00:11:39 +03:00
|
|
|
|
2009-01-12 00:48:07 +02:00
|
|
|
ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h))
|
2011-06-28 16:45:57 +03:00
|
|
|
SKIPHEADERS += $(ARCH_HEADERS:%=$(ARCH)/%) $(SKIPHEADERS-)
|
|
|
|
SKIPHEADERS := $(SKIPHEADERS:%=$(SUBDIR)%)
|
2012-08-07 04:11:25 +03:00
|
|
|
HOBJS = $(filter-out $(SKIPHEADERS:.h=.h.o),$(ALLHEADERS:.h=.h.o))
|
|
|
|
checkheaders: $(HOBJS)
|
|
|
|
.SECONDARY: $(HOBJS:.o=.c)
|
2006-02-13 14:53:25 +02:00
|
|
|
|
2011-07-10 22:26:25 +03:00
|
|
|
alltools: $(TOOLS)
|
|
|
|
|
2009-10-29 02:55:35 +02:00
|
|
|
$(HOSTOBJS): %.o: %.c
|
2012-07-20 13:01:19 +03:00
|
|
|
$(call COMPILE,HOSTCC)
|
2009-10-29 02:55:35 +02:00
|
|
|
|
|
|
|
$(HOSTPROGS): %$(HOSTEXESUF): %.o
|
2012-08-28 15:02:35 +03:00
|
|
|
$(HOSTLD) $(HOSTLDFLAGS) $(HOSTLD_O) $< $(HOSTLIBS)
|
2009-10-29 02:55:35 +02:00
|
|
|
|
2012-08-09 05:56:20 +03:00
|
|
|
$(OBJS): | $(sort $(dir $(OBJS)))
|
|
|
|
$(HOSTOBJS): | $(sort $(dir $(HOSTOBJS)))
|
|
|
|
$(TESTOBJS): | $(sort $(dir $(TESTOBJS)))
|
|
|
|
$(HOBJS): | $(sort $(dir $(HOBJS)))
|
|
|
|
$(TOOLOBJS): | tools
|
2011-06-28 20:45:13 +03:00
|
|
|
|
2012-08-09 05:56:20 +03:00
|
|
|
OBJDIRS := $(OBJDIRS) $(dir $(OBJS) $(HOSTOBJS) $(TESTOBJS) $(HOBJS))
|
2011-06-28 20:45:13 +03:00
|
|
|
|
2012-08-09 01:26:38 +03:00
|
|
|
CLEANSUFFIXES = *.d *.o *~ *.h.c *.map *.ver *.ho *.gcno *.gcda
|
2009-11-22 16:22:13 +02:00
|
|
|
DISTCLEANSUFFIXES = *.pc
|
2012-04-30 11:33:49 +03:00
|
|
|
LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a
|
2008-02-25 11:22:11 +02:00
|
|
|
|
2012-09-15 21:33:56 +03:00
|
|
|
clean::
|
|
|
|
$(RM) $(OBJS) $(OBJS:.o=.d)
|
|
|
|
|
2012-08-07 04:11:25 +03:00
|
|
|
-include $(wildcard $(OBJS:.o=.d) $(HOSTOBJS:.o=.d) $(TESTOBJS:.o=.d) $(HOBJS:.o=.d))
|