Add --enable-wiringpi to configure script to allow to disable wiringpi even when it is installed. Use SDL2 instead of partly old SDL.

Fri, 15 Mar 2024 20:57:49 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Fri, 15 Mar 2024 20:57:49 +0100
changeset 637
21e542c15832
parent 636
80967361f257
child 638
186f0c2d3e76

Add --enable-wiringpi to configure script to allow to disable wiringpi even when it is installed. Use SDL2 instead of partly old SDL.

brewpanel/brewpanel.c file | annotate | diff | comparison | revisions
brewpanel/brewpanel.h file | annotate | diff | comparison | revisions
brewpanel/dlgBrew.c file | annotate | diff | comparison | revisions
brewpanel/dlgBrew.h file | annotate | diff | comparison | revisions
brewpanel/sdlgui.c file | annotate | diff | comparison | revisions
brewpanel/sdlgui.h file | annotate | diff | comparison | revisions
brewpanel/slcd.c file | annotate | diff | comparison | revisions
brewpanel/slcd.h file | annotate | diff | comparison | revisions
brewpanel/sockio.c file | annotate | diff | comparison | revisions
brewpanel/sockio.h file | annotate | diff | comparison | revisions
config.h.in file | annotate | diff | comparison | revisions
configure file | annotate | diff | comparison | revisions
configure.ac file | annotate | diff | comparison | revisions
--- a/brewpanel/brewpanel.c	Thu Mar 14 19:37:53 2024 +0100
+++ b/brewpanel/brewpanel.c	Fri Mar 15 20:57:49 2024 +0100
@@ -24,7 +24,7 @@
 #include "sdlgui.h"
 #include "dlgBrew.h"
 
-#ifdef HAVE_SDL_SDL_H
+#ifdef HAVE_SDL2_SDL_H
 
 int			debug = FALSE;			/* Console debugging		*/
 static pid_t		pgrp, mypid;
@@ -36,8 +36,8 @@
 int			LCD_fcol;			/* LCD foreground color		*/
 int			LCD_bcol;			/* LCD background color		*/
 
-SDL_Surface		*PAN_surface = NULL;		/* Main surface			*/
-
+SDL_Surface		*S_screen = NULL;		/* Main screen			*/
+SDL_Window		*S_window;			/* Main window			*/
 
 int server(void);
 
