diff -pruN 2.5.35-10/debian/changelog 2.5.35-10ubuntu3/debian/changelog
--- 2.5.35-10/debian/changelog	2011-11-07 21:21:10.000000000 +0000
+++ 2.5.35-10ubuntu3/debian/changelog	2011-11-07 21:21:11.000000000 +0000
@@ -1,3 +1,27 @@
+flex (2.5.35-10ubuntu3) precise; urgency=low
+
+  * Add a Breaks: flex (<<) to libfl-dev, so that removing libfl-dev after
+    a partial upgrade doesn't leave a broken flex installation.
+
+ -- Steve Langasek <steve.langasek@ubuntu.com>  Mon, 07 Nov 2011 10:25:37 -0800
+
+flex (2.5.35-10ubuntu2) precise; urgency=low
+
+  * Split the flex package into flex and libfl-dev, with flex as a
+    Multi-Arch: foreign package depending on a Multi-Arch: same libfl-dev,
+    so that flex works for cross-building.  Thanks to
+    Riku Voipio <riku.voipio@iki.fi> for the initial version of this patch.
+    Closes: #611230, LP: #873015.
+
+ -- Steve Langasek <steve.langasek@ubuntu.com>  Sun, 06 Nov 2011 18:46:54 -0800
+
+flex (2.5.35-10ubuntu1) natty; urgency=low
+
+  * debian/control: flex should be declared Multi-Arch: allowed since it
+    contains both an executable and a library.
+
+ -- Steve Langasek <steve.langasek@ubuntu.com>  Wed, 26 Jan 2011 14:48:22 -0800
+
 flex (2.5.35-10) unstable; urgency=low
 
   * Bug fix: "flex is not GNU flex", thanks to Santiago Vila
