简体   繁体   English

makefile 的多个 extra-cflags

[英]Multiple extra-cflags of a makefile

so there is this library am trying to use ffmpeg.js and am customizing the Makefile .所以这个库正在尝试使用ffmpeg.js并正在自定义Makefile I have done everything that I wanted to do but on building, I got the error ERROR: opus not found using pkg-config .我已经完成了我想做的所有事情,但是在构建时,我收到错误ERROR: opus not found using pkg-config Now I have two problems:现在我有两个问题:

--extra-cflags="-s USE_ZLIB=1 -I../lame/dist/include -I../libvpx/dist/include" this configuration was initially --extra-cflags="-s USE_ZLIB=1 -I../lame/dist/include" but I wanted to include two folders, so is the merging correct or that's where I went wrong. --extra-cflags="-s USE_ZLIB=1 -I../lame/dist/include -I../libvpx/dist/include"这个配置最初是--extra-cflags="-s USE_ZLIB=1 -I../lame/dist/include"但我想包括两个文件夹,所以合并是正确的还是那是我出错的地方。

The complete Makefile is as below (there are alot of changes from the original one from the repository), is there anything I did wrong?完整的Makefile如下(与存储库中的原始版本相比有很多更改),我做错了什么吗?

PRE_JS = build/pre.js
POST_JS_SYNC = build/post-sync.js

COMMON_FILTERS = aresample scale crop overlay hstack vstack
COMMON_DEMUXERS = matroska ogg mov mp3 wav image2 concat
COMMON_DECODERS = vp8 vp9 h264 vorbis opus mp3 aac pcm_s16le mjpeg png

COMMON_BSFS = vp9_superframe

MUXERS = mp4 mp3 webm ogg null
ENCODERS = libx264 libmp3lame aac libvpx_vp8 libopus
FFMPEG_BC = build/ffmpeg/ffmpeg.bc
FFMPEG_PC_PATH = ../x264/dist/lib/pkgconfig
SHARED_DEPS = \
    build/lame/dist/lib/libmp3lame.so \
    build/x264/dist/lib/libx264.so \
    build/opus/dist/lib/libopus.so \
    build/libvpx/dist/lib/libvpx.so

all: ffmpeg.js

clean: clean-js \
    clean-opus clean-libvpx clean-lame \
    clean-x264 clean-ffmpeg
clean-js:
    rm -f ffmpeg*.js
clean-opus:
    cd build/opus && git clean -xdf
clean-libvpx:
    cd build/libvpx && git clean -xdf
clean-lame:
    cd build/lame && git clean -xdf
clean-x264:
    cd build/x264 && git clean -xdf
clean-ffmpeg:
    cd build/ffmpeg-mp4 && git clean -xdf

build/opus/configure:
    cd build/opus && ./autogen.sh

build/opus/dist/lib/libopus.so: build/opus/configure
    cd build/opus && \
    emconfigure ./configure \
        CFLAGS=-O3 \
        --prefix="$$(pwd)/dist" \
        --disable-static \
        --disable-doc \
        --disable-extra-programs \
        --disable-asm \
        --disable-rtcd \
        --disable-intrinsics \
        --disable-hardening \
        --disable-stack-protector \
        && \
    emmake make -j && \
    emmake make install

build/libvpx/dist/lib/libvpx.so:
    cd build/libvpx && \
    git reset --hard && \
    patch -p1 < ../libvpx-fix-ld.patch && \
    emconfigure ./configure \
        --prefix="$$(pwd)/dist" \
        --target=generic-gnu \
        --disable-dependency-tracking \
        --disable-multithread \
        --disable-runtime-cpu-detect \
        --enable-shared \
        --disable-static \
        \
        --disable-examples \
        --disable-docs \
        --disable-unit-tests \
        --disable-webm-io \
        --disable-libyuv \
        --disable-vp8-decoder \
        --disable-vp9 \
        && \
    emmake make -j && \
    emmake make install

build/lame/dist/lib/libmp3lame.so:
    cd build/lame/lame && \
    git reset --hard && \
    patch -p2 < ../../lame-fix-ld.patch && \
    emconfigure ./configure \
        CFLAGS="-DNDEBUG -O3" \
        --prefix="$$(pwd)/../dist" \
        --host=x86-none-linux \
        --disable-static \
        \
        --disable-gtktest \
        --disable-analyzer-hooks \
        --disable-decoder \
        --disable-frontend \
        && \
    emmake make -j && \
    emmake make install

build/x264/dist/lib/libx264.so:
    cd build/x264 && \
    emconfigure ./configure \
        --prefix="$$(pwd)/dist" \
        --extra-cflags="-Wno-unknown-warning-option" \
        --host=x86-none-linux \
        --disable-cli \
        --enable-shared \
        --disable-opencl \
        --disable-thread \
        --disable-interlaced \
        --bit-depth=8 \
        --chroma-format=420 \
        --disable-asm \
        \
        --disable-avs \
        --disable-swscale \
        --disable-lavf \
        --disable-ffms \
        --disable-gpac \
        --disable-lsmash \
        && \
    emmake make -j && \
    emmake make install

