$NetBSD: patch-ab,v 1.17 2018/05/06 13:19:10 leot Exp $

- Handle the various operating systems in the same way avoiding hardcoding
- Avoid internal version of freeglut and try to pick it up via pkg-config and
  set SYS_GLUT_{CFLAGS,LIBS} accordingly.
- Avoid internal version of lcms2 and try to pick it up via pkg-config and
  set SYS_LCMS2_{CFLAGS,LIBS} accordingly.
  If no lcms2 is available just pass `-DNO_ICC' to disable it via
  SYS_LCMS2_CFLAGS.

--- Makerules.orig	2018-04-12 13:14:06.000000000 +0000
+++ Makerules
@@ -65,38 +65,10 @@ else
 $(error unknown build setting: '$(build)')
 endif
 
-# Windows (MINGW) build doesn't use system libraries.
-ifeq "$(OS)" "MINGW"
-
-WINDRES := windres
-HAVE_X11 ?= no
-HAVE_WIN32 := yes
-
-# Mac OS X doesn't have pkg-config so we hard code paths.
-else ifeq "$(OS)" "MACOS"
-
-HAVE_X11 ?= no
-
-HAVE_GLUT ?= yes
-SYS_GLUT_CFLAGS := -Wno-deprecated-declarations
-SYS_GLUT_LIBS := -framework GLUT -framework OpenGL
-
-CC = xcrun cc
-AR = xcrun ar
-LD = xcrun ld
-RANLIB_CMD = xcrun ranlib $@
-
-# Linux uses pkg-config for system libraries.
-else ifeq "$(OS)" "Linux"
-
 HAVE_PTHREAD := yes
 SYS_PTHREAD_CFLAGS :=
 SYS_PTHREAD_LIBS := -lpthread
 
-HAVE_GLUT := yes
-SYS_GLUT_CFLAGS :=
-SYS_GLUT_LIBS := -lglut -lGL
-
 ifeq "$(shell pkg-config --exists 'libcrypto >= 1.1.0' && echo yes)" "yes"
 HAVE_LIBCRYPTO := yes
 SYS_LIBCRYPTO_CFLAGS := -DHAVE_LIBCRYPTO $(shell pkg-config --cflags libcrypto)
@@ -113,7 +85,6 @@ SYS_CURL_CFLAGS += $(shell pkg-config --
 SYS_CURL_DEPS += $(shell pkg-config --libs openssl)
 endif
 endif
-SYS_CURL_DEPS += -lpthread -lrt
 
 ifeq "$(shell pkg-config --exists x11 xext && echo yes)" "yes"
 HAVE_X11 := yes
@@ -121,6 +92,12 @@ SYS_X11_CFLAGS := $(shell pkg-config --c
 SYS_X11_LIBS := $(shell pkg-config --libs x11 xext)
 endif
 
+ifeq "$(shell pkg-config --exists glut && pkg-config --exists gl && echo yes)" "yes"
+HAVE_GLUT ?= yes
+SYS_GLUT_CFLAGS := $(shell pkg-config --cflags glut)
+SYS_GLUT_LIBS := $(shell pkg-config --libs glut)
+endif
+
 ifeq "$(shell pkg-config --exists harfbuzz && echo yes)" "yes"
 SYS_HARFBUZZ_CFLAGS := $(shell pkg-config --cflags harfbuzz)
 SYS_HARFBUZZ_LIBS := $(shell pkg-config --libs harfbuzz)
@@ -136,12 +113,17 @@ SYS_OPENJPEG_CFLAGS := $(shell pkg-confi
 SYS_OPENJPEG_LIBS := $(shell pkg-config --libs libopenjp2)
 endif
 
+ifeq "$(shell pkg-config --exists lcms2 && echo yes)" "yes"
+SYS_LCMS2_CFLAGS := $(shell pkg-config --cflags lcms2)
+SYS_LCMS2_LIBS := $(shell pkg-config --libs lcms2)
+else
+SYS_LCMS2_CFLAGS := -DNO_ICC
+endif
+
 SYS_JBIG2DEC_LIBS := -ljbig2dec
 SYS_LIBJPEG_LIBS := -ljpeg
 SYS_ZLIB_LIBS := -lz
 
-endif
-
 # The following section is an example of how to simply do cross-compilation
 # using these Makefiles. It builds for a beagleboard running ARM linux,
 # compiling on windows with the CodeSourcery G++ compilers.
