Commit f061f767 authored by Marcus Meissner's avatar Marcus Meissner Committed by Alexandre Julliard

Do not link against -lcups directly, but dynamically load it if

present (just like freetype etc.)
parent bd4a385c
...@@ -362,17 +362,6 @@ then ...@@ -362,17 +362,6 @@ then
fi fi
AC_SUBST(CURSESLIBS) AC_SUBST(CURSESLIBS)
CUPSLIBS=""
dnl **** Check for CUPS ****
wine_cv_warn_cups_h=no
AC_CHECK_LIB(cups,cupsGetPPD,
[AC_CHECK_HEADER(cups/cups.h,
[AC_DEFINE(HAVE_CUPS, 1, [Define if we have CUPS])
CUPSLIBS="-lcups"],
wine_cv_warn_cups_h=yes)]
)
AC_SUBST(CUPSLIBS)
dnl **** Check for SANE **** dnl **** Check for SANE ****
AC_CHECK_PROG(sane_devel,sane-config,sane-config,no) AC_CHECK_PROG(sane_devel,sane-config,sane-config,no)
if test "$sane_devel" = "no" if test "$sane_devel" = "no"
...@@ -856,6 +845,7 @@ then ...@@ -856,6 +845,7 @@ then
WINE_GET_SONAME(Xext,XextCreateExtension,[$X_LIBS -lX11 $X_EXTRA_LIBS]) WINE_GET_SONAME(Xext,XextCreateExtension,[$X_LIBS -lX11 $X_EXTRA_LIBS])
WINE_GET_SONAME(Xrender,XRenderQueryExtension,[$X_LIBS -lXext -lX11 $X_EXTRA_LIBS]) WINE_GET_SONAME(Xrender,XRenderQueryExtension,[$X_LIBS -lXext -lX11 $X_EXTRA_LIBS])
WINE_GET_SONAME(freetype,FT_Init_FreeType,[$X_LIBS]) WINE_GET_SONAME(freetype,FT_Init_FreeType,[$X_LIBS])
WINE_GET_SONAME(cups,cupsGetDefault)
fi fi
...@@ -969,6 +959,7 @@ dnl **** Check for header files **** ...@@ -969,6 +959,7 @@ dnl **** Check for header files ****
AC_CHECK_HEADERS(\ AC_CHECK_HEADERS(\
arpa/inet.h \ arpa/inet.h \
arpa/nameser.h \ arpa/nameser.h \
cups/cups.h \
direct.h \ direct.h \
elf.h \ elf.h \
float.h \ float.h \
...@@ -1597,14 +1588,6 @@ then ...@@ -1597,14 +1588,6 @@ then
echo "*** support before reporting bugs." echo "*** support before reporting bugs."
fi fi
if test "$wine_cv_warn_cups_h" = "yes"
then
echo
echo "*** Note: You have cups runtime libraries, but no development"
echo "*** libraries. Install the cups-devel package or whichever package"
echo "*** contains cups.h to enable CUPS support in Wine."
fi
if test "$wine_cv_msg_freetype" = "yes" if test "$wine_cv_msg_freetype" = "yes"
then then
echo echo
......
...@@ -5,7 +5,6 @@ VPATH = @srcdir@ ...@@ -5,7 +5,6 @@ VPATH = @srcdir@
MODULE = wineps.dll MODULE = wineps.dll
IMPORTS = user32 gdi32 winspool.drv advapi32 kernel32 IMPORTS = user32 gdi32 winspool.drv advapi32 kernel32
ALTNAMES = wineps16.dll ALTNAMES = wineps16.dll
EXTRALIBS = @CUPSLIBS@
EXTRAINCL = @FREETYPEINCL@ EXTRAINCL = @FREETYPEINCL@
LDDLLFLAGS = @LDDLLFLAGS@ LDDLLFLAGS = @LDDLLFLAGS@
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
*/ */
#include "config.h" #include "config.h"
#include "wine/port.h"
#include <string.h> #include <string.h>
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
...@@ -33,11 +34,17 @@ ...@@ -33,11 +34,17 @@
#include "winspool.h" #include "winspool.h"
#include "winerror.h" #include "winerror.h"
#ifdef HAVE_CUPS WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
# include <cups/cups.h>
#ifdef HAVE_CUPS_CUPS_H
#include <cups/cups.h>
#ifndef CUPS_SONAME
#define CUPS_SONAME "libcups.so"
#endif #endif
WINE_DEFAULT_DEBUG_CHANNEL(psdrv); static void *cupshandle = NULL;
#endif
static PSDRV_DEVMODEA DefaultDevmode = static PSDRV_DEVMODEA DefaultDevmode =
{ {
...@@ -127,12 +134,25 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved ) ...@@ -127,12 +134,25 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
HeapDestroy(PSDRV_Heap); HeapDestroy(PSDRV_Heap);
return FALSE; return FALSE;
} }
#ifdef HAVE_CUPS_CUPS_H
/* dynamically load CUPS if not yet loaded */
if (!cupshandle) {
cupshandle = wine_dlopen(CUPS_SONAME, RTLD_NOW, NULL, 0);
if (!cupshandle) cupshandle = (void*)-1;
}
#endif
break; break;
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
DeleteObject( PSDRV_DefaultFont ); DeleteObject( PSDRV_DefaultFont );
HeapDestroy( PSDRV_Heap ); HeapDestroy( PSDRV_Heap );
#ifdef HAVE_CUPS_CUPS_H
if (cupshandle && (cupshandle != (void*)-1)) {
wine_dlclose(cupshandle, NULL, 0);
cupshandle = NULL;
}
#endif
break; break;
} }
...@@ -491,24 +511,28 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCSTR name) ...@@ -491,24 +511,28 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCSTR name)
goto cleanup; goto cleanup;
} }
#ifdef HAVE_CUPS #ifdef HAVE_CUPS_CUPS_H
{ if (cupshandle != (void*)-1) {
ppd = cupsGetPPD(name); typeof(cupsGetPPD) * pcupsGetPPD = NULL;
if (ppd) { pcupsGetPPD = wine_dlsym(cupshandle, "cupsGetPPD", NULL, 0);
needed=strlen(ppd)+1; if (pcupsGetPPD) {
ppdFileName=HeapAlloc(PSDRV_Heap, 0, needed); ppd = pcupsGetPPD(name);
memcpy(ppdFileName, ppd, needed);
ppdType=REG_SZ; if (ppd) {
res = ERROR_SUCCESS; needed=strlen(ppd)+1;
/* we should unlink() that file later */ ppdFileName=HeapAlloc(PSDRV_Heap, 0, needed);
} else { memcpy(ppdFileName, ppd, needed);
res = ERROR_FILE_NOT_FOUND; ppdType=REG_SZ;
WARN("Did not find ppd for %s\n",name); res = ERROR_SUCCESS;
/* we should unlink() that file later */
} else {
res = ERROR_FILE_NOT_FOUND;
WARN("Did not find ppd for %s\n",name);
}
} }
} }
#endif #endif
if (!ppdFileName) { if (!ppdFileName) {
res = GetPrinterDataA(hPrinter, "PPD File", NULL, NULL, 0, &needed); res = GetPrinterDataA(hPrinter, "PPD File", NULL, NULL, 0, &needed);
if ((res==ERROR_SUCCESS) || (res==ERROR_MORE_DATA)) { if ((res==ERROR_SUCCESS) || (res==ERROR_MORE_DATA)) {
......
...@@ -5,7 +5,6 @@ SRCDIR = @srcdir@ ...@@ -5,7 +5,6 @@ SRCDIR = @srcdir@
VPATH = @srcdir@ VPATH = @srcdir@
MODULE = winspool.drv MODULE = winspool.drv
IMPORTS = advapi32 kernel32 IMPORTS = advapi32 kernel32
EXTRALIBS = @CUPSLIBS@
LDDLLFLAGS = @LDDLLFLAGS@ LDDLLFLAGS = @LDDLLFLAGS@
SYMBOLFILE = $(MODULE).tmp.o SYMBOLFILE = $(MODULE).tmp.o
......
...@@ -23,14 +23,19 @@ ...@@ -23,14 +23,19 @@
*/ */
#include "config.h" #include "config.h"
#include "wine/port.h"
#include "wine/library.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <stddef.h> #include <stddef.h>
#ifdef HAVE_CUPS #ifdef HAVE_CUPS_CUPS_H
# include <cups/cups.h> # include <cups/cups.h>
# ifndef CUPS_SONAME
# define CUPS_SONAME "libcups.so"
# endif
#endif #endif
#include "winspool.h" #include "winspool.h"
#include "winbase.h" #include "winbase.h"
...@@ -115,21 +120,39 @@ WINSPOOL_SetDefaultPrinter(const char *devname, const char *name,BOOL force) { ...@@ -115,21 +120,39 @@ WINSPOOL_SetDefaultPrinter(const char *devname, const char *name,BOOL force) {
} }
} }
#ifdef HAVE_CUPS #ifdef HAVE_CUPS_CUPS_H
BOOL BOOL
CUPS_LoadPrinters(void) { CUPS_LoadPrinters(void) {
typeof(cupsGetPrinters) *pcupsGetPrinters = NULL;
typeof(cupsGetDefault) *pcupsGetDefault = NULL;
typeof(cupsGetPPD) *pcupsGetPPD = NULL;
char **printers; char **printers;
int i,nrofdests,hadprinter = FALSE; int i,nrofdests,hadprinter = FALSE;
PRINTER_INFO_2A pinfo2a; PRINTER_INFO_2A pinfo2a;
const char* def = cupsGetDefault(); const char* def;
void *cupshandle = NULL;
nrofdests = cupsGetPrinters(&printers); cupshandle = wine_dlopen(CUPS_SONAME, RTLD_NOW, NULL, 0);
if (!cupshandle)
return FALSE;
#define DYNCUPS(x) \
p##x = wine_dlsym(cupshandle, #x, NULL,0); \
if (!p##x) return FALSE;
DYNCUPS(cupsGetDefault);
DYNCUPS(cupsGetPPD);
DYNCUPS(cupsGetPrinters);
#undef DYNCUPS
def = pcupsGetDefault();
if (def && !strcmp(def,"none")) /* CUPS has "none" for no default printer */ if (def && !strcmp(def,"none")) /* CUPS has "none" for no default printer */
def = NULL; def = NULL;
nrofdests = pcupsGetPrinters(&printers);
for (i=0;i<nrofdests;i++) { for (i=0;i<nrofdests;i++) {
const char *ppd = cupsGetPPD(printers[i]); const char *ppd = pcupsGetPPD(printers[i]);
char *port,*devline; char *port,*devline;
if (!ppd) { if (!ppd) {
...@@ -180,6 +203,7 @@ CUPS_LoadPrinters(void) { ...@@ -180,6 +203,7 @@ CUPS_LoadPrinters(void) {
} }
HeapFree(GetProcessHeap(),0,port); HeapFree(GetProcessHeap(),0,port);
} }
wine_dlclose(cupshandle, NULL, 0);
return hadprinter; return hadprinter;
} }
#endif #endif
...@@ -341,7 +365,7 @@ WINSPOOL_LoadSystemPrinters() { ...@@ -341,7 +365,7 @@ WINSPOOL_LoadSystemPrinters() {
ERR("Failed adding PS Driver (%ld)\n",GetLastError()); ERR("Failed adding PS Driver (%ld)\n",GetLastError());
return; return;
} }
#ifdef HAVE_CUPS #ifdef HAVE_CUPS_CUPS_H
/* If we have any CUPS based printers, skip looking for printcap printers */ /* If we have any CUPS based printers, skip looking for printcap printers */
if (CUPS_LoadPrinters()) if (CUPS_LoadPrinters())
return; return;
...@@ -1827,7 +1851,7 @@ static BOOL WINSPOOL_GetPrinter(HANDLE hPrinter, DWORD Level, LPBYTE pPrinter, ...@@ -1827,7 +1851,7 @@ static BOOL WINSPOOL_GetPrinter(HANDLE hPrinter, DWORD Level, LPBYTE pPrinter,
RegCloseKey(hkeyPrinter); RegCloseKey(hkeyPrinter);
RegCloseKey(hkeyPrinters); RegCloseKey(hkeyPrinters);
TRACE("returing %d needed = %ld\n", ret, needed); TRACE("returning %d needed = %ld\n", ret, needed);
if(pcbNeeded) *pcbNeeded = needed; if(pcbNeeded) *pcbNeeded = needed;
if(!ret) if(!ret)
SetLastError(ERROR_INSUFFICIENT_BUFFER); SetLastError(ERROR_INSUFFICIENT_BUFFER);
...@@ -2544,10 +2568,12 @@ BOOL WINAPI EnumJobsA(HANDLE hPrinter, DWORD FirstJob, DWORD NoJobs, ...@@ -2544,10 +2568,12 @@ BOOL WINAPI EnumJobsA(HANDLE hPrinter, DWORD FirstJob, DWORD NoJobs,
DWORD Level, LPBYTE pJob, DWORD cbBuf, LPDWORD pcbNeeded, DWORD Level, LPBYTE pJob, DWORD cbBuf, LPDWORD pcbNeeded,
LPDWORD pcReturned) LPDWORD pcReturned)
{ {
FIXME("stub\n"); FIXME("(%p,first=%ld,no=%ld,level=%ld,job=%p,cb=%ld,%p,%p), stub!\n",
hPrinter, FirstJob, NoJobs, Level, pJob, cbBuf, pcbNeeded, pcReturned
);
if(pcbNeeded) *pcbNeeded = 0; if(pcbNeeded) *pcbNeeded = 0;
if(pcReturned) *pcReturned = 0; if(pcReturned) *pcReturned = 0;
return TRUE; return FALSE;
} }
...@@ -2559,10 +2585,12 @@ BOOL WINAPI EnumJobsW(HANDLE hPrinter, DWORD FirstJob, DWORD NoJobs, ...@@ -2559,10 +2585,12 @@ BOOL WINAPI EnumJobsW(HANDLE hPrinter, DWORD FirstJob, DWORD NoJobs,
DWORD Level, LPBYTE pJob, DWORD cbBuf, LPDWORD pcbNeeded, DWORD Level, LPBYTE pJob, DWORD cbBuf, LPDWORD pcbNeeded,
LPDWORD pcReturned) LPDWORD pcReturned)
{ {
FIXME("stub\n"); FIXME("(%p,first=%ld,no=%ld,level=%ld,job=%p,cb=%ld,%p,%p), stub!\n",
hPrinter, FirstJob, NoJobs, Level, pJob, cbBuf, pcbNeeded, pcReturned
);
if(pcbNeeded) *pcbNeeded = 0; if(pcbNeeded) *pcbNeeded = 0;
if(pcReturned) *pcReturned = 0; if(pcReturned) *pcReturned = 0;
return TRUE; return FALSE;
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -56,8 +56,8 @@ ...@@ -56,8 +56,8 @@
/* Define if we have linux/input.h AND it contains the INPUT event API */ /* Define if we have linux/input.h AND it contains the INPUT event API */
#undef HAVE_CORRECT_LINUXINPUT_H #undef HAVE_CORRECT_LINUXINPUT_H
/* Define if we have CUPS */ /* Define to 1 if you have the <cups/cups.h> header file. */
#undef HAVE_CUPS #undef HAVE_CUPS_CUPS_H
/* Define to 1 if you have the <curses.h> header file. */ /* Define to 1 if you have the <curses.h> header file. */
#undef HAVE_CURSES_H #undef HAVE_CURSES_H
...@@ -686,6 +686,9 @@ ...@@ -686,6 +686,9 @@
/* The size of a `long long', as computed by sizeof. */ /* The size of a `long long', as computed by sizeof. */
#undef SIZEOF_LONG_LONG #undef SIZEOF_LONG_LONG
/* Define to the soname of the libcups library. */
#undef SONAME_LIBCUPS
/* Define to the soname of the libfreetype library. */ /* Define to the soname of the libfreetype library. */
#undef SONAME_LIBFREETYPE #undef SONAME_LIBFREETYPE
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment