Combined patches from git.
--- fltk1.1-1.1.10.orig/FL/forms.H
+++ fltk1.1-1.1.10/FL/forms.H
@@ -651,7 +651,7 @@ inline int fl_show_question(const char*
 FL_EXPORT void fl_show_message(const char *,const char *,const char *);
 FL_EXPORT void fl_show_alert(const char *,const char *,const char *,int=0);
 FL_EXPORT int fl_show_question(const char *,const char *,const char *);
-inline const char *fl_show_input(const char *l,const char*d=0) {return fl_input(l,d);}
+inline const char *fl_show_input(const char *l,const char*d=0) {return fl_input("%s",l,d);}
 FL_EXPORT /*const*/ char *fl_show_simple_input(const char *label, const char *deflt = 0);
 FL_EXPORT int fl_show_choice(
     const char *m1,
--- fltk1.1-1.1.10.orig/FL/x.H
+++ fltk1.1-1.1.10/FL/x.H
@@ -65,10 +65,30 @@ extern FL_EXPORT int fl_screen;
 extern FL_EXPORT XVisualInfo *fl_visual;
 extern FL_EXPORT Colormap fl_colormap;
 
+// access to core fonts
+FL_EXPORT XFontStruct* fl_xxfont();
+class Fl_XFont_On_Demand
+{
+public:
+  Fl_XFont_On_Demand(XFontStruct* p = NULL) : ptr(p) { }
+  Fl_XFont_On_Demand& operator=(const Fl_XFont_On_Demand& x)
+    { ptr = x.ptr;  return *this; }
+  Fl_XFont_On_Demand& operator=(XFontStruct* p)
+    { ptr = p;  return *this; }
+  XFontStruct* value() { if (!ptr) { ptr = fl_xxfont(); }  return ptr; }
+  operator XFontStruct*() { return value(); }
+  XFontStruct& operator*() { return *value(); }
+  XFontStruct* operator->() { return value(); }
+  bool operator==(const Fl_XFont_On_Demand& x) { return ptr == x.ptr; }
+  bool operator!=(const Fl_XFont_On_Demand& x) { return ptr != x.ptr; }
+private:
+  XFontStruct* ptr;
+};
+extern FL_EXPORT Fl_XFont_On_Demand fl_xfont;
+
 // drawing functions:
 extern FL_EXPORT GC fl_gc;
 extern FL_EXPORT Window fl_window;
-extern FL_EXPORT XFontStruct* fl_xfont;
 extern FL_EXPORT void *fl_xftfont;
 FL_EXPORT ulong fl_xpixel(Fl_Color i);
 FL_EXPORT ulong fl_xpixel(uchar r, uchar g, uchar b);
--- fltk1.1-1.1.10.orig/Makefile
+++ fltk1.1-1.1.10/Makefile
@@ -110,8 +110,8 @@ makeinclude: configure configh.in makein
 	touch config.h
 	chmod +x fltk-config
 
-configure: configure.in
-	autoconf
+# configure: configure.in
+# 	autoconf
 
 portable-dist:
 	epm -v -s fltk.xpm fltk
--- fltk1.1-1.1.10.orig/configure.in
+++ fltk1.1-1.1.10/configure.in
@@ -202,10 +202,10 @@ if test x$enable_shared = xyes; then
             FLDSONAME="libfltk_forms.so.$FL_API_VERSION"
             GLDSONAME="libfltk_gl.so.$FL_API_VERSION"
             IMGDSONAME="libfltk_images.so.$FL_API_VERSION"
-            DSOCOMMAND="\$(CXX) \$(DSOFLAGS) -Wl,-soname,\$@ \$(LDLIBS) -shared -fPIC $DEBUGFLAG -o"
-	    if test "x$libdir" != "x/usr/lib"; then
-		    DSOLINK="-Wl,-rpath,$libdir"
-            fi
+            DSOCOMMAND="\$(CXX) \$(DSOFLAGS) -Wl,-soname,\$@ -shared -fPIC $DEBUGFLAG -o"
+#	    if test "x$libdir" != "x/usr/lib"; then
+#		    DSOLINK="-Wl,-rpath,$libdir"
+#           fi
 	    ;;
 	AIX*)
             DSONAME="libfltk_s.a"
@@ -496,8 +496,10 @@ fi
 AC_CHECK_FUNC(strtoll, AC_DEFINE(HAVE_STRTOLL))
 
 dnl Check for dlopen/dlsym...
+SAVELIBS=$LIBS
 AC_SEARCH_LIBS(dlsym, dl, AC_DEFINE(HAVE_DLSYM))
 AC_CHECK_HEADER(dlfcn.h, AC_DEFINE(HAVE_DLFCN_H))
+LIBS=$SAVELIBS
 
 dnl Check for audio libraries...
 AUDIOLIBS=""
@@ -595,8 +597,8 @@ if test x$enable_localzlib = xyes -o x$s
 else
     ZLIBINC=""
     ZLIB=""
-    LIBS="-lz $LIBS"
-    IMAGELIBS="-lz $IMAGELIBS"
+    # LIBS="-lz $LIBS"
+    # IMAGELIBS="-lz $IMAGELIBS"
     STATICIMAGELIBS="-lz $STATICIMAGELIBS"
     AC_DEFINE(HAVE_LIBZ)
 fi
@@ -691,6 +693,7 @@ if test "x$enable_threads" = xyes; then
 		break
 	    fi
 	done
+	LIBS=$SAVELIBS
     fi
 fi
 
@@ -806,7 +809,7 @@ case $uname in
 	    AC_MSG_WARN(Ignoring libraries \"$X_PRE_LIBS\" requested by configure.)
 	fi
 
-	LIBS="$LIBS -lXext -lX11 $X_EXTRA_LIBS"
+	LIBS="$LIBS -lX11 $X_EXTRA_LIBS"
 	CFLAGS="$CFLAGS $X_CFLAGS"
 	CXXFLAGS="$CXXFLAGS $X_CFLAGS"
 	LDFLAGS="$X_LIBS $LDFLAGS"
@@ -831,12 +834,12 @@ case $uname in
 	    )
 	    AC_CHECK_HEADER(GL/glu.h,
         	AC_DEFINE(HAVE_GL_GLU_H)
-		if test x$ac_cv_lib_GL_glXMakeCurrent = xyes; then
-		    GLLIB="-lGLU $GLLIB"
-		fi
-		if test x$ac_cv_lib_MesaGL_glXMakeCurrent = xyes; then
-		    GLLIB="-lMesaGLU $GLLIB"
-		fi
+		# if test x$ac_cv_lib_GL_glXMakeCurrent = xyes; then
+		#     GLLIB="-lGLU $GLLIB"
+		# fi
+		# if test x$ac_cv_lib_MesaGL_glXMakeCurrent = xyes; then
+		#     GLLIB="-lMesaGLU $GLLIB"
+		# fi
 	    )
 
 	    if test x$ac_cv_lib_GL_glXMakeCurrent != xyes -a x$ac_cv_lib_MesaGL_glXMakeCurrent != xyes; then
@@ -874,7 +877,7 @@ case $uname in
 		AC_CHECK_HEADER(X11/Xft/Xft.h,
 		    AC_CHECK_LIB(Xft, XftDrawCreate,
 	        	AC_DEFINE(USE_XFT)
-			LIBS="-lXft $LIBS"))
+			LIBS="-lXft -lfontconfig $LIBS", [], -lfontconfig))
 	    fi
 	fi
 
