#!/usr/bin/env bash # # Script for various external toolchain tasks, refer to # the --help output for more information. # # Copyright (C) 2012 Jo-Philipp Wich # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA CC="" CXX="" CPP="" CFLAGS="" TOOLCHAIN="." LIBC_TYPE="" # Library specs LIB_SPECS=" c: ld-* lib{anl,c,cidn,crypt,dl,m,nsl,nss_dns,nss_files,resolv,util} rt: librt-* librt pthread: libpthread-* libpthread stdcpp: libstdc++ gcc: libgcc_s ssp: libssp gfortran: libgfortran " # Binary specs BIN_SPECS=" ldd: ldd ldconfig: ldconfig gdb: gdb gdbserver: gdbserver " test_c() { cat <<-EOT | "${CC:-false}" $CFLAGS -o /dev/null -x c - 2>/dev/null #include int main(int argc, char **argv) { printf("Hello, world!\n"); return 0; } EOT } test_cxx() { cat <<-EOT | "${CXX:-false}" $CFLAGS -o /dev/null -x c++ - 2>/dev/null #include using namespace std; int main() { cout << "Hello, world!" << endl; return 0; } EOT } test_softfloat() { cat <<-EOT | "$CC" $CFLAGS -msoft-float -o /dev/null -x c - 2>/dev/null int main(int argc, char **argv) { double a = 0.1; double b = 0.2; double c = (a + b) / (a * b); return 1; } EOT } test_uclibc() { local sysroot="$("$CC" $CFLAGS -print-sysroot 2>/dev/null)" if [ -d "${sysroot:-$TOOLCHAIN}" ]; then local lib for lib in "${sysroot:-$TOOLCHAIN}"/{lib,usr/lib,usr/local/lib}/ld-uClibc*.so*; do if [ -f "$lib" ] && [ ! -h "$lib" ]; then return 0 fi done fi return 1 } test_feature() { local feature="$1"; shift # find compilers, libc type probe_cc probe_cxx probe_libc # common toolchain feature tests case "$feature" in c) test_c; return $? ;; c++) test_cxx; return $? ;; soft*) test_softfloat; return $? ;; esac # assume eglibc/glibc supports all libc features if [ "$LIBC_TYPE" != "uclibc" ]; then return 0 fi # uclibc feature tests local inc local sysroot="$("$CC" "$@" -muclibc -print-sysroot 2>/dev/null)" for inc in "include" "usr/include" "usr/local/include"; do local conf="${sysroot:-$TOOLCHAIN}/$inc/bits/uClibc_config.h" if [ -f "$conf" ]; then case "$feature" in lfs) grep -q '__UCLIBC_HAS_LFS__ 1' "$conf"; return $?;; ipv6) grep -q '__UCLIBC_HAS_IPV6__ 1' "$conf"; return $?;; rpc) grep -q '__UCLIBC_HAS_RPC__ 1' "$conf"; return $?;; locale) grep -q '__UCLIBC_HAS_LOCALE__ 1' "$conf"; return $?;; wchar) grep -q '__UCLIBC_HAS_WCHAR__ 1' "$conf"; return $?;; threads) grep -q '__UCLIBC_HAS_THREADS__ 1' "$conf"; return $?;; esac fi done return 1 } find_libs() { local spec="$(echo "$LIB_SPECS" | sed -ne "s#^[[:space:]]*$1:##ip")" if [ -n "$spec" ] && probe_cpp; then local libdir libdirs for libdir in $( "$CPP" $CFLAGS -v -x c /dev/null 2>&1 | \ sed -ne 's#:# #g; s#^LIBRARY_PATH=##p' ); do if [ -d "$libdir" ]; then libdirs="$libdirs $(cd "$libdir"; pwd)/" fi done local pattern for pattern in $(eval echo $spec); do find $libdirs -name "$pattern.so*" | sort -u done return 0 fi return 1 } find_bins() { local spec="$(echo "$BIN_SPECS" | sed -ne "s#^[[:space:]]*$1:##ip")" if [ -n "$spec" ] && probe_cpp; then local sysroot="$("$CPP" -print-sysroot)" local bindir bindirs for bindir in $( echo "${sysroot:-$TOOLCHAIN}/bin"; echo "${sysroot:-$TOOLCHAIN}/usr/bin"; echo "${sysroot:-$TOOLCHAIN}/usr/local/bin"; "$CPP" $CFLAGS -v -x c /dev/null 2>&1 | \ sed -ne 's#:# #g; s#^COMPILER_PATH=##p' ); do if [ -d "$bindir" ]; then bindirs="$bindirs $(cd "$bindir"; pwd)/" fi done local pattern for pattern in $(eval echo $spec); do find $bindirs -name "$pattern" | sort -u done return 0 fi return 1 } wrap_bin_cc() { local out="$1" local bin="$2" echo '#!/bin/sh' > "$out" echo 'for arg in "$@"; do' >> "$out" echo ' case "$arg" in -l*|-L*|-shared|-static)' >> "$out" echo -n ' exec "'"$bin"'" '"$CFLAGS"' ${STAGING_DIR:+' >> "$out" echo -n '-idirafter "$STAGING_DIR/usr/include" ' >> "$out" echo -n '-L "$STAGING_DIR/usr/lib" ' >> "$out" echo '-Wl,-rpath-link,"$STAGING_DIR/usr/lib"} "$@" ;;' >> "$out" echo ' esac' >> "$out" echo 'done' >> "$out" echo -n 'exec "'"$bin"'" '"$CFLAGS"' ${STAGING_DIR:+' >> "$out" echo '-idirafter "$STAGING_DIR/usr/include"} "$@"' >> "$out" chmod +x "$out" } wrap_bin_ld() { local out="$1" local bin="$2" echo '#!/bin/sh' > "$out" echo -n 'exec "'"$bin"'" ${STAGING_DIR:+' >> "$out" echo -n '-L "$STAGING_DIR/usr/lib" ' >> "$out" echo '-rpath-link "$STAGING_DIR/usr/lib"} "$@"' >> "$out" chmod +x "$out" } wrap_bin_other() { local out="$1" local bin="$2" echo '#!/bin/sh' > "$out" echo 'exec "'"$bin"'" "$@"' >> "$out" chmod +x "$out" } wrap_bins() { if probe_cc; then mkdir -p "$1" || return 1 local cmd for cmd in "${CC%-*}-"*; do if [ -x "$cmd" ]; then local out="$1/${cmd##*/}" local bin="$cmd" if [ -x "$out" ] && ! grep -q STAGING_DIR "$out"; then mv "$out" "$out.bin" bin='$(dirname "$0")/'"${out##*/}"'.bin' fi case "${cmd##*/}" in *-*cc|*-*cc-*|*-*++|*-*++-*|*-cpp) wrap_bin_cc "$out" "$bin" ;; *-ld) wrap_bin_ld "$out" "$bin" ;; *) wrap_bin_other "$out" "$bin" ;; esac fi done return 0 fi return 1 } print_config() { local mktarget="$1" local mksubtarget local target="$("$CC" $CFLAGS -dumpmachine)" local cpu
# 
# Copyright (C) 2006 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
# $Id$

