Add libinklevel (#4335), thanks Raphael

git-svn-id: svn://svn.openwrt.org/openwrt/packages@13614 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
florian 2008-12-12 14:51:12 +00:00
parent e05f4ad1c0
commit d8232d1e79
3 changed files with 139 additions and 0 deletions

66
libs/libinklevel/Makefile Normal file
View File

@ -0,0 +1,66 @@
#
# Copyright (C) 2008 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
# $Id: Makefile 12228 2008-08-06 22:43:15Z nbd $
include $(TOPDIR)/rules.mk
PKG_NAME:=libinklevel
PKG_VERSION:=0.7.3
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=@SF/libinklevel
PKG_MD5SUM:=c7ccefec29d1d218d1aae240f6044fe1
include $(INCLUDE_DIR)/package.mk
define Package/libinklevel
SECTION:=libs
CATEGORY:=Libraries
DEPENDS:=$(if $(WITH_PARPORT), +libieee1284)
TITLE:=Printers Ink Level Library
URL:=http://libinklevel.sourceforge.net/
endef
define Package/libinklevel/description
Libinklevel is a library for checking the ink level of your printer on a system which runs Linux.
endef
TARGET_CFLAGS += $(FPIC)
TARGET_LIBS += $(if $(WITH_PARPORT), -lieee1284)
define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR) \
CC="$(TARGET_CC)" \
CFLAGS="$(TARGET_CFLAGS)" \
CPPFLAGS="$(TARGET_CPPFLAGS)" \
LDFLAGS="$(TARGET_LDFLAGS)" \
LIBS="$(TARGET_LIBS)" \
DESTDIR="$(PKG_INSTALL_DIR)" \
all install
endef
define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/include
$(INSTALL_DATA) \
$(PKG_INSTALL_DIR)/usr/include/inklevel.h \
$(1)/usr/include/
$(INSTALL_DIR) $(1)/usr/lib
$(CP) \
$(PKG_INSTALL_DIR)/usr/lib/libinklevel.so* \
$(1)/usr/lib/
endef
define Package/libinklevel/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) \
$(PKG_INSTALL_DIR)/usr/lib/libinklevel.so* \
$(1)/usr/lib/
endef
$(eval $(call BuildPackage,libinklevel))

View File

@ -0,0 +1,21 @@
--- libinklevel-0.7.3.orig/Makefile 2008-12-10 17:09:05.052017664 +0100
+++ libinklevel-0.7.3/Makefile 2008-12-10 19:40:44.904051107 +0100
@@ -1,7 +1,7 @@
-DESTDIR =
-PREFIX = /usr/local
-CFLAGS += -Wall -O2 -fPIC -DPIC -I.
-CC = gcc
+#DESTDIR =
+PREFIX = /usr
+#CFLAGS += -Wall -O2 -fPIC -DPIC -I.
+#CC = gcc
all: libinklevel.so.4.0.7.3
@@ -36,5 +36,5 @@ libinklevel.so.4.0.7.3: canon.o d4lib.o
linux.o util.o
$(CC) $(CFLAGS) -shared -Wl,-soname,libinklevel.so.4 \
-o libinklevel.so.4.0.7.3 canon.o d4lib.o epson_new.o \
- hp_new.o libinklevel.o linux.o util.o -lc -lieee1284
+ hp_new.o libinklevel.o linux.o util.o $(LIBS)

View File

@ -0,0 +1,52 @@
--- libinklevel-0.7.3.orig/linux.c 2008-12-10 17:09:05.052017664 +0100
+++ libinklevel-0.7.3/linux.c 2008-12-10 17:19:59.362144646 +0100
@@ -8,7 +8,9 @@
#include "inklevel.h"
+#ifdef WITH_PARPORT
#include <ieee1284.h>
+#endif
#include <stdio.h>
#include <sys/types.h>
@@ -30,7 +32,9 @@ int open_printer_device(const int port,
int get_device_id(const int port, const char *device_file,
const int portnumber, char *device_id) {
+#ifdef WITH_PARPORT
struct parport_list parports;
+#endif
char tmp[BUFLEN];
char device_file1[256];
char device_file2[256];
@@ -39,6 +43,7 @@ int get_device_id(const int port, const
char *c;
int realsize;
+#ifdef WITH_PARPORT
if (port == PARPORT ) {
/* check if we have appropiate permissions */
@@ -71,7 +76,9 @@ int get_device_id(const int port, const
return COULD_NOT_GET_DEVICE_ID;
- } else if (port == USB || port == CUSTOM_USB) {
+ } else
+#endif
+ if (port == USB || port == CUSTOM_USB) {
if (port == USB) {
sprintf(device_file1, "/dev/usb/lp%d", portnumber);
@@ -132,8 +139,10 @@ int open_printer_device(const int port,
if (port == USB) {
sprintf(device_file1, "/dev/usb/lp%d", portnumber);
sprintf(device_file2, "/dev/usblp%d", portnumber);
+#ifdef WITH_PARPORT
} else if (port == PARPORT) {
sprintf(device_file1, "/dev/lp%d", portnumber);
+#endif
} else if (port == CUSTOM_USB) {
strncpy(device_file1, device_file, 255);
device_file1[255] = '\0';