@@ -1163,7 +1166,7 @@ dnl Define the FLTK documentation direct
 if test x$prefix = xNONE; then
     AC_DEFINE_UNQUOTED(FLTK_DOCDIR, "/usr/local/share/doc/fltk")
 else
-    AC_DEFINE_UNQUOTED(FLTK_DOCDIR, "$prefix/share/doc/fltk")
+    AC_DEFINE_UNQUOTED(FLTK_DOCDIR, "$prefix/share/doc/fltk1.1-doc/HTML")
 fi
 
 dnl Define the FLTK data directory...
--- fltk1.1-1.1.10.orig/documentation/Makefile
+++ fltk1.1-1.1.10/documentation/Makefile
@@ -232,9 +232,9 @@ depend:
 
 install: $(MANPAGES)
 	echo "Installing documentation files in $(DESTDIR)$(docdir)..."
-	-$(INSTALL_DIR) $(DESTDIR)$(docdir)
+	-$(INSTALL_DIR) $(DESTDIR)$(docdir)/HTML
 	for file in $(HTMLFILES) $(IMAGEFILES) index.html; do \
-		$(INSTALL_DATA) $$file $(DESTDIR)$(docdir); \
+		$(INSTALL_DATA) $$file $(DESTDIR)$(docdir)/HTML; \
 	done
 	echo "Installing man pages in $(DESTDIR)$(mandir)..."
 	-$(INSTALL_DIR) $(DESTDIR)$(mandir)/cat1