@@ -172,7 +172,6 @@
 
 int server(void)
 {
-    SDL_Rect    **modes;
     char        title[81];
 
     /* 
@@ -182,27 +181,33 @@
 	syslog(LOG_NOTICE, "[main] could not initialize SDL: %s", SDL_GetError());
 	exit(-1);
     }
+    if ((TTF_Init() < 0)) {
+        syslog(LOG_NOTICE, "[main] SDL_ttf could not initialize! SDL_ttf Error: %s", TTF_GetError());
+        exit(-1);
+    }
+    SDLGui_Init();
 
-    modes = SDL_ListModes(NULL, SDL_FULLSCREEN);
-    if (modes != (SDL_Rect **)0) {
-	/* Check if our resolution is restricted */
-	if (modes == (SDL_Rect **)-1) {
-	    syslog(LOG_NOTICE, "SDL all resolutions available.\n");
-	}
+    /*
+     * Get available fullscreen modes, so we will get the effective screensize
+     */
+    SDL_DisplayMode modes = { SDL_PIXELFORMAT_UNKNOWN, 0, 0, 0, 0 };
+    if (SDL_GetDisplayMode(0, 0, &modes) != 0) {
+        syslog(LOG_NOTICE, "[main] SDL_GetDisplayMode failed: %s", SDL_GetError());
+        exit(-1);
     }
 
     PAN_x = 384;
     PAN_y = 480;
 
-    PAN_surface = SDL_SetVideoMode( PAN_x, PAN_y, 32, SDL_SWSURFACE|SDL_DOUBLEBUF );
-    if (PAN_surface == NULL) {
-	syslog(LOG_NOTICE, "Could not create main surface: %s", SDL_GetError());
+    snprintf(title, 80, "brewpanel v%s", VERSION);
+    S_window = SDL_CreateWindow(title, 0, 0, PAN_x, PAN_y, SDL_WINDOW_OPENGL);
+
+    S_screen = SDL_GetWindowSurface(S_window);
+    if (S_screen == NULL) {
+	syslog(LOG_NOTICE, "Could not create S_screen: %s", SDL_GetError());
 	exit(-1);
     }
 
-    SDLGui_Init();
-    snprintf(title, 80, "brewpanel v%s", VERSION);
-    SDL_WM_SetCaption(title, NULL);
 
     syslog(LOG_NOTICE, "Starting mainloop");
     if (strlen(Paneltype) && !strcmp(Paneltype, (char *)"ferm") ) {
@@ -213,7 +218,7 @@
     syslog(LOG_NOTICE, "Out of mainloop, cleanup");
 
     SDLGui_UnInit();
-    SDL_FreeSurface(PAN_surface);
+    SDL_FreeSurface(S_screen);
     SDL_Quit();
 
     return 0;
--- a/brewpanel/brewpanel.h	Thu Mar 14 19:37:53 2024 +0100
+++ b/brewpanel/brewpanel.h	Fri Mar 15 20:57:49 2024 +0100
@@ -29,7 +29,7 @@
 #include <math.h>
 
 
-#ifdef HAVE_SDL_SDL_H
+#ifdef HAVE_SDL2_SDL_H
 #include <SDL.h>
 #include <SDL_ttf.h>
 #endif
--- a/brewpanel/dlgBrew.c	Thu Mar 14 19:37:53 2024 +0100
+++ b/brewpanel/dlgBrew.c	Fri Mar 15 20:57:49 2024 +0100
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * Copyright (C) 2015
+ * Copyright (C) 2015-2024
  *   
  * Michiel Broek <mbroek at mbse dot eu>
  *
@@ -30,9 +30,9 @@
 #include "sockio.h"
 
 
-#ifdef HAVE_SDL_SDL_H
+#ifdef HAVE_SDL2_SDL_H
 
-extern SDL_Surface	*PAN_surface;
+extern SDL_Surface	*S_screen;
 extern int		my_shutdown;
 extern int		debug;
 extern uint16_t		keys;
@@ -97,8 +97,8 @@
     int nOldMouseX, nOldMouseY;
     int x, y, w, h, cols, rows, fd;
 
-    if (SDLGui_SetScreen(PAN_surface)) {
-	syslog(LOG_NOTICE, "SDLGui_SetScreen(PAN_surface) failed: %s", SDL_GetError());
+    if (SDLGui_SetScreen(S_screen)) {
+	syslog(LOG_NOTICE, "SDLGui_SetScreen(S_screen) failed: %s", SDL_GetError());
 	return FALSE;
     }
 
--- a/brewpanel/dlgBrew.h	Thu Mar 14 19:37:53 2024 +0100
+++ b/brewpanel/dlgBrew.h	Fri Mar 15 20:57:49 2024 +0100
@@ -1,7 +1,7 @@
 #ifndef	_DLGBREW_H
 #define	_DLGBREW_H
 
-#ifdef HAVE_SDL_SDL_H
+#ifdef HAVE_SDL2_SDL_H
 
 int  Dialog_LCDinit(int *x, int *y, int *w, int *h, int *cols, int *rows, int index);
 int  Dialog_BrewDlg(int fermenter);
--- a/brewpanel/sdlgui.c	Thu Mar 14 19:37:53 2024 +0100
+++ b/brewpanel/sdlgui.c	Fri Mar 15 20:57:49 2024 +0100
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * Copyright (C) 2015-2020
+ * Copyright (C) 2015-2024
  *   
  * Michiel Broek <mbroek at mbse dot eu>
  *
@@ -27,7 +27,7 @@
 #include "sdlgui.h"
 #include "sockio.h"
 
-#ifdef HAVE_SDL_SDL_H
+#ifdef HAVE_SDL2_SDL_H
 
 #include "lcdfont10x16.h"
 
@@ -44,6 +44,7 @@
 extern int		my_shutdown;
 extern int		debug;
 
+extern SDL_Window	*S_window;
 
 /*-----------------------------------------------------------------------*/
 /*
@@ -104,10 +105,10 @@
     }
 
     /* Set color palette of the LCD font graphics: */
-    SDL_SetColors(pFontGfx, blackWhiteColors, 0, 2);
+    SDL_SetPaletteColors(pFontGfx->format->palette, blackWhiteColors, 0, 2);
 
     /* Set font color 0 as transparent: */
-    SDL_SetColorKey(pFontGfx, (SDL_SRCCOLORKEY|SDL_RLEACCEL), 0);
+    SDL_SetColorKey(pFontGfx, SDL_RLEACCEL, 0);
 
     if (TTF_Init() == -1) {
 	syslog(LOG_NOTICE, "Could not init SDL_ttf");
@@ -242,7 +243,7 @@
     	dr.h = 2;
 
     	SDL_FillRect(pSdlGuiScrn, &dr, color);
-    	SDL_UpdateRect(pSdlGuiScrn, x, y, fontwidth, fontheight);
+//    	SDL_UpdateRect(pSdlGuiScrn, x, y, fontwidth, fontheight);
     }
 }
 
@@ -287,8 +288,8 @@
 	i++;
     }
 
-    SDL_SetColors(CGchar, blackWhiteColors, 0, 2);
-    SDL_SetColorKey(CGchar, (SDL_SRCCOLORKEY|SDL_RLEACCEL), 0);
+//    SDL_SetColors(CGchar, blackWhiteColors, 0, 2);
+    SDL_SetColorKey(CGchar, SDL_RLEACCEL, 0);
     bg = LCDbg0;
 
     sr.x = sr.y = 0;
@@ -299,7 +300,8 @@
 
     SDL_FillRect(pSdlGuiScrn, &dr, bg);
     SDL_BlitSurface(CGchar, &sr, pSdlGuiScrn, &dr);
-    SDL_UpdateRect(pSdlGuiScrn, x, y, fontwidth, fontheight);
+    //SDL_UpdateRect(pSdlGuiScrn, x, y, fontwidth, fontheight);
+    SDL_UpdateWindowSurface(S_window);
     SDL_FreeSurface(CGchar);
 }
 
@@ -330,7 +332,8 @@
 
     SDL_FillRect(pSdlGuiScrn, &dr, bg);
     SDL_BlitSurface(pFontGfx, &sr, pSdlGuiScrn, &dr);
-    SDL_UpdateRect(pSdlGuiScrn, x, y, fontwidth, fontheight);
+//    SDL_UpdateRect(pSdlGuiScrn, x, y, fontwidth, fontheight);
+    SDL_UpdateWindowSurface(S_window);
 }
 
 
