PROGNAME = picshow BINARY = $(PROGNAME) CFLAGS = -Wall -std=c99 -pedantic -march=native -O3 CXXFLAGS = -Wall -pedantic LDFLAGS = LIBS = -lm DISABLED_FEATURES = ENABLED_FEATURES = ifneq ($(shell pkg-config --modversion --silence-errors sdl),) CFLAGS += -DHAVE_SDL $(shell pkg-config --cflags-only-I sdl) LIBS += $(shell pkg-config --libs sdl) ENABLED_FEATURES += "[SDL preview]" else DISABLED_FEATURES += "[SDL preview]" endif ifneq ($(shell pkg-config --modversion --silence-errors x264),) CFLAGS += -DHAVE_X264 $(shell pkg-config --cflags x264) LIBS += $(shell pkg-config --libs x264) ENABLED_FEATURES += "[x264 encoding]" else DISABLED_FEATURES += "[x264 encoding]" endif ifneq ($(shell pkg-config --modversion --silence-errors libavcodec),) CFLAGS += -DHAVE_FFMPEG $(shell pkg-config --cflags libavcodec) LIBS += $(shell pkg-config --libs libavcodec) ENABLED_FEATURES += "[FFmpeg encoding]" else DISABLED_FEATURES += "[FFmpeg encoding]" endif all: info $(BINARY) doc info: ifeq ($(ENABLED_FEATURES),) @echo "Enabled optional features: none" else @echo "Enabled optional features:$(ENABLED_FEATURES)" endif ifeq ($(DISABLED_FEATURES),) @echo "Disabled optional features: none" else @echo "Disabled optional features:$(DISABLED_FEATURES)" endif ##### DEPENDENCIES ############################################################# scale.o: scale.c scale.h ujpeg.o: ujpeg.c ujpeg.h random.o: random.c random.h rgb2yuv.o: rgb2yuv.c rgb2yuv.h preview.o: preview.c preview.h encode.o: encode.c encode.h core.o: core.c core.h ujpeg.h scale.h random.h optread.o: optread.c optread.h main.o: main.c optread.h core.h ujpeg.h rgb2yuv.h preview.h encode.h main.h config.o: config.c optread.h core.h ujpeg.h encode.h main.h random.h help.o: help.c test_ujpeg.o: test_ujpeg.cpp ujpeg.h test_scale.o: test_scale.c scale.h ujpeg.h test_output.o: test_output.c ujpeg.h scale.h rgb2yuv.h preview.h encode.h test_core.o: test_core.c core.h ujpeg.h scale.h random.h preview.h test_optread.o: test_optread.c optread.h ##### APPLICATIONS ############################################################# $(BINARY): main.o config.o core.o ujpeg.o scale.o rgb2yuv.o preview.o encode.o optread.o random.o help.o $(CC) -o $@ $(LDFLAGS) $^ $(LIBS) test: $(BINARY) test.opts ./$< -c test.opts test_ujpeg: test_ujpeg.o ujpeg.o $(CXX) -o $@ $(LDFLAGS) $^ $(LIBS) do-test-ujpeg: test_ujpeg time ./$< WeserFlowers.jpg test_ujpeg.ppm test_scale: test_scale.o scale.o ujpeg.o $(CC) -o $@ $(LDFLAGS) $^ $(LIBS) do-test-scale: test_scale ./$< WeserFlowers_small.jpg test_output: test_output.o ujpeg.o scale.o rgb2yuv.o preview.o encode.o $(CC) -o $@ $(LDFLAGS) $^ $(LIBS) do-test-output: test_output time ./$< WeserFlowers.jpg test_output.m2v test_core: test_core.o core.o ujpeg.o scale.o random.o preview.o $(CC) -o $@ $(LDFLAGS) $^ $(LIBS) do-test-core: test_core time ./$< WeserFlowers_small.jpg 654321 Colorful_Lorikeets.jpg test_optread: test_optread.o optread.o $(CC) -o $@ $(LDFLAGS) $^ $(LIBS) do-test-optread: test_optread test_optread.opts ./$< -file test_optread.opts ##### DEPENDENCIES ############################################################# doc: $(PROGNAME).1 do-test-doc: $(PROGNAME).1 man -l $< %.1: %.html html2man.py python html2man.py $< ##### CONVENIENCE STUFF ######################################################## clean: rm -f *.o rm -f $(BINARY) test_scale test_ujpeg test_output test_core test_optread rm -f test_ujpeg.ppm test_output.264 test_output.y4m test_output.m2v test_output.m4v rm -f $(PROGNAME).1 .PHONY: all info doc clean test .PHONY: do-test-scale do-test-ujpeg do-test-output do-test-core do-test-optread do-test-doc