From 5da9c9ebcaa8d2c8c42a7ff8287950dccd42aed2 Mon Sep 17 00:00:00 2001
From: nico <nico@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Date: Wed, 10 Aug 2005 21:01:34 +0000
Subject: [PATCH] Add cgilib package

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@1600 3c298f89-4303-0410-b956-a3cf2f4a3e73
---
 openwrt/package/Config.in                     |  1 +
 openwrt/package/Makefile                      |  1 +
 openwrt/package/cgilib/Config.in              | 12 +++++
 openwrt/package/cgilib/Makefile               | 51 +++++++++++++++++++
 openwrt/package/cgilib/ipkg/cgilib.control    |  9 ++++
 .../cgilib/patches/100-shared_lib.patch       | 41 +++++++++++++++
 .../cgilib/patches/200-cgitest_bugfix.patch   | 11 ++++
 7 files changed, 126 insertions(+)
 create mode 100644 openwrt/package/cgilib/Config.in
 create mode 100644 openwrt/package/cgilib/Makefile
 create mode 100644 openwrt/package/cgilib/ipkg/cgilib.control
 create mode 100644 openwrt/package/cgilib/patches/100-shared_lib.patch
 create mode 100644 openwrt/package/cgilib/patches/200-cgitest_bugfix.patch

diff --git a/openwrt/package/Config.in b/openwrt/package/Config.in
index 2476c4dd8..e562df838 100644
--- a/openwrt/package/Config.in
+++ b/openwrt/package/Config.in
@@ -103,6 +103,7 @@ source "package/xinetd/Config.in"
 source "package/wificonf/Config.in"
 
 comment "Libraries"
+source "package/cgilib/Config.in"
 source "package/glib/Config.in"
 source "package/libamsel/Config.in"
 source "package/libdb/Config.in"
diff --git a/openwrt/package/Makefile b/openwrt/package/Makefile
index fe6551c65..008b4bf55 100644
--- a/openwrt/package/Makefile
+++ b/openwrt/package/Makefile
@@ -15,6 +15,7 @@ package-$(BR2_PACKAGE_BLUEZ_UTILS) += bluez-utils
 package-$(BR2_PACKAGE_BRIDGE) += bridge
 package-$(BR2_PACKAGE_BUSYBOX) += busybox
 package-$(BR2_PACKAGE_BWM) += bwm
+package-$(BR2_PACKAGE_CGILIB) += cgilib
 package-$(BR2_PACKAGE_CHILLISPOT) += chillispot
 package-$(BR2_PACKAGE_CIFSMOUNT) += cifsmount
 package-$(BR2_PACKAGE_CUPS) += cups
