Commit b25d6290 authored by James Almer's avatar James Almer

Merge commit 'acb0dea2'

* commit 'acb0dea2':
  build: Split logic for building examples off into a separate Makefile

We already have a Makefile in doc/examples, but it's separate from the build
system and meant to be installed as part of the documentation to help users
compile the installed .c example files.
Move it to Makefile.example to make place for the new build system Makefile.
Merged-by: 's avatarJames Almer <jamrial@gmail.com>
parents 6f7bd8cd acb0dea2
...@@ -56,7 +56,6 @@ FFLIBS-$(CONFIG_SWSCALE) += swscale ...@@ -56,7 +56,6 @@ FFLIBS-$(CONFIG_SWSCALE) += swscale
FFLIBS := avutil FFLIBS := avutil
DATA_FILES := $(wildcard $(SRC_PATH)/presets/*.ffpreset) $(SRC_PATH)/doc/ffprobe.xsd DATA_FILES := $(wildcard $(SRC_PATH)/presets/*.ffpreset) $(SRC_PATH)/doc/ffprobe.xsd
EXAMPLES_FILES := $(wildcard $(SRC_PATH)/doc/examples/*.c) $(SRC_PATH)/doc/examples/Makefile $(SRC_PATH)/doc/examples/README
SKIPHEADERS = compat/w32pthreads.h SKIPHEADERS = compat/w32pthreads.h
...@@ -119,6 +118,7 @@ endef ...@@ -119,6 +118,7 @@ endef
$(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D)))) $(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D))))
include $(SRC_PATH)/doc/Makefile include $(SRC_PATH)/doc/Makefile
include $(SRC_PATH)/doc/examples/Makefile
define DOPROG define DOPROG
OBJS-$(1) += $(1).o $(OBJS-$(1)-yes) OBJS-$(1) += $(1).o $(OBJS-$(1)-yes)
...@@ -168,10 +168,11 @@ install-progs: install-progs-yes $(AVPROGS) ...@@ -168,10 +168,11 @@ install-progs: install-progs-yes $(AVPROGS)
$(Q)mkdir -p "$(BINDIR)" $(Q)mkdir -p "$(BINDIR)"
$(INSTALL) -c -m 755 $(INSTPROGS) "$(BINDIR)" $(INSTALL) -c -m 755 $(INSTPROGS) "$(BINDIR)"
install-data: $(DATA_FILES) $(EXAMPLES_FILES) install-data: $(DATA_FILES) $(EXAMPLES_FILES) $(EXAMPLE_MAKEFILE)
$(Q)mkdir -p "$(DATADIR)/examples" $(Q)mkdir -p "$(DATADIR)/examples"
$(INSTALL) -m 644 $(DATA_FILES) "$(DATADIR)" $(INSTALL) -m 644 $(DATA_FILES) "$(DATADIR)"
$(INSTALL) -m 644 $(EXAMPLES_FILES) "$(DATADIR)/examples" $(INSTALL) -m 644 $(EXAMPLES_FILES) "$(DATADIR)/examples"
$(INSTALL) -m 644 -T $(EXAMPLE_MAKEFILE:%=%.example) "$(DATADIR)/examples/Makefile"
uninstall: uninstall-libs uninstall-headers uninstall-progs uninstall-data uninstall: uninstall-libs uninstall-headers uninstall-progs uninstall-data
...@@ -219,5 +220,4 @@ $(sort $(OBJDIRS)): ...@@ -219,5 +220,4 @@ $(sort $(OBJDIRS)):
# so this saves some time on slow systems. # so this saves some time on slow systems.
.SUFFIXES: .SUFFIXES:
.PHONY: all all-yes alltools check *clean config install* .PHONY: all all-yes alltools check *clean config install* testprogs uninstall*
.PHONY: testprogs uninstall*
...@@ -36,33 +36,6 @@ DOCS-$(CONFIG_MANPAGES) += $(MANPAGES) ...@@ -36,33 +36,6 @@ DOCS-$(CONFIG_MANPAGES) += $(MANPAGES)
DOCS-$(CONFIG_TXTPAGES) += $(TXTPAGES) DOCS-$(CONFIG_TXTPAGES) += $(TXTPAGES)
DOCS = $(DOCS-yes) DOCS = $(DOCS-yes)
DOC_EXAMPLES-$(CONFIG_AVIO_DIR_CMD_EXAMPLE) += avio_dir_cmd
DOC_EXAMPLES-$(CONFIG_AVIO_READING_EXAMPLE) += avio_reading
DOC_EXAMPLES-$(CONFIG_DECODE_AUDIO_EXAMPLE) += decode_audio
DOC_EXAMPLES-$(CONFIG_DECODE_VIDEO_EXAMPLE) += decode_video
DOC_EXAMPLES-$(CONFIG_DEMUXING_DECODING_EXAMPLE) += demuxing_decoding
DOC_EXAMPLES-$(CONFIG_ENCODE_AUDIO_EXAMPLE) += encode_audio
DOC_EXAMPLES-$(CONFIG_ENCODE_VIDEO_EXAMPLE) += encode_video
DOC_EXAMPLES-$(CONFIG_EXTRACT_MVS_EXAMPLE) += extract_mvs
DOC_EXAMPLES-$(CONFIG_FILTER_AUDIO_EXAMPLE) += filter_audio
DOC_EXAMPLES-$(CONFIG_FILTERING_AUDIO_EXAMPLE) += filtering_audio
DOC_EXAMPLES-$(CONFIG_FILTERING_VIDEO_EXAMPLE) += filtering_video
DOC_EXAMPLES-$(CONFIG_HTTP_MULTICLIENT_EXAMPLE) += http_multiclient
DOC_EXAMPLES-$(CONFIG_HW_DECODE_EXAMPLE) += hw_decode
DOC_EXAMPLES-$(CONFIG_METADATA_EXAMPLE) += metadata
DOC_EXAMPLES-$(CONFIG_MUXING_EXAMPLE) += muxing
DOC_EXAMPLES-$(CONFIG_QSVDEC_EXAMPLE) += qsvdec
DOC_EXAMPLES-$(CONFIG_REMUXING_EXAMPLE) += remuxing
DOC_EXAMPLES-$(CONFIG_RESAMPLING_AUDIO_EXAMPLE) += resampling_audio
DOC_EXAMPLES-$(CONFIG_SCALING_VIDEO_EXAMPLE) += scaling_video
DOC_EXAMPLES-$(CONFIG_TRANSCODE_AAC_EXAMPLE) += transcode_aac
DOC_EXAMPLES-$(CONFIG_TRANSCODING_EXAMPLE) += transcoding
DOC_EXAMPLES := $(DOC_EXAMPLES-yes:%=doc/examples/%$(PROGSSUF)$(EXESUF))
ALL_DOC_EXAMPLES := $(DOC_EXAMPLES) $(DOC_EXAMPLES-:%=doc/examples/%$(PROGSSUF)$(EXESUF))
ALL_DOC_EXAMPLES_G := $(DOC_EXAMPLES) $(DOC_EXAMPLES-:%=doc/examples/%$(PROGSSUF)_g$(EXESUF))
PROGS += $(DOC_EXAMPLES)
all-$(CONFIG_DOC): doc all-$(CONFIG_DOC): doc
doc: documentation doc: documentation
...@@ -70,8 +43,6 @@ doc: documentation ...@@ -70,8 +43,6 @@ doc: documentation
apidoc: doc/doxy/html apidoc: doc/doxy/html
documentation: $(DOCS) documentation: $(DOCS)
examples: $(DOC_EXAMPLES)
TEXIDEP = perl $(SRC_PATH)/doc/texidep.pl $(SRC_PATH) $< $@ >$(@:%=%.d) TEXIDEP = perl $(SRC_PATH)/doc/texidep.pl $(SRC_PATH) $< $@ >$(@:%=%.d)
doc/%.txt: TAG = TXT doc/%.txt: TAG = TXT
...@@ -124,10 +95,8 @@ doc/%.3: doc/%.pod $(GENTEXI) ...@@ -124,10 +95,8 @@ doc/%.3: doc/%.pod $(GENTEXI)
$(M)pod2man --section=3 --center=" " --release=" " --date=" " $< > $@ $(M)pod2man --section=3 --center=" " --release=" " --date=" " $< > $@
$(DOCS) doc/doxy/html: | doc/ $(DOCS) doc/doxy/html: | doc/
$(DOC_EXAMPLES:%$(EXESUF)=%.o): | doc/examples
OBJDIRS += doc/examples
DOXY_INPUT = $(INSTHEADERS) $(DOC_EXAMPLES:%$(EXESUF)=%.c) DOXY_INPUT = $(INSTHEADERS)
DOXY_INPUT_DEPS = $(addprefix $(SRC_PATH)/, $(DOXY_INPUT)) ffbuild/config.mak DOXY_INPUT_DEPS = $(addprefix $(SRC_PATH)/, $(DOXY_INPUT)) ffbuild/config.mak
doc/doxy/html: TAG = DOXY doc/doxy/html: TAG = DOXY
...@@ -174,11 +143,7 @@ clean:: docclean ...@@ -174,11 +143,7 @@ clean:: docclean
distclean:: docclean distclean:: docclean
$(RM) doc/config.texi $(RM) doc/config.texi
examplesclean: docclean::
$(RM) $(ALL_DOC_EXAMPLES) $(ALL_DOC_EXAMPLES_G)
$(RM) $(CLEANSUFFIXES:%=doc/examples/%)
docclean: examplesclean
$(RM) $(CLEANSUFFIXES:%=doc/%) $(RM) $(CLEANSUFFIXES:%=doc/%)
$(RM) $(TXTPAGES) doc/*.html doc/*.pod doc/*.1 doc/*.3 doc/avoptions_*.texi $(RM) $(TXTPAGES) doc/*.html doc/*.pod doc/*.1 doc/*.3 doc/avoptions_*.texi
$(RM) -r doc/doxy/html $(RM) -r doc/doxy/html
......
# use pkg-config for getting CFLAGS and LDLIBS DOC_EXAMPLES-$(CONFIG_AVIO_DIR_CMD_EXAMPLE) += avio_dir_cmd
FFMPEG_LIBS= libavdevice \ DOC_EXAMPLES-$(CONFIG_AVIO_READING_EXAMPLE) += avio_reading
libavformat \ DOC_EXAMPLES-$(CONFIG_DECODE_AUDIO_EXAMPLE) += decode_audio
libavfilter \ DOC_EXAMPLES-$(CONFIG_DECODE_VIDEO_EXAMPLE) += decode_video
libavcodec \ DOC_EXAMPLES-$(CONFIG_DEMUXING_DECODING_EXAMPLE) += demuxing_decoding
libswresample \ DOC_EXAMPLES-$(CONFIG_ENCODE_AUDIO_EXAMPLE) += encode_audio
libswscale \ DOC_EXAMPLES-$(CONFIG_ENCODE_VIDEO_EXAMPLE) += encode_video
libavutil \ DOC_EXAMPLES-$(CONFIG_EXTRACT_MVS_EXAMPLE) += extract_mvs
DOC_EXAMPLES-$(CONFIG_FILTER_AUDIO_EXAMPLE) += filter_audio
CFLAGS += -Wall -g DOC_EXAMPLES-$(CONFIG_FILTERING_AUDIO_EXAMPLE) += filtering_audio
CFLAGS := $(shell pkg-config --cflags $(FFMPEG_LIBS)) $(CFLAGS) DOC_EXAMPLES-$(CONFIG_FILTERING_VIDEO_EXAMPLE) += filtering_video
LDLIBS := $(shell pkg-config --libs $(FFMPEG_LIBS)) $(LDLIBS) DOC_EXAMPLES-$(CONFIG_HTTP_MULTICLIENT_EXAMPLE) += http_multiclient
DOC_EXAMPLES-$(CONFIG_HW_DECODE_EXAMPLE) += hw_decode
EXAMPLES= avio_dir_cmd \ DOC_EXAMPLES-$(CONFIG_METADATA_EXAMPLE) += metadata
avio_reading \ DOC_EXAMPLES-$(CONFIG_MUXING_EXAMPLE) += muxing
decode_audio \ DOC_EXAMPLES-$(CONFIG_QSVDEC_EXAMPLE) += qsvdec
decode_video \ DOC_EXAMPLES-$(CONFIG_REMUXING_EXAMPLE) += remuxing
demuxing_decoding \ DOC_EXAMPLES-$(CONFIG_RESAMPLING_AUDIO_EXAMPLE) += resampling_audio
encode_audio \ DOC_EXAMPLES-$(CONFIG_SCALING_VIDEO_EXAMPLE) += scaling_video
encode_video \ DOC_EXAMPLES-$(CONFIG_TRANSCODE_AAC_EXAMPLE) += transcode_aac
extract_mvs \ DOC_EXAMPLES-$(CONFIG_TRANSCODING_EXAMPLE) += transcoding
filtering_video \
filtering_audio \ DOC_EXAMPLES := $(DOC_EXAMPLES-yes:%=doc/examples/%$(PROGSSUF)$(EXESUF))
http_multiclient \ ALL_DOC_EXAMPLES := $(DOC_EXAMPLES) $(DOC_EXAMPLES-:%=doc/examples/%$(PROGSSUF)$(EXESUF))
hw_decode \ ALL_DOC_EXAMPLES_G := $(DOC_EXAMPLES) $(DOC_EXAMPLES-:%=doc/examples/%$(PROGSSUF)_g$(EXESUF))
metadata \ PROGS += $(DOC_EXAMPLES)
muxing \
remuxing \ EXAMPLES_FILES := $(wildcard $(SRC_PATH)/doc/examples/*.c) $(SRC_PATH)/doc/examples/README
resampling_audio \ EXAMPLE_MAKEFILE := $(SRC_PATH)/doc/examples/Makefile
scaling_video \
transcode_aac \ examples: $(DOC_EXAMPLES)
transcoding \
$(DOC_EXAMPLES:%$(EXESUF)=%.o): | doc/examples
OBJS=$(addsuffix .o,$(EXAMPLES)) OBJDIRS += doc/examples
# the following examples make explicit use of the math library DOXY_INPUT += $(DOC_EXAMPLES:%$(EXESUF)=%.c)
avcodec: LDLIBS += -lm
encode_audio: LDLIBS += -lm examplesclean:
muxing: LDLIBS += -lm $(RM) $(ALL_DOC_EXAMPLES) $(ALL_DOC_EXAMPLES_G)
resampling_audio: LDLIBS += -lm $(RM) $(CLEANSUFFIXES:%=doc/examples/%)
.phony: all clean-test clean docclean:: examplesclean
all: $(OBJS) $(EXAMPLES) .PHONY: examples
clean-test:
$(RM) test*.pgm test.h264 test.mp2 test.sw test.mpg
clean: clean-test
$(RM) $(EXAMPLES) $(OBJS)
# use pkg-config for getting CFLAGS and LDLIBS
FFMPEG_LIBS= libavdevice \
libavformat \
libavfilter \
libavcodec \
libswresample \
libswscale \
libavutil \
CFLAGS += -Wall -g
CFLAGS := $(shell pkg-config --cflags $(FFMPEG_LIBS)) $(CFLAGS)
LDLIBS := $(shell pkg-config --libs $(FFMPEG_LIBS)) $(LDLIBS)
EXAMPLES= avio_dir_cmd \
avio_reading \
decode_audio \
decode_video \
demuxing_decoding \
encode_audio \
encode_video \
extract_mvs \
filtering_video \
filtering_audio \
http_multiclient \
hw_decode \
metadata \
muxing \
remuxing \
resampling_audio \
scaling_video \
transcode_aac \
transcoding \
OBJS=$(addsuffix .o,$(EXAMPLES))
# the following examples make explicit use of the math library
avcodec: LDLIBS += -lm
encode_audio: LDLIBS += -lm
muxing: LDLIBS += -lm
resampling_audio: LDLIBS += -lm
.phony: all clean-test clean
all: $(OBJS) $(EXAMPLES)
clean-test:
$(RM) test*.pgm test.h264 test.mp2 test.sw test.mpg
clean: clean-test
$(RM) $(EXAMPLES) $(OBJS)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment