22GO =$(shell which go)
33DOCKER =$(shell which docker)
44
5- # Current ffmpeg version and config
5+ # Source version
66FFMPEG_VERSION =ffmpeg-7.1.1
7- # Empty variable to collect FFmpeg configuration options - will be populated dynamically
8- FFMPEG_CONFIG =
7+ CHROMAPRINT_VERSION =chromaprint-1.5.1
98
109# Build flags
1110BUILD_MODULE := $(shell cat go.mod | head -1 | cut -d ' ' -f 2)
@@ -32,17 +31,17 @@ PREFIX ?= ${BUILD_DIR}/install
3231# TARGETS
3332
3433.PHONY : all
35- all : clean ffinstall cli
34+ all : clean ffmpeg cli
3635
3736.PHONY : cmds
3837cmds : $(CMD_DIR )
3938
4039.PHONY : cli
41- cli : go-dep mkdir
40+ cli : go-dep go-tidy mkdir
4241 @echo Build media tool
4342 @PKG_CONFIG_PATH=" $( shell realpath ${PREFIX} ) /lib/pkgconfig" CGO_LDFLAGS_ALLOW=" -(W|D).*" ${GO} build ${BUILD_FLAGS} -o ${BUILD_DIR} /media ./cmd/media
4443
45- $(CMD_DIR ) : go-dep mkdir
44+ $(CMD_DIR ) : go-dep go-tidy mkdir
4645 @echo Build cmd $(notdir $@ )
4746 @PKG_CONFIG_PATH=" $( shell realpath ${PREFIX} ) /lib/pkgconfig" CGO_LDFLAGS_ALLOW=" -(W|D).*" ${GO} build ${BUILD_FLAGS} -o ${BUILD_DIR} /$(notdir $@ ) ./$@
4847
@@ -60,8 +59,8 @@ ${BUILD_DIR}/${FFMPEG_VERSION}:
6059 fi
6160
6261# Configure ffmpeg
63- .PHONY : ffmpeg
64- ffmpeg : mkdir ${BUILD_DIR}/${FFMPEG_VERSION} ffmpeg-dep
62+ .PHONY : ffmpeg-configure
63+ ffmpeg-configure : mkdir ${BUILD_DIR}/${FFMPEG_VERSION} ffmpeg-dep
6564 @echo " Configuring ${FFMPEG_VERSION} => ${PREFIX} "
6665 @cd ${BUILD_DIR} /${FFMPEG_VERSION} && ./configure \
6766 --enable-static --disable-doc --disable-programs \
@@ -71,17 +70,57 @@ ffmpeg: mkdir ${BUILD_DIR}/${FFMPEG_VERSION} ffmpeg-dep
7170 --enable-gpl --enable-nonfree ${FFMPEG_CONFIG}
7271
7372# Build ffmpeg
74- .PHONY : ffbuild
75- ffbuild : ffmpeg
73+ .PHONY : ffmpeg-build
74+ ffmpeg-build : ffmpeg-configure
7675 @echo " Building ${FFMPEG_VERSION} "
77- @cd $(BUILD_DIR ) /$(FFMPEG_VERSION ) && make
76+ @cd $(BUILD_DIR ) /$(FFMPEG_VERSION ) && make -j2
7877
7978# Install ffmpeg
80- .PHONY : ffinstall
81- ffinstall : ffbuild
82- @echo " Installing ${FFMPEG_VERSION} "
79+ .PHONY : ffmpeg
80+ ffmpeg : ffmpeg-build
81+ @echo " Installing ${FFMPEG_VERSION} => ${PREFIX} "
8382 @cd $(BUILD_DIR ) /$(FFMPEG_VERSION ) && make install
8483
84+ # ##############################################################################
85+ # CHROMAPRINT
86+
87+ # Download ffmpeg sources
88+ ${BUILD_DIR}/${CHROMAPRINT_VERSION} :
89+ @if [ ! -d " $( BUILD_DIR) /$( CHROMAPRINT_VERSION) " ]; then \
90+ echo " Downloading $( CHROMAPRINT_VERSION) " ; \
91+ mkdir -p $(BUILD_DIR ) /${CHROMAPRINT_VERSION} ; \
92+ curl -L -o $(BUILD_DIR ) /chromaprint.tar.gz https://github.com/acoustid/chromaprint/releases/download/v1.5.1/$(CHROMAPRINT_VERSION ) .tar.gz; \
93+ tar -xzf $(BUILD_DIR ) /chromaprint.tar.gz -C $(BUILD_DIR ) ; \
94+ rm -f $(BUILD_DIR ) /chromaprint.tar.gz; \
95+ fi
96+
97+
98+ # Configure chromaprint
99+ .PHONY : chromaprint-configure
100+ chromaprint-configure : mkdir ${BUILD_DIR}/${CHROMAPRINT_VERSION}
101+ @echo " Configuring ${CHROMAPRINT_VERSION} => ${PREFIX} "
102+ cmake \
103+ -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
104+ -DCMAKE_BUILD_TYPE=Release \
105+ -DBUILD_SHARED_LIBS=0 \
106+ -DBUILD_TESTS=0 \
107+ -DBUILD_TOOLS=0 \
108+ --install-prefix " $( shell realpath ${PREFIX} ) " \
109+ -S ${BUILD_DIR} /${CHROMAPRINT_VERSION} \
110+ -B ${BUILD_DIR}
111+
112+ # Build chromaprint
113+ .PHONY : chromaprint-build
114+ chromaprint-build : chromaprint-configure
115+ @echo " Building ${CHROMAPRINT_VERSION} "
116+ @cd $(BUILD_DIR ) && make -j2
117+
118+ # Install chromaprint
119+ .PHONY : chromaprint
120+ chromaprint : chromaprint-build
121+ @echo " Installing ${CHROMAPRINT_VERSION} => ${PREFIX} "
122+ @cd $(BUILD_DIR ) && make install
123+
85124# ##############################################################################
86125# DOCKER
87126
@@ -102,11 +141,26 @@ docker-push: docker-dep
102141# ##############################################################################
103142# TESTS
104143
105- test : go-dep
144+ .PHONY : test
145+ test : test-ffmpeg test-chromaprint
146+
147+ .PHONY : test-chromaprint
148+ test-chromaprint : go-dep go-tidy
149+ @echo Test
150+ @echo ... test sys/chromaprint
151+ @PKG_CONFIG_PATH=$(shell realpath ${PREFIX}) /lib/pkgconfig ${GO} test ./sys/chromaprint
152+
153+ .PHONY : test-ffmpeg
154+ test-ffmpeg : go-dep go-tidy
106155 @echo Test
107- @${GO} mod tidy
108156 @echo ... test sys/ffmpeg71
109- @PKG_CONFIG_PATH=$(shell realpath ${PREFIX}) /lib/pkgconfig ${GO} test ./sys/ffmpeg71
157+ @PKG_CONFIG_PATH=" $( shell realpath ${PREFIX} ) /lib/pkgconfig" CGO_LDFLAGS_ALLOW=" -(W|D).*" ${GO} test ./sys/ffmpeg71
158+ @echo ... test pkg/segmenter
159+ @PKG_CONFIG_PATH=" $( shell realpath ${PREFIX} ) /lib/pkgconfig" CGO_LDFLAGS_ALLOW=" -(W|D).*" ${GO} test ./pkg/segmenter
160+ @echo ... test pkg/chromaprint
161+ @PKG_CONFIG_PATH=" $( shell realpath ${PREFIX} ) /lib/pkgconfig" CGO_LDFLAGS_ALLOW=" -(W|D).*" ${GO} test ./pkg/chromaprint
162+
163+
110164# @echo ... test pkg/ffmpeg
111165# @${GO} test -v ./pkg/ffmpeg
112166# @echo ... test sys/chromaprint
@@ -122,7 +176,7 @@ test: go-dep
122176# @echo ... test pkg
123177# @${GO} test ./pkg/...
124178
125- container-test : go-dep
179+ container-test : go-dep go-tidy
126180 @echo Test
127181 @${GO} mod tidy
128182 @${GO} test --tags=container ./sys/ffmpeg71
@@ -134,22 +188,30 @@ container-test: go-dep
134188# ##############################################################################
135189# DEPENDENCIES, ETC
136190
191+ .PHONY : go-dep
137192go-dep :
138193 @test -f " ${GO} " && test -x " ${GO} " || (echo " Missing go binary" && exit 1)
139194
195+ .PHONY : docker-dep
140196docker-dep :
141197 @test -f " ${DOCKER} " && test -x " ${DOCKER} " || (echo " Missing docker binary" && exit 1)
142198
199+ .PHONY : mkdir
143200mkdir :
144201 @echo Mkdir ${BUILD_DIR}
145202 @install -d ${BUILD_DIR}
146203 @install -d ${PREFIX}
147204
148- clean :
205+ .PHONY : go-tidy
206+ go-tidy :
207+ @echo Tidy
208+ @${GO} mod tidy
209+
210+ .PHONY : clean
211+ clean : go-tidy
149212 @echo Clean
150213 @rm -fr $(BUILD_DIR )
151- @${GO} mod tidy
152- @${GO} clean
214+ @${GO} clean -cache
153215
154216# Check for FFmpeg dependencies
155217.PHONY : ffmpeg-dep
0 commit comments