2006-02-13 14:53:25 +02:00
|
|
|
#
|
|
|
|
# common bits used by all libraries
|
|
|
|
#
|
|
|
|
|
2016-10-08 16:18:33 +02:00
|
|
|
DEFAULT_X86ASMD=.dbg
|
2015-02-08 13:18:27 +02:00
|
|
|
|
2015-03-08 18:54:25 +02:00
|
|
|
ifeq ($(DBG),1)
|
2016-10-08 16:18:33 +02:00
|
|
|
X86ASMD=$(DEFAULT_X86ASMD)
|
2015-02-18 11:51:17 +02:00
|
|
|
else
|
2016-10-08 16:18:33 +02:00
|
|
|
X86ASMD=
|
2015-02-08 13:18:27 +02:00
|
|
|
endif
|
|
|
|
|
2011-06-24 10:02:57 +03:00
|
|
|
ifndef SUBDIR
|
|
|
|
|
2021-06-11 23:54:34 +02:00
|
|
|
BIN2CEXE = ffbuild/bin2c$(HOSTEXESUF)
|
|
|
|
BIN2C = $(BIN2CEXE)
|
|
|
|
|
2011-06-24 10:02:57 +03:00
|
|
|
ifndef V
|
|
|
|
Q = @
|
|
|
|
ECHO = printf "$(1)\t%s\n" $(2)
|
2021-06-11 23:54:34 +02:00
|
|
|
BRIEF = CC CXX OBJCC HOSTCC HOSTLD AS X86ASM AR LD STRIP CP WINDRES NVCC BIN2C
|
2016-10-08 16:18:33 +02:00
|
|
|
SILENT = DEPCC DEPHOSTCC DEPAS DEPX86ASM RANLIB RM
|
2012-08-09 01:26:38 +03:00
|
|
|
|
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
|
|
|
|
|
2022-05-13 00:16:30 +02:00
|
|
|
# Prepend to a recursively expanded variable without making it simply expanded.
|
|
|
|
PREPEND = $(eval $(1) = $(patsubst %,$$(%), $(2)) $(value $(1)))
|
|
|
|
|
2011-06-24 11:04:22 +03:00
|
|
|
# NASM requires -I path terminated with /
|
2016-01-25 02:42:23 +02:00
|
|
|
IFLAGS := -I. -I$(SRC_LINK)/
|
2011-06-27 04:32:45 +03:00
|
|
|
CPPFLAGS := $(IFLAGS) $(CPPFLAGS)
|
|
|
|
CFLAGS += $(ECFLAGS)
|
2012-07-28 00:42:19 +03:00
|
|
|
CCFLAGS = $(CPPFLAGS) $(CFLAGS)
|
2015-12-05 12:49:44 +02:00
|
|
|
OBJCFLAGS += $(EOBJCFLAGS)
|
|
|
|
OBJCCFLAGS = $(CPPFLAGS) $(CFLAGS) $(OBJCFLAGS)
|
2012-07-28 00:42:19 +03:00
|
|
|
ASFLAGS := $(CPPFLAGS) $(ASFLAGS)
|
2022-05-13 00:16:30 +02:00
|
|
|
# Use PREPEND here so that later (target-dependent) additions to CPPFLAGS
|
|
|
|
# end up in CXXFLAGS.
|
|
|
|
$(call PREPEND,CXXFLAGS, CPPFLAGS CFLAGS)
|
2016-10-13 02:45:09 +02:00
|
|
|
X86ASMFLAGS += $(IFLAGS:%=%/) -I$(<D)/ -Pconfig.asm
|
2012-08-08 00:04:55 +03:00
|
|
|
|
2013-02-24 17:24:38 +03:00
|
|
|
HOSTCCFLAGS = $(IFLAGS) $(HOSTCPPFLAGS) $(HOSTCFLAGS)
|
2016-01-25 02:42:23 +02: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))
|
2020-07-18 17:35:37 +02:00
|
|
|
$($(1)) $($(1)FLAGS) $($(2)) $($(1)_DEPFLAGS) $($(1)_C) $($(1)_O) $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<)
|
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)
|
2015-12-05 12:49:44 +02:00
|
|
|
COMPILE_M = $(call COMPILE,OBJCC)
|
2016-10-13 02:45:09 +02:00
|
|
|
COMPILE_X86ASM = $(call COMPILE,X86ASM)
|
2013-12-02 22:03:24 +03:00
|
|
|
COMPILE_HOSTC = $(call COMPILE,HOSTCC)
|
2017-05-11 22:53:41 +02:00
|
|
|
COMPILE_NVCC = $(call COMPILE,NVCC)
|
2020-07-18 17:35:37 +02:00
|
|
|
COMPILE_MMI = $(call COMPILE,CC,MMIFLAGS)
|
|
|
|
COMPILE_MSA = $(call COMPILE,CC,MSAFLAGS)
|
2021-12-15 05:51:04 +02:00
|
|
|
COMPILE_LSX = $(call COMPILE,CC,LSXFLAGS)
|
|
|
|
COMPILE_LASX = $(call COMPILE,CC,LASXFLAGS)
|
2020-07-18 17:35:37 +02:00
|
|
|
|
|
|
|
%_mmi.o: %_mmi.c
|
|
|
|
$(COMPILE_MMI)
|
|
|
|
|
|
|
|
%_msa.o: %_msa.c
|
|
|
|
$(COMPILE_MSA)
|
2011-06-27 04:32:45 +03:00
|
|
|
|
2021-12-15 05:51:04 +02:00
|
|
|
%_lsx.o: %_lsx.c
|
|
|
|
$(COMPILE_LSX)
|
|
|
|
|
|
|
|
%_lasx.o: %_lasx.c
|
|
|
|
$(COMPILE_LASX)
|
|
|
|
|
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)
|
|
|
|
|
2014-03-24 12:55:35 +03:00
|
|
|
%.o: %.m
|
2015-12-05 12:49:44 +02:00
|
|
|
$(COMPILE_M)
|
2014-03-24 12:55:35 +03:00
|
|
|
|
2011-03-04 21:41:33 +02:00
|
|
|
%.s: %.c
|
2015-12-02 06:55:37 +02:00
|
|
|
$(CC) $(CCFLAGS) -S -o $@ $<
|
2011-03-04 21:41:33 +02:00
|
|
|
|
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
|
|
|
|
2013-12-02 22:17:36 +03:00
|
|
|
%_host.o: %.c
|
|
|
|
$(COMPILE_HOSTC)
|
|
|
|
|
2016-10-08 16:18:33 +02:00
|
|
|
%$(DEFAULT_X86ASMD).asm: %.asm
|
2016-10-13 02:45:09 +02:00
|
|
|
$(DEPX86ASM) $(X86ASMFLAGS) -M -o $@ $< > $(@:.asm=.d)
|
|
|
|
$(X86ASM) $(X86ASMFLAGS) -e $< | sed '/^%/d;/^$$/d;' > $@
|
2017-03-23 22:48:28 +02:00
|
|
|
|
|
|
|
%.o: %.asm
|
2016-10-13 02:45:09 +02:00
|
|
|
$(COMPILE_X86ASM)
|
2017-03-23 22:48:28 +02:00
|
|
|
-$(if $(ASMSTRIPFLAGS), $(STRIP) $(ASMSTRIPFLAGS) $@)
|
|
|
|
|
2013-12-05 23:50:14 +03:00
|
|
|
%.o: %.rc
|
2021-05-14 23:42:38 +02:00
|
|
|
$(WINDRES) $(IFLAGS) $(foreach ARG,$(CC_DEPFLAGS),--preprocessor-arg "$(ARG)") -o $@ $<
|
2013-12-05 23:50:14 +03:00
|
|
|
|
2012-11-23 15:30:51 +03:00
|
|
|
%.i: %.c
|
|
|
|
$(CC) $(CCFLAGS) $(CC_E) $<
|
|
|
|
|
2012-08-09 04:46:43 +03:00
|
|
|
%.h.c:
|
|
|
|
$(Q)echo '#include "$*.h"' >$@
|
2011-06-24 10:02:57 +03:00
|
|
|
|
2021-06-11 23:54:34 +02:00
|
|
|
$(BIN2CEXE): ffbuild/bin2c_host.o
|
|
|
|
$(HOSTLD) $(HOSTLDFLAGS) $(HOSTLD_O) $^ $(HOSTEXTRALIBS)
|
|
|
|
|
2021-12-16 21:28:01 +02:00
|
|
|
%.metal.air: %.metal
|
2021-12-20 11:09:09 +02:00
|
|
|
$(METALCC) $< -o $@
|
2021-12-16 21:28:01 +02:00
|
|
|
|
|
|
|
%.metallib: %.metal.air
|
2021-12-20 11:09:09 +02:00
|
|
|
$(METALLIB) --split-module-without-linking $< -o $@
|
2021-12-16 21:28:01 +02:00
|
|
|
|
|
|
|
%.metallib.c: %.metallib $(BIN2CEXE)
|
2021-12-20 11:09:09 +02:00
|
|
|
$(BIN2C) $< $@ $(subst .,_,$(basename $(notdir $@)))
|
2021-12-16 21:28:01 +02:00
|
|
|
|
2019-07-30 09:51:42 +02:00
|
|
|
%.ptx: %.cu $(SRC_PATH)/compat/cuda/cuda_runtime.h
|
2017-05-11 22:53:41 +02:00
|
|
|
$(COMPILE_NVCC)
|
|
|
|
|
2021-06-11 23:54:34 +02:00
|
|
|
ifdef CONFIG_PTX_COMPRESSION
|
|
|
|
%.ptx.gz: TAG = GZIP
|
|
|
|
%.ptx.gz: %.ptx
|
2023-09-30 01:25:39 +02:00
|
|
|
$(M)gzip -nc9 $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<) >$@
|
2021-06-11 23:54:34 +02:00
|
|
|
|
|
|
|
%.ptx.c: %.ptx.gz $(BIN2CEXE)
|
|
|
|
$(BIN2C) $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<) $@ $(subst .,_,$(basename $(notdir $@)))
|
|
|
|
else
|
|
|
|
%.ptx.c: %.ptx $(BIN2CEXE)
|
|
|
|
$(BIN2C) $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<) $@ $(subst .,_,$(basename $(notdir $@)))
|
|
|
|
endif
|
|
|
|
|
|
|
|
clean::
|
2024-03-08 10:04:16 +02:00
|
|
|
$(RM) $(BIN2CEXE) $(CLEANSUFFIXES:%=ffbuild/%)
|
2017-05-11 22:53:41 +02:00
|
|
|
|
2017-05-05 00:59:30 +02:00
|
|
|
%.c %.h %.pc %.ver %.version: TAG = GEN
|
2011-06-24 10:02:57 +03:00
|
|
|
|
2011-06-24 20:53:28 +03:00
|
|
|
# Dummy rule to stop make trying to rebuild removed or renamed headers
|
2021-01-28 01:04:53 +02:00
|
|
|
%.h %_template.c:
|
2011-06-24 20:53:28 +03:00
|
|
|
@:
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
2017-05-03 12:51:48 +02:00
|
|
|
include $(SRC_PATH)/ffbuild/arch.mak
|
2009-04-13 01:48:44 +03:00
|
|
|
|
2009-03-25 20:14:28 +02:00
|
|
|
OBJS += $(OBJS-yes)
|
2013-12-05 23:50:14 +03:00
|
|
|
SLIBOBJS += $(SLIBOBJS-yes)
|
2021-02-09 13:40:04 +02:00
|
|
|
SHLIBOBJS += $(SHLIBOBJS-yes)
|
|
|
|
STLIBOBJS += $(STLIBOBJS-yes)
|
2014-05-15 19:11:19 +03:00
|
|
|
FFLIBS := $($(NAME)_FFLIBS) $(FFLIBS-yes) $(FFLIBS)
|
2009-03-25 20:14:28 +02:00
|
|
|
TESTPROGS += $(TESTPROGS-yes)
|
2006-02-13 14:53:25 +02:00
|
|
|
|
2012-08-28 18:06:56 +03:00
|
|
|
LDLIBS = $(FFLIBS:%=%$(BUILDSUF))
|
2017-10-12 22:32:10 +02:00
|
|
|
FFEXTRALIBS := $(LDLIBS:%=$(LD_LIB)) $(foreach lib,EXTRALIBS-$(NAME) $(FFLIBS:%=EXTRALIBS-%),$($(lib))) $(EXTRALIBS)
|
2006-02-13 14:53:25 +02:00
|
|
|
|
2011-06-28 16:45:57 +03:00
|
|
|
OBJS := $(sort $(OBJS:%=$(SUBDIR)%))
|
2013-12-05 23:50:14 +03:00
|
|
|
SLIBOBJS := $(sort $(SLIBOBJS:%=$(SUBDIR)%))
|
2021-02-09 13:40:04 +02:00
|
|
|
SHLIBOBJS := $(sort $(SHLIBOBJS:%=$(SUBDIR)%))
|
|
|
|
STLIBOBJS := $(sort $(STLIBOBJS:%=$(SUBDIR)%))
|
2016-04-20 11:40:40 +02:00
|
|
|
TESTOBJS := $(TESTOBJS:%=$(SUBDIR)tests/%) $(TESTPROGS:%=$(SUBDIR)tests/%.o)
|
|
|
|
TESTPROGS := $(TESTPROGS:%=$(SUBDIR)tests/%$(EXESUF))
|
2011-06-28 16:45:57 +03:00
|
|
|
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))
|
2012-10-25 17:13:06 +03:00
|
|
|
HEADERS += $(HEADERS-yes)
|
2006-02-13 14:53:25 +02:00
|
|
|
|
2015-07-21 23:22:42 +02:00
|
|
|
PATH_LIBNAME = $(foreach NAME,$(1),lib$(NAME)/$($(2)LIBNAME))
|
|
|
|
DEP_LIBS := $(foreach lib,$(FFLIBS),$(call PATH_LIBNAME,$(lib),$(CONFIG_SHARED:yes=S)))
|
|
|
|
STATIC_DEP_LIBS := $(foreach lib,$(FFLIBS),$(call PATH_LIBNAME,$(lib)))
|
2008-04-10 00:11:39 +03:00
|
|
|
|
2013-03-01 21:52:32 +03:00
|
|
|
SRC_DIR := $(SRC_PATH)/lib$(NAME)
|
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))
|
2017-05-11 22:53:41 +02:00
|
|
|
PTXOBJS = $(filter %.ptx.o,$(OBJS))
|
2016-03-09 16:39:29 +02:00
|
|
|
$(HOBJS): CCFLAGS += $(CFLAGS_HEADERS)
|
2012-08-07 04:11:25 +03:00
|
|
|
checkheaders: $(HOBJS)
|
2021-06-11 23:54:34 +02:00
|
|
|
.SECONDARY: $(HOBJS:.o=.c) $(PTXOBJS:.o=.c) $(PTXOBJS:.o=.gz) $(PTXOBJS:.o=)
|
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
|
2013-12-02 05:51:48 +03:00
|
|
|
$(COMPILE_HOSTC)
|
2009-10-29 02:55:35 +02:00
|
|
|
|
|
|
|
$(HOSTPROGS): %$(HOSTEXESUF): %.o
|
2016-12-06 19:19:09 +02:00
|
|
|
$(HOSTLD) $(HOSTLDFLAGS) $(HOSTLD_O) $^ $(HOSTEXTRALIBS)
|
2009-10-29 02:55:35 +02:00
|
|
|
|
2012-08-09 05:56:20 +03:00
|
|
|
$(OBJS): | $(sort $(dir $(OBJS)))
|
2013-02-20 02:15:15 +03:00
|
|
|
$(HOBJS): | $(sort $(dir $(HOBJS)))
|
2012-08-09 05:56:20 +03:00
|
|
|
$(HOSTOBJS): | $(sort $(dir $(HOSTOBJS)))
|
2013-12-05 23:50:14 +03:00
|
|
|
$(SLIBOBJS): | $(sort $(dir $(SLIBOBJS)))
|
2021-02-09 13:40:04 +02:00
|
|
|
$(SHLIBOBJS): | $(sort $(dir $(SHLIBOBJS)))
|
|
|
|
$(STLIBOBJS): | $(sort $(dir $(STLIBOBJS)))
|
2012-08-09 05:56:20 +03:00
|
|
|
$(TESTOBJS): | $(sort $(dir $(TESTOBJS)))
|
|
|
|
$(TOOLOBJS): | tools
|
2011-06-28 20:45:13 +03:00
|
|
|
|
2021-02-09 13:40:04 +02:00
|
|
|
OUTDIRS := $(OUTDIRS) $(dir $(OBJS) $(HOBJS) $(HOSTOBJS) $(SLIBOBJS) $(SHLIBOBJS) $(STLIBOBJS) $(TESTOBJS))
|
2011-06-28 20:45:13 +03:00
|
|
|
|
2021-06-11 23:54:34 +02:00
|
|
|
CLEANSUFFIXES = *.d *.gcda *.gcno *.h.c *.ho *.map *.o *.pc *.ptx *.ptx.gz *.ptx.c *.ver *.version *$(DEFAULT_X86ASMD).asm *~ *.ilk *.pdb
|
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-12-10 17:55:28 +03:00
|
|
|
define RULES
|
2012-09-15 21:33:56 +03:00
|
|
|
clean::
|
2016-04-20 11:40:40 +02:00
|
|
|
$(RM) $(HOSTPROGS) $(TESTPROGS) $(TOOLS)
|
2012-12-10 17:55:28 +03:00
|
|
|
endef
|
|
|
|
|
|
|
|
$(eval $(RULES))
|
2012-09-15 21:33:56 +03:00
|
|
|
|
2021-02-09 13:40:04 +02:00
|
|
|
-include $(wildcard $(OBJS:.o=.d) $(HOSTOBJS:.o=.d) $(TESTOBJS:.o=.d) $(HOBJS:.o=.d) $(SHLIBOBJS:.o=.d) $(STLIBOBJS:.o=.d) $(SLIBOBJS:.o=.d)) $(OBJS:.o=$(DEFAULT_X86ASMD).d)
|