Only build lcms-compare if lcms is available

The lcms detection make code is pretty lame...
diff --git a/Makefile b/Makefile
index ce119b7..5e4e6af 100644
--- a/Makefile
+++ b/Makefile
@@ -3,13 +3,21 @@
 #COVERAGE_FLAGS=
 OPT_FLAGS=-O0
 OPT_FLAGS=
-CFLAGS=-Wall $(OPT_FLAGS) $(COVERAGE_FLAGS) -Wdeclaration-after-statement -ggdb `pkg-config --cflags lcms`
-LDFLAGS=`pkg-config --libs lcms` -ldl
+CFLAGS=`pkg-config --cflags lcms` -Wall $(OPT_FLAGS) $(COVERAGE_FLAGS) -Wdeclaration-after-statement -ggdb
+LDFLAGS=-ldl
 
 QCMS_SRC=iccread.c transform.c matrix.c chain.c transform_util.c transform-sse2.c transform-sse1.c
 QCMS_OBJS=iccread.o transform.o matrix.o chain.o transform_util.o transform-sse2.o transform-sse1.o
 
-PROGRAMS=profile-gen test test-invalid lcms-compare dump-profile div-test coverage malloc-fail invalid-coverage
+PROGRAMS=profile-gen test test-invalid dump-profile div-test coverage malloc-fail invalid-coverage
+
+# I don't know a good way to get the exit code of pkg-config into a make variable
+HAS_LCMS:=$(shell pkg-config --exists lcms; echo $$?)
+ifeq ($(HAS_LCMS),0)
+PROGRAMS+=lcms-compare
+CFLAGS+=`pkg-config --cflags lcms`
+LDFLAGS+=`pkg-config --libs lcms`
+endif
 
 all: $(PROGRAMS)