compat/cuda/ptx2c: remove shell loop; fix BSD sed compat
[ffmpeg.git] / Makefile
1 MAIN_MAKEFILE=1
2 include ffbuild/config.mak
3
4 vpath %.c    $(SRC_PATH)
5 vpath %.cpp  $(SRC_PATH)
6 vpath %.h    $(SRC_PATH)
7 vpath %.inc  $(SRC_PATH)
8 vpath %.m    $(SRC_PATH)
9 vpath %.S    $(SRC_PATH)
10 vpath %.asm  $(SRC_PATH)
11 vpath %.rc   $(SRC_PATH)
12 vpath %.v    $(SRC_PATH)
13 vpath %.texi $(SRC_PATH)
14 vpath %.cu   $(SRC_PATH)
15 vpath %.ptx  $(SRC_PATH)
16 vpath %/fate_config.sh.template $(SRC_PATH)
17
18 TESTTOOLS   = audiogen videogen rotozoom tiny_psnr tiny_ssim base64 audiomatch
19 HOSTPROGS  := $(TESTTOOLS:%=tests/%) doc/print_options
20
21 # $(FFLIBS-yes) needs to be in linking order
22 FFLIBS-$(CONFIG_AVDEVICE)   += avdevice
23 FFLIBS-$(CONFIG_AVFILTER)   += avfilter
24 FFLIBS-$(CONFIG_AVFORMAT)   += avformat
25 FFLIBS-$(CONFIG_AVCODEC)    += avcodec
26 FFLIBS-$(CONFIG_AVRESAMPLE) += avresample
27 FFLIBS-$(CONFIG_POSTPROC)   += postproc
28 FFLIBS-$(CONFIG_SWRESAMPLE) += swresample
29 FFLIBS-$(CONFIG_SWSCALE)    += swscale
30
31 FFLIBS := avutil
32
33 DATA_FILES := $(wildcard $(SRC_PATH)/presets/*.ffpreset) $(SRC_PATH)/doc/ffprobe.xsd
34
35 SKIPHEADERS = compat/w32pthreads.h
36
37 # first so "all" becomes default target
38 all: all-yes
39
40 include $(SRC_PATH)/tools/Makefile
41 include $(SRC_PATH)/ffbuild/common.mak
42
43 FF_EXTRALIBS := $(FFEXTRALIBS)
44 FF_DEP_LIBS  := $(DEP_LIBS)
45 FF_STATIC_DEP_LIBS := $(STATIC_DEP_LIBS)
46
47 $(TOOLS): %$(EXESUF): %.o
48         $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(EXTRALIBS-$(*F)) $(EXTRALIBS) $(ELIBS)
49
50 target_dec_%_fuzzer$(EXESUF): target_dec_%_fuzzer.o $(FF_DEP_LIBS)
51         $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH)
52
53 tools/target_bsf_%_fuzzer$(EXESUF): tools/target_bsf_%_fuzzer.o $(FF_DEP_LIBS)
54         $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH)
55
56 tools/target_dem_fuzzer$(EXESUF): tools/target_dem_fuzzer.o $(FF_DEP_LIBS)
57         $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH)
58
59 tools/sofa2wavs$(EXESUF): ELIBS = $(FF_EXTRALIBS)
60 tools/uncoded_frame$(EXESUF): $(FF_DEP_LIBS)
61 tools/uncoded_frame$(EXESUF): ELIBS = $(FF_EXTRALIBS)
62 tools/target_dec_%_fuzzer$(EXESUF): $(FF_DEP_LIBS)
63
64 CONFIGURABLE_COMPONENTS =                                           \
65     $(wildcard $(FFLIBS:%=$(SRC_PATH)/lib%/all*.c))                 \
66     $(SRC_PATH)/libavcodec/bitstream_filters.c                      \
67     $(SRC_PATH)/libavcodec/parsers.c                                \
68     $(SRC_PATH)/libavformat/protocols.c                             \
69
70 config.h: ffbuild/.config
71 ffbuild/.config: $(CONFIGURABLE_COMPONENTS)
72         @-tput bold 2>/dev/null
73         @-printf '\nWARNING: $(?) newer than config.h, rerun configure\n\n'
74         @-tput sgr0 2>/dev/null
75
76 SUBDIR_VARS := CLEANFILES FFLIBS HOSTPROGS TESTPROGS TOOLS               \
77                HEADERS ARCH_HEADERS BUILT_HEADERS SKIPHEADERS            \
78                ARMV5TE-OBJS ARMV6-OBJS ARMV8-OBJS VFP-OBJS NEON-OBJS     \
79                ALTIVEC-OBJS VSX-OBJS MMX-OBJS X86ASM-OBJS                \
80                MIPSFPU-OBJS MIPSDSPR2-OBJS MIPSDSP-OBJS MSA-OBJS         \
81                MMI-OBJS OBJS SLIBOBJS HOSTOBJS TESTOBJS
82
83 define RESET
84 $(1) :=
85 $(1)-yes :=
86 endef
87
88 define DOSUBDIR
89 $(foreach V,$(SUBDIR_VARS),$(eval $(call RESET,$(V))))
90 SUBDIR := $(1)/
91 include $(SRC_PATH)/$(1)/Makefile
92 -include $(SRC_PATH)/$(1)/$(ARCH)/Makefile
93 -include $(SRC_PATH)/$(1)/$(INTRINSICS)/Makefile
94 include $(SRC_PATH)/ffbuild/library.mak
95 endef
96
97 $(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D))))
98
99 include $(SRC_PATH)/fftools/Makefile
100 include $(SRC_PATH)/doc/Makefile
101 include $(SRC_PATH)/doc/examples/Makefile
102
103 libavcodec/utils.o libavformat/utils.o libavdevice/avdevice.o libavfilter/avfilter.o libavutil/utils.o libpostproc/postprocess.o libswresample/swresample.o libswscale/utils.o : libavutil/ffversion.h
104
105 $(PROGS): %$(PROGSSUF)$(EXESUF): %$(PROGSSUF)_g$(EXESUF)
106 ifeq ($(STRIPTYPE),direct)
107         $(STRIP) -o $@ $<
108 else
109         $(CP) $< $@
110         $(STRIP) $@
111 endif
112
113 %$(PROGSSUF)_g$(EXESUF): $(FF_DEP_LIBS)
114         $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $(OBJS-$*) $(FF_EXTRALIBS)
115
116 VERSION_SH  = $(SRC_PATH)/ffbuild/version.sh
117 GIT_LOG     = $(SRC_PATH)/.git/logs/HEAD
118
119 .version: $(wildcard $(GIT_LOG)) $(VERSION_SH) ffbuild/config.mak
120 .version: M=@
121
122 libavutil/ffversion.h .version:
123         $(M)$(VERSION_SH) $(SRC_PATH) libavutil/ffversion.h $(EXTRA_VERSION)
124         $(Q)touch .version
125
126 # force version.sh to run whenever version might have changed
127 -include .version
128
129 install: install-libs install-headers
130
131 install-libs: install-libs-yes
132
133 install-data: $(DATA_FILES)
134         $(Q)mkdir -p "$(DATADIR)"
135         $(INSTALL) -m 644 $(DATA_FILES) "$(DATADIR)"
136
137 uninstall: uninstall-data uninstall-headers uninstall-libs uninstall-pkgconfig
138
139 uninstall-data:
140         $(RM) -r "$(DATADIR)"
141
142 clean::
143         $(RM) $(CLEANSUFFIXES)
144         $(RM) $(addprefix compat/,$(CLEANSUFFIXES)) $(addprefix compat/*/,$(CLEANSUFFIXES)) $(addprefix compat/*/*/,$(CLEANSUFFIXES))
145         $(RM) -r coverage-html
146         $(RM) -rf coverage.info coverage.info.in lcov
147
148 distclean:: clean
149         $(RM) .version avversion.h config.asm config.h mapfile  \
150                 ffbuild/.config ffbuild/config.* libavutil/avconfig.h \
151                 version.h libavutil/ffversion.h libavcodec/codec_names.h \
152                 libavcodec/bsf_list.c libavformat/protocol_list.c \
153                 libavcodec/codec_list.c libavcodec/parser_list.c \
154                 libavfilter/filter_list.c libavdevice/indev_list.c libavdevice/outdev_list.c \
155                 libavformat/muxer_list.c libavformat/demuxer_list.c
156 ifeq ($(SRC_LINK),src)
157         $(RM) src
158 endif
159         $(RM) -rf doc/examples/pc-uninstalled
160
161 config:
162         $(SRC_PATH)/configure $(value FFMPEG_CONFIGURATION)
163
164 build: all alltools examples testprogs
165 check: all alltools examples testprogs fate
166
167 include $(SRC_PATH)/tests/Makefile
168
169 $(sort $(OUTDIRS)):
170         $(Q)mkdir -p $@
171
172 # Dummy rule to stop make trying to rebuild removed or renamed headers
173 %.h:
174         @:
175
176 # Disable suffix rules.  Most of the builtin rules are suffix rules,
177 # so this saves some time on slow systems.
178 .SUFFIXES:
179
180 .PHONY: all all-yes alltools build check config testprogs
181 .PHONY: *clean install* uninstall*