@@ -695,7 +698,8 @@
 				SDLGUI_DrawLEDYellow(dlg, i);
 				break;
 	    }
-	    SDL_UpdateRect(pSdlGuiScrn, dlg[i].x - dlg[i].w, dlg[i].y - dlg[i].w, dlg[i].w * 2, dlg[i].w * 2);
+	    SDL_UpdateWindowSurface(S_window);
+	    //SDL_UpdateRect(pSdlGuiScrn, dlg[i].x - dlg[i].w, dlg[i].y - dlg[i].w, dlg[i].w * 2, dlg[i].w * 2);
 	}
     }
 }
@@ -741,7 +745,8 @@
 	}
     }
 
-    SDL_UpdateRect(pSdlGuiScrn, 0,0,0,0);
+    SDL_UpdateWindowSurface(S_window);
+  //  SDL_UpdateRect(pSdlGuiScrn, 0,0,0,0);
 }
 
 
@@ -798,7 +803,7 @@
     pBgSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, dlgrect.w, dlgrect.h, pSdlGuiScrn->format->BitsPerPixel,
 	                                  pSdlGuiScrn->format->Rmask, pSdlGuiScrn->format->Gmask, pSdlGuiScrn->format->Bmask, pSdlGuiScrn->format->Amask);
     if (pSdlGuiScrn->format->palette != NULL) {
-	SDL_SetColors(pBgSurface, pSdlGuiScrn->format->palette->colors, 0, pSdlGuiScrn->format->palette->ncolors-1);
+	SDL_SetPaletteColors(pBgSurface->format->palette, pSdlGuiScrn->format->palette->colors, 0, pSdlGuiScrn->format->palette->ncolors-1);
     }
 
     if (pBgSurface != NULL) {
@@ -847,7 +852,8 @@
 				    if (dlg[obj].type == SGBUTTON) {
 					dlg[obj].state |= SG_SELECTED;
 					SDLGui_DrawButton(dlg, obj);
-					SDL_UpdateRect(pSdlGuiScrn, dlg[0].x + dlg[obj].x - 2, dlg[0].y + dlg[obj].y - 2, dlg[obj].w + 4, dlg[obj].h + 4);
+					SDL_UpdateWindowSurface(S_window);
+					//SDL_UpdateRect(pSdlGuiScrn, dlg[0].x + dlg[obj].x - 2, dlg[0].y + dlg[obj].y - 2, dlg[obj].w + 4, dlg[obj].h + 4);
 					retbutton = obj + 1000;
 				    }
 				}
