Project import
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..842db03
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,109 @@
+#
+#    Copyright (c) 2010-2011 Nest, Inc.
+#    All rights reserved.
+#
+#    This document is the property of Nest. It is considered
+#    confidential and proprietary information.
+#
+#    This document may not be reproduced or transmitted in any form,
+#    in whole or in part, without the express written permission of
+#    Nest.
+#
+#    Description:
+#      This file is the make file for beep, a basic application that
+#      allows for driving a Linux input subsystem-compatible speaker or
+#      piezo by specifying pitch, duration and repetitions.
+#
+
+
+include pre.mak
+
+PackageName		:= beep
+
+PackageExtension	:= tar.gz
+PackageSeparator	:= -
+
+PackagePatchArgs	:=
+
+PackageArchive		:= $(PackageName).$(PackageExtension)
+PackageSourceDir	:= $(PackageName)$(PackageSeparator)$(PackageVersion)
+
+PackageBuildMakefile	= $(call GenerateBuildPaths,Makefile)
+
+LicenseSourceFile	:= $(PackageSourceDir)/COPYING
+
+CleanPaths		+= $(PackageLicenseFile)
+
+LinuxHeaderDir		:= $(call GenerateResultPaths,sw/tps/linux,include)
+
+SOURCEDIRS                      = $(PackageSourceDir)
+$(PackageSourceDir)_RULE_TARGET = $(BuildDirectory)/configure
+
+all: $(PackageDefaultGoal)
+
+# Generate the package license contents.
+
+$(LicenseSourceFile): $(BuildDirectory)/source
+
+$(PackageLicenseFile): $(LicenseSourceFile)
+	$(copy-result)
+
+# Extract the source from the archive and apply patches, if any.
+
+$(PackageSourceDir): $(PackageArchive) $(PackagePatchPaths)
+	$(expand-and-patch-package)
+
+# Prepare the sources.
+
+$(BuildDirectory)/source: | $(PackageSourceDir)
+	$(Verbose)touch $@
+
+# Patch the sources, if necessary.
+
+$(BuildDirectory)/patch: $(BuildDirectory)/source
+	$(Verbose)touch $@
+
+# Generate the package build makefile.
+
+$(PackageBuildMakefile): | $(PackageSourceDir) $(BuildDirectory)
+	$(call create-links,$(CURDIR)/$(PackageSourceDir),$(BuildDirectory))
+
+# Configure the source for building.
+
+$(BuildDirectory)/configure: $(BuildDirectory)/source $(PackageBuildMakefile)
+	$(Verbose)touch $@
+
+# Build the source.
+#
+# We have to unset MAKEFLAGS since they confuse the package build otherwise.
+
+$(BuildDirectory)/build: $(BuildDirectory)/configure | $(BuildDirectory)
+	$(Verbose)unset MAKEFLAGS && \
+	$(MAKE) $(JOBSFLAG) -C $(BuildDirectory) \
+	INSTALL="$(INSTALL) $(INSTALLFLAGS)" \
+	CC="$(CC)" CXX="$(CXX)" AR=$(AR) NM=$(NM) RANLIB=$(RANLIB) STRIP=$(STRIP) \
+	CFLAGS="-I$(LinuxHeaderDir)" \
+	default
+	$(Verbose)touch $@
+
+# Stage the build to a temporary installation area.
+#
+# We have to unset MAKEFLAGS since they confuse the package build otherwise.
+
+$(BuildDirectory)/stage: $(BuildDirectory)/build | $(ResultDirectory)
+	$(Verbose)unset MAKEFLAGS && \
+	$(MAKE) $(JOBSFLAG) -C $(BuildDirectory) \
+	INSTALL="$(INSTALL) $(INSTALLFLAGS)" \
+	INSTALL_PREFIX=$(ResultDirectory) \
+	install
+	$(Verbose)touch $@
+
+.PHONY: stage
+stage: $(BuildDirectory)/stage
+
+clean:
+	$(Verbose)$(RM) $(RMFLAGS) -r $(PackageSourceDir)
+	$(Verbose)$(RM) $(RMFLAGS) -r $(BuildDirectory)
+	$(Verbose)$(RM) $(RMFLAGS) -r $(ResultDirectory)
+
+include post.mak
diff --git a/beep.patches/beep-50.description b/beep.patches/beep-50.description
new file mode 100644
index 0000000..74c828f
--- /dev/null
+++ b/beep.patches/beep-50.description
@@ -0,0 +1 @@
+This patch allows beep to be compiled against a different set of Linux headers outside of the normal tool chain by supporting CFLAGS and also allows beep to be installed in a non-root location.
diff --git a/beep.patches/beep-50.patch b/beep.patches/beep-50.patch
new file mode 100644
index 0000000..229bbb6
--- /dev/null
+++ b/beep.patches/beep-50.patch
@@ -0,0 +1,33 @@
+diff -aruN a/Makefile b/Makefile
+--- a/Makefile	2010-08-03 06:57:27.000000000 -0700
++++ b/Makefile	2010-11-04 08:16:03.930197265 -0700
+@@ -1,19 +1,22 @@
+ CC=gcc
+-FLAGS=-Wall
++FLAGS=-Wall ${CFLAGS}
+ EXEC_NAME=beep
+-INSTALL_DIR=/usr/bin
++INSTALL_PREFIX=
++BIN_DIR=${INSTALL_PREFIX}/usr/bin
+ MAN_FILE=beep.1.gz
+-MAN_DIR=/usr/man/man1
++MAN_DIR=${INSTALL_PREFIX}/usr/man/man1
+ 
+-default : beep
++default : ${EXEC_NAME}
+ 
+ clean : 
+ 	rm ${EXEC_NAME}
+ 
+-beep : beep.c
++${EXEC_NAME} : beep.c
+ 	${CC} ${FLAGS} -o ${EXEC_NAME} beep.c
+ 
+-install : 
+-	cp ${EXEC_NAME} ${INSTALL_DIR}
++install :
++	-mkdir -p ${BIN_DIR}
++	cp ${EXEC_NAME} ${BIN_DIR}
+ 	# rm -f /usr/man/man1/beep.1.bz2
++	-mkdir -p ${MAN_DIR}
+ 	cp ${MAN_FILE} ${MAN_DIR}
diff --git a/beep.patches/beep-51.description b/beep.patches/beep-51.description
new file mode 100644
index 0000000..ce84b8f
--- /dev/null
+++ b/beep.patches/beep-51.description
@@ -0,0 +1,6 @@
+This patch replaces CLOCK_TICK_RATE with PIT_TICK_RATE, in name only. 
+The use of PIT_TICK_RATE is historic with the KIOCSOUND and KDMKTONE 
+ioctls; howwever, it used to be the platform-dependent CLOCK_TICK_RATE 
+between kernel version 2.6.12 and 2.6.36, which was a minor but 
+unfortunate ABI change that ended up polluting, at least in name, beep 
+as well.
diff --git a/beep.patches/beep-51.patch b/beep.patches/beep-51.patch
new file mode 100644
index 0000000..d7731d8
--- /dev/null
+++ b/beep.patches/beep-51.patch
@@ -0,0 +1,23 @@
+diff -aruN a/beep.c b/beep.c
+--- a/beep.c	2010-08-03 06:57:27.000000000 -0700
++++ b/beep.c	2010-11-09 17:17:01.000000000 -0800
+@@ -44,8 +44,8 @@
+    resets the counter to the original value, and starts over. The end
+    result of this is a tone at approximately the desired frequency. :)
+ */
+-#ifndef CLOCK_TICK_RATE
+-#define CLOCK_TICK_RATE 1193180
++#ifndef PIT_TICK_RATE
++#define PIT_TICK_RATE 1193180
+ #endif
+ 
+ #define VERSION_STRING "beep-1.3"
+@@ -100,7 +100,7 @@
+ void do_beep(int freq) {
+   if (console_type == BEEP_TYPE_CONSOLE) {
+     if(ioctl(console_fd, KIOCSOUND, freq != 0
+-      ? (int)(CLOCK_TICK_RATE/freq)
++      ? (int)(PIT_TICK_RATE/freq)
+       : freq) < 0) {
+       printf("\a");  /* Output the only beep we can, in an effort to fall back on usefulness */
+       perror("ioctl");
diff --git a/beep.tar.gz b/beep.tar.gz
new file mode 100644
index 0000000..30a7e2c
--- /dev/null
+++ b/beep.tar.gz
Binary files differ
diff --git a/beep.url b/beep.url
new file mode 100644
index 0000000..9f1b697
--- /dev/null
+++ b/beep.url
@@ -0,0 +1 @@
+http://johnath.com/beep/beep-1.3.tar.gz
diff --git a/beep.version b/beep.version
new file mode 100644
index 0000000..7e32cd5
--- /dev/null
+++ b/beep.version
@@ -0,0 +1 @@
+1.3