FFMPEG_COMMON_ARGS = \
    --cc=emcc \
    --ranlib=emranlib \
    --enable-cross-compile \
    --target-os=none \
    --arch=x86 \
    --disable-runtime-cpudetect \
    --disable-asm \
    --disable-fast-unaligned \
    --disable-pthreads \
    --disable-w32threads \
    --disable-os2threads \
    --disable-debug \
    --disable-stripping \
    --disable-safe-bitstream-reader \
    \
    --disable-all \
    --enable-ffmpeg \
    --enable-avcodec \
    --enable-avformat \
    --enable-avfilter \
    --enable-swresample \
    --enable-swscale \
    --disable-network \
    --disable-d3d11va \
    --disable-dxva2 \
    --disable-vaapi \
    --disable-vdpau \
    $(addprefix --enable-bsf=,$(COMMON_BSFS)) \
    $(addprefix --enable-decoder=,$(COMMON_DECODERS)) \
    $(addprefix --enable-demuxer=,$(COMMON_DEMUXERS)) \
    --enable-protocol=file \
    $(addprefix --enable-filter=,$(COMMON_FILTERS)) \
    --disable-bzlib \
    --disable-iconv \
    --disable-libxcb \
    --disable-lzma \
    --disable-sdl2 \
    --disable-securetransport \
    --disable-xlib \
    --enable-zlib

build/ffmpeg/ffmpeg.bc: $(SHARED_DEPS)
    cd build/ffmpeg-mp4 && \
    EM_PKG_CONFIG_PATH=$(FFMPEG_PC_PATH) emconfigure ./configure \
        $(FFMPEG_COMMON_ARGS) \
        $(addprefix --enable-encoder=,$(ENCODERS)) \
        $(addprefix --enable-muxer=,$(MUXERS)) \
        --enable-gpl \
        --enable-libmp3lame \
        --enable-libx264 \
        --enable-libopus \
        --enable-libvpx \
        --extra-cflags="-s USE_ZLIB=1 -I../lame/dist/include -I../libvpx/dist/include" \
        --extra-ldflags="-L../lame/dist/lib -L../libvpx/dist/lib" \
        && \
    emmake make -j && \
    cp ffmpeg ffmpeg.bc

EMCC_COMMON_ARGS = \
    -O3 \
    --closure 1 \
    --memory-init-file 0 \
    -s WASM=0 \
    -s WASM_ASYNC_COMPILATION=0 \
    -s ASSERTIONS=0 \
    -s EXIT_RUNTIME=1 \
    -s NODEJS_CATCH_EXIT=0 \
    -s NODEJS_CATCH_REJECTION=0 \
    -s TOTAL_MEMORY=67108864 \
    -lnodefs.js -lworkerfs.js \
    --pre-js $(PRE_JS) \
    -o $@

ffmpeg.js: $(FFMPEG_BC) $(PRE_JS) $(POST_JS_SYNC)
    emcc $(FFMPEG_BC) $(SHARED_DEPS) \
        --post-js $(POST_JS_SYNC) \
        $(EMCC_COMMON_ARGS) -O2

What I was trying to achieve was combine some of the webm encoders and muxers into the mp4 module so I use only that one module for all webm and mp4 format types.我试图实现的是将一些 webm 编码器和多路复用器组合到 mp4 模块中,因此我只将那个模块用于所有 webm 和 mp4 格式类型。

Also one thing to know about me, the whole Makefile and C and building it is totally new territory for me, I just did what I thought was right, thanks in advance.还有一件事要了解我,整个 Makefile 和 C 以及构建它对我来说都是全新的领域,我只是做了我认为正确的事情,在此先感谢。

It's good you have solid goals.你有坚定的目标是件好事。 Without those, the problem is much harder.没有这些,问题就更难了。

What you need to do is understand the commands you would run, without make or Makefiles, to achieve those goals, and the files that are created along the way.您需要做的是了解为实现这些目标而在没有 make 或 Makefile 的情况下要运行的命令,以及在此过程中创建的文件。 With this, you then encode those commands in the format这样,您就可以将这些命令编码为以下格式

file_to_be_created:source_file_1 source_file_2 source_file_3
<tab>command to be executed
<tab>second command to be executed

The tabs are an unfortunate side-effect of a bad choice in make's history.这些选项卡是 make 历史上错误选择的不幸副作用。

With this, you can modify the Makefile. If you have one source that is built from other sources, make two "make" rules using the pattern above, and make will correctly determine the build order and run the commands needed.有了这个,您可以修改 Makefile。如果您有一个源是从其他源构建的,请使用上面的模式制定两个“make”规则,make 将正确确定构建顺序并运行所需的命令。 If make determines a crated file is newer than its sources, it will skip building the created file.如果 make 确定创建的文件比其来源更新,它将跳过构建创建的文件。

As you can see, while make is not very complicated, it does little to help you know the commands you must run.正如您所看到的,虽然 make 不是很复杂,但它几乎无法帮助您了解必须运行的命令。 Maybe you know them already;也许你已经认识他们了; but, if you don't I'd take your personal knowledge and what you can read out of the Makefile and combine them to see if you can fashion the make file rules you need.但是,如果你不这样做,我会利用你的个人知识和你可以从 Makefile 中读到的内容,并将它们结合起来,看看你是否可以设计你需要的 make 文件规则。

Initially, I'd do this by creating new rules and new files, because if you break a rule you need, odds are you won't find out until much later.最初,我会通过创建新规则和新文件来做到这一点,因为如果你违反了你需要的规则,很可能要等到很久以后你才会发现。 Once you get something building, you can review if you should roll you rules into some of the existing ones or not.一旦你建立了一些东西,你就可以审查是否应该将你的规则纳入一些现有的规则中。

Good luck!祝你好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM