From 6245f18091cad11520c159248c1cf7a84f12857c Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Wed, 5 Apr 2017 13:15:43 -0700
Subject: [PATCH] make: Respect variables from environement

link with shared zlib

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 Makefile.unx | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/Makefile.unx b/Makefile.unx
index 772da46..4ae7061 100644
--- a/Makefile.unx
+++ b/Makefile.unx
@@ -24,18 +24,16 @@ ZINC = -I$(ZPATH)
 ZLIB = $(ZPATH)/libz.a
 
 INCS = $(ZINC)
-LIBS = $(ZLIB)
+LIBS = -lz
 
-CC = gcc
-LD = gcc
-RM = rm
-CFLAGS = -O -Wall $(INCS) -DUSE_ZLIB
+CC ?= gcc
+LD ?= gcc
+RM ?= rm
+CFLAGS += -O -Wall $(INCS) -DUSE_ZLIB
 # [note that -Wall is a gcc-specific compilation flag ("all warnings on")]
 O = .o
 E =
 
-LDFLAGS =
-
 PROG = pngcheck
 PROG2 = pngsplit
 PROG3 = png-fix-IDAT-windowsize
@@ -57,13 +55,13 @@ EXES = $(PROG)$(E) $(PROG2)$(E) $(PROG3)$(E)
 all:  $(EXES)
 
 $(PROG)$(E): $(PROG).c
-	$(CC) $(CFLAGS) -o $@ $(PROG).c $(LIBS)
+	$(CC) $(CFLAGS) -o $@ $(PROG).c $(LDFLAGS) $(LIBS)
 
 $(PROG2)$(E): gpl/$(PROG2).c
-	$(CC) $(CFLAGS) -o $@ gpl/$(PROG2).c $(LIBS)
+	$(CC) $(CFLAGS) -o $@ gpl/$(PROG2).c $(LDFLAGS) $(LIBS)
 
 $(PROG3)$(E): gpl/$(PROG3).c
-	$(CC) $(CFLAGS) -o $@ gpl/$(PROG3).c $(LIBS)
+	$(CC) $(CFLAGS) -o $@ gpl/$(PROG3).c $(LDFLAGS) $(LIBS)
 
 
 # maintenance ---------------------------------------------------------------
-- 
2.12.2

