Add some skeletons for Makefile, init script and config file
authorFlorian Fainelli <florian@openwrt.org>
Sun, 16 Dec 2007 16:14:20 +0000 (16:14 +0000)
committerFlorian Fainelli <florian@openwrt.org>
Sun, 16 Dec 2007 16:14:20 +0000 (16:14 +0000)
SVN-Revision: 9780

skels/Makefile [new file with mode: 0644]
skels/files/package.conf [new file with mode: 0644]
skels/files/package.init [new file with mode: 0755]

diff --git a/skels/Makefile b/skels/Makefile
new file mode 100644 (file)
index 0000000..2676825
--- /dev/null
@@ -0,0 +1,81 @@
+# 
+# Copyright (C) 2007 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+# This Makefile is a skeleton
+#
+# $Id: $
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=
+PKG_VERSION:=
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=
+PKG_MD5SUM:=
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
+PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/package
+  SECTION:=net
+  CATEGORY:=Network
+  TITLE:=package
+  URL:=
+endef
+
+define Package/package/description
+endef
+
+CONFIGURE_ARGS += \
+       --enable-static \
+       --enable-shared
+
+# If you wish to link against uclibc++ consider using the
+# following variables :
+CONFIGURE_VARS += \
+       CXXFLAGS="$$$$CXXFLAGS -fno-builtin -fno-rtti -nostdinc++"  \
+       CPPFLAGS="$$$$CPPFLAGS -I$(STAGING_DIR)/usr/include/uClibc++ -I$(LINUX_DIR)/include" \
+       LDFLAGS="$$$$LDFLAGS" \
+       LIBS="-nodefaultlibs -luClibc++ -lm -lnotimpl" \
+
+MAKE_FLAGS += \
+       CFLAGS="$(TARGET_CFLAGS)"
+
+
+define Build/Compile
+       # pass CFLAGS again to override -O2 set by configure
+       $(MAKE) -C $(PKG_BUILD_DIR) \
+               CFLAGS="$(TARGET_CFLAGS)" \
+               DESTDIR="$(PKG_INSTALL_DIR)" \
+               all install
+endef
+
+
+define Build/InstallDev
+       mkdir -p $(1)/usr/include/
+       $(CP) $(PKG_INSTALL_DIR)/usr/include/*.h $(1)/usr/include/
+       mkdir -p $(1)/usr/package
+       $(CP) $(PKG_INSTALL_DIR)/usr/package/package.{a,so*} $(1)/usr/package/
+endef
+
+define Build/UninstallDev
+       rm -rf  $(1)/usr/include/package \
+               $(1)/usr/package/package.{a,so*}
+endef
+
+define Package/package/install
+       $(INSTALL_DIR) $(1)/usr/package
+       $(CP) $(PKG_INSTALL_DIR)/usr/package/package.so.* $(1)/usr/package/
+       $(INSTALL_DIR) $(1)/etc/init.d
+       $(INSTALL_BIN) ./files/package.init $(1)/etc/init.d/package
+       $(INSTALL_DIR) $(1)/etc/config/
+       $(INSTALL_CONF) $(1)/etc/config/package
+endef
+
+$(eval $(call BuildPackage,package))
diff --git a/skels/files/package.conf b/skels/files/package.conf
new file mode 100644 (file)
index 0000000..db3bc4d
--- /dev/null
@@ -0,0 +1,4 @@
+# Sample configuration file
+config package
+        option option1     'some default value'
+        option option2 ''
diff --git a/skels/files/package.init b/skels/files/package.init
new file mode 100755 (executable)
index 0000000..32179f9
--- /dev/null
@@ -0,0 +1,43 @@
+#!/bin/sh /etc/rc.common
+# Sample init script reading its
+# configuration from /etc/config/package
+START=46
+STOP=46
+
+start_service() {
+       local section="$1"
+       
+       include /lib/network
+       scan_interfaces
+       config_load /var/state/network
+
+       config_get LAN lan ifname
+       config_get option1 "$section" option1
+       config_get option2 "$section" option2
+
+       # Do some action with the variables
+       echo "option1 = $option1"
+}
+
+stop_service() {
+       local section="$1"
+       
+       include /lib/network
+       scan_interfaces
+       config_load /var/state/network
+
+       config_get LAN lan ifname
+       config_get option1 "$section" option1
+       config_get option2 "$section" option2
+}
+start() {
+       # Do some optionnal testing
+       # before starting the program
+       config_load "package"
+       config_foreach start_service package
+}
+
+stop () {
+       config_load "package"
+       config_foreach stop_service package
+}