+SRC2 = $(SRCS) $(SRCCLI)
+# These should cover most of the important codepaths
+OPT0 = --crf 30 -b1 -m1 -r1 --me dia --no-cabac
+OPT1 = --crf 18 -b2 -m3 -r3 --me hex -8 --cqm jvt --direct spatial
+OPT2 = --crf 24 -b3 -m7 -r5 --me umh -8 -w -t1 -A all --b-pyramid --b-rdo --mixed-refs --direct auto
+
+ifeq (,$(VIDS))
+fprofiled:
+ @echo 'usage: make fprofiled VIDS="infile1 infile2 ..."'
+ @echo 'where infiles are anything that x264 understands,'
+ @echo 'i.e. YUV with resolution in the filename, y4m, or avisynth.'
+else
+fprofiled:
+ $(MAKE) clean
+ mv config.mak config.mak2
+ sed -e 's/CFLAGS.*/& -fprofile-generate/; s/LDFLAGS.*/& -fprofile-generate/' config.mak2 > config.mak
+ $(MAKE) x264$(EXE)
+ $(foreach V, $(VIDS), $(foreach I, 0 1 2, ./x264$(EXE) $(OPT$I) $(V) --progress -o $(DEVNULL) ;))
+ rm -f $(SRC2:%.c=%.o)
+ sed -e 's/CFLAGS.*/& -fprofile-use/; s/LDFLAGS.*/& -fprofile-use/' config.mak2 > config.mak
+ $(MAKE)
+ rm -f $(SRC2:%.c=%.gcda) $(SRC2:%.c=%.gcno)
+ mv config.mak2 config.mak
+endif
+