@@ -284,15 +284,22 @@ fltk.d/index.html: $(HTMLFILES) $(IMAGEF
 	-$(INSTALL_DIR) fltk.d
 	-$(HTMLDOC) --verbose --batch fltk.book -d fltk.d -t html
 
+DEB_DATE := $(shell cd .. && dpkg-parsechangelog -S Date)
+PDF_DATE := $(shell date -ud '$(DEB_DATE)' +D:%Y%m%d%H%M%SZ)
+
 fltk.ps: $(HTMLFILES) $(IMAGEFILES)
 	echo "Generating PostScript documentation..."
 	$(RM) fltk.ps
-	-$(HTMLDOC) --verbose --batch fltk.book $(MEDIA) -f fltk.ps
+	-$(HTMLDOC) --verbose --batch fltk.book $(MEDIA) -f fltk.ps && \
+	    sed -i 's/^\(%%CreationDate: \)D:.*/\1$(PDF_DATE)/' $@
 
 fltk.pdf: $(HTMLFILES) $(IMAGEFILES)
 	echo "Generating PDF documentation..."
 	$(RM) fltk.pdf
-	-$(HTMLDOC) --verbose --batch fltk.book $(MEDIA) -f fltk.pdf
+	-$(HTMLDOC) --verbose --batch fltk.book $(MEDIA) -f fltk.pdf && \
+	    MD5=`(echo $(DEB_DATE) && du -b $@) | md5sum | cut -c -32` && \
+	    sed -i -e '3s|\(/CreationDate(\)D:[^)]*|\1$(PDF_DATE)|' \
+	        -e "s|/ID\\[\\(<[0-9a-f]\\{32\\}>\\)\\1]|/ID[<$$MD5><$$MD5>]|" $@
 
 #
 # End of "$Id: Makefile 5663 2007-02-06 19:35:28Z mike $".
--- fltk1.1-1.1.10.orig/documentation/fluid.html
+++ fltk1.1-1.1.10/documentation/fluid.html
@@ -8,7 +8,7 @@
 <P>This chapter shows how to use the Fast Light User-Interface Designer
 (&quot;FLUID&quot;) to create your GUIs.</P>
 
-<P>Subchapters:
+<P>Subchapters:</P>
 <UL>
 <LI><A HREF="#what_is_fluid">What is FLUID</A></LI>
 <LI><A HREF="#fluid_under_linux">Running FLUID Under UNIX</A></LI>
@@ -18,7 +18,7 @@
 <LI><A HREF="#references">FLUID Reference</A></LI>
 <LI><A HREF="#I18N">Internationalization with FLUID</A></LI>
 <LI><A HREF="#limitations">Know limitations</A></LI>
-</UL></P>
+</UL>
 
 <H2><A NAME="what_is_fluid">What is FLUID?</A></H2>
 
--- fltk1.1-1.1.10.orig/fltk-config.in
+++ fltk1.1-1.1.10/fltk-config.in
@@ -217,26 +217,27 @@ else
     includes=
 fi
 
-if test "$libdir" != /usr/lib -a "$libdir" != /usr/lib32; then
-    libs=-L$libdir
-else
-    libs=
-fi
+# if test "$libdir" != /usr/lib -a "$libdir" != /usr/lib32; then
+#     libs=-L$libdir
+# else
+#     libs=
+# fi
+libs=
 
 # Calculate needed libraries
 LDSTATIC="$libdir/libfltk.a $LDLIBS"
-LDLIBS="-lfltk$SHAREDSUFFIX $LDLIBS"
+LDLIBS="-lfltk$SHAREDSUFFIX -lX11"
 
 if test x$use_forms = xyes; then
     LDLIBS="-lfltk_forms$SHAREDSUFFIX $LDLIBS"
     LDSTATIC="$libdir/libfltk_forms.a $LDSTATIC"
 fi
 if test x$use_gl = xyes; then
-    LDLIBS="-lfltk_gl$SHAREDSUFFIX @GLLIB@ $LDLIBS"
+    LDLIBS="-lfltk_gl$SHAREDSUFFIX $LDLIBS"
     LDSTATIC="$libdir/libfltk_gl.a @GLLIB@ $LDSTATIC"
 fi
 if test x$use_images = xyes; then
-    LDLIBS="-lfltk_images$SHAREDSUFFIX $IMAGELIBS $LDLIBS"
+    LDLIBS="-lfltk_images$SHAREDSUFFIX $LDLIBS"
     LDSTATIC="$libdir/libfltk_images.a $STATICIMAGELIBS $LDSTATIC"
 fi
 
@@ -270,8 +271,8 @@ if test -n "$compile"; then
 	    
     post=$prog
 
-    echo $CXX $ARCHFLAGS $includes $CXXFLAGS $debug -o $prog $compile $LDSTATIC
-    $CXX $ARCHFLAGS $includes $CXXFLAGS $debug -o $prog $compile $LDSTATIC
+    echo $CXX $ARCHFLAGS $includes $CXXFLAGS $debug -o $prog $compile $LDLIBS
+    $CXX $ARCHFLAGS $includes $CXXFLAGS $debug -o $prog $compile $LDLIBS
 
     # stop after compilation in case of errors
     err=$?
@@ -286,11 +287,11 @@ if test -n "$post" -a "$POSTBUILD" != ":
 fi
 
 if test "$echo_cflags" = "yes"; then
-    echo $includes $CFLAGS
+    echo "$includes $CFLAGS" | sed -e 's/ -[DfgOW][^ ]*//g'
 fi
 
 if test "$echo_cxxflags" = "yes"; then
-    echo $includes $CXXFLAGS
+    echo "$includes $CXXFLAGS" | sed -e 's/ -[DfgOW][^ ]*//g'
 fi
 
 if test "$echo_optim" = "yes"; then
@@ -310,33 +311,34 @@ if test "$echo_ldflags" = "yes"; then
 	    fi
 	fi
     done
-    echo $libdirs $my_libs
+    echo " $libdirs $my_libs" | sed -e 's/ -W[^ ]*//g' -e 's/^ *//'
 fi
 
 if test "$echo_ldstaticflags" = "yes"; then
-    echo $LDSTATIC
+    echo " $LDSTATIC " | sed -e 's/ -W[^ ]*//g' -e 's/^ *//'
 fi
 
 if test "$echo_libs" = "yes"; then
-    echo $libdir/libfltk.a
+    echo -n $libdir/libfltk.a
 
     if test x$use_forms = xyes; then
-        echo $libdir/libfltk_forms.a
+        echo -n " $libdir/libfltk_forms.a"
     fi
 
     if test x$use_gl = xyes; then
-        echo $libdir/libfltk_gl.a
+        echo -n " $libdir/libfltk_gl.a"
     fi
 
     if test x$use_images = xyes; then
-        echo $libdir/libfltk_images.a
+        echo -n " $libdir/libfltk_images.a"
 
         for lib in fltk_jpeg fltk_png fltk_z; do
             if test -f $libdir/lib$lib.a; then
-                echo $libdir/lib$lib.a
+                echo -n " $libdir/lib$lib.a"
             fi
 	done
     fi
+    echo
 fi
 
 #
--- fltk1.1-1.1.10.orig/fluid/Fl_Function_Type.cxx
+++ fltk1.1-1.1.10/fluid/Fl_Function_Type.cxx
@@ -181,7 +181,7 @@ void Fl_Function_Type::open() {
   function_panel->show();
   const char* message = 0;
   for (;;) { // repeat as long as there are errors
-    if (message) fl_alert(message);
+    if (message) fl_alert("%s", message);
     for (;;) {
       Fl_Widget* w = Fl::readqueue();
       if (w == f_panel_cancel) goto BREAK2;
@@ -412,7 +412,7 @@ void Fl_Code_Type::open() {
   code_panel->show();
   const char* message = 0;
   for (;;) { // repeat as long as there are errors
-    if (message) fl_alert(message);
+    if (message) fl_alert("%s", message);
     for (;;) {
       Fl_Widget* w = Fl::readqueue();
       if (w == code_panel_cancel) goto BREAK2;
@@ -479,7 +479,7 @@ void Fl_CodeBlock_Type::open() {
   codeblock_panel->show();
   const char* message = 0;
   for (;;) { // repeat as long as there are errors
-    if (message) fl_alert(message);
+    if (message) fl_alert("%s", message);
     for (;;) {
       Fl_Widget* w = Fl::readqueue();
       if (w == codeblock_panel_cancel) goto BREAK2;
@@ -573,7 +573,7 @@ void Fl_Decl_Type::open() {
   decl_panel->show();
   const char* message = 0;
   for (;;) { // repeat as long as there are errors
-    if (message) fl_alert(message);
+    if (message) fl_alert("%s", message);
     for (;;) {
       Fl_Widget* w = Fl::readqueue();
       if (w == decl_panel_cancel) goto BREAK2;
@@ -710,7 +710,7 @@ void Fl_DeclBlock_Type::open() {
   declblock_panel->show();
   const char* message = 0;
   for (;;) { // repeat as long as there are errors
-    if (message) fl_alert(message);
+    if (message) fl_alert("%s", message);
     for (;;) {
       Fl_Widget* w = Fl::readqueue();
       if (w == declblock_panel_cancel) goto BREAK2;
@@ -833,7 +833,7 @@ void Fl_Comment_Type::open() {
   char itempath[256]; itempath[0] = 0;
   int last_selected_item = 0;
   for (;;) { // repeat as long as there are errors
-    if (message) fl_alert(message);
+    if (message) fl_alert("%s", message);
     for (;;) {
       Fl_Widget* w = Fl::readqueue();
       if (w == comment_panel_cancel) goto BREAK2;
@@ -1087,7 +1087,7 @@ void Fl_Class_Type::open() {
   char *na=0,*pr=0,*p=0; // name and prefix substrings
 
   for (;;) { // repeat as long as there are errors
-    if (message) fl_alert(message);
+    if (message) fl_alert("%s", message);
     for (;;) {
       Fl_Widget* w = Fl::readqueue();
       if (w == c_panel_cancel) goto BREAK2;
--- fltk1.1-1.1.10.orig/fluid/Fl_Type.h
+++ fltk1.1-1.1.10/fluid/Fl_Type.h
@@ -41,10 +41,12 @@
 
 void set_modflag(int mf);
 
+Fl_Widget *make_type_browser(int,int,int,int,const char *l=0);
+
 class Fl_Type {
 
   friend class Widget_Browser;
-  friend Fl_Widget *make_type_browser(int,int,int,int,const char *l=0);
+  friend Fl_Widget *make_type_browser(int,int,int,int,const char *l);
   friend class Fl_Window_Type;
   virtual void setlabel(const char *); // virtual part of label(char*)
 
--- fltk1.1-1.1.10.orig/fluid/Makefile
+++ fltk1.1-1.1.10/fluid/Makefile
@@ -64,7 +64,9 @@ fluid$(EXEEXT):		$(OBJECTS) $(LIBNAME) $
 fluid-shared$(EXEEXT):	$(OBJECTS) ../src/$(DSONAME) ../src/$(FLDSONAME) \
 			../src/$(IMGDSONAME)
 	echo Linking $@...
-	$(CXX) $(ARCHFLAGS) $(LDFLAGS) -o $@ $(OBJECTS) $(LINKSHARED) $(LDLIBS)
+	$(CXX) $(ARCHFLAGS) $(LDFLAGS) -o $@ $(OBJECTS) \
+	    -L../src -Wl,-rpath-link,../src -lfltk_images -lfltk_forms -lfltk \
+	    -lpng -lX11
 	$(POSTBUILD) $@ ../FL/mac.r
 
 clean:
--- fltk1.1-1.1.10.orig/fluid/file.cxx
+++ fltk1.1-1.1.10/fluid/file.cxx
@@ -159,7 +159,7 @@ void read_error(const char *format, ...)
   if (!fin) {
     char buffer[1024];
     vsnprintf(buffer, sizeof(buffer), format, args);
-    fl_message(buffer);
+    fl_message("%s", buffer);
   } else {
     fprintf(stderr, "%s:%d: ", fname, lineno);
     vfprintf(stderr, format, args);
--- fltk1.1-1.1.10.orig/fluid/fluid.desktop
+++ fltk1.1-1.1.10/fluid/fluid.desktop
@@ -2,7 +2,7 @@
 Name=FLUID
 Comment=FLTK GUI Designer
 TryExec=fluid
-Exec=cd %D && fluid %F
+Exec=perl -e 'if (@ARGV && @ARGV[0]=~/^(.*\/)//) { chdir($1) }; exec("fluid", @ARGV);' %F
 Icon=fluid
 Terminal=false
 Type=Application
--- fltk1.1-1.1.10.orig/makeinclude.in
+++ fltk1.1-1.1.10/makeinclude.in
@@ -34,7 +34,7 @@ includedir	= @includedir@
 libdir		= @libdir@
 mandir		= @mandir@
 srcdir		= @srcdir@
-docdir		= $(datadir)/doc/fltk
+docdir		= $(datadir)/doc/fltk1.1-doc
 VPATH		= @srcdir@
 
 # programs we use...
@@ -132,7 +132,7 @@ INSTALL_DESKTOP	= @INSTALL_DESKTOP@
 UNINSTALL_DESKTOP = @UNINSTALL_DESKTOP@
 
 # Be quiet when building...
-.SILENT:
+#.SILENT:
 
 # Build commands and filename extensions...
 .SUFFIXES:	.0 .1 .3 .6 .c .cxx .h .fl .man .o .z $(EXEEXT)
--- fltk1.1-1.1.10.orig/src/Fl_File_Chooser2.cxx
+++ fltk1.1-1.1.10/src/Fl_File_Chooser2.cxx
@@ -569,7 +569,7 @@ Fl_File_Chooser::fileNameCB()
       }
     } else {
       // File doesn't exist, so beep at and alert the user...
-      fl_alert(existing_file_label);
+      fl_alert("%s", existing_file_label);
     }
   }
   else if (Fl::event_key() != FL_Delete &&
@@ -757,7 +757,7 @@ Fl_File_Chooser::newdir()
 
 
   // Get a directory name from the user
-  if ((dir = fl_input(new_directory_label, NULL)) == NULL)
+  if ((dir = fl_input("%s", NULL, new_directory_label)) == NULL)
     return;
 
   // Make it relative to the current directory as needed...
@@ -928,7 +928,7 @@ Fl_File_Chooser::showChoiceCB()
   item = showChoice->text(showChoice->value());
 
   if (strcmp(item, custom_filter_label) == 0) {
-    if ((item = fl_input(custom_filter_label, pattern_)) != NULL) {
+    if ((item = fl_input("%s", pattern_, custom_filter_label)) != NULL) {
       strlcpy(pattern_, item, sizeof(pattern_));
 
       quote_pathname(temp, item, sizeof(temp));
--- fltk1.1-1.1.10.orig/src/Fl_PNG_Image.cxx
+++ fltk1.1-1.1.10/src/Fl_PNG_Image.cxx
@@ -66,6 +66,8 @@ Fl_PNG_Image::Fl_PNG_Image(const char *p
   png_structp	pp;			// PNG read pointer
   png_infop	info;			// PNG info pointers
   png_bytep	*rows;			// PNG row pointers
+  png_uint_32	width, height;
+  int		bit_depth, color_type, num_trans = 0;
 
 
   // Open the PNG file...
@@ -75,7 +77,7 @@ Fl_PNG_Image::Fl_PNG_Image(const char *p
   pp   = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
   info = png_create_info_struct(pp);
 
-  if (setjmp(pp->jmpbuf))
+  if (setjmp(png_jmpbuf(pp)))
   {
     Fl::warning("PNG file \"%s\" contains errors!\n", png);
     return;
@@ -87,27 +89,33 @@ Fl_PNG_Image::Fl_PNG_Image(const char *p
   // Get the image dimensions and convert to grayscale or RGB...
   png_read_info(pp, info);
 
-  if (info->color_type == PNG_COLOR_TYPE_PALETTE)
+  png_get_IHDR(pp, info, &width, &height, &bit_depth, &color_type,
+	       NULL /* interlace */, NULL /* compress */, NULL /* filter */);
+#ifdef PNG_tRNS_SUPPORTED
+  png_get_tRNS(pp, info, NULL /* trans */, &num_trans, NULL /* values */);
+#endif
+
+  if (color_type == PNG_COLOR_TYPE_PALETTE)
     png_set_expand(pp);
 
-  if (info->color_type & PNG_COLOR_MASK_COLOR)
+  if (color_type & PNG_COLOR_MASK_COLOR)
     channels = 3;
   else
     channels = 1;
 
-  if ((info->color_type & PNG_COLOR_MASK_ALPHA) || info->num_trans)
+  if ((color_type & PNG_COLOR_MASK_ALPHA) || num_trans)
     channels ++;
 
-  w((int)(info->width));
-  h((int)(info->height));
+  w((int)(width));
+  h((int)(height));
   d(channels);
 
-  if (info->bit_depth < 8)
+  if (bit_depth < 8)
   {
     png_set_packing(pp);
     png_set_expand(pp);
   }
-  else if (info->bit_depth == 16)
+  else if (bit_depth == 16)
     png_set_strip_16(pp);
 
 #  if defined(HAVE_PNG_GET_VALID) && defined(HAVE_PNG_SET_TRNS_TO_ALPHA)
--- fltk1.1-1.1.10.orig/src/Fl_x.cxx
+++ fltk1.1-1.1.10/src/Fl_x.cxx
@@ -290,6 +290,14 @@ Atom fl_XdndFinished;
 Atom fl_XdndURIList;
 
 
+/*
+  X defines 32-bit-entities to have a format value of max. 32,
+  although sizeof(atom) can be 8 (64 bits) on a 64-bit OS.
+  See also fl_open_display() for sizeof(atom) < 4.
+  Used for XChangeProperty (see STR #2419).
+*/
+static int atom_bits = 32;
+
 static void fd_callback(int,void *) {
   do_queued_events();
 }
@@ -343,6 +351,9 @@ void fl_open_display(Display* d) {
   //fl_XdndProxy        = XInternAtom(d, "XdndProxy",		0);
   fl_XdndEnter          = XInternAtom(d, "XdndEnter",		0);
   fl_XdndURIList        = XInternAtom(d, "text/uri-list",	0);
+  
+  if (sizeof(Atom) < 4)
+    atom_bits = sizeof(Atom) * 8;
 
   Fl::add_fd(ConnectionNumber(d), POLLIN, fd_callback);
 
@@ -638,7 +649,7 @@ int fl_handle(const XEvent& thisevent)
     if (e.target == TARGETS) {
       Atom a = XA_STRING;
       XChangeProperty(fl_display, e.requestor, e.property,
-		      XA_ATOM, sizeof(Atom)*8, 0, (unsigned char*)&a, 1);
+		      XA_ATOM, atom_bits, 0, (unsigned char*)&a, 1);
     } else if (/*e.target == XA_STRING &&*/ fl_selection_length[clipboard]) {
       XChangeProperty(fl_display, e.requestor, e.property,
 		      e.target, 8, 0,
--- fltk1.1-1.1.10.orig/src/Makefile
+++ fltk1.1-1.1.10/src/Makefile
@@ -192,6 +192,9 @@ CFILES = fl_call_main.c flstring.c scand
 
 include ../makeinclude
 
+CFLAGS   := $(CFLAGS:-fPIE=-fPIC)
+CXXFLAGS := $(CXXFLAGS:-fPIE=-fPIC)
+
 OBJECTS = $(CPPFILES:.cxx=.o) $(CFILES:.c=.o)
 GLOBJECTS = $(GLCPPFILES:.cxx=.o)
 FLOBJECTS = $(FLCPPFILES:.cxx=.o)
@@ -210,13 +213,13 @@ $(LIBNAME): $(OBJECTS)
 
 libfltk.so.1.1: $(OBJECTS)
 	echo $(DSOCOMMAND) $@ ...
-	$(DSOCOMMAND) $@ $(OBJECTS)
+	$(DSOCOMMAND) $@ $(OBJECTS) $(LDLIBS) -lpthread
 	$(RM) libfltk.so
 	$(LN) libfltk.so.1.1 libfltk.so
 
 libfltk.sl.1.1: $(OBJECTS)
 	echo $(DSOCOMMAND) $@ ...
-	$(DSOCOMMAND) $@ $(OBJECTS)
+	$(DSOCOMMAND) $@ $(OBJECTS) $(LDLIBS)
 	$(RM) libfltk.sl
 	$(LN) libfltk.sl.1.1 libfltk.sl
 
@@ -282,13 +285,13 @@ $(GLLIBNAME): $(GLOBJECTS)
 
 libfltk_gl.so.1.1: $(GLOBJECTS) libfltk.so.1.1
 	echo $(DSOCOMMAND) $@ ...
-	$(DSOCOMMAND) $@ $(GLOBJECTS) -L. -lfltk
+	$(DSOCOMMAND) $@ $(GLOBJECTS) -lGL -lX11 -ldl -L. -lfltk
 	$(RM) libfltk_gl.so
 	$(LN) libfltk_gl.so.1.1 libfltk_gl.so
 
 libfltk_gl.sl.1.1: $(GLOBJECTS) libfltk.sl.1.1
 	echo $(DSOCOMMAND) $@ ...
-	$(DSOCOMMAND) $@ $(GLOBJECTS) -L. -lfltk
+	$(DSOCOMMAND) $@ $(GLOBJECTS) -lGL -lX11 -ldl -L. -lfltk
 	$(RM) libfltk_gl.sl
 	$(LN) libfltk_gl.sl.1.1 libfltk_gl.sl
 
--- fltk1.1-1.1.10.orig/src/fl_draw.cxx
+++ fltk1.1-1.1.10/src/fl_draw.cxx
@@ -32,7 +32,6 @@
 // Expands all unprintable characters to ^X or \nnn notation
 // Aligns them against the inside of the box.
 
-#define min(a,b) ((a)<(b)?(a):(b))
 #include <FL/fl_draw.H>
 #include <FL/Fl_Image.H>
 
@@ -40,6 +39,7 @@
 #include <ctype.h>
 #include <math.h>
 
+#define min(a,b) ((a)<(b)?(a):(b))
 #define MAXBUF 1024
 
 char fl_draw_shortcut;	// set by fl_labeltypes.cxx
--- fltk1.1-1.1.10.orig/src/fl_font_xft.cxx
+++ fltk1.1-1.1.10/src/fl_font_xft.cxx
@@ -90,7 +90,7 @@ Fl_Fontdesc* fl_fonts = built_in_table;
 
 int fl_font_ = 0;
 int fl_size_ = 0;
-XFontStruct* fl_xfont = 0;
+Fl_XFont_On_Demand fl_xfont;
 void *fl_xftfont = 0;
 const char* fl_encoding_ = "iso8859-1";
 Fl_FontSize* fl_fontsize = 0;
@@ -120,6 +120,8 @@ void fl_font(int fnum, int size) {
   fl_fontsize = f;
 #if XFT_MAJOR < 2
   fl_xfont    = f->font->u.core.font;
+#else
+  fl_xfont    = NULL; // invalidate
 #endif // XFT_MAJOR < 2
   fl_xftfont = (void*)f->font;
 }
--- fltk1.1-1.1.10.orig/src/forms_compatability.cxx
+++ fltk1.1-1.1.10/src/forms_compatability.cxx
@@ -202,7 +202,7 @@ int fl_show_choice(
 }
 
 char *fl_show_simple_input(const char *str1, const char *defstr) {
-  const char *r = fl_input(str1, defstr);
+  const char *r = fl_input("%s", str1, defstr);
   return (char *)(r ? r : defstr);
 }
 
--- fltk1.1-1.1.10.orig/test/Makefile
+++ fltk1.1-1.1.10/test/Makefile
@@ -27,6 +27,16 @@
 
 include ../makeinclude
 
+# Streamline dependencies
+GLDLIBS       = -lGL
+IMAGELIBS     =
+LDLIBS        =
+LINKFLTK      = -L../src -Wl,-rpath-link,../src -lfltk
+LINKFLTKFORMS = -L../src -Wl,-rpath-link,../src -lfltk_forms -lfltk
+LINKFLTKGL    = -L../src -Wl,-rpath-link,../src -lfltk_gl -lfltk
+LINKFLTKIMG   = -L../src -Wl,-rpath-link,../src -lfltk_images -lfltk
+LINKSHARED    = -L../src -Wl,-rpath-link,../src -lfltk_images -lfltk_forms -lfltk
+
 CPPFILES =\
 	unittests.cxx \
 	adjuster.cxx \
@@ -294,6 +304,8 @@ colbrowser$(EXEEXT): colbrowser.o
 	$(POSTBUILD) $@ ../FL/mac.r
 
 color_chooser$(EXEEXT): color_chooser.o
+	echo Linking $@...
+	$(CXX) $(ARCHFLAGS) $(LDFLAGS) color_chooser.o -o $@ $(LINKFLTK) -lX11
 
 cursor$(EXEEXT): cursor.o
 
@@ -336,6 +348,8 @@ help$(EXEEXT): help.o $(IMGLIBNAME)
 iconize$(EXEEXT): iconize.o
 
 image$(EXEEXT): image.o
+	echo Linking $@...
+	$(CXX) $(ARCHFLAGS) $(LDFLAGS) image.o -o $@ $(LINKFLTK) -lX11
 
 inactive$(EXEEXT): inactive.o
 inactive.cxx:	inactive.fl ../fluid/fluid$(EXEEXT)
@@ -359,6 +373,8 @@ label$(EXEEXT): label.o
 line_style$(EXEEXT): line_style.o
 
 list_visuals$(EXEEXT): list_visuals.o
+	echo Linking $@...
+	$(CXX) $(ARCHFLAGS) $(LDFLAGS) list_visuals.o -o $@ $(LINKFLTK) -lX11
 
 mandelbrot$(EXEEXT): mandelbrot_ui.o mandelbrot.o
 	echo Linking $@...
@@ -408,7 +424,7 @@ subwindow$(EXEEXT): subwindow.o
 
 sudoku: sudoku.o
 	echo Linking $@...
-	$(CXX) $(ARCHFLAGS) $(LDFLAGS) sudoku.o -o $@ $(AUDIOLIBS) $(LINKFLTKIMG) $(LDLIBS)
+	$(CXX) $(ARCHFLAGS) $(LDFLAGS) sudoku.o -o $@ $(AUDIOLIBS) $(LINKFLTKIMG) -lX11
 	$(OSX_ONLY) $(INSTALL_BIN) sudoku$(EXEEXT) sudoku.app/Contents/MacOS
 	$(POSTBUILD) $@ ../FL/mac.r
 
@@ -423,6 +439,9 @@ tabs$(EXEEXT): tabs.o
 tabs.cxx:	tabs.fl ../fluid/fluid$(EXEEXT)
 
 threads$(EXEEXT): threads.o
+	echo Linking $@...
+	$(CXX) -I.. $(LDFLAGS) threads.o -o $@ $(LINKFLTK) -lpthread
+	$(POSTBUILD) $@ ../FL/mac.r
 # This ensures that we have this dependency even if threads are not
 # enabled in the current tree...
 threads.o:	threads.h
@@ -430,6 +449,8 @@ threads.o:	threads.h
 tile$(EXEEXT): tile.o
 
 tiled_image$(EXEEXT): tiled_image.o
+	echo Linking $@...
+	$(CXX) $(ARCHFLAGS) $(LDFLAGS) tiled_image.o -o $@ $(LINKFLTK) -lX11
 
 valuators$(EXEEXT): valuators.o
 valuators.cxx:	valuators.fl ../fluid/fluid$(EXEEXT)
@@ -456,7 +477,7 @@ cube$(EXEEXT): cube.o
 
 fractals$(EXEEXT): fractals.o fracviewer.o
 	echo Linking $@...
-	$(CXX) $(ARCHFLAGS) $(LDFLAGS) -o $@ fractals.o fracviewer.o $(LINKFLTKGL) $(LINKFLTK) $(GLDLIBS)
+	$(CXX) $(ARCHFLAGS) $(LDFLAGS) -o $@ fractals.o fracviewer.o $(LINKFLTKGL) $(LINKFLTK) -lGLU $(GLDLIBS)
 	$(POSTBUILD) $@ ../FL/mac.r
 
 fullscreen$(EXEEXT): fullscreen.o
@@ -466,7 +487,7 @@ fullscreen$(EXEEXT): fullscreen.o
 
 glpuzzle$(EXEEXT): glpuzzle.o
 	echo Linking $@...
-	$(CXX) $(ARCHFLAGS) $(LDFLAGS) -o $@ glpuzzle.o $(LINKFLTKGL) $(LINKFLTK) $(GLDLIBS)
+	$(CXX) $(ARCHFLAGS) $(LDFLAGS) -o $@ glpuzzle.o $(LINKFLTKGL) $(LINKFLTK) -lGLU $(GLDLIBS)
 	$(POSTBUILD) $@ ../FL/mac.r
 
 gl_overlay$(EXEEXT): gl_overlay.o
