# -*- coding: ascii; tab-width: 4 -*-
Package: endian-dev
Version: 20110604
Revision: 1
Type: nosource
Description: Linux-style endian.h header file
DescDetail: <<
	Some packages assume that all systems have a Linux-style
	endian.h header file defining the macros

	htobe16()
	htole16()
	be16toh()
	le16toh()
	htobe32()
	htole32()
	be32toh()
	le32toh()
	htobe64()
	htole64()
	be64toh()
	le64toh()

	Since Mac OS X doesn't have this, we create a endian.h
	that maps those macros to the OS X equivalents.
<<
DescUsage: <<
	To use, BuildDepend on %n and add -I%%p/lib/%n to CPPFLAGS.
<<
License: Public Domain
Maintainer: Daniel Johnson <daniel@daniel-johnson.org>

BuildDependsOnly: true

CompileScript: <<
	#!/bin/bash -ev
	cat >endian.h <<EOF
/*
  This is a simple compatibility shim to convert
  Linux endian macros to the Mac OS X equivalents.
  It is public domain.
*/

#include <libkern/OSByteOrder.h>

#define htobe16(x) OSSwapHostToBigInt16(x)
#define htole16(x) OSSwapHostToLittleInt16(x)
#define be16toh(x) OSSwapBigToHostInt16(x)
#define le16toh(x) OSSwapLittleToHostInt16(x)

#define htobe32(x) OSSwapHostToBigInt32(x)
#define htole32(x) OSSwapHostToLittleInt32(x)
#define be32toh(x) OSSwapBigToHostInt32(x)
#define le32toh(x) OSSwapLittleToHostInt32(x)

#define htobe64(x) OSSwapHostToBigInt64(x)
#define htole64(x) OSSwapHostToLittleInt64(x)
#define be64toh(x) OSSwapBigToHostInt64(x)
#define le64toh(x) OSSwapLittleToHostInt64(x)
EOF
<<

InstallScript: <<
	install -d %i/lib/%n
	install -m 0644 endian.h %i/lib/%n
<<