diff --git a/openwrt/package/cgilib/Config.in b/openwrt/package/cgilib/Config.in
new file mode 100644
index 000000000..ac5088451
--- /dev/null
+++ b/openwrt/package/cgilib/Config.in
@@ -0,0 +1,12 @@
+config BR2_PACKAGE_CGILIB
+	tristate "cgilib - Simple CGI Library"
+#	default m if CONFIG_DEVEL
+	default n
+	help
+	  This library provides a simple programming API to the Common Gateway
+	  Interface (CGI).  It features HTTP Redirect, provides read access to
+	  FORM variables, sets HTTP Cookies and reads them.
+	  
+	  http://www.infodrom.org/projects/cgilib/
+	  
+
diff --git a/openwrt/package/cgilib/Makefile b/openwrt/package/cgilib/Makefile
new file mode 100644
index 000000000..3e17975c1
--- /dev/null
+++ b/openwrt/package/cgilib/Makefile
@@ -0,0 +1,51 @@
+# $Id$
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=cgilib
+PKG_VERSION:=0.5
+PKG_RELEASE:=1
+PKG_MD5SUM:=5187ba11b2ec165b6c5b6629087733b0
+
+PKG_SOURCE_URL:=http://www.infodrom.org/projects/cgilib/download
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_CAT:=zcat
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
+
+include $(TOPDIR)/package/rules.mk
+
+$(eval $(call PKG_template,CGILIB,cgilib,$(PKG_VERSION)-$(PKG_RELEASE),$(ARCH)))
+
+$(PKG_BUILD_DIR)/.configured:
+	touch $@
+
+$(PKG_BUILD_DIR)/.built:
+	$(MAKE) -C $(PKG_BUILD_DIR) \
+		$(TARGET_CONFIGURE_OPTS) \
+		OFLAGS="$(TARGET_CFLAGS)" \
+		all
+	touch $@
+
+$(IPKG_CGILIB):
+	install -d -m0755 $(IDIR_CGILIB)/usr/lib
+	cp -fpR $(PKG_BUILD_DIR)/libcgi.so.* $(IDIR_CGILIB)/usr/lib/
+	$(RSTRIP) $(IDIR_CGILIB)
+	$(IPKG_BUILD) $(IDIR_CGILIB) $(PACKAGE_DIR)
+
+$(STAGING_DIR)/usr/lib/libcgi.so: $(PKG_BUILD_DIR)/.built
+	mkdir -p $(STAGING_DIR)/usr/include
+	cp -fpR $(PKG_BUILD_DIR)/cgi.h $(STAGING_DIR)/usr/include/
+	mkdir -p $(STAGING_DIR)/usr/lib
+	cp -fpR $(PKG_BUILD_DIR)/libcgi.{a,so*} $(STAGING_DIR)/usr/lib/
+	touch $@
+
+install-dev: $(STAGING_DIR)/usr/lib/libcgi.so
+
+uninstall-dev:
+	rm -rf \
+	  $(STAGING_DIR)/usr/include/cgi.h \
+	  $(STAGING_DIR)/usr/lib/libcgi.{a,so*} \
+
+compile: install-dev
+clean: uninstall-dev
diff --git a/openwrt/package/cgilib/ipkg/cgilib.control b/openwrt/package/cgilib/ipkg/cgilib.control
new file mode 100644
index 000000000..a42b356c5
--- /dev/null
+++ b/openwrt/package/cgilib/ipkg/cgilib.control
@@ -0,0 +1,9 @@
+Package: cgilib
+Priority: optional
+Section: libs
+Maintainer: Oliver Ertl <oliver@ertl-net.net>, OpenWrt Developers <bugs@openwrt.org>
+Source: http://openwrt.org/cgi-bin/viewcvs.cgi/openwrt/package/cgilib/
+Description: Simple CGI Library. 
+ This library provides a simple programming API to the Common Gateway
+ Interface (CGI).  It features HTTP Redirect, provides read access to
+ FORM variables, sets HTTP Cookies and reads them.
diff --git a/openwrt/package/cgilib/patches/100-shared_lib.patch b/openwrt/package/cgilib/patches/100-shared_lib.patch
new file mode 100644
index 000000000..5603340f9
--- /dev/null
+++ b/openwrt/package/cgilib/patches/100-shared_lib.patch
@@ -0,0 +1,41 @@
+diff -ruN cgilib-0.5-orig/Makefile cgilib-0.5-1/Makefile
+--- cgilib-0.5-orig/Makefile	1999-08-20 23:14:07.000000000 +0200
++++ cgilib-0.5-1/Makefile	2005-08-10 20:28:17.000000000 +0200
+@@ -14,14 +14,26 @@
+ #   along with this program; if not, write to the Free Software
+ #   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+ 
+-CFLAGS = -I. -Wall -O2 -g
++OFLAGS = -O2 -g
++CFLAGS = -I. -Wall $(OFLAGS)
+ LDFLAGS = -L.
+ LIBS = -lcgi
+ 
++SOVER_MAJ := 0
++SOVER_MIN := 0
++SOVER_REV := 0
++SONAME := libcgi.so.$(SOVER_MAJ)
++SOREAL := libcgi.so.$(SOVER_MAJ).$(SOVER_MIN).$(SOVER_REV)
++
+ OBJS = cgi.o cookies.o
+ 
+ libcgi.a: $(OBJS)
+-	ar rc $@ $^
++	$(AR) rc $@ $^
++
++libcgi.so: $(OBJS)
++	$(CC) -shared -o $(SOREAL) $(LDFLAGS) -Wl,-soname,$(SONAME) $^
++	ln -sf $(SOREAL) $(SONAME)
++	ln -sf $(SONAME) libcgi.so
+ 
+ cgitest: cgitest.o libcgi.a
+ 	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
+@@ -29,7 +41,7 @@
+ jumpto: jumpto.o libcgi.a
+ 	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
+ 
+-all: libcgi.a cgitest jumpto
++all: libcgi.a libcgi.so cgitest jumpto
+ 
+ install: cgitest
+ 	install -m 755 cgitest /usr/lib/cgi-bin
diff --git a/openwrt/package/cgilib/patches/200-cgitest_bugfix.patch b/openwrt/package/cgilib/patches/200-cgitest_bugfix.patch
new file mode 100644
index 000000000..62a68e739
--- /dev/null
+++ b/openwrt/package/cgilib/patches/200-cgitest_bugfix.patch
@@ -0,0 +1,11 @@
+--- cgilib-0.5/cgitest.c.orig	1999-08-17 15:21:20.000000000 +0200
++++ cgilib-0.5/cgitest.c	2005-08-10 20:49:01.000000000 +0200
+@@ -113,7 +113,7 @@
+             cgiHeader();
+ 	    printf ("<html>\n<head><title>cgilib</title></title>\n\n<body bgcolor=\"#ffffff\">\n");
+ 	    printf ("<h1><a href=\"%s\">cgilib</a></h1>\n", URL);
+-	    printf ("<h3>Cookie "Library" set</h3>\n");
++	    printf ("<h3>Cookie \"Library\" set</h3>\n");
+ 	    printf ("<p><br><p><br><a href=\"/cgi-bin/cgitest\">Test</a><p>\n");
+ 	    printf ("<p><br><p><br><a href=\"/cgi-bin/cgitest/redirect\">Redirect</a><p>\n");
+ 	    printf ("<p><br><p><br><a href=\"/cgi-bin/cgitest/listall\">List Everything</a><p>\n");
-- 
2.20.1