@@ -864,7 +870,8 @@
 				    if (dlg[obj].type == SGBUTTON) {
 					dlg[obj].state &= ~SG_SELECTED;
 					SDLGui_DrawButton(dlg, obj);
-					SDL_UpdateRect(pSdlGuiScrn, dlg[0].x + dlg[obj].x - 2, dlg[0].y + dlg[obj].y - 2, dlg[obj].w + 4, dlg[obj].h + 4);
+					SDL_UpdateWindowSurface(S_window);
+					//SDL_UpdateRect(pSdlGuiScrn, dlg[0].x + dlg[obj].x - 2, dlg[0].y + dlg[obj].y - 2, dlg[obj].w + 4, dlg[obj].h + 4);
 					retbutton = obj;
 				    }
 				}
--- a/brewpanel/sdlgui.h	Thu Mar 14 19:37:53 2024 +0100
+++ b/brewpanel/sdlgui.h	Fri Mar 15 20:57:49 2024 +0100
@@ -1,7 +1,7 @@
 #ifndef _SDLGUI_H
 #define _SDLGUI_H
 
-#ifdef HAVE_SDL_SDL_H
+#ifdef HAVE_SDL2_SDL_H
 
 enum
 {
--- a/brewpanel/slcd.c	Thu Mar 14 19:37:53 2024 +0100
+++ b/brewpanel/slcd.c	Fri Mar 15 20:57:49 2024 +0100
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * Copyright (C) 2015
+ * Copyright (C) 2015-2024
  *   
  * Michiel Broek <mbroek at mbse dot eu>
  *
@@ -29,7 +29,7 @@
 #include "slcd.h"
 #include "dlgBrew.h"
 
-#ifdef HAVE_SDL_SDL_H
+#ifdef HAVE_SDL2_SDL_H
 
 
 // Bits in the control register
--- a/brewpanel/slcd.h	Thu Mar 14 19:37:53 2024 +0100
+++ b/brewpanel/slcd.h	Fri Mar 15 20:57:49 2024 +0100
@@ -1,6 +1,6 @@
 #ifndef _SLCD_H
 #define	_SLCD_H
-#ifdef	HAVE_SDL_SDL_H
+#ifdef	HAVE_SDL2_SDL_H
 
 #define	MAX_SLCDS	8
 
--- a/brewpanel/sockio.c	Thu Mar 14 19:37:53 2024 +0100
+++ b/brewpanel/sockio.c	Fri Mar 15 20:57:49 2024 +0100
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * Copyright (C) 2015
+ * Copyright (C) 2015-2024
  *   
  * Michiel Broek <mbroek at mbse dot eu>
  *
@@ -26,7 +26,7 @@
 #include "futil.h"
 #include "sockio.h"
 
-#ifdef HAVE_SDL_SDL_H
+#ifdef HAVE_SDL2_SDL_H
 
 
 int			sock = -1;		/* Unix datagram socket		*/
--- a/brewpanel/sockio.h	Thu Mar 14 19:37:53 2024 +0100
+++ b/brewpanel/sockio.h	Fri Mar 15 20:57:49 2024 +0100
@@ -1,6 +1,6 @@
 #ifndef _SOCKIO_H
 #define	_SOCKIO_H
-#ifdef	HAVE_SDL_SDL_H
+#ifdef	HAVE_SDL2_SDL_H
 
 
 void socket_recv(SGOBJ *dlg);
--- a/config.h.in	Thu Mar 14 19:37:53 2024 +0100
+++ b/config.h.in	Fri Mar 15 20:57:49 2024 +0100
@@ -55,4 +55,4 @@
 #undef HAVE_MOSQUITTO_H
 
 /* Define if you have the <SDL/SDL.h> header file. */
-#undef HAVE_SDL_SDL_H
+#undef HAVE_SDL2_SDL_H
--- a/configure	Thu Mar 14 19:37:53 2024 +0100
+++ b/configure	Fri Mar 15 20:57:49 2024 +0100
@@ -683,6 +683,7 @@
 ac_subst_files=''
 ac_user_opts='
 enable_option_checking
+enable_wiringpi
 enable_experiment
 enable_simulator
 enable_debugging
@@ -1303,6 +1304,7 @@
   --disable-option-checking  ignore unrecognized --enable/--with options
   --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
+  --enable-wiringpi       Compile wiringPi code
   --enable-experiment     Compile experimental code
   --enable-simulator      Compile simulator code
   --enable-debugging      Compile for debugging
@@ -3509,7 +3511,15 @@
 fi
 
 WIRINGPI=No
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for wiringPiSetup in -lwiringPi" >&5
+# Check whether --enable-wiringpi was given.
+if test "${enable_wiringpi+set}" = set; then :
+  enableval=$enable_wiringpi;  wiringpi=$enableval
+else
+   wiringpi=yes
+fi
+
+if test "$wiringpi" = "yes"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for wiringPiSetup in -lwiringPi" >&5
 $as_echo_n "checking for wiringPiSetup in -lwiringPi... " >&6; }
 if ${ac_cv_lib_wiringPi_wiringPiSetup+:} false; then :
   $as_echo_n "(cached) " >&6
