Merge commit 'acb0dea27efff4b35796015b96570b59fd517078'
authorJames Almer <jamrial@gmail.com>
Fri, 29 Sep 2017 18:09:19 +0000 (15:09 -0300)
committerJames Almer <jamrial@gmail.com>
Fri, 29 Sep 2017 18:12:43 +0000 (15:12 -0300)
* commit 'acb0dea27efff4b35796015b96570b59fd517078':
  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: James Almer <jamrial@gmail.com>
1  2 
Makefile
doc/Makefile
doc/examples/Makefile
doc/examples/Makefile.example

diff --cc Makefile
+++ b/Makefile
@@@ -55,8 -101,7 +55,7 @@@ FFLIBS-$(CONFIG_SWSCALE)    += swscal
  
  FFLIBS := avutil
  
 -DATA_FILES := $(wildcard $(SRC_PATH)/presets/*.avpreset)
 +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
  
@@@ -166,12 -197,11 +166,13 @@@ install-progs-$(CONFIG_SHARED): install
  
  install-progs: install-progs-yes $(AVPROGS)
        $(Q)mkdir -p "$(BINDIR)"
 -      $(INSTALL) -c -m 755 $(AVPROGS) "$(BINDIR)"
 +      $(INSTALL) -c -m 755 $(INSTPROGS) "$(BINDIR)"
  
- install-data: $(DATA_FILES) $(EXAMPLES_FILES)
 -install-data: $(DATA_FILES)
 -      $(Q)mkdir -p "$(DATADIR)"
++install-data: $(DATA_FILES) $(EXAMPLES_FILES) $(EXAMPLE_MAKEFILE)
 +      $(Q)mkdir -p "$(DATADIR)/examples"
        $(INSTALL) -m 644 $(DATA_FILES) "$(DATADIR)"
 +      $(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
  
diff --cc doc/Makefile
@@@ -27,57 -11,17 +27,28 @@@ HTMLPAGES   = $(AVPROGS-yes:%=doc/%.htm
                doc/nut.html                                              \
                doc/platform.html                                         \
  
 -DOCS-$(CONFIG_POD2MAN)                          += $(MANPAGES) $(PODPAGES)
 -DOCS-$(CONFIG_TEXI2HTML)                        += $(HTMLPAGES)
 +TXTPAGES    = doc/fate.txt                                              \
 +
 +
 +DOCS-$(CONFIG_HTMLPAGES) += $(HTMLPAGES)
 +DOCS-$(CONFIG_PODPAGES)  += $(PODPAGES)
 +DOCS-$(CONFIG_MANPAGES)  += $(MANPAGES)
 +DOCS-$(CONFIG_TXTPAGES)  += $(TXTPAGES)
  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: $(DOCS)
 +all-$(CONFIG_DOC): doc
 +
 +doc: documentation
  
  apidoc: doc/doxy/html
  documentation: $(DOCS)
  
- examples: $(DOC_EXAMPLES)
 -TEXIDEP = awk '/^@include/ { printf "$@: $(@D)/%s\n", $$2 }' <$< >$(@:%=%.d)
 +TEXIDEP = perl $(SRC_PATH)/doc/texidep.pl $(SRC_PATH) $< $@ >$(@:%=%.d)
 +
 +doc/%.txt: TAG = TXT
 +doc/%.txt: doc/%.texi
 +      $(Q)$(TEXIDEP)
 +      $(M)makeinfo --force --no-headers -o $@ $< 2>/dev/null
  
  GENTEXI  = format codec
  GENTEXI := $(GENTEXI:%=doc/avoptions_%.texi)
@@@ -87,69 -33,34 +58,67 @@@ $(GENTEXI): doc/avoptions_%.texi: doc/p
        $(M)doc/print_options $* > $@
  
  doc/%.html: TAG = HTML
 -doc/%.html: doc/%.texi $(SRC_PATH)/doc/t2h.init
 +doc/%-all.html: TAG = HTML
 +
 +ifdef HAVE_MAKEINFO_HTML
 +doc/%.html: doc/%.texi $(SRC_PATH)/doc/t2h.pm $(GENTEXI)
        $(Q)$(TEXIDEP)
 -      $(M)texi2html -I doc -monolithic --init-file $(SRC_PATH)/doc/t2h.init --output $@ $<
 +      $(M)makeinfo --html -I doc --no-split -D config-not-all --init-file=$(SRC_PATH)/doc/t2h.pm --output $@ $<
 +
 +doc/%-all.html: doc/%.texi $(SRC_PATH)/doc/t2h.pm $(GENTEXI)
 +      $(Q)$(TEXIDEP)
 +      $(M)makeinfo --html -I doc --no-split -D config-all --init-file=$(SRC_PATH)/doc/t2h.pm --output $@ $<
 +else
 +doc/%.html: doc/%.texi $(SRC_PATH)/doc/t2h.init $(GENTEXI)
 +      $(Q)$(TEXIDEP)
 +      $(M)texi2html -I doc -monolithic --D=config-not-all --init-file $(SRC_PATH)/doc/t2h.init --output $@ $<
 +
 +doc/%-all.html: doc/%.texi $(SRC_PATH)/doc/t2h.init $(GENTEXI)
 +      $(Q)$(TEXIDEP)
 +      $(M)texi2html -I doc -monolithic --D=config-all --init-file $(SRC_PATH)/doc/t2h.init --output $@ $<
 +endif
  
  doc/%.pod: TAG = POD
 -doc/%.pod: doc/%.texi $(SRC_PATH)/doc/texi2pod.pl
 +doc/%.pod: doc/%.texi $(SRC_PATH)/doc/texi2pod.pl $(GENTEXI)
 +      $(Q)$(TEXIDEP)
 +      $(M)perl $(SRC_PATH)/doc/texi2pod.pl -Dconfig-not-all=yes -Idoc $< $@
 +
 +doc/%-all.pod: TAG = POD
 +doc/%-all.pod: doc/%.texi $(SRC_PATH)/doc/texi2pod.pl $(GENTEXI)
        $(Q)$(TEXIDEP)
 -      $(M)$(SRC_PATH)/doc/texi2pod.pl -Idoc $< $@
 +      $(M)perl $(SRC_PATH)/doc/texi2pod.pl -Dconfig-all=yes -Idoc $< $@
  
 -doc/%.1: TAG = MAN
 -doc/%.1: doc/%.pod
 -      $(M)pod2man --section=1 --center=" " --release=" " $< > $@
 +doc/%.1 doc/%.3: TAG = MAN
 +doc/%.1: doc/%.pod $(GENTEXI)
 +      $(M)pod2man --section=1 --center=" " --release=" " --date=" " $< > $@
 +doc/%.3: doc/%.pod $(GENTEXI)
 +      $(M)pod2man --section=3 --center=" " --release=" " --date=" " $< > $@
  
  $(DOCS) doc/doxy/html: | doc/
- $(DOC_EXAMPLES:%$(EXESUF)=%.o): | doc/examples
- OBJDIRS += doc/examples
  
- DOXY_INPUT      = $(INSTHEADERS) $(DOC_EXAMPLES:%$(EXESUF)=%.c)
 -DOXY_INPUT      = $(addprefix $(SRC_PATH)/, $(INSTHEADERS))
 -DOXY_TEMPLATES  = doxy_stylesheet.css footer.html header.html
 -DOXY_TEMPLATES := $(addprefix $(SRC_PATH)/doc/doxy/, $(DOXY_TEMPLATES))
++DOXY_INPUT      = $(INSTHEADERS)
 +DOXY_INPUT_DEPS = $(addprefix $(SRC_PATH)/, $(DOXY_INPUT)) ffbuild/config.mak
 +
 +doc/doxy/html: TAG = DOXY
 +doc/doxy/html: $(SRC_PATH)/doc/Doxyfile $(SRC_PATH)/doc/doxy-wrapper.sh $(DOXY_INPUT_DEPS)
 +      $(M)OUT_DIR=$$PWD/doc/doxy; cd $(SRC_PATH); ./doc/doxy-wrapper.sh $$OUT_DIR $< $(DOXYGEN) $(DOXY_INPUT);
 +
 +install-doc: install-html install-man
  
 -doc/doxy/html: $(SRC_PATH)/doc/Doxyfile $(DOXY_INPUT) $(DOXY_TEMPLATES)
 -      $(M)$(SRC_PATH)/doc/doxy-wrapper.sh $(SRC_PATH) $< $(DOXY_INPUT)
 +install-html:
  
 -install-progs-$(CONFIG_POD2MAN): install-man
 -install-progs-$(CONFIG_TEXI2HTML): install-doc
 +install-man:
  
 -install-doc: $(HTMLPAGES)
 +ifdef CONFIG_HTMLPAGES
 +install-progs-$(CONFIG_DOC): install-html
 +
 +install-html: $(HTMLPAGES)
        $(Q)mkdir -p "$(DOCDIR)"
        $(INSTALL) -m 644 $(HTMLPAGES) "$(DOCDIR)"
 +endif
 +
 +ifdef CONFIG_MANPAGES
 +install-progs-$(CONFIG_DOC): install-man
  
  install-man: $(MANPAGES)
        $(Q)mkdir -p "$(MANDIR)/man1"
@@@ -166,21 -72,11 +135,17 @@@ uninstall-html
        $(RM) -r "$(DOCDIR)"
  
  uninstall-man:
 -      $(RM) $(addprefix "$(MANDIR)/man1/",$(ALLMANPAGES))
 +      $(RM) $(addprefix "$(MANDIR)/man1/",$(AVPROGS-yes:%=%.1) $(AVPROGS-yes:%=%-all.1) $(COMPONENTS-yes:%=%.1))
 +      $(RM) $(addprefix "$(MANDIR)/man3/",$(LIBRARIES-yes:%=%.3))
 +
 +clean:: docclean
 +
 +distclean:: docclean
 +      $(RM) doc/config.texi
  
- examplesclean:
-       $(RM) $(ALL_DOC_EXAMPLES) $(ALL_DOC_EXAMPLES_G)
-       $(RM) $(CLEANSUFFIXES:%=doc/examples/%)
- docclean: examplesclean
 -clean::
++docclean::
        $(RM) $(CLEANSUFFIXES:%=doc/%)
 -      $(RM) doc/*.html doc/*.pod doc/*.1 doc/avoptions_*.texi
 +      $(RM) $(TXTPAGES) doc/*.html doc/*.pod doc/*.1 doc/*.3 doc/avoptions_*.texi
        $(RM) -r doc/doxy/html
  
  -include $(wildcard $(DOCS:%=%.d))
@@@ -1,50 -1,26 +1,44 @@@
- # 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
 -DOC_EXAMPLES-$(CONFIG_DECODE_AUDIO_EXAMPLE)     += decode_audio
 -DOC_EXAMPLES-$(CONFIG_DECODE_VIDEO_EXAMPLE)     += decode_video
 -DOC_EXAMPLES-$(CONFIG_ENCODE_AUDIO_EXAMPLE)     += encode_audio
 -DOC_EXAMPLES-$(CONFIG_ENCODE_VIDEO_EXAMPLE)     += encode_video
 -DOC_EXAMPLES-$(CONFIG_FILTER_AUDIO_EXAMPLE)     += filter_audio
 -DOC_EXAMPLES-$(CONFIG_METADATA_EXAMPLE)         += metadata
 -DOC_EXAMPLES-$(CONFIG_OUTPUT_EXAMPLE)           += output
 -DOC_EXAMPLES-$(CONFIG_QSVDEC_EXAMPLE)           += qsvdec
 -DOC_EXAMPLES-$(CONFIG_TRANSCODE_AAC_EXAMPLE)    += transcode_aac
--
- clean: clean-test
-       $(RM) $(EXAMPLES) $(OBJS)
 -DOC_EXAMPLES     := $(DOC_EXAMPLES-yes:%=doc/examples/%$(EXESUF))
 -ALL_DOC_EXAMPLES := $(DOC_EXAMPLES) $(DOC_EXAMPLES-:%=doc/examples/%$(EXESUF))
 -PROGS            += $(DOC_EXAMPLES)
++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)
++
++EXAMPLES_FILES := $(wildcard $(SRC_PATH)/doc/examples/*.c) $(SRC_PATH)/doc/examples/README
++EXAMPLE_MAKEFILE := $(SRC_PATH)/doc/examples/Makefile
+ examples: $(DOC_EXAMPLES)
+ $(DOC_EXAMPLES:%$(EXESUF)=%.o): | doc/examples
+ OBJDIRS += doc/examples
 -DOXY_INPUT += $(addprefix $(SRC_PATH)/, $(DOC_EXAMPLES:%$(EXESUF)=%.c))
++DOXY_INPUT += $(DOC_EXAMPLES:%$(EXESUF)=%.c)
 -clean::
 -      $(RM) $(ALL_DOC_EXAMPLES)
++examplesclean:
++      $(RM) $(ALL_DOC_EXAMPLES) $(ALL_DOC_EXAMPLES_G)
+       $(RM) $(CLEANSUFFIXES:%=doc/examples/%)
++docclean:: examplesclean
++
+ .PHONY: examples
index 0000000,0000000..6428154
new file mode 100644 (file)
--- /dev/null
--- /dev/null
@@@ -1,0 -1,0 +1,50 @@@
++# 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)