2006-02-13 13:53:25 +01:00
|
|
|
#
|
|
|
|
# common bits used by all libraries
|
|
|
|
#
|
|
|
|
|
2010-03-09 15:58:18 +01:00
|
|
|
# first so "all" becomes default target
|
|
|
|
all: all-yes
|
2008-03-07 20:27:17 +01:00
|
|
|
|
2015-02-08 12:18:27 +01:00
|
|
|
DEFAULT_YASMD=.dbg
|
|
|
|
|
2015-02-18 10:51:17 +01:00
|
|
|
ifeq (1, DBG)
|
2015-02-08 12:18:27 +01:00
|
|
|
YASMD=$(DEFAULT_YASMD)
|
2015-02-18 10:51:17 +01:00
|
|
|
else
|
|
|
|
YASMD=
|
2015-02-08 12:18:27 +01:00
|
|
|
endif
|
|
|
|
|
2011-06-24 09:02:57 +02:00
|
|
|
ifndef SUBDIR
|
|
|
|
|
|
|
|
ifndef V
|
|
|
|
Q = @
|
|
|
|
ECHO = printf "$(1)\t%s\n" $(2)
|
2013-12-05 21:50:14 +01:00
|
|
|
BRIEF = CC CXX HOSTCC HOSTLD AS YASM AR LD STRIP CP WINDRES
|
2012-08-09 00:26:38 +02:00
|
|
|
SILENT = DEPCC DEPHOSTCC DEPAS DEPYASM RANLIB RM
|
|
|
|
|
2011-06-24 09:02:57 +02: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 22:01:59 +02:00
|
|
|
ALLFFLIBS = avcodec avdevice avfilter avformat avresample avutil postproc swscale swresample
|
2011-07-21 16:27:55 +02:00
|
|
|
|
2011-06-24 10:04:22 +02:00
|
|
|
# NASM requires -I path terminated with /
|
2011-06-27 03:32:45 +02:00
|
|
|
IFLAGS := -I. -I$(SRC_PATH)/
|
|
|
|
CPPFLAGS := $(IFLAGS) $(CPPFLAGS)
|
|
|
|
CFLAGS += $(ECFLAGS)
|
2012-07-27 23:42:19 +02:00
|
|
|
CCFLAGS = $(CPPFLAGS) $(CFLAGS)
|
|
|
|
ASFLAGS := $(CPPFLAGS) $(ASFLAGS)
|
2012-07-30 17:44:56 +02:00
|
|
|
CXXFLAGS += $(CPPFLAGS) $(CFLAGS)
|
2012-10-31 13:57:09 +01:00
|
|
|
YASMFLAGS += $(IFLAGS:%=%/) -Pconfig.asm
|
2012-08-07 23:04:55 +02:00
|
|
|
|
2013-02-24 15:24:38 +01:00
|
|
|
HOSTCCFLAGS = $(IFLAGS) $(HOSTCPPFLAGS) $(HOSTCFLAGS)
|
2012-08-30 17:28:21 +02:00
|
|
|
LDFLAGS := $(ALLFFLIBS:%=$(LD_PATH)lib%) $(LDFLAGS)
|
2011-06-24 09:02:57 +02:00
|
|
|
|
2011-06-27 03:32:45 +02:00
|
|
|
define COMPILE
|
2012-07-27 23:42:19 +02:00
|
|
|
$(call $(1)DEP,$(1))
|
2012-07-29 01:56:31 +02:00
|
|
|
$($(1)) $($(1)FLAGS) $($(1)_DEPFLAGS) $($(1)_C) $($(1)_O) $<
|
2011-06-27 03:32:45 +02:00
|
|
|
endef
|
|
|
|
|
|
|
|
COMPILE_C = $(call COMPILE,CC)
|
2011-09-14 01:23:16 +02:00
|
|
|
COMPILE_CXX = $(call COMPILE,CXX)
|
2011-06-27 03:32:45 +02:00
|
|
|
COMPILE_S = $(call COMPILE,AS)
|
2013-12-02 20:03:24 +01:00
|
|
|
COMPILE_HOSTC = $(call COMPILE,HOSTCC)
|
2011-06-27 03:32:45 +02:00
|
|
|
|
2011-06-24 09:02:57 +02:00
|
|
|
%.o: %.c
|
2011-06-27 03:32:45 +02:00
|
|
|
$(COMPILE_C)
|
2011-06-24 09:02:57 +02:00
|
|
|
|
2011-09-14 01:23:16 +02:00
|
|
|
%.o: %.cpp
|
|
|
|
$(COMPILE_CXX)
|
|
|
|
|
2014-03-24 10:55:35 +01:00
|
|
|
%.o: %.m
|
|
|
|
$(COMPILE_C)
|
|
|
|
|
2011-03-04 20:41:33 +01:00
|
|
|
%.s: %.c
|
|
|
|
$(CC) $(CPPFLAGS) $(CFLAGS) -S -o $@ $<
|
|
|
|
|
2011-06-24 09:02:57 +02:00
|
|
|
%.o: %.S
|
2011-06-27 03:32:45 +02:00
|
|
|
$(COMPILE_S)
|
2011-06-24 09:02:57 +02:00
|
|
|
|
2013-12-02 20:17:36 +01:00
|
|
|
%_host.o: %.c
|
|
|
|
$(COMPILE_HOSTC)
|
|
|
|
|
2013-12-05 21:50:14 +01:00
|
|
|
%.o: %.rc
|
2013-12-09 02:44:52 +01:00
|
|
|
$(WINDRES) $(IFLAGS) --preprocessor "$(DEPWINDRES) -E -xc-header -DRC_INVOKED $(CC_DEPFLAGS)" -o $@ $<
|
2013-12-05 21:50:14 +01:00
|
|
|
|
2012-11-23 13:30:51 +01:00
|
|
|
%.i: %.c
|
|
|
|
$(CC) $(CCFLAGS) $(CC_E) $<
|
|
|
|
|
2012-08-09 03:46:43 +02:00
|
|
|
%.h.c:
|
|
|
|
$(Q)echo '#include "$*.h"' >$@
|
2011-06-24 09:02:57 +02:00
|
|
|
|
|
|
|
%.ver: %.v
|
|
|
|
$(Q)sed 's/$$MAJOR/$($(basename $(@F))_VERSION_MAJOR)/' $^ > $@
|
|
|
|
|
|
|
|
%.c %.h: TAG = GEN
|
|
|
|
|
2011-06-24 19:53:28 +02: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 09:02:57 +02:00
|
|
|
endif
|
|
|
|
|
2012-03-27 23:10:02 +02:00
|
|
|
include $(SRC_PATH)/arch.mak
|
2009-04-13 00:48:44 +02:00
|
|
|
|
2009-03-25 19:14:28 +01:00
|
|
|
OBJS += $(OBJS-yes)
|
2013-12-05 21:50:14 +01:00
|
|
|
SLIBOBJS += $(SLIBOBJS-yes)
|
2014-05-15 18:11:19 +02:00
|
|
|
FFLIBS := $($(NAME)_FFLIBS) $(FFLIBS-yes) $(FFLIBS)
|
2009-03-25 19:14:28 +01:00
|
|
|
TESTPROGS += $(TESTPROGS-yes)
|
2006-02-13 13:53:25 +01:00
|
|
|
|
2012-08-28 17:06:56 +02:00
|
|
|
LDLIBS = $(FFLIBS:%=%$(BUILDSUF))
|
|
|
|
FFEXTRALIBS := $(LDLIBS:%=$(LD_LIB)) $(EXTRALIBS)
|
2006-02-13 13:53:25 +01:00
|
|
|
|
2011-06-28 15:45:57 +02:00
|
|
|
OBJS := $(sort $(OBJS:%=$(SUBDIR)%))
|
2013-12-05 21:50:14 +01:00
|
|
|
SLIBOBJS := $(sort $(SLIBOBJS:%=$(SUBDIR)%))
|
2011-06-28 15:45:57 +02:00
|
|
|
TESTOBJS := $(TESTOBJS:%=$(SUBDIR)%) $(TESTPROGS:%=$(SUBDIR)%-test.o)
|
|
|
|
TESTPROGS := $(TESTPROGS:%=$(SUBDIR)%-test$(EXESUF))
|
|
|
|
HOSTOBJS := $(HOSTPROGS:%=$(SUBDIR)%.o)
|
|
|
|
HOSTPROGS := $(HOSTPROGS:%=$(SUBDIR)%$(HOSTEXESUF))
|
2011-07-10 21:26:25 +02:00
|
|
|
TOOLS += $(TOOLS-yes)
|
|
|
|
TOOLOBJS := $(TOOLS:%=tools/%.o)
|
|
|
|
TOOLS := $(TOOLS:%=tools/%$(EXESUF))
|
2012-10-25 16:13:06 +02:00
|
|
|
HEADERS += $(HEADERS-yes)
|
2006-02-13 13:53:25 +01:00
|
|
|
|
2013-10-01 13:34:02 +02:00
|
|
|
PATH_LIBNAME = $(foreach NAME,$(1),lib$(NAME)/$($(CONFIG_SHARED:yes=S)LIBNAME))
|
|
|
|
DEP_LIBS := $(foreach lib,$(FFLIBS),$(call PATH_LIBNAME,$(lib)))
|
2008-04-09 23:11:39 +02:00
|
|
|
|
2013-03-01 19:52:32 +01:00
|
|
|
SRC_DIR := $(SRC_PATH)/lib$(NAME)
|
2009-01-11 23:48:07 +01:00
|
|
|
ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h))
|
2011-06-28 15:45:57 +02:00
|
|
|
SKIPHEADERS += $(ARCH_HEADERS:%=$(ARCH)/%) $(SKIPHEADERS-)
|
|
|
|
SKIPHEADERS := $(SKIPHEADERS:%=$(SUBDIR)%)
|
2012-08-07 03:11:25 +02:00
|
|
|
HOBJS = $(filter-out $(SKIPHEADERS:.h=.h.o),$(ALLHEADERS:.h=.h.o))
|
|
|
|
checkheaders: $(HOBJS)
|
|
|
|
.SECONDARY: $(HOBJS:.o=.c)
|
2006-02-13 13:53:25 +01:00
|
|
|
|
2011-07-10 21:26:25 +02:00
|
|
|
alltools: $(TOOLS)
|
|
|
|
|
2009-10-29 01:55:35 +01:00
|
|
|
$(HOSTOBJS): %.o: %.c
|
2013-12-02 03:51:48 +01:00
|
|
|
$(COMPILE_HOSTC)
|
2009-10-29 01:55:35 +01:00
|
|
|
|
|
|
|
$(HOSTPROGS): %$(HOSTEXESUF): %.o
|
2013-11-10 22:19:07 +01:00
|
|
|
$(HOSTLD) $(HOSTLDFLAGS) $(HOSTLD_O) $^ $(HOSTLIBS)
|
2009-10-29 01:55:35 +01:00
|
|
|
|
2012-08-09 04:56:20 +02:00
|
|
|
$(OBJS): | $(sort $(dir $(OBJS)))
|
2013-02-20 00:15:15 +01:00
|
|
|
$(HOBJS): | $(sort $(dir $(HOBJS)))
|
2012-08-09 04:56:20 +02:00
|
|
|
$(HOSTOBJS): | $(sort $(dir $(HOSTOBJS)))
|
2013-12-05 21:50:14 +01:00
|
|
|
$(SLIBOBJS): | $(sort $(dir $(SLIBOBJS)))
|
2012-08-09 04:56:20 +02:00
|
|
|
$(TESTOBJS): | $(sort $(dir $(TESTOBJS)))
|
|
|
|
$(TOOLOBJS): | tools
|
2011-06-28 19:45:13 +02:00
|
|
|
|
2013-12-05 21:50:14 +01:00
|
|
|
OBJDIRS := $(OBJDIRS) $(dir $(OBJS) $(HOBJS) $(HOSTOBJS) $(SLIBOBJS) $(TESTOBJS))
|
2011-06-28 19:45:13 +02:00
|
|
|
|
2015-02-08 12:18:27 +01:00
|
|
|
CLEANSUFFIXES = *.d *.o *~ *.h.c *.map *.ver *.ho *.gcno *.gcda *$(DEFAULT_YASMD).asm
|
2009-11-22 15:22:13 +01:00
|
|
|
DISTCLEANSUFFIXES = *.pc
|
2012-04-30 10:33:49 +02:00
|
|
|
LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a
|
2008-02-25 10:22:11 +01:00
|
|
|
|
2012-12-10 15:55:28 +01:00
|
|
|
define RULES
|
2012-09-15 20:33:56 +02:00
|
|
|
clean::
|
2015-02-18 10:51:17 +01:00
|
|
|
$(RM) $(OBJS) $(OBJS:.o=.d) $(OBJS:.o=$(DEFAULT_YASMD).d)
|
2012-12-10 15:55:28 +01:00
|
|
|
$(RM) $(HOSTPROGS)
|
|
|
|
$(RM) $(TOOLS)
|
|
|
|
endef
|
|
|
|
|
|
|
|
$(eval $(RULES))
|
2012-09-15 20:33:56 +02:00
|
|
|
|
2015-02-18 10:51:17 +01:00
|
|
|
-include $(wildcard $(OBJS:.o=.d) $(HOSTOBJS:.o=.d) $(TESTOBJS:.o=.d) $(HOBJS:.o=.d) $(SLIBOBJS:.o=.d)) $(OBJS:.o=$(DEFAULT_YASMD).d)
|