Skip to content

Commit

Permalink
Repair Mac Build processes (#1390)
Browse files Browse the repository at this point in the history
* Fix Mac Build processes

For all:
  Add Neon files to libpng for Apple Silicon
  Update compilation.md documentation

For autoconf:
  Make Linux and Mac Makefile.am and configure.ac identical
  Fix wrong location for zvbi/bcd.h in both Mac/Linux

For cmake::
  Include GPAC config for Darwin in Mac version

For mac/build.command:
  Update for new zvbi location

* Update CHANGES.TXT for Mac Build commit
  • Loading branch information
mackworth committed Nov 10, 2021
1 parent 8c10ded commit 0ebeec4
Show file tree
Hide file tree
Showing 13 changed files with 1,393 additions and 189 deletions.
251 changes: 126 additions & 125 deletions docs/CHANGES.TXT

Large diffs are not rendered by default.

50 changes: 23 additions & 27 deletions docs/COMPILATION.MD
Expand Up @@ -60,7 +60,7 @@ cd ccextractor/linux
sudo apt-get install autoconf #Dependency to generate configuration script
cd ccextractor/linux
./autogen.sh
./configure or ./configure --without-rust
./configure # OR ./configure --without-rust
make

# test your build
Expand All @@ -74,14 +74,12 @@ sudo make install

```bash
#Create and navigate to directory where you want to store built files

cd ccextractor/
mkdir build
cd build

#Generate makefile using cmake and then compile

cmake ../src/
cmake ../src/ # options here
make

# test your build
Expand All @@ -91,13 +89,16 @@ make
sudo make install
```

`cmake` also accepts the argument `-DWITH_OCR=ON` to enable OCR and `-DWITHOUT_RUST=ON` to disable rust.
`cmake` also accepts the options:
`-DWITH_OCR=ON` to enable OCR
`-DWITHOUT_RUST=ON` to disable rust.
`-DWITH_HARDSUBX=ON` to enable burned-in subtitles

### Compiling with GUI:

To build CCExtractor with a gui you will additionally need to install [GLEW](http://glew.sourceforge.net/build.html) and [GLFW](http://www.glfw.org/docs/latest/compile.html)
To build CCExtractor with a GUI, you will additionally need to install [GLEW](http://glew.sourceforge.net/build.html) and [GLFW](http://www.glfw.org/docs/latest/compile.html)

In order to compile it you'll need to configure it using autoconf by passing the `-with-gui` option.
In order to compile it, you'll need to configure it using autoconf by passing the `-with-gui` option.

```bash
./autogen.sh
Expand All @@ -112,16 +113,18 @@ Once set up you can run the GUI interface from the terminal `./ccextractorGUI`

## macOS

1. Make sure all the dependencies are met. They can be installed via Homebrew as
1. Make sure all the dependencies are met. Decide if you want OCR; if so, you'll need to install tesseract and leptonica.
Dependencies can be installed via Homebrew as:

```bash
brew install pkg-config
brew install autoconf automake libtool
# optional if you want OCR:
brew install tesseract
brew install leptonica
```

Use pkg-config to verify tesseract and leptonica dependencies, e.g.
If configuring OCR, use pkg-config to verify tesseract and leptonica dependencies, e.g.

```bash
pkg-config --exists --print-errors tesseract
Expand All @@ -134,17 +137,7 @@ pkg-config --exists --print-errors lept

```bash
cd ccextractor/mac
./build.command OCR

# test your build
./ccextractor
```

If you don't want the OCR capabilities, then you don't need to configure the tesseract and leptonica packages, and build it with just

```bash
cd ccextractor/mac
./build.command
./build.command # OR ./build.command OCR

# test your build
./ccextractor
Expand All @@ -154,26 +147,29 @@ cd ccextractor/mac

```bash
#Create and navigate to directory where you want to store built files

cd ccextractor/
mkdir build
cd build

#Generate makefile using cmake and then compile

cmake ../src/
cmake ../src/ # options here
make

# test your build
./ccextractor
```

`cmake` also accepts the options:
`-DWITH_OCR=ON` to enable OCR
`-DWITHOUT_RUST=ON` to disable rust.
`-DWITH_HARDSUBX=ON` to enable burned-in subtitles

#### Standard compilation through Autoconf scripts:

```bash
cd ccextractor/mac
./autogen.sh
./configure
./configure # OR .configure --without-rust
make

# test your build
Expand All @@ -189,15 +185,15 @@ brew install glfw
brew install glew
```

In order to compile it you'll need to configure it using autoconf by passing the `-with-gui` option.
In order to compile it, you'll need to configure it using autoconf by passing the `-with-gui` option.

```bash
./autogen.sh
./configure --with-gui
./configure --with-gui #OR .configure --with-gui --without-rust
make
```

Once set up you can run the GUI interface from the terminal `./ccextractorGUI`
Once set up, you can run the GUI interface from the terminal `./ccextractorGUI`

## Windows
Note: Following screenshots and steps are based on Visual Studio 2017, but they should be more or less same for other versions.
Expand Down
18 changes: 12 additions & 6 deletions linux/Makefile.am
Expand Up @@ -262,7 +262,7 @@ ccextractor_SOURCES = \
../src/thirdparty/lib_hash/sha2.h \
../src/thirdparty/protobuf-c/protobuf-c.c \
../src/thirdparty/protobuf-c/protobuf-c.h \
../src/thirdparty/zvbi/bcd.h \
../src/lib_ccx/zvbi/bcd.h \
../src/lib_ccx/zvbi/bit_slicer.c \
../src/lib_ccx/zvbi/bit_slicer.h \
../src/lib_ccx/zvbi/decoder.c \
Expand All @@ -274,7 +274,7 @@ ccextractor_SOURCES = \
../src/lib_ccx/zvbi/sampling_par.h \
../src/lib_ccx/zvbi/sliced.h \
../src/lib_ccx/zvbi/zvbi_decoder.h \
../src/freetype/* \
../src/freetype/* \
../src/thirdparty/freetype/autofit/autofit.c \
../src/thirdparty/freetype/base/ftbase.c \
../src/thirdparty/freetype/base/ftbbox.c \
Expand Down Expand Up @@ -303,7 +303,7 @@ ccextractor_SOURCES = \
../src/thirdparty/freetype/cff/cff.c \
../src/thirdparty/freetype/cid/type1cid.c \
../src/thirdparty/freetype/gzip/ftgzip.c \
../src/thirdparty/freetype/include/ft2build.h \
../src/thirdparty/freetype/include/ft2build.h \
../src/thirdparty/freetype/lzw/ftlzw.c \
../src/thirdparty/freetype/pcf/pcf.c \
../src/thirdparty/freetype/pfr/pfr.c \
Expand All @@ -318,9 +318,15 @@ ccextractor_SOURCES = \
../src/thirdparty/freetype/type42/type42.c \
../src/thirdparty/freetype/winfonts/winfnt.c

if SYS_IS_APPLE_SILICON
ccextractor_SOURCES += ../src/thirdparty/libpng/arm/arm_init.c \
../src/thirdparty/libpng/arm/filter_neon_intrinsics.c \
../src/thirdparty/libpng/arm/palette_neon_intrinsics.c
endif

ccextractor_CFLAGS = -std=gnu99 -Wno-write-strings -Wno-pointer-sign -D_FILE_OFFSET_BITS=64 -DVERSION_FILE_PRESENT -DFT2_BUILD_LIBRARY -DGPAC_DISABLE_VTT -DGPAC_DISABLE_OD_DUMP -DGPAC_DISABLE_REMOTERY -DNO_GZIP -DGPAC_HAVE_CONFIG_H

ccextractor_CPPFLAGS =-I../src/lib_ccx/ -I../src/thirdparty/gpacmp4/ -I../src/thirdparty/libpng/ -I../src/thirdparty/zlib/ -I../src/thirdparty/zvbi/ -I../src/thirdparty/lib_hash/ -I../src/thirdparty/protobuf-c/ -I../src/thirdparty -I../src/ -I../src/thirdparty/freetype/include/
ccextractor_CPPFLAGS =-I../src/lib_ccx/ -I../src/thirdparty/gpacmp4/ -I../src/thirdparty/libpng/ -I../src/thirdparty/zlib/ -I../src/lib_ccx/zvbi/ -I../src/thirdparty/lib_hash/ -I../src/thirdparty/protobuf-c/ -I../src/thirdparty -I../src/ -I../src/thirdparty/freetype/include/


ccextractor_LDADD=-lm -lpthread -ldl
Expand Down Expand Up @@ -348,7 +354,7 @@ endif

if SYS_IS_MAC
ccextractor_CFLAGS += -DPAC_CONFIG_DARWIN -Dfopen64=fopen -Dopen64=open -Dlseek64=lseek
ccextractor_LDADD += -liconv -lz
ccextractor_LDADD += -liconv -lz
endif

if SYS_IS_64_BIT
Expand Down Expand Up @@ -445,7 +451,7 @@ endif

if HARDSUBX_IS_ENABLED
if OCR_IS_ENABLED
ccextractorGUI_CFLAGS += -DENABLE_OCR
ccextractorGUI_CFLAGS += -DENABLE_OCR
endif
endif

Expand Down
1 change: 1 addition & 0 deletions linux/configure.ac
Expand Up @@ -158,6 +158,7 @@ AM_CONDITIONAL(TESSERACT_PRESENT, [ test ! -z `pkg-config --libs-only-l --silen
AM_CONDITIONAL(TESSERACT_PRESENT_RPI, [ test -d "/usr/include/tesseract" && test `ls -A /usr/include/tesseract | wc -l` -gt 0 ])
AM_CONDITIONAL(SYS_IS_LINUX, [ test `uname -s` = "Linux"])
AM_CONDITIONAL(SYS_IS_MAC, [ test `uname -s` = "Darwin"])
AM_CONDITIONAL(SYS_IS_APPLE_SILICON, [ test `uname -a | awk '{print $NF}'` = "arm64" ])
AM_CONDITIONAL(BUILD_WITH_GUI, [test "x$with_gui" = "xyes"])
AM_CONDITIONAL(SYS_IS_64_BIT,[test `getconf LONG_BIT` = "64"])

Expand Down
65 changes: 47 additions & 18 deletions mac/Makefile.am
@@ -1,5 +1,5 @@
AUTOMAKE_OPTIONS = foreign

ACLOCAL_AMFLAGS = -I m4/

bin_PROGRAMS = ccextractor
ccextractor_SOURCES = \
Expand Down Expand Up @@ -80,6 +80,7 @@ ccextractor_SOURCES = \
../src/thirdparty/gpacmp4/gpac/tools.h \
../src/thirdparty/gpacmp4/gpac/utf.h \
../src/thirdparty/gpacmp4/gpac/version.h \
../src/thirdparty/gpacmp4/gpac/iso639.h \
../src/thirdparty/gpacmp4/gpac/internal/avilib.h \
../src/thirdparty/gpacmp4/gpac/internal/isomedia_dev.h \
../src/thirdparty/gpacmp4/gpac/internal/media_dev.h \
Expand Down Expand Up @@ -261,18 +262,19 @@ ccextractor_SOURCES = \
../src/thirdparty/lib_hash/sha2.h \
../src/thirdparty/protobuf-c/protobuf-c.c \
../src/thirdparty/protobuf-c/protobuf-c.h \
../src/thirdparty/zvbi/bcd.h \
../src/thirdparty/zvbi/bit_slicer.c \
../src/thirdparty/zvbi/bit_slicer.h \
../src/thirdparty/zvbi/decoder.c \
../src/thirdparty/zvbi/macros.h \
../src/thirdparty/zvbi/misc.h \
../src/thirdparty/zvbi/raw_decoder.c \
../src/thirdparty/zvbi/raw_decoder.h \
../src/thirdparty/zvbi/sampling_par.c \
../src/thirdparty/zvbi/sampling_par.h \
../src/thirdparty/zvbi/sliced.h \
../src/thirdparty/zvbi/zvbi_decoder.h \
../src/lib_ccx/zvbi/bcd.h \
../src/lib_ccx/zvbi/bit_slicer.c \
../src/lib_ccx/zvbi/bit_slicer.h \
../src/lib_ccx/zvbi/decoder.c \
../src/lib_ccx/zvbi/macros.h \
../src/lib_ccx/zvbi/misc.h \
../src/lib_ccx/zvbi/raw_decoder.c \
../src/lib_ccx/zvbi/raw_decoder.h \
../src/lib_ccx/zvbi/sampling_par.c \
../src/lib_ccx/zvbi/sampling_par.h \
../src/lib_ccx/zvbi/sliced.h \
../src/lib_ccx/zvbi/zvbi_decoder.h \
../src/freetype/* \
../src/thirdparty/freetype/autofit/autofit.c \
../src/thirdparty/freetype/base/ftbase.c \
../src/thirdparty/freetype/base/ftbbox.c \
Expand Down Expand Up @@ -301,6 +303,7 @@ ccextractor_SOURCES = \
../src/thirdparty/freetype/cff/cff.c \
../src/thirdparty/freetype/cid/type1cid.c \
../src/thirdparty/freetype/gzip/ftgzip.c \
../src/thirdparty/freetype/include/ft2build.h \
../src/thirdparty/freetype/lzw/ftlzw.c \
../src/thirdparty/freetype/pcf/pcf.c \
../src/thirdparty/freetype/pfr/pfr.c \
Expand All @@ -314,22 +317,48 @@ ccextractor_SOURCES = \
../src/thirdparty/freetype/type1/type1.c \
../src/thirdparty/freetype/type42/type42.c \
../src/thirdparty/freetype/winfonts/winfnt.c


if SYS_IS_APPLE_SILICON
ccextractor_SOURCES += ../src/thirdparty/libpng/arm/arm_init.c \
../src/thirdparty/libpng/arm/filter_neon_intrinsics.c \
../src/thirdparty/libpng/arm/palette_neon_intrinsics.c
endif

ccextractor_CFLAGS = -std=gnu99 -Wno-write-strings -Wno-pointer-sign -D_FILE_OFFSET_BITS=64 -DVERSION_FILE_PRESENT -DFT2_BUILD_LIBRARY -DGPAC_DISABLE_VTT -DGPAC_DISABLE_OD_DUMP -DGPAC_DISABLE_REMOTERY -DNO_GZIP -DGPAC_HAVE_CONFIG_H

ccextractor_CPPFLAGS =-I../src/lib_ccx/ -I../src/thirdparty/gpacmp4/ -I../src/thirdparty/libpng/ -I../src/thirdparty/zlib/ -I../src/thirdparty/zvbi/ -I../src/thirdparty/lib_hash/ -I../src/thirdparty/protobuf-c -I../src/thirdparty -I../src -I../src/thirdparty/freetype/include
ccextractor_CPPFLAGS =-I../src/lib_ccx/ -I../src/thirdparty/gpacmp4/ -I../src/thirdparty/libpng/ -I../src/thirdparty/zlib/ -I../src/lib_ccx/zvbi/ -I../src/thirdparty/lib_hash/ -I../src/thirdparty/protobuf-c/ -I../src/thirdparty -I../src/ -I../src/thirdparty/freetype/include/


ccextractor_LDADD=-lm -lpthread -ldl

if WITH_RUST
ccextractor_LDADD += ./rust/@RUST_TARGET_SUBDIR@/libccx_rust.a
else
ccextractor_CFLAGS += -DDISABLE_RUST
ccextractor_CPPFLAGS += -DDISABLE_RUST
endif

if DEBUG_RELEASE
CARGO_RELEASE_ARGS=
else
CARGO_RELEASE_ARGS=--release
endif

./rust/@RUST_TARGET_SUBDIR@/libccx_rust.a:
cd ../src/rust && \
CARGO_TARGET_DIR=../../linux/rust $(CARGO) build $(CARGO_RELEASE_ARGS);

if SYS_IS_LINUX
ccextractor_CFLAGS += -O3 -s -DGPAC_CONFIG_LINUX
endif

if SYS_IS_MAC
ccextractor_CFLAGS += -DPAC_CONFIG_DARWIN -Dfopen64=fopen -Dopen64=open -Dlseek64=lseek
ccextractor_LDADD += -liconv -lz
ccextractor_LDADD += -liconv -lz
endif

if SYS_IS_64_BIT
ccextractor_CFLAGS += -DGPAC_64_BITS
endif

if HARDSUBX_IS_ENABLED
Expand Down Expand Up @@ -417,12 +446,12 @@ ccextractorGUI_CFLAGS += -O3 -DUNIX
ccextractorGUI_CFLAGS += ${glew_CFLAGS}
ccextractorGUI_LDADD += ${glew_LIBS}
ccextractorGUI_LDFLAGS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
ccextractorGUI_LDADD += -lm -L/usr/local/lib -lpthread
ccextractorGUI_LDADD += -lglfw -lm -L/usr/local/lib -lpthread
endif

if HARDSUBX_IS_ENABLED
if OCR_IS_ENABLED
ccextractorGUI_CFLAGS += -DENABLE_OCR
ccextractorGUI_CFLAGS += -DENABLE_OCR
endif
endif

Expand Down
5 changes: 2 additions & 3 deletions mac/build.command
@@ -1,8 +1,8 @@
#!/bin/bash
cd `dirname $0`
BLD_FLAGS="-std=gnu99 -Wno-write-strings -Wno-pointer-sign -DGPAC_CONFIG_DARWIN -D_FILE_OFFSET_BITS=64 -DVERSION_FILE_PRESENT -Dfopen64=fopen -Dopen64=open -Dlseek64=lseek -DFT2_BUILD_LIBRARY -DGPAC_DISABLE_VTT -DGPAC_DISABLE_OD_DUMP -DGPAC_DISABLE_REMOTERY -DNO_GZIP -DGPAC_HAVE_CONFIG_H"
BLD_FLAGS="-std=gnu99 -Wno-write-strings -Wno-pointer-sign -DGPAC_CONFIG_DARWIN -D_FILE_OFFSET_BITS=64 -DVERSION_FILE_PRESENT -Dfopen64=fopen -Dopen64=open -Dlseek64=lseek -DFT2_BUILD_LIBRARY -DGPAC_DISABLE_VTT -DGPAC_DISABLE_OD_DUMP -DGPAC_DISABLE_REMOTERY -DNO_GZIP -DGPAC_HAVE_CONFIG_H -DDISABLE_RUST"
[[ $1 = "OCR" ]] && BLD_FLAGS="$BLD_FLAGS -DENABLE_OCR"
BLD_INCLUDE="-I../src/ -I../src/lib_ccx -I../src/thirdparty/gpacmp4 -I../src/lib_hash -I../src/thirdparty/libpng -I../src/thirdparty -I../src/thirdparty/protobuf-c -I../src/thirdparty/zlib -I../src/thirdparty/zvbi -I../src/thirdparty/freetype/include"
BLD_INCLUDE="-I../src/ -I../src/lib_ccx -I../src/thirdparty/gpacmp4 -I../src/lib_hash -I../src/thirdparty/libpng -I../src/thirdparty -I../src/thirdparty/protobuf-c -I../src/thirdparty/zlib -I../src/thirdparty/freetype/include"
[[ $1 = "OCR" ]] && BLD_INCLUDE="$BLD_INCLUDE `pkg-config --cflags --silence-errors tesseract`"
SRC_CCX="$(find ../src/lib_ccx -name '*.c')"
SRC_GPAC="$(find ../src/thirdparty/gpacmp4 -name '*.c')"
Expand All @@ -11,7 +11,6 @@ SRC_LIBPNG="$(find ../src/thirdparty/libpng -name '*.c')"
SRC_PROTOBUF="$(find ../src/thirdparty/protobuf-c -name '*.c')"
SRC_UTF8="../src/thirdparty/utf8proc/utf8proc.c"
SRC_ZLIB="$(find ../src/thirdparty/zlib -name '*.c')"
SRC_ZVBI="$(find ../src/thirdparty/zvbi -name '*.c')"
SRC_FREETYPE="../src/thirdparty/freetype/autofit/autofit.c \
../src/thirdparty/freetype/base/ftbase.c \
../src/thirdparty/freetype/base/ftbbox.c \
Expand Down

0 comments on commit 0ebeec4

Please sign in to comment.