@@ -3551,9 +3561,9 @@
   result=no
 fi
 
-if test "$result" = "yes"; then
-  LIBS="$LIBS -lwiringPi -lwiringPiDev"
-  for ac_header in wiringPi.h
+  if test "$result" = "yes"; then
+    LIBS="$LIBS -lwiringPi -lwiringPiDev"
+    for ac_header in wiringPi.h
 do :
   ac_fn_c_check_header_mongrel "$LINENO" "wiringPi.h" "ac_cv_header_wiringPi_h" "$ac_includes_default"
 if test "x$ac_cv_header_wiringPi_h" = xyes; then :
@@ -3567,6 +3577,10 @@
 
 done
 
+  fi
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: check wiringPi disabled" >&5
+$as_echo "check wiringPi disabled" >&6; }
 fi
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for json_object_iter_init_default in -ljson-c" >&5
@@ -3799,29 +3813,29 @@
 SDL_CFLAGS=""
 SDL_LIBS=""
 SDL="No"
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking SDL library" >&5
-$as_echo_n "checking SDL library... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking SDL2 library" >&5
+$as_echo_n "checking SDL2 library... " >&6; }
 pkg-config --exists sdl
 if test "$?" = "0"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking sdl library v1.2.0 or newer" >&5
-$as_echo_n "checking sdl library v1.2.0 or newer... " >&6; }
-  pkg-config --atleast-version=1.2.0 sdl
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking sdl2 library v2.0.0 or newer" >&5
+$as_echo_n "checking sdl2 library v2.0.0 or newer... " >&6; }
+  pkg-config --atleast-version=2.0.0 sdl2
   if test "$?" = "0"; then
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5
 $as_echo "found" >&6; }
   else
     as_fn_error $? "not found" "$LINENO" 5
   fi
