--- Makefile.orig
+++ Makefile
@@ -54,7 +54,7 @@ $(OBJS): $(OBJ_DIR)/Sentry
 # Under Cygwin replace strip $@ with strip $@.exe
 
 cfdg: $(OBJS)
-	$(LINK.o) $^ -L/usr/local/lib -lstdc++ -lpng -lz -fexceptions -o $@
+	$(LINK.o) $^ `libpng-config --ldflags` -lstdc++ -fexceptions -o $@
 	strip $@
 
 
@@ -105,7 +105,7 @@ $(OUTPUT_DIR)/rtest-2k.png: cfdg $(RTEST_CFDG)
 #
 
 CPPFLAGS += $(patsubst %,-I%,$(INC_DIRS))
-CPPFLAGS += -O3 -Wall
+CPPFLAGS += -Wall `libpng-config --cflags`
 #CPPFLAGS += -ggdb
 
 $(OBJ_DIR)/%.o : %.cpp