include $(TOPDIR)/rules.mk

PKG_NAME:=linux-atm
PKG_VERSION:=2.4.1
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION).orig.tar.gz
PKG_SOURCE_URL:=http://ftp.debian.org/debian/pool/main/l/linux-atm/
PKG_MD5SUM:=84fef49cc39ff2605204246666f65864
PKG_CAT:=zcat

PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install

include $(INCLUDE_DIR)/package.mk

define Package/linux-atm/Default
  URL:=http://linux-atm.sourceforge.net/
endef

define Package/linux-atm
  $(call Package/linux-atm/Default)
  SECTION:=libs
  CATEGORY:=Libraries
  TITLE:=Linux ATM Library
  DESCRIPTION:=\
	This package contains a library for accessing the Linux ATM subsystem.
endef

define Package/br2684ctl
  $(call Package/linux-atm/Default)
  SECTION:=net
  CATEGORY:=Network
  DEPENDS:=+linux-atm
  TITLE:=RFC2684 bridging utility
  DESCRIPTION:=\
	This package contains an ATM RFC2684 bridging utility.
endef

define Build/Configure
	$(call Build/Configure/Default)
	# prevent autoheader invocation
	touch $(PKG_BUILD_DIR)/stamp-h.in
endef

define Build/Compile
	$(call Build/Compile/Default, \
		DESTDIR="$(PKG_INSTALL_DIR)" \
		all install \
	)
endef

define Build/InstallDev
	mkdir -p $(STAGING_DIR)/usr/include
	$(CP)	$(PKG_INSTALL_DIR)/usr/include/atm{,d,sap}.h \
		$(STAGING_DIR)/usr/include/
	mkdir -p $(STAGING_DIR)/usr/lib
	$(CP)	$(PKG_INSTALL_DIR)/usr/lib/libatm.{a,so*} \
		$(STAGING_DIR)/usr/lib/
endef

define Build/UninstallDev
	rm -rf	$(STAGING_DIR)/usr/include/atm{,d,sap}.h \
		$(STAGING_DIR)/usr/lib/libatm.{a,so*}
endef

define Package/linux-atm/install
	install -d -m0755 $(1)/usr/lib
	cp -f $(PKG_INSTALL_DIR)/usr/lib/libatm.so.1 $(1)/usr/lib
endef

define Package/br2684ctl/install
	install -d -m0755 $(1)/usr/sbin
	$(CP) $(PKG_INSTALL_DIR)/usr/sbin/br2684ctl $(1)/usr/sbin/
	install -d -m0755 $(1)/etc/hotplug.d/net
	install -m0644 ./files/br2684.hotplug $(1)/etc/hotplug.d/net/30-br2684
endef

$(eval $(call BuildPackage,linux-atm))
$(eval $(call BuildPackage,br2684ctl))