-  SDL_CFLAGS="$(pkg-config --cflags sdl)"
-  SDL_LIBS="$(pkg-config --libs sdl)"
-  for ac_header in SDL/SDL.h
+  SDL_CFLAGS="$(pkg-config --cflags sdl2)"
+  SDL_LIBS="$(pkg-config --libs sdl2)"
+  for ac_header in SDL2/SDL.h
 do :
-  ac_fn_c_check_header_mongrel "$LINENO" "SDL/SDL.h" "ac_cv_header_SDL_SDL_h" "$ac_includes_default"
-if test "x$ac_cv_header_SDL_SDL_h" = xyes; then :
+  ac_fn_c_check_header_mongrel "$LINENO" "SDL2/SDL.h" "ac_cv_header_SDL2_SDL_h" "$ac_includes_default"
+if test "x$ac_cv_header_SDL2_SDL_h" = xyes; then :
   cat >>confdefs.h <<_ACEOF
-#define HAVE_SDL_SDL_H 1
+#define HAVE_SDL2_SDL_H 1
 _ACEOF
 
 fi
@@ -3835,15 +3849,15 @@
 fi
 
 # Check for SDL_ttf
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking SDL_ttf library" >&5
-$as_echo_n "checking SDL_ttf library... " >&6; }
-pkg-config --exists SDL_ttf
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking SDL2_ttf library" >&5
+$as_echo_n "checking SDL2_ttf library... " >&6; }
+pkg-config --exists SDL2_ttf
 if test "$?" = "0"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking sdl library v2.0.0 or newer" >&5
-$as_echo_n "checking sdl library v2.0.0 or newer... " >&6; }
-  pkg-config --atleast-version=2.0.0 SDL_ttf
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking sdl2 library v2.0.0 or newer" >&5
+$as_echo_n "checking sdl2 library v2.0.0 or newer... " >&6; }
+  pkg-config --atleast-version=2.0.0 SDL2_ttf
   if test "$?" = "0"; then
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5
 $as_echo "found" >&6; }
@@ -3851,8 +3865,8 @@
     as_fn_error $? "not found" "$LINENO" 5
   fi
   # Override flags
-  SDL_CFLAGS="$(pkg-config --cflags SDL_ttf)"
-  SDL_LIBS="$(pkg-config --libs SDL_ttf)"
+  SDL_CFLAGS="$(pkg-config --cflags SDL2_ttf)"
+  SDL_LIBS="$(pkg-config --libs SDL2_ttf)"
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
@@ -5258,7 +5272,7 @@
     Version : ............ ${VERSION}
     Main directory : ..... ${prefix}
     WiringPi : ........... ${WIRINGPI}
-    SDL library : ........ ${SDL}
+    SDL2 library : ....... ${SDL}
     Simulator : .......... ${SIMULATOR}
 
   Now type 'make' and 'sudo make install'
@@ -5271,7 +5285,7 @@
     Version : ............ ${VERSION}
     Main directory : ..... ${prefix}
     WiringPi : ........... ${WIRINGPI}
-    SDL library : ........ ${SDL}
+    SDL2 library : ....... ${SDL}
     Simulator : .......... ${SIMULATOR}
 
   Now type 'make' and 'sudo make install'
--- a/configure.ac	Thu Mar 14 19:37:53 2024 +0100
+++ b/configure.ac	Fri Mar 15 20:57:49 2024 +0100
@@ -41,10 +41,15 @@
 fi
 
 WIRINGPI=No
