1.    在package/utils下创建privoxy_lib目录。在wifidog_lib目录下创建一个文件夹src和一个Makefile文件。Makefile文件编写内容如下:

#

# Copyright (C)2006,2013 OpenWrt.org

#

# This is freesoftware, licensed under the GNU General Public License v2.

# See /LICENSE formore information.

#

 

include$(TOPDIR)/rules.mk

 

PKG_NAME:=privoxy_lib

PKG_VERSION:=3.0.21

PKG_RELEASE:=1

 

 

PKG_LICENSE:=GPLv2

PKG_LICENSE_FILES:=LICENSE

 

PKG_BUILD_DIR :=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)-stable

 

include$(INCLUDE_DIR)/package.mk

 

definePackage/privoxy_lib

  SECTION:=utils

  CATEGORY:=Utilities

  DEPENDS:=+libpcre +libpthread +zlib

  TITLE:=web proxy with advanced filteringcapabilities

endef

 

definePackage/privoxy_lib/description

      Privoxy is a web proxy with advancedfiltering capabilities for

      protecting privacy, modifying web pagecontent, managing cookies,

      controlling access, and removing ads,banners, pop-ups and other

      obnoxious Internet junk. Privoxy has avery flexible configuration

      and can be customized to suit individualneeds and tastes. Privoxy

      has application for both stand-alonesystems and multi-user networks.

endef

 

defineBuild/Prepare

      mkdir -p $(PKG_BUILD_DIR)

      $(CP) ./src/* $(PKG_BUILD_DIR)/

endef

 

defineBuild/Configure

endef

 

defineBuild/Compile

      $(MAKE) -C $(PKG_BUILD_DIR) \

           CC="$(TARGET_CC)" \

           CFLAGS="$(TARGET_CFLAGS)-Wall" \

           LDFLAGS="$(TARGET_LDFLAGS)"

endef

     

definePackage/privoxy_lib/conffiles

/etc/privoxy/config

endef

 

definePackage/privoxy_lib/install

      $(INSTALL_DIR) $(1)/usr/bin

      $(INSTALL_BIN) $(PKG_BUILD_DIR)/test_libprivoxy$(1)/usr/bin/

      $(INSTALL_DIR) $(1)/usr/lib

      $(CP) $(PKG_BUILD_DIR)/libprivoxy.so*$(1)/usr/lib/

      $(INSTALL_DIR) $(1)/etc/privoxy

      $(CP) $(PKG_INSTALL_DIR)/etc/privoxy/*$(1)/etc/privoxy/

      $(INSTALL_CONF) ./files/privoxy.config$(1)/etc/privoxy/config

endef

 

$(eval $(callBuildPackage,privoxy_lib))

 

2.    解压privoxy包进入src目录

Tar xzvf privoxy-3.0.21-stable-src.tar.gz –C src

 

3.    在src下创建Makefile文件,内容如下:

LIB_VERMAJOR = 0

LIB_VERMINOR = 1

LIB_FILENAME =libprivoxy.so

 

OBJEXT = o

 

EXTRA_CFLAGS +=-pthread -MD -fPIC -DPIC 

 

LIB_CFLAGS  = $(CFLAGS) $(EXTRA_CFLAGS) -shared

LIB_LDFLAGS =$(LDFLAGS) -pthread -Wl,-soname,$(LIB_FILENAME).$(LIB_VERMAJOR).$(LIB_VERMINOR)

 

privoxy_OBJECTS =actions.$(OBJEXT) cgi.$(OBJEXT)\

      cgiedit.$(OBJEXT) cgisimple.$(OBJEXT) deanimate.$(OBJEXT)\

      encode.$(OBJEXT) errlog.$(OBJEXT)filters.$(OBJEXT) \

      gateway.$(OBJEXT) jbsockets.$(OBJEXT)jcc.$(OBJEXT) \

      list.$(OBJEXT) loadcfg.$(OBJEXT)loaders.$(OBJEXT) \

      miscutil.$(OBJEXT) parsers.$(OBJEXT)  \

      ssplit.$(OBJEXT) urlmatch.$(OBJEXT)pcrs.$(OBJEXT)\

      pcre/get.$(OBJEXT)pcre/maketables.$(OBJEXT) pcre/study.$(OBJEXT)\

      pcre/pcre.$(OBJEXT)pcre/pcreposix.$(OBJEXT) privoxyapi.$(OBJEXT)

 

LIB_OBJ =$(privoxy_OBJECTS)

 

DEFAULT_INCLUDES =-Ipcre

 

AM_CPPFLAGS +=

 

COMPILE = $(CC)$(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \

      $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)

 

CCLD = $(CC)

LINK = $(CCLD)$(AM_CFLAGS) $(CFLAGS) $(EXTRA_CFLAGS) $(AM_LDFLAGS) \

      $(LDFLAGS) -o $@

 

 

LIBS = -lnsl  -lz 

 

 

all: Makefile   libprivoxy  test_libprivoxy

 

test_libprivoxy:main.o libprivoxy

      @rm -f test_libprivoxy

      $(LINK) main.o $(LIB_FILENAME).$(LIB_VERMAJOR).$(LIB_VERMINOR)  $(LIBS)

 

 

libprivoxy:$(LIB_OBJ)

      $(CC) $(LIB_CFLAGS) $(LIB_LDFLAGS)  $(LIB_OBJ) $(LIBS) \

           -o $(LIB_FILENAME).$(LIB_VERMAJOR).$(LIB_VERMINOR)

 

.c.o:

    $(CC) $(DEFS) $(AM_CPPFLAGS)$(DEFAULT_INCLUDES) $(INCLUDES) $(CFLAGS)       $(EXTRA_CFLAGS)-c -o $@ $<

 

 

clean:

      rm -f $(LIB_FILENAME)* *.o

4. 修改src下对应的源代码,同时把files/privoxy.init脚本提供的功能通过lib库提供,这样 lib库需要提供intprivoxy_start (),int privoxy_stop ()。makepackage/privoxy_lib/compile  V=s进行编译生成libprivoxy.so.0.1和测试程序test_libprivoxy

 

10-08 04:45