diff -pruN 2.5.35-10/debian/common/archvars.mk 2.5.35-10ubuntu3/debian/common/archvars.mk
--- 2.5.35-10/debian/common/archvars.mk	2011-11-07 21:21:10.000000000 +0000
+++ 2.5.35-10ubuntu3/debian/common/archvars.mk	2011-11-07 21:21:11.000000000 +0000
@@ -80,6 +80,7 @@ export DEB_HOST_ARCH_CPU   := $(shell $(
 export DEB_HOST_GNU_CPU    := $(shell $(DPKG_ARCH) $(ha) -qDEB_HOST_GNU_CPU)
 export DEB_HOST_GNU_SYSTEM := $(shell $(DPKG_ARCH) $(ha) -qDEB_HOST_GNU_SYSTEM)
 export DEB_HOST_GNU_TYPE   := $(shell $(DPKG_ARCH) $(ha) -qDEB_HOST_GNU_TYPE)
+export DEB_HOST_MULTIARCH  := $(shell $(DPKG_ARCH) $(ha) -qDEB_HOST_MULTIARCH)
 
 # arrgh. future proofing
 ifeq ($(DEB_HOST_GNU_SYSTEM), linux)
diff -pruN 2.5.35-10/debian/control 2.5.35-10ubuntu3/debian/control
--- 2.5.35-10/debian/control	2011-11-07 21:21:10.000000000 +0000
+++ 2.5.35-10ubuntu3/debian/control	2011-11-07 21:21:11.000000000 +0000
@@ -5,16 +5,18 @@ Section: devel
 Homepage: http://flex.sf.net/
 Priority: optional
 Build-Depends: bison, gettext, texinfo, help2man, file, po-debconf,
-               autoconf, automake | automaken, autopoint
-Maintainer: Manoj Srivastava <srivasta@debian.org>
+               autoconf, automake | automaken, autopoint, dpkg-dev (>= 1.16.0)
+Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
+XSBC-Original-Maintainer: Manoj Srivastava <srivasta@debian.org>
 Standards-Version: 3.8.3.0
 
 Package: flex
 Architecture: any
 Pre-Depends: debconf | debconf-2.0
-Depends: ${shlibs:Depends}, m4, dpkg (>= 1.15.4) |  install-info
+Depends: ${shlibs:Depends}, m4, libfl-dev (= ${binary:Version}), dpkg (>= 1.15.4) |  install-info
 Recommends: gcc | c-compiler
 Suggests: bison, build-essential
+Multi-Arch: foreign
 Description: A fast lexical analyzer generator.
  Flex is a tool for generating scanners: programs which recognized lexical
  patterns in text. It reads the given input files for a description of a
@@ -40,3 +42,22 @@ Description: Documentation for flex (a f
  expressions. Whenever it finds one, it executes the corresponding C code.
  .
  This package contains the HTML documentation for flex.
+
+Package: libfl-dev
+Section: libdevel
+Priority: optional
+Architecture: any
+Multi-Arch: same
+Breaks: flex (<< 2.5.35-10ubuntu2)
+Replaces: flex (<< 2.5.35-10ubuntu2)
+Description: static library for flex (a fast lexical analyzer generator).
+ Flex is a tool for generating scanners: programs which recognized lexical
+ patterns in text. It reads the given input files for a description of a
+ scanner to generate. The description is in the form of pairs of regular
+ expressions and C code, called rules. Flex generates as output a C source
+ file, lex.yy.c, which defines a routine yylex().  This file is compiled
+ and linked with the -lfl library to produce an executable. When the
+ executable is run, it analyzes its input for occurrences of the regular
+ expressions. Whenever it finds one, it executes the corresponding C code.
+ .
+ This package contains the static library for flex.
diff -pruN 2.5.35-10/debian/libfl.shared_object 2.5.35-10ubuntu3/debian/libfl.shared_object
--- 2.5.35-10/debian/libfl.shared_object	2011-11-07 21:21:10.000000000 +0000
+++ 2.5.35-10ubuntu3/debian/libfl.shared_object	2011-11-07 21:21:11.000000000 +0000
@@ -19,5 +19,5 @@
  * arch-tag: ce35efb4-3893-42c7-bdcb-56d95beba2ac
  */
 
-INPUT( /usr/lib/libfl_pic.a )
+INPUT( /usr/lib/#DEB_HOST_MULTIARCH#/libfl_pic.a )
 
diff -pruN 2.5.35-10/debian/local.mk 2.5.35-10ubuntu3/debian/local.mk
--- 2.5.35-10/debian/local.mk	2011-11-07 21:21:10.000000000 +0000
+++ 2.5.35-10ubuntu3/debian/local.mk	2011-11-07 21:21:11.000000000 +0000
@@ -27,6 +27,10 @@ debian/stamp/BUILD/flex-doc:    debian/s
 debian/stamp/INST/flex-doc:     debian/stamp/install/flex-doc
 debian/stamp/BIN/flex-doc:      debian/stamp/binary/flex-doc
 
+debian/stamp/BUILD/libfl-dev:    debian/stamp/build/flex
+debian/stamp/INST/libfl-dev:     debian/stamp/install/libfl-dev
+debian/stamp/BIN/libfl-dev:      debian/stamp/binary/libfl-dev
+
 CLN-common::
 	$(REASON)
 	$(MAKE) clean -C po || true
@@ -38,6 +42,9 @@ CLEAN/flex::
 CLEAN/flex-doc::
 	-rm -rf $(TMPTOP)
 
+CLEAN/libfl-dev::
+	-rm -rf $(TMPTOP)
+
 debian/stamp/conf/flex:
 	$(checkdir)
 	$(REASON)
@@ -111,29 +118,20 @@ debian/stamp/install/flex:
 	rm -rf               $(TMPTOP)
 	$(make_directory)    $(TMPTOP)
 	$(make_directory)    $(BINDIR)
-	$(make_directory)    $(LIBDIR)
 	$(make_directory)    $(INFODIR)
 	$(make_directory)    $(MAN1DIR)
-	$(make_directory)    $(DOCDIR)
+	mkdir -p             $(TMPTOP)/usr/share/doc
+	ln -s                libfl-dev $(DOCDIR)
 	$(make_directory)    $(LINTIANDIR)
 	$(install_file)      debian/lintian.overrides $(LINTIANDIR)/$(package)
 	$(MAKE)              $(INT_INSTALL_TARGET)  prefix=$(TMPTOP)/usr \
 	                     infodir=$(INFODIR)     mandir=$(MANDIR)     \
                               INSTALL_PROGRAM="$(install_program)"
-	$(install_file)      debian/libfl.shared_object $(LIBDIR)/libfl.so
 	$(MAKE) install      -C po                  infodir=$(INFODIR) prefix=$(TMPTOP)/usr
 	$(MAKE) install-info -C doc                 infodir=$(INFODIR) prefix=$(TMPTOP)/usr
 	ln -s                flex                   $(BINDIR)/flex++
 	test ! -e            $(INFODIR)/dir         || rm -f $(INFODIR)/dir
 	test ! -e            $(INFODIR)/dir.old     || rm -f $(INFODIR)/dir.old
-	$(install_file)      README                 $(DOCDIR)/README
-	$(install_file)      debian/README          $(DOCDIR)/README.Debian 
-	$(install_file)      debian/NEWS.Debian     $(DOCDIR)/NEWS.Debian 
-	$(install_file)      NEWS                   $(DOCDIR)/NEWS
-	$(install_file)      debian/changelog       $(DOCDIR)/changelog.Debian
-	gzip -9frq           $(DOCDIR)/
-# Make sure the copyright file is not compressed
-	$(install_file)      debian/copyright       $(DOCDIR)/copyright
 	gzip -9fqr           $(MANDIR)/
 	test ! -e            $(INFODIR)/dir        || rm -f $(INFODIR)/dir
 	test ! -e            $(INFODIR)/dir.old    || rm -f $(INFODIR)/dir.old
@@ -143,12 +141,36 @@ debian/stamp/install/flex:
               md5sum scan.l >      debian/scan.l.md5sum;                                 \
         fi
 	$(strip-exec)
-	$(strip-lib)
-	ln -s 	             NEWS.gz                $(DOCDIR)/changelog.gz
 	ln -s                flex.1.gz              $(MAN1DIR)/lex.1.gz
 	ln -s                flex.1.gz              $(MAN1DIR)/flex++.1.gz
 	ln -s                flex                   $(BINDIR)/lex
+	@test -d debian/stamp/install || mkdir -p debian/stamp/install
+	@echo done > $@
+
+debian/stamp/install/libfl-dev:
+	$(checkdir)
+	$(REASON)
+	$(TESTROOT)
+	rm -rf               $(TMPTOP)
+	$(make_directory)    $(TMPTOP)
+	$(make_directory)    $(LIBDIR)
+	$(make_directory)    $(DOCDIR)
+	mv                   debian/flex/usr/lib/* $(LIBDIR)
+	mv                   debian/flex/usr/include debian/libfl-dev/usr/include
+	$(install_file)      debian/libfl.shared_object $(LIBDIR)/libfl.so
+	sed -e 's,#DEB_HOST_MULTIARCH#,$(DEB_HOST_MULTIARCH),' \
+	 debian/libfl.shared_object > $(LIBDIR)/libfl.so
 	ln -s                libfl.a                $(LIBDIR)/libl.a
+	$(install_file)      README                 $(DOCDIR)/README
+	$(install_file)      debian/README          $(DOCDIR)/README.Debian 
+	$(install_file)      debian/NEWS.Debian     $(DOCDIR)/NEWS.Debian 
+	$(install_file)      NEWS                   $(DOCDIR)/NEWS
+	$(install_file)      debian/changelog       $(DOCDIR)/changelog.Debian
+	gzip -9frqn          $(DOCDIR)/
+# Make sure the copyright file is not compressed
+	$(install_file)      debian/copyright       $(DOCDIR)/copyright
+	$(strip-lib)
+	ln -s 	             NEWS.gz                $(DOCDIR)/changelog.gz
 	@test -d debian/stamp/install || mkdir -p debian/stamp/install
 	@echo done > $@
 
@@ -183,3 +205,16 @@ debian/stamp/binary/flex:
 	dpkg --build         $(TMPTOP) ..
 	@test -d debian/stamp/binary || mkdir -p debian/stamp/binary
 	@echo done > $@
+
+debian/stamp/binary/libfl-dev:
+	$(checkdir)
+	$(REASON)
+	$(TESTROOT)
+	$(make_directory)   $(TMPTOP)/DEBIAN
+	dpkg-gencontrol      -p$(package) -isp       -P$(TMPTOP)
+	$(create_md5sum)     $(TMPTOP)
+	chown -R root:root   $(TMPTOP)
+	chmod -R u+w,go=rX   $(TMPTOP)
+	dpkg --build         $(TMPTOP) ..
+	@test -d debian/stamp/binary || mkdir -p debian/stamp/binary
+	@echo done > $@
diff -pruN 2.5.35-10/debian/local-vars.mk 2.5.35-10ubuntu3/debian/local-vars.mk
--- 2.5.35-10/debian/local-vars.mk	2011-11-07 21:21:10.000000000 +0000
+++ 2.5.35-10ubuntu3/debian/local-vars.mk	2011-11-07 21:21:11.000000000 +0000
@@ -82,7 +82,7 @@ MENUDIR    = $(TMPTOP)/usr/share/menu
 
 
 BINDIR  = $(TMPTOP)$(PREFIX)/bin
-LIBDIR  = $(TMPTOP)$(PREFIX)/lib
+LIBDIR  = $(TMPTOP)$(PREFIX)/lib/$(DEB_HOST_MULTIARCH)
 MANDIR  = $(TMPTOP)$(PREFIX)/share/man
 DOCDIR  = $(TMPTOP)$(PREFIX)/share/doc/$(package)
 INFODIR = $(TMPTOP)$(PREFIX)/share/info