-AC_CHECK_LIB(wiringPi,wiringPiSetup,result=yes,result=no)
-if test "$result" = "yes"; then
-  LIBS="$LIBS -lwiringPi -lwiringPiDev"
-  AC_CHECK_HEADERS(wiringPi.h,WIRINGPI=Yes,WIRINGPI=No)
+AC_ARG_ENABLE(wiringpi,  [  --enable-wiringpi       Compile wiringPi code],     [ wiringpi=$enableval ], [ wiringpi=yes ])
+if test "$wiringpi" = "yes"; then
+  AC_CHECK_LIB(wiringPi,wiringPiSetup,result=yes,result=no)
+  if test "$result" = "yes"; then
+    LIBS="$LIBS -lwiringPi -lwiringPiDev"
+    AC_CHECK_HEADERS(wiringPi.h,WIRINGPI=Yes,WIRINGPI=No)
+  fi
+else
+  AC_MSG_RESULT(check wiringPi disabled)
 fi
 
 AC_CHECK_LIB(json-c,json_object_iter_init_default,result=yes,result=no)
@@ -101,40 +106,40 @@
 SDL_CFLAGS=""
 SDL_LIBS=""
 SDL="No"
-AC_MSG_CHECKING(SDL library)
+AC_MSG_CHECKING(SDL2 library)
 pkg-config --exists sdl
 if test "$?" = "0"; then
   AC_MSG_RESULT(yes)
-  AC_MSG_CHECKING(sdl library v1.2.0 or newer)
-  pkg-config --atleast-version=1.2.0 sdl
+  AC_MSG_CHECKING(sdl2 library v2.0.0 or newer)
+  pkg-config --atleast-version=2.0.0 sdl2
   if test "$?" = "0"; then
     AC_MSG_RESULT(found)
   else
     AC_MSG_ERROR(not found)
   fi
-  SDL_CFLAGS="$(pkg-config --cflags sdl)"
-  SDL_LIBS="$(pkg-config --libs sdl)"
-  AC_CHECK_HEADERS(SDL/SDL.h)
+  SDL_CFLAGS="$(pkg-config --cflags sdl2)"
+  SDL_LIBS="$(pkg-config --libs sdl2)"
+  AC_CHECK_HEADERS(SDL2/SDL.h)
   SDL="Yes"
 else
   AC_MSG_RESULT(no)
 fi
 
 # Check for SDL_ttf
-AC_MSG_CHECKING(SDL_ttf library)
-pkg-config --exists SDL_ttf
+AC_MSG_CHECKING(SDL2_ttf library)
+pkg-config --exists SDL2_ttf
 if test "$?" = "0"; then
   AC_MSG_RESULT(yes)
-  AC_MSG_CHECKING(sdl library v2.0.0 or newer)
-  pkg-config --atleast-version=2.0.0 SDL_ttf
+  AC_MSG_CHECKING(sdl2 library v2.0.0 or newer)
+  pkg-config --atleast-version=2.0.0 SDL2_ttf
   if test "$?" = "0"; then
     AC_MSG_RESULT(found)
   else
     AC_MSG_ERROR(not found)
   fi
   # Override flags
-  SDL_CFLAGS="$(pkg-config --cflags SDL_ttf)"
-  SDL_LIBS="$(pkg-config --libs SDL_ttf)"
+  SDL_CFLAGS="$(pkg-config --cflags SDL2_ttf)"
+  SDL_LIBS="$(pkg-config --libs SDL2_ttf)"
 else
   AC_MSG_RESULT(no)
 fi
@@ -158,7 +163,7 @@
     Version : ............ ${VERSION}
     Main directory : ..... ${prefix}
     WiringPi : ........... ${WIRINGPI}
-    SDL library : ........ ${SDL}
+    SDL2 library : ....... ${SDL}
     Simulator : .......... ${SIMULATOR}
 
   Now type 'make' and 'sudo make install'

mercurial