root/trunk/wifidog/ipkg/rules @ 472

Revision 472, 4.5 KB (checked in by minaguib, 8 years ago)

Documentation & URL updating

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1#!/usr/bin/make -f
2
3ifndef BUILDROOT
4        ERR := $(error Please set BUILDROOT to OpenWRT's buildroot)
5endif
6
7ARCH:=mipsel
8
9WIFIDOG_MAJOR_VERSION := $(shell awk -F= '$$1 == "WIFIDOG_MAJOR_VERSION" {print $$2}' configure.in)
10WIFIDOG_MINOR_VERSION := $(shell awk -F= '$$1 == "WIFIDOG_MINOR_VERSION" {print $$2}' configure.in)
11WIFIDOG_MICRO_VERSION := $(shell awk -F= '$$1 == "WIFIDOG_MICRO_VERSION" {print $$2}' configure.in)
12VERSION=$(WIFIDOG_MAJOR_VERSION).$(WIFIDOG_MINOR_VERSION).$(WIFIDOG_MICRO_VERSION)
13
14BUILD_DIR:=$(CURDIR)/ipkg
15TMP_DIR:=$(BUILD_DIR)/tmp
16STAGING_DIR=$(BUILDROOT)/build_$(ARCH)/staging_dir
17IPKG_DIR := $(wildcard $(BUILDROOT)/build_$(ARCH)/ipkg-utils-*/)
18IPTABLES_DIR := $(wildcard $(BUILDROOT)/build_$(ARCH)/iptables-*/)
19KERNEL_VERSION := $(shell awk '$$1 == "\#define" && $$2 == "UTS_RELEASE" {gsub(/["]/, "", $$3); print $$3}' $(BUILDROOT)/build_$(ARCH)/WRT54GS/release/src/linux/linux/include/linux/version.h)
20KERNEL_MODULES_DIR := $(BUILDROOT)/build_$(ARCH)/WRT54GS/release/src/linux/linux/modules/lib/modules/$(KERNEL_VERSION)
21UCLIBC_DIR := $(wildcard $(BUILDROOT)/build_$(ARCH)/uClibc*/)
22
23GNU_TARGET_NAME=$(ARCH)-linux
24TARGET_CROSS=$(STAGING_DIR)/bin/$(ARCH)-linux-uclibc-
25
26CC=$(TARGET_CROSS)gcc
27LD=$(TARGET_CROSS)ld
28AR=$(TARGET_CROSS)ar
29RANLIB=$(TARGET_CROSS)ranlib
30STRIP=$(TARGET_CROSS)strip
31IPKG_BUILD=$(STAGING_DIR)/bin/ipkg-build
32
33all: binary
34
35build: build-wifidog build-iptables build-ipkg-utils
36
37build-wifidog: build-wifidog-stamp
38build-wifidog-stamp:
39        ./autogen.sh
40        -$(MAKE) distclean
41        CC=$(CC) LD=$(LD) AR=$(AR) RANLIB=$(RANLIB) ./configure --prefix=/usr  --host=$(ARCH) --target=$(ARCH)
42        $(MAKE)
43
44        touch build-wifidog-stamp
45
46build-ipkg-utils: build-ipkg-utils-stamp
47build-ipkg-utils-stamp:
48        $(MAKE) -C $(BUILDROOT) ipkg-utils
49        touch build-ipkg-utils-stamp
50
51build-iptables: build-iptables-stamp
52build-iptables-stamp:
53        sed "s/PF_EXT_SLIB:=icmp/PF_EXT_SLIB:=mac icmp/" $(IPTABLES_DIR)/extensions/Makefile > $(IPTABLES_DIR)/extensions/Makefile.patched
54        mv -f $(IPTABLES_DIR)/extensions/Makefile.patched $(IPTABLES_DIR)/extensions/Makefile
55        CC=$(CC) LD=$(LD) AR=$(AR) RANLIB=$(RANLIB) $(MAKE) -C $(IPTABLES_DIR) KERNEL_DIR=../../linux/linux/
56
57        touch build-iptables-stamp
58         
59clean:
60        -$(MAKE) clean
61        -$(MAKE) distclean
62        $(MAKE) -C $(IPTABLES_DIR) clean
63        rm -rf $(TMP_DIR)
64        rm -f build-wifidog-stamp
65        rm -f build-iptables-stamp
66        rm -f build-ipkg-utils-stamp
67
68install: build install-wifidog install-iptables install-kernel-modules install-pthread
69        mkdir -p $(TMP_DIR)/etc
70        cp $(CURDIR)/wifidog.conf $(TMP_DIR)/etc
71        mkdir -p $(TMP_DIR)/usr/bin
72        #OpenWrt doesn't have a full init.d architecture, but we still need the module check so we install the normal init.d script in /usr/bin/wifidog-init
73        cp $(CURDIR)/scripts/init.d/wifidog $(TMP_DIR)/usr/bin/wifidog-init
74        chmod +x $(TMP_DIR)/usr/bin/wifidog-init
75        #And call wifidog-init from S65wifidog
76        mkdir -p $(TMP_DIR)/etc/init.d
77        cp $(CURDIR)/scripts/openwrt/S65wifidog $(TMP_DIR)/etc/init.d
78        chmod +x $(TMP_DIR)/etc/init.d/S65wifidog
79
80install-wifidog:
81        mkdir -p $(TMP_DIR)/usr/bin
82        cp $(CURDIR)/src/wifidog $(TMP_DIR)/usr/bin
83        cp $(CURDIR)/src/wdctl $(TMP_DIR)/usr/bin
84        $(STRIP) $(TMP_DIR)/usr/bin/wifidog
85        $(STRIP) $(TMP_DIR)/usr/bin/wdctl
86
87install-iptables:
88        mkdir -p $(TMP_DIR)/usr/lib/iptables
89        cp $(IPTABLES_DIR)/extensions/libipt_{mac,mark,MARK}.so $(TMP_DIR)/usr/lib/iptables
90
91install-kernel-modules:
92        mkdir -p $(TMP_DIR)/lib/modules/$(KERNEL_VERSION)/kernel/net/ipv4/netfilter
93        cp $(KERNEL_MODULES_DIR)/kernel/net/ipv4/netfilter/ipt_mac.o $(TMP_DIR)/lib/modules/$(KERNEL_VERSION)/kernel/net/ipv4/netfilter
94
95install-pthread:
96        mkdir -p $(TMP_DIR)/lib
97        cp $(UCLIBC_DIR)/lib/libpthread*so $(TMP_DIR)/lib
98        cp $(UCLIBC_DIR)/lib/libpthread*so.0 $(TMP_DIR)/lib
99
100binary: build install
101        mkdir -p $(TMP_DIR)/CONTROL
102        echo "Package: wifidog" > $(TMP_DIR)/CONTROL/control
103        echo "Version: $(VERSION)" >> $(TMP_DIR)/CONTROL/control
104        echo "Architecture: $(ARCH)" >> $(TMP_DIR)/CONTROL/control
105        echo "Section: base" >> $(TMP_DIR)/CONTROL/control
106        echo "Maintainer: WiFiDog <wifidog@listes.ilesansfil.org>" >> $(TMP_DIR)/CONTROL/control
107        echo "Priority: optional" >> $(TMP_DIR)/CONTROL/control
108        echo "Description: The WiFiDog project is a complete and embeedable captive portal solution for wireless community groups or individuals who wish to open a free HotSpot while still preventing abuse of their Internet connection." >> $(TMP_DIR)/CONTROL/control
109        echo "Source: http://www.ilesansfil.org/wiki/WiFiDog" >> $(TMP_DIR)/CONTROL/control
110        echo "/etc/wifidog.conf" > $(TMP_DIR)/CONTROL/conffiles
111        $(IPKG_BUILD) -c -o root -g root $(TMP_DIR) $(CURDIR)
112
113.PHONY: all clean build install binary
114
Note: See TracBrowser for help on using the browser.