Browse Source

Fresh pull from upstream master

RISCi_ATOM 5 years ago
commit
38dd0e34d2
100 changed files with 9270 additions and 0 deletions
  1. 1 0
      .gitattributes
  2. 32 0
      .gitignore
  3. 7 0
      BSDmakefile
  4. 34 0
      Config.in
  5. 340 0
      LICENSE
  6. 105 0
      Makefile
  7. 15 0
      README.md
  8. 275 0
      config/Config-build.in
  9. 121 0
      config/Config-devel.in
  10. 289 0
      config/Config-images.in
  11. 835 0
      config/Config-kernel.in
  12. 96 0
      docs/Basic_Wireless_Settings.md
  13. 263 0
      docs/Ben_Nanonote.md
  14. 101 0
      docs/Bridge_Mode.md
  15. 24 0
      docs/Flavors.md
  16. 46 0
      docs/GL-AR300M.md
  17. 61 0
      docs/How To Submit A Change To This Wiki.md
  18. 81 0
      docs/How_To_Build_libreCMC.md
  19. 15 0
      docs/Image_Support.md
  20. 430 0
      docs/LICENSE.md
  21. 22 0
      docs/List_of_Tested_Hardware.md
  22. 103 0
      docs/OpenVPN_Layer_2_Server.md
  23. 84 0
      docs/Port_Forwards.md
  24. 15 0
      docs/README.md
  25. 53 0
      docs/Router_Reset_Instructions.md
  26. 104 0
      docs/Serial.md
  27. 32 0
      docs/Soft_Brick_Recovery_With_IPv6.md
  28. 37 0
      docs/Supported_Hardware.md
  29. 67 0
      docs/System_Log.md
  30. 42 0
      docs/TL_MR3020.md
  31. 120 0
      docs/TL_WR1043ND.md
  32. 37 0
      docs/TL_WR741ND.md
  33. 60 0
      docs/TL_WR841ND.md
  34. 41 0
      docs/TL_WR842ND.md
  35. 48 0
      docs/TPE_NWIFIROUTER2.md
  36. 47 0
      docs/TPE_R1100.md
  37. 47 0
      docs/WNDR3800.md
  38. 13 0
      docs/WZR_HP_G300NH.md
  39. 71 0
      docs/Welcome.md
  40. 15 0
      docs/embedded.md
  41. BIN
      docs/images/librecmc-changing-admin-password.png
  42. BIN
      docs/images/librecmc-changing-essid.png
  43. BIN
      docs/images/librecmc-changing-wifi-password.png
  44. BIN
      docs/images/librecmc-default-interfaces.png
  45. BIN
      docs/images/librecmc-default-login.png
  46. BIN
      docs/images/librecmc-dhcp-server-ignore-lan.png
  47. BIN
      docs/images/librecmc-eth0-added-to-lan.png
  48. BIN
      docs/images/librecmc-luci-selecting-system-log.png
  49. BIN
      docs/images/librecmc-luci-system-log.png
  50. BIN
      docs/images/librecmc-port-forwards-after-save-apply.png
  51. BIN
      docs/images/librecmc-port-forwards-entering-parameters.png
  52. BIN
      docs/images/librecmc-selecting-firewall-menu.png
  53. BIN
      docs/images/librecmc-selecting-port-forwards-tab.png
  54. BIN
      docs/images/librecmc-switch-lan-to-dhcp.png
  55. BIN
      docs/images/serial.png
  56. 24 0
      docs/old/Save_WiFi.md
  57. 12 0
      docs/testing.md
  58. 26 0
      docs/unbrick_with_uboot_mod.md
  59. 1 0
      feeds.conf.default
  60. 170 0
      include/autotools.mk
  61. 113 0
      include/cmake.mk
  62. 51 0
      include/debug.mk
  63. 54 0
      include/depends.mk
  64. 5 0
      include/device_table.txt
  65. 324 0
      include/download.mk
  66. 43 0
      include/feeds.mk
  67. 2 0
      include/hardened-ld-pie.specs
  68. 57 0
      include/hardening.mk
  69. 211 0
      include/host-build.mk
  70. 362 0
      include/image-commands.mk
  71. 93 0
      include/image-legacy.mk
  72. 613 0
      include/image.mk
  73. 174 0
      include/kernel-build.mk
  74. 164 0
      include/kernel-defaults.mk
  75. 38 0
      include/kernel-version.mk
  76. 297 0
      include/kernel.mk
  77. 414 0
      include/netfilter.mk
  78. 40 0
      include/nls.mk
  79. 43 0
      include/package-bin.mk
  80. 164 0
      include/package-defaults.mk
  81. 60 0
      include/package-dumpinfo.mk
  82. 243 0
      include/package-ipkg.mk
  83. 15 0
      include/package-seccomp.mk
  84. 324 0
      include/package.mk
  85. 164 0
      include/prereq-build.mk
  86. 109 0
      include/prereq.mk
  87. 183 0
      include/quilt.mk
  88. 96 0
      include/rootfs.mk
  89. 19 0
      include/scan.awk
  90. 110 0
      include/scan.mk
  91. 23 0
      include/scons.mk
  92. 15 0
      include/shell.sh
  93. 30 0
      include/site/aarch64
  94. 30 0
      include/site/aarch64_be
  95. 30 0
      include/site/arc
  96. 30 0
      include/site/arm
  97. 30 0
      include/site/armeb
  98. 2 0
      include/site/darwin
  99. 3 0
      include/site/i386
  100. 30 0
      include/site/i486

+ 1 - 0
.gitattributes

@@ -0,0 +1 @@
+* -text

+ 32 - 0
.gitignore

@@ -0,0 +1,32 @@
+*.o
+.DS_Store
+.*.swp
+/env
+/dl
+/.config
+/.config.old
+/bin
+/build_dir
+/staging_dir
+/tmp
+/logs
+/feeds
+/feeds.conf
+/files
+/overlay
+/package/feeds
+/package/openwrt-packages
+key-build*
+*.orig
+*.rej
+*~
+.#*
+*#
+.emacs.desktop*
+TAGS*~
+git-src
+*.o
+*.so
+*.swp
+*.po~
+/package/luci/modules/luci-base/src/po2lmo

+ 7 - 0
BSDmakefile

@@ -0,0 +1,7 @@
+# Copyright (C) 2006 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+world ${.TARGETS}:
+	@gmake $@

+ 34 - 0
Config.in

@@ -0,0 +1,34 @@
+# Copyright (C) 2006-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+mainmenu "libreCMC Configuration"
+
+config MODULES
+	option modules
+	bool
+	default y
+
+config HAVE_DOT_CONFIG
+	bool
+	default y
+
+source "target/Config.in"
+
+source "config/Config-images.in"
+
+source "config/Config-build.in"
+
+source "config/Config-devel.in"
+
+source "toolchain/Config.in"
+
+source "target/imagebuilder/Config.in"
+
+source "target/sdk/Config.in"
+
+source "target/toolchain/Config.in"
+
+source "tmp/.config-package.in"

+ 340 - 0
LICENSE

@@ -0,0 +1,340 @@
+		    GNU GENERAL PUBLIC LICENSE
+		       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+		    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+			    NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
+
+	    How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    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
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year  name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.

+ 105 - 0
Makefile

@@ -0,0 +1,105 @@
+# Makefile for libreCMC
+#
+# Copyright (C) 2007 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+TOPDIR:=${CURDIR}
+LC_ALL:=C
+LANG:=C
+TZ:=UTC
+export TOPDIR LC_ALL LANG TZ
+
+empty:=
+space:= $(empty) $(empty)
+$(if $(findstring $(space),$(TOPDIR)),$(error ERROR: The path to the libreCMC directory must not include any spaces))
+
+world:
+
+export PATH:=$(TOPDIR)/staging_dir/host/bin:$(PATH)
+
+ifneq ($(LIBRECMC_BUILD),1)
+  _SINGLE=export MAKEFLAGS=$(space);
+
+  override LIBRECMC_BUILD=1
+  export LIBRECMC_BUILD
+  GREP_OPTIONS=
+  export GREP_OPTIONS
+  CDPATH=
+  export CDPATH
+  include $(TOPDIR)/include/debug.mk
+  include $(TOPDIR)/include/depends.mk
+  include $(TOPDIR)/include/toplevel.mk
+else
+  include rules.mk
+  include $(INCLUDE_DIR)/depends.mk
+  include $(INCLUDE_DIR)/subdir.mk
+  include target/Makefile
+  include package/Makefile
+  include tools/Makefile
+  include toolchain/Makefile
+
+$(toolchain/stamp-compile): $(tools/stamp-compile)
+$(target/stamp-compile): $(toolchain/stamp-compile) $(tools/stamp-compile) $(BUILD_DIR)/.prepared
+$(package/stamp-compile): $(target/stamp-compile) $(package/stamp-cleanup)
+$(package/stamp-install): $(package/stamp-compile)
+$(target/stamp-install): $(package/stamp-compile) $(package/stamp-install)
+check: $(tools/stamp-check) $(toolchain/stamp-check) $(package/stamp-check)
+
+printdb:
+	@true
+
+prepare: $(target/stamp-compile)
+
+clean: FORCE
+	rm -rf $(BUILD_DIR) $(STAGING_DIR) $(BIN_DIR) $(OUTPUT_DIR)/packages/$(ARCH_PACKAGES) $(BUILD_LOG_DIR) $(TOPDIR)/staging_dir/packages
+
+dirclean: clean
+	rm -rf $(STAGING_DIR_HOST) $(STAGING_DIR_HOSTPKG) $(TOOLCHAIN_DIR) $(BUILD_DIR_BASE)/host $(BUILD_DIR_BASE)/hostpkg $(BUILD_DIR_TOOLCHAIN)
+	rm -rf $(TMP_DIR)
+
+ifndef DUMP_TARGET_DB
+$(BUILD_DIR)/.prepared: Makefile
+	@mkdir -p $$(dirname $@)
+	@touch $@
+
+tmp/.prereq_packages: .config
+	unset ERROR; \
+	for package in $(sort $(prereq-y) $(prereq-m)); do \
+		$(_SINGLE)$(NO_TRACE_MAKE) -s -r -C package/$$package prereq || ERROR=1; \
+	done; \
+	if [ -n "$$ERROR" ]; then \
+		echo "Package prerequisite check failed."; \
+		false; \
+	fi
+	touch $@
+endif
+
+# check prerequisites before starting to build
+prereq: $(target/stamp-prereq) tmp/.prereq_packages
+	@if [ ! -f "$(INCLUDE_DIR)/site/$(ARCH)" ]; then \
+		echo 'ERROR: Missing site config for architecture "$(ARCH)" !'; \
+		echo '       The missing file will cause configure scripts to fail during compilation.'; \
+		echo '       Please provide a "$(INCLUDE_DIR)/site/$(ARCH)" file and restart the build.'; \
+		exit 1; \
+	fi
+
+checksum: FORCE
+	$(call sha256sums,$(BIN_DIR),$(CONFIG_BUILDBOT))
+
+diffconfig: FORCE
+	mkdir -p $(BIN_DIR)
+	$(SCRIPT_DIR)/diffconfig.sh > $(BIN_DIR)/config.seed
+
+prepare: .config $(tools/stamp-compile) $(toolchain/stamp-compile)
+	$(_SINGLE)$(SUBMAKE) -r diffconfig
+
+world: prepare $(target/stamp-compile) $(package/stamp-compile) $(package/stamp-install) $(target/stamp-install) FORCE
+	$(_SINGLE)$(SUBMAKE) -r package/index
+	$(_SINGLE)$(SUBMAKE) -r checksum
+
+.PHONY: clean dirclean prereq prepare world package/symlinks package/symlinks-install package/symlinks-clean
+
+endif

+ 15 - 0
README.md

@@ -0,0 +1,15 @@
+# libreCMC : The _libre_ Embedded GNU/Linux Distro.
+
+libreCMC is a set of fully [free](http://www.gnu.org/philosophy/free-sw.en.html) embedded Operating Systems for general purpose computers. It aims to give its users freedom and control over the software that runs on their hardware. Most of the hardware that libreCMC supports includes a wide range of routers and some small single board computers.
+
+## Useful links:
+
+* [Get libreCMC source code](/) : Checkout the latest libreCMC sources.
+
+* [Supported Hardware](/docs/Supported_Hardware.md): Devices officially supported by libreCMC.
+
+* [Router reset instructions](/docs/Router_Reset_Instructions.md) : Generic libreCMC router reset instructions.
+
+* [Report a bug or issue](https://gogs.librecmc.org/libreCMC/libreCMC/issues) : Is something broken? Did you find a non-free component or do you want to make libreCMC better? Submit an issue.
+
+* [Build Documentation](/docs/How_To_Build_libreCMC.md) : Learn how to build libreCMC for your device. 

+ 275 - 0
config/Config-build.in

@@ -0,0 +1,275 @@
+# Copyright (C) 2006-2013 OpenWrt.org
+# Copyright (C) 2016 LEDE Project
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+menu "Global build settings"
+
+	config ALL_NONSHARED
+		bool "Select all target specific packages by default"
+		select ALL_KMODS
+		default BUILDBOT
+
+	config ALL_KMODS
+		bool "Select all kernel module packages by default"
+
+	config ALL
+		bool "Select all userspace packages by default"
+		select ALL_KMODS
+		select ALL_NONSHARED
+
+	config BUILDBOT
+		bool "Set build defaults for automatic builds (e.g. via buildbot)"
+		default n
+		help
+		  This option changes several defaults to be more suitable for
+		  automatic builds. This includes the following changes:
+		  - Deleting build directories after compiling (to save space)
+		  - Enabling per-device rootfs support
+		  ...
+
+	config SIGNED_PACKAGES
+		bool "Cryptographically signed package lists"
+		default y
+
+	comment "General build options"
+
+	config DISPLAY_SUPPORT
+		bool "Show packages that require graphics support (local or remote)"
+		default n
+
+	config BUILD_PATENTED
+		default n
+		bool "Compile with support for patented functionality"
+		help
+		  When this option is disabled, software which provides patented functionality
+		  will not be built.  In case software provides optional support for patented
+		  functionality, this optional support will get disabled for this package.
+
+	config BUILD_NLS
+		default n
+		bool "Compile with full language support"
+		help
+		  When this option is enabled, packages are built with the full versions of
+		  iconv and GNU gettext instead of the default libreCMC stubs. If uClibc is
+		  used, it is also built with locale support.
+
+	config SHADOW_PASSWORDS
+		bool
+		default y
+
+	config CLEAN_IPKG
+		bool
+		prompt "Remove ipkg/opkg status data files in final images"
+		default n
+		help
+		  This removes all ipkg/opkg status data files from the target directory
+		  before building the root filesystem.
+
+	config INCLUDE_CONFIG
+		bool "Include build configuration in firmware" if DEVEL
+		default n
+		help
+		  If enabled, config.seed will be stored in /etc/build.config of firmware.
+
+	config COLLECT_KERNEL_DEBUG
+		bool
+		prompt "Collect kernel debug information"
+		select KERNEL_DEBUG_INFO
+		default BUILDBOT
+		help
+		  This collects debugging symbols from the kernel and all compiled modules.
+		  Useful for release builds, so that kernel issues can be debugged offline
+		  later.
+
+	menu "Kernel build options"
+
+	source "config/Config-kernel.in"
+
+	endmenu
+
+	comment "Package build options"
+
+	config DEBUG
+		bool
+		prompt "Compile packages with debugging info"
+		default n
+		help
+		  Adds -g3 to the CFLAGS.
+
+	config IPV6
+		bool
+		prompt "Enable IPv6 support in packages"
+		default y
+		help
+		  Enables IPv6 support in kernel (builtin) and packages.
+
+	comment "Stripping options"
+
+	choice
+		prompt "Binary stripping method"
+		default USE_STRIP   if EXTERNAL_TOOLCHAIN
+		default USE_STRIP   if USE_GLIBC
+		default USE_SSTRIP
+		help
+		  Select the binary stripping method you wish to use.
+
+		config NO_STRIP
+			bool "none"
+			help
+			  This will install unstripped binaries (useful for native
+			  compiling/debugging).
+
+		config USE_STRIP
+			bool "strip"
+			help
+			  This will install binaries stripped using strip from binutils.
+
+
+		config USE_SSTRIP
+			bool "sstrip"
+			depends on !USE_GLIBC
+			help
+			  This will install binaries stripped using sstrip.
+	endchoice
+
+	config STRIP_ARGS
+		string
+		prompt "Strip arguments"
+		depends on USE_STRIP
+		default "--strip-unneeded --remove-section=.comment --remove-section=.note" if DEBUG
+		default "--strip-all"
+		help
+		  Specifies arguments passed to the strip command when stripping binaries.
+
+	config STRIP_KERNEL_EXPORTS
+		bool "Strip unnecessary exports from the kernel image"
+		help
+		  Reduces kernel size by stripping unused kernel exports from the kernel
+		  image.  Note that this might make the kernel incompatible with any kernel
+		  modules that were not selected at the time the kernel image was created.
+
+	config USE_MKLIBS
+		bool "Strip unnecessary functions from libraries"
+		help
+		  Reduces libraries to only those functions that are necessary for using all
+		  selected packages (including those selected as <M>).  Note that this will
+		  make the system libraries incompatible with most of the packages that are
+		  not selected during the build process.
+
+	choice
+		prompt "Preferred standard C++ library"
+		default USE_LIBSTDCXX if USE_GLIBC
+		default USE_UCLIBCXX
+		help
+		  Select the preferred standard C++ library for all packages that support this.
+
+		config USE_UCLIBCXX
+			bool "uClibc++"
+
+		config USE_LIBSTDCXX
+			bool "libstdc++"
+	endchoice
+
+	comment "Hardening build options"
+
+	config PKG_CHECK_FORMAT_SECURITY
+		bool
+		prompt "Enable gcc format-security"
+		default y
+		help
+		  Add -Wformat -Werror=format-security to the CFLAGS.  You can disable
+		  this per package by adding PKG_CHECK_FORMAT_SECURITY:=0 in the package
+		  Makefile.
+
+	config PKG_ASLR_PIE
+		bool
+		prompt "User space ASLR PIE compilation"
+		select BUSYBOX_DEFAULT_PIE
+		default n
+		help
+		  Add -fPIC to CFLAGS and -specs=hardened-build-ld to LDFLAGS.
+		  This enables package build as Position Independent Executables (PIE)
+		  to protect against "return-to-text" attacks. This belongs to the
+		  feature of Address Space Layout Randomisation (ASLR), which is
+		  implemented by the kernel and the ELF loader by randomising the
+		  location of memory allocations. This makes memory addresses harder
+		  to predict when an attacker is attempting a memory-corruption exploit.
+		  You can disable this per package by adding PKG_ASLR_PIE:=0 in the package
+		  Makefile.
+
+	choice
+		prompt "User space Stack-Smashing Protection"
+		depends on USE_MUSL
+		default PKG_CC_STACKPROTECTOR_REGULAR
+		help
+		  Enable GCC Stack Smashing Protection (SSP) for userspace applications
+		config PKG_CC_STACKPROTECTOR_NONE
+			bool "None"
+		config PKG_CC_STACKPROTECTOR_REGULAR
+			bool "Regular"
+			select GCC_LIBSSP if !USE_MUSL
+			depends on KERNEL_CC_STACKPROTECTOR_REGULAR
+		config PKG_CC_STACKPROTECTOR_STRONG
+			bool "Strong"
+			select GCC_LIBSSP if !USE_MUSL
+			depends on !GCC_VERSION_4_8
+			depends on KERNEL_CC_STACKPROTECTOR_STRONG
+	endchoice
+
+	choice
+		prompt "Kernel space Stack-Smashing Protection"
+		default KERNEL_CC_STACKPROTECTOR_REGULAR
+		depends on USE_MUSL || !(x86_64 || i386)
+		help
+		  Enable GCC Stack-Smashing Protection (SSP) for the kernel
+		config KERNEL_CC_STACKPROTECTOR_NONE
+			bool "None"
+		config KERNEL_CC_STACKPROTECTOR_REGULAR
+			bool "Regular"
+		config KERNEL_CC_STACKPROTECTOR_STRONG
+			depends on !GCC_VERSION_4_8
+			bool "Strong"
+	endchoice
+
+	choice
+		prompt "Enable buffer-overflows detection (FORTIFY_SOURCE)"
+		default PKG_FORTIFY_SOURCE_1
+		help
+		  Enable the _FORTIFY_SOURCE macro which introduces additional
+		  checks to detect buffer-overflows in the following standard library
+		  functions: memcpy, mempcpy, memmove, memset, strcpy, stpcpy,
+		  strncpy, strcat, strncat, sprintf, vsprintf, snprintf, vsnprintf,
+		  gets.  "Conservative" (_FORTIFY_SOURCE set to 1) only introduces
+		  checks that shouldn't change the behavior of conforming programs,
+		  while "aggressive" (_FORTIFY_SOURCES set to 2) some more checking is
+		  added, but some conforming programs might fail.
+		config PKG_FORTIFY_SOURCE_NONE
+			bool "None"
+		config PKG_FORTIFY_SOURCE_1
+			bool "Conservative"
+		config PKG_FORTIFY_SOURCE_2
+			bool "Aggressive"
+	endchoice
+
+	choice
+		prompt "Enable RELRO protection"
+		default PKG_RELRO_FULL
+		help
+		  Enable a link-time protection known as RELRO (Relocation Read Only)
+		  which helps to protect from certain type of exploitation techniques
+		  altering the content of some ELF sections. "Partial" RELRO makes the
+		  .dynamic section not writeable after initialization, introducing
+		  almost no performance penalty, while "full" RELRO also marks the GOT
+		  as read-only at the cost of initializing all of it at startup.
+		config PKG_RELRO_NONE
+			bool "None"
+		config PKG_RELRO_PARTIAL
+			bool "Partial"
+		config PKG_RELRO_FULL
+			bool "Full"
+	endchoice
+
+endmenu

+ 121 - 0
config/Config-devel.in

@@ -0,0 +1,121 @@
+# Copyright (C) 2006-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+menuconfig DEVEL
+	bool "Advanced configuration options (for developers)"
+	default n
+
+	config BROKEN
+		bool "Show broken platforms / packages" if DEVEL
+		default n
+
+	config BINARY_FOLDER
+		string "Binary folder" if DEVEL
+		default ""
+		help
+		  Store built firmware images and filesystem images in this directory.
+		  If not set, uses './bin/$(BOARD)'
+
+	config DOWNLOAD_FOLDER
+		string "Download folder" if DEVEL
+		default ""
+		help
+		  Store downloaded source bundles in this directory.
+		  If not set then defaults to './dl', which is removed by operations such as
+		  'git clean -xdf' or 'make distclean'.
+		  This option is useful if you have a low bandwidth Internet connection, and by
+		  setting a path outside the libreCMC tree downloads will be saved.
+
+	config LOCALMIRROR
+		string "Local mirror for source packages" if DEVEL
+		default ""
+
+	config AUTOREBUILD
+		bool "Automatic rebuild of packages" if DEVEL
+		default y
+		help
+		  Automatically rebuild packages when their files change.
+
+	config AUTOREMOVE
+		bool "Automatic removal of build directories" if DEVEL
+		default n
+		help
+		  Automatically delete build directories after make target completed.
+		  This allows you to symlink build_dir into a scratch location, e.g. a ramdisk,
+		  which does not have enough space to keep a complete build_dir.
+
+	config BUILD_SUFFIX
+		string "Build suffix to append to the target BUILD_DIR variable" if DEVEL
+		default ""
+		help
+		  Build suffix to append to the BUILD_DIR variable, i.e: './build_dir/{target-build-dir}_$(BUILD_SUFFIX)'.
+		  This allows you to switch to a different .config whilst retaining all the build
+		  objects generated by the first .config
+
+	config TARGET_ROOTFS_DIR
+		string "Override the default TARGET_ROOTFS_DIR variable" if DEVEL
+		default ""
+		help
+		  Override the default TARGET_ROOTFS_DIR variable content $(BUILD_DIR) with
+		  custom path.  Use this option to re-define the location of the target
+		  root filesystem directory.
+
+	config CCACHE
+		bool "Use ccache" if DEVEL
+		default n
+		help
+		  Compiler cache; see https://ccache.samba.org/
+
+	config EXTERNAL_KERNEL_TREE
+		string "Use external kernel tree" if DEVEL
+		default ""
+
+	config KERNEL_GIT_CLONE_URI
+		string "Enter git repository to clone" if DEVEL
+		default ""
+		help
+		  Enter the full git repository path i.e.:
+		  git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
+		  This will create a git clone of the kernel in your build directory.
+
+	config KERNEL_GIT_LOCAL_REPOSITORY
+		string "Enter path to local reference repository" if DEVEL
+		depends on (KERNEL_GIT_CLONE_URI != "")
+		default ""
+		help
+		  Enter a full pathname to a local reference git repository.
+		  In this instance, the --reference option of git clone will
+		  be used thus creating a quick local clone of your repo.
+
+	config KERNEL_GIT_REF
+		string "Enter git ref at which to checkout" if DEVEL
+		depends on (KERNEL_GIT_CLONE_URI != "")
+		default ""
+		help
+		  Enter the git ref at which to checkout the git repository
+		  after it is cloned, and before making it a tar-ball.
+		  It can be a git hash or a branch name.
+		  If unused, the clone's repository HEAD will be checked-out.
+
+	config BUILD_LOG
+		bool "Enable log files during build process" if DEVEL
+		help
+		  If enabled, log files will be written to the ./log directory.
+
+	config SRC_TREE_OVERRIDE
+		bool "Enable package source tree override" if DEVEL
+		help
+		  If enabled, you can force a package to use a git tree as source
+		  code instead of the normal tarball. Create a symlink 'git-src'
+		  in the package directory, pointing to the .git tree that you want
+		  to pull the source code from.
+
+	config EXTRA_OPTIMIZATION
+		string "Additional compiler options" if DEVEL
+		default "-fno-caller-saves -fno-plt" if !CONFIG_EXTERNAL_TOOLCHAIN && !arc
+		default "-fno-caller-saves"
+		help
+		  Extra target-independent optimizations to use when building for the target.

+ 289 - 0
config/Config-images.in

@@ -0,0 +1,289 @@
+# Copyright (C) 2006-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+menu "Target Images"
+
+	menuconfig TARGET_ROOTFS_INITRAMFS
+		bool "ramdisk"
+		default y if USES_INITRAMFS
+		help
+		  Embed the root filesystem into the kernel (initramfs).
+
+		choice
+			prompt "Compression"
+			default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_ar71xx
+			default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_ramips
+			default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_apm821xx
+			default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_mpc85xx
+			default TARGET_INITRAMFS_COMPRESSION_NONE
+			depends on TARGET_ROOTFS_INITRAMFS
+			help
+			  Select ramdisk compression.
+
+			config TARGET_INITRAMFS_COMPRESSION_NONE
+				bool "none"
+
+			config TARGET_INITRAMFS_COMPRESSION_GZIP
+				bool "gzip"
+
+			config TARGET_INITRAMFS_COMPRESSION_BZIP2
+				bool "bzip2"
+
+			config TARGET_INITRAMFS_COMPRESSION_LZMA
+				bool "lzma"
+
+			config TARGET_INITRAMFS_COMPRESSION_LZO
+				bool "lzo"
+
+			config TARGET_INITRAMFS_COMPRESSION_LZ4
+				bool "lz4"
+
+			config TARGET_INITRAMFS_COMPRESSION_XZ
+				bool "xz"
+		endchoice
+
+		config EXTERNAL_CPIO
+			string
+			prompt "Use external cpio" if TARGET_ROOTFS_INITRAMFS
+			default ""
+			help
+			  Kernel uses specified external cpio as INITRAMFS_SOURCE.
+
+		config TARGET_INITRAMFS_FORCE
+                        bool "Force"
+                        depends on TARGET_ROOTFS_INITRAMFS
+                        default n
+                        help
+                          Ignore the initramfs passed by the bootloader.
+
+	comment "Root filesystem archives"
+
+	config TARGET_ROOTFS_CPIOGZ
+		bool "cpio.gz"
+		default y if USES_CPIOGZ
+		help
+		  Build a compressed cpio archive of the root filesystem.
+
+	config TARGET_ROOTFS_TARGZ
+		bool "tar.gz"
+		default y if USES_TARGZ
+		help
+		  Build a compressed tar archive of the root filesystem.
+
+	comment "Root filesystem images"
+
+	menuconfig TARGET_ROOTFS_EXT4FS
+		bool "ext4"
+		default y if USES_EXT4
+		help
+		  Build an ext4 root filesystem.
+
+		config TARGET_EXT4_RESERVED_PCT
+			int "Percentage of reserved blocks in root filesystem"
+			depends on TARGET_ROOTFS_EXT4FS
+			default 0
+			help
+			  Select the percentage of reserved blocks in the root filesystem.
+
+		choice
+			prompt "Root filesystem block size"
+			default TARGET_EXT4_BLOCKSIZE_4K
+			depends on TARGET_ROOTFS_EXT4FS
+			help
+			  Select the block size of the root filesystem.
+
+			config TARGET_EXT4_BLOCKSIZE_4K
+				bool "4k"
+
+			config TARGET_EXT4_BLOCKSIZE_2K
+				bool "2k"
+
+			config TARGET_EXT4_BLOCKSIZE_1K
+				bool "1k"
+		endchoice
+
+		config TARGET_EXT4_BLOCKSIZE
+			int
+			default 4096 if TARGET_EXT4_BLOCKSIZE_4K
+			default 2048 if TARGET_EXT4_BLOCKSIZE_2K
+			default 1024 if TARGET_EXT4_BLOCKSIZE_1K
+			depends on TARGET_ROOTFS_EXT4FS
+
+		config TARGET_EXT4_JOURNAL
+			bool "Create a journaling filesystem"
+			depends on TARGET_ROOTFS_EXT4FS
+			default n
+			help
+			  Create an ext4 filesystem with a journal.
+
+	config TARGET_ROOTFS_ISO
+		bool "iso"
+		default n
+		depends on TARGET_x86_generic
+		help
+		  Create a bootable ISO image.
+
+	config TARGET_ROOTFS_JFFS2
+		bool "jffs2"
+		depends on USES_JFFS2
+		help
+		  Build a JFFS2 root filesystem.
+
+	config TARGET_ROOTFS_JFFS2_NAND
+		bool "jffs2 for NAND"
+		default y if USES_JFFS2_NAND
+		depends on USES_JFFS2_NAND
+		help
+		  Build a JFFS2 root filesystem for NAND flash.
+
+	menuconfig TARGET_ROOTFS_SQUASHFS
+		bool "squashfs"
+		default y if USES_SQUASHFS
+		help
+		  Build a squashfs-lzma root filesystem.
+
+		config TARGET_SQUASHFS_BLOCK_SIZE
+			int "Block size (in KiB)"
+			depends on TARGET_ROOTFS_SQUASHFS
+			default 64 if LOW_MEMORY_FOOTPRINT
+			default 1024 if (SMALL_FLASH && !LOW_MEMORY_FOOTPRINT)
+			default 256
+
+	menuconfig TARGET_ROOTFS_UBIFS
+		bool "ubifs"
+		default y if USES_UBIFS
+		depends on USES_UBIFS
+		help
+		  Build a UBIFS root filesystem.
+
+		choice
+			prompt "compression"
+			default TARGET_UBIFS_COMPRESSION_ZLIB
+			depends on TARGET_ROOTFS_UBIFS
+			help
+			  Select compression type
+
+			config TARGET_UBIFS_COMPRESSION_NONE
+				bool "none"
+
+			config TARGET_UBIFS_COMPRESSION_LZO
+				bool "lzo"
+
+			config TARGET_UBIFS_COMPRESSION_ZLIB
+				bool "zlib"
+		endchoice
+
+		config TARGET_UBIFS_FREE_SPACE_FIXUP
+			bool "free space fixup" if TARGET_ROOTFS_UBIFS
+			default y
+			help
+			  The filesystem free space has to be fixed up on first mount.
+
+		config TARGET_UBIFS_JOURNAL_SIZE
+			string
+			prompt "journal size" if TARGET_ROOTFS_UBIFS
+			default ""
+
+	config GRUB_IMAGES
+		bool "Build GRUB images (Linux x86 or x86_64 host only)"
+		depends on TARGET_x86
+		depends on TARGET_ROOTFS_EXT4FS || TARGET_ROOTFS_ISO || TARGET_ROOTFS_JFFS2 || TARGET_ROOTFS_SQUASHFS
+		select PACKAGE_grub2
+		default y
+
+	config GRUB_CONSOLE
+		bool "Use Console Terminal (in addition to Serial)"
+		depends on GRUB_IMAGES
+		default n if (TARGET_x86_generic_Soekris45xx || TARGET_x86_generic_Soekris48xx || TARGET_x86_net5501 || TARGET_x86_geos || TARGET_x86_alix2)
+		default y
+
+	config GRUB_SERIAL
+		string "Serial port device"
+		depends on GRUB_IMAGES
+		default "hvc0" if TARGET_x86_xen_domu
+		default "ttyS0" if ! TARGET_x86_xen_domu
+
+	config GRUB_BAUDRATE
+		int "Serial port baud rate"
+		depends on GRUB_IMAGES
+		default 38400 if TARGET_x86_generic
+		default 115200
+
+	config GRUB_FLOWCONTROL
+		bool "Use RTE/CTS on serial console"
+		depends on GRUB_SERIAL != ""
+		default n
+
+	config GRUB_BOOTOPTS
+		string "Extra kernel boot options"
+		depends on GRUB_IMAGES
+		default "xencons=hvc" if TARGET_x86_xen_domu
+		help
+		  If you don't know, just leave it blank.
+
+	config GRUB_TIMEOUT
+		string "Seconds to wait before booting the default entry"
+		depends on GRUB_IMAGES
+		default "5"
+		help
+		  If you don't know, 5 seconds is a reasonable default.
+
+	config GRUB_TITLE
+		string "Title for the menu entry in GRUB"
+		depends on GRUB_IMAGES
+		default "libreCMC"
+		help
+		  This is the title of the GRUB menu entry.
+		  If unspecified, it defaults to libreCMC.
+
+	config VDI_IMAGES
+		bool "Build VirtualBox image files (VDI)"
+		depends on TARGET_x86 || TARGET_x86_64
+		select GRUB_IMAGES
+		select TARGET_IMAGES_PAD
+		select PACKAGE_kmod-e1000
+
+	config VMDK_IMAGES
+		bool "Build VMware image files (VMDK)"
+		depends on TARGET_x86 || TARGET_x86_64
+		select GRUB_IMAGES
+		select TARGET_IMAGES_PAD
+		select PACKAGE_kmod-e1000
+
+	config TARGET_IMAGES_PAD
+		bool "Pad images to filesystem size (for JFFS2)"
+		depends on GRUB_IMAGES
+
+	config TARGET_IMAGES_GZIP
+		bool "GZip images"
+		depends on TARGET_IMAGES_PAD || TARGET_ROOTFS_EXT4FS || TARGET_x86
+		default y
+
+	comment "Image Options"
+
+	source "target/linux/*/image/Config.in"
+
+	config TARGET_KERNEL_PARTSIZE
+		int "Kernel partition size (in MB)"
+		depends on GRUB_IMAGES || USES_BOOT_PART
+		default 16
+
+	config TARGET_ROOTFS_PARTSIZE
+		int "Root filesystem partition size (in MB)"
+		depends on GRUB_IMAGES || USES_ROOTFS_PART || TARGET_ROOTFS_EXT4FS || TARGET_mvebu || TARGET_rb532 || TARGET_sunxi || TARGET_uml
+		default 256
+		help
+		  Select the root filesystem partition size.
+
+	config TARGET_ROOTFS_PARTNAME
+		string "Root partition on target device"
+		depends on GRUB_IMAGES
+		help
+		  Override the root partition on the final device. If left empty,
+		  it will be mounted by PARTUUID which makes the kernel find the
+		  appropriate disk automatically.
+
+endmenu

+ 835 - 0
config/Config-kernel.in

@@ -0,0 +1,835 @@
+# Copyright (C) 2006-2014 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+config KERNEL_BUILD_USER
+	string "Custom Kernel Build User Name"
+	default ""
+	help
+	  Sets the Kernel build user string, which for example will be returned
+	  by 'uname -a' on running systems.
+	  If not set, uses system user at build time.
+
+config KERNEL_BUILD_DOMAIN
+	string "Custom Kernel Build Domain Name"
+	default ""
+	help
+	  Sets the Kernel build domain string, which for example will be
+	  returned by 'uname -a' on running systems.
+	  If not set, uses system hostname at build time.
+
+config KERNEL_PRINTK
+	bool "Enable support for printk"
+	default y
+
+config KERNEL_CRASHLOG
+	bool "Crash logging"
+	depends on !(arm || powerpc || sparc || TARGET_uml || i386 || x86_64)
+	default y
+
+config KERNEL_SWAP
+	bool "Support for paging of anonymous memory (swap)"
+	default y if !SMALL_FLASH
+
+config KERNEL_DEBUG_FS
+	bool "Compile the kernel with debug filesystem enabled"
+	default y
+	help
+	  debugfs is a virtual file system that kernel developers use to put
+	  debugging files into. Enable this option to be able to read and
+	  write to these files. Many common debugging facilities, such as
+	  ftrace, require the existence of debugfs.
+
+config KERNEL_MIPS_FPU_EMULATOR
+	bool "Compile the kernel with MIPS FPU Emulator"
+	default y if TARGET_pistachio
+	depends on (mips || mipsel || mips64 || mips64el)
+
+config KERNEL_ARM_PMU
+	bool
+	default n
+	depends on (arm || aarch64)
+
+config KERNEL_PERF_EVENTS
+	bool "Compile the kernel with performance events and counters"
+	default n
+	select KERNEL_ARM_PMU if (arm || aarch64)
+
+config KERNEL_PROFILING
+	bool "Compile the kernel with profiling enabled"
+	default n
+	select KERNEL_PERF_EVENTS
+	help
+	  Enable the extended profiling support mechanisms used by profilers such
+	  as OProfile.
+
+config KERNEL_TASKSTATS
+	bool "Compile the kernel with task resource/io statistics and accounting"
+	default n
+	help
+	  Enable the collection and publishing of task/io statistics and
+	  accounting.  Enable this option to enable i/o monitoring in system
+	  monitors.
+
+if KERNEL_TASKSTATS
+
+	config KERNEL_TASK_DELAY_ACCT
+		def_bool y
+
+	config KERNEL_TASK_IO_ACCOUNTING
+		def_bool y
+
+	config KERNEL_TASK_XACCT
+		def_bool y
+
+endif
+
+config KERNEL_KALLSYMS
+	bool "Compile the kernel with symbol table information"
+	default y if !SMALL_FLASH
+	help
+	  This will give you more information in stack traces from kernel oopses.
+
+config KERNEL_FTRACE
+	bool "Compile the kernel with tracing support"
+	depends on !TARGET_uml
+	default n
+
+config KERNEL_FTRACE_SYSCALLS
+	bool "Trace system calls"
+	depends on KERNEL_FTRACE
+	default n
+
+config KERNEL_ENABLE_DEFAULT_TRACERS
+	bool "Trace process context switches and events"
+	depends on KERNEL_FTRACE
+	default n
+
+config KERNEL_FUNCTION_TRACER
+	bool "Function tracer"
+	depends on KERNEL_FTRACE
+	default n
+
+config KERNEL_FUNCTION_GRAPH_TRACER
+	bool "Function graph tracer"
+	depends on KERNEL_FUNCTION_TRACER
+	default n
+
+config KERNEL_DYNAMIC_FTRACE
+	bool "Enable/disable function tracing dynamically"
+	depends on KERNEL_FUNCTION_TRACER
+	default n
+
+config KERNEL_FUNCTION_PROFILER
+	bool "Function profiler"
+	depends on KERNEL_FUNCTION_TRACER
+	default n
+
+config KERNEL_DEBUG_KERNEL
+	bool
+	default n
+
+config KERNEL_DEBUG_INFO
+	bool "Compile the kernel with debug information"
+	default y if !SMALL_FLASH
+	select KERNEL_DEBUG_KERNEL
+	help
+	  This will compile your kernel and modules with debug information.
+
+config KERNEL_DEBUG_LL_UART_NONE
+	bool
+	default n
+	depends on arm
+
+config KERNEL_DEBUG_LL
+	bool
+	default n
+	depends on arm
+	select KERNEL_DEBUG_LL_UART_NONE
+	help
+	  ARM low level debugging.
+
+config KERNEL_DYNAMIC_DEBUG
+	bool "Compile the kernel with dynamic printk"
+	select KERNEL_DEBUG_FS
+	default n
+	help
+	  Compiles debug level messages into the kernel, which would not
+	  otherwise be available at runtime. These messages can then be
+	  enabled/disabled based on various levels of scope - per source file,
+	  function, module, format string, and line number. This mechanism
+	  implicitly compiles in all pr_debug() and dev_dbg() calls, which
+	  enlarges the kernel text size by about 2%.
+
+config KERNEL_EARLY_PRINTK
+	bool "Compile the kernel with early printk"
+	default y if TARGET_bcm53xx
+	default n
+	depends on arm
+	select KERNEL_DEBUG_KERNEL
+	select KERNEL_DEBUG_LL if arm
+	help
+	  Compile the kernel with early printk support.  This is only useful for
+	  debugging purposes to send messages over the serial console in early boot.
+	  Enable this to debug early boot problems.
+
+config KERNEL_KPROBES
+	bool "Compile the kernel with kprobes support"
+	default n
+	select KERNEL_FTRACE
+	select KERNEL_PERF_EVENTS
+	help
+	  Compiles the kernel with KPROBES support, which allows you to trap
+	  at almost any kernel address and execute a callback function.
+	  register_kprobe() establishes a probepoint and specifies the
+	  callback. Kprobes is useful for kernel debugging, non-intrusive
+	  instrumentation and testing.
+	  If in doubt, say "N".
+
+config KERNEL_KPROBE_EVENT
+	bool
+	default y if KERNEL_KPROBES
+
+config KERNEL_AIO
+	bool "Compile the kernel with asynchronous IO support"
+	default n
+
+config KERNEL_FHANDLE
+	bool "Compile the kernel with support for fhandle syscalls"
+	default n
+
+config KERNEL_FANOTIFY
+	bool "Compile the kernel with modern file notification support"
+	default n
+
+config KERNEL_BLK_DEV_BSG
+	bool "Compile the kernel with SCSI generic v4 support for any block device"
+	default n
+
+config KERNEL_MAGIC_SYSRQ
+	bool "Compile the kernel with SysRq support"
+	default y
+
+config KERNEL_DEBUG_PINCTRL
+	bool "Compile the kernel with pinctrl debugging"
+	select KERNEL_DEBUG_KERNEL
+
+config KERNEL_DEBUG_GPIO
+	bool "Compile the kernel with gpio debugging"
+	select KERNEL_DEBUG_KERNEL
+
+config KERNEL_COREDUMP
+	bool
+
+config KERNEL_ELF_CORE
+	bool "Enable process core dump support"
+	select KERNEL_COREDUMP
+	default y if !SMALL_FLASH
+
+config KERNEL_PROVE_LOCKING
+	bool "Enable kernel lock checking"
+	select KERNEL_DEBUG_KERNEL
+	default n
+
+config KERNEL_PRINTK_TIME
+	bool "Enable printk timestamps"
+	default y
+
+config KERNEL_SLUB_DEBUG
+	bool
+
+config KERNEL_SLUB_DEBUG_ON
+	bool
+
+config KERNEL_SLABINFO
+	select KERNEL_SLUB_DEBUG
+	select KERNEL_SLUB_DEBUG_ON
+	bool "Enable /proc slab debug info"
+
+config KERNEL_PROC_PAGE_MONITOR
+	bool "Enable /proc page monitoring"
+
+config KERNEL_RELAY
+	bool
+
+config KERNEL_KEXEC
+	bool "Enable kexec support"
+
+config KERNEL_PROC_VMCORE
+	bool
+
+config KERNEL_CRASH_DUMP
+	depends on i386 || x86_64 || arm || armeb
+	select KERNEL_KEXEC
+	select KERNEL_PROC_VMCORE
+	bool "Enable support for kexec crashdump"
+	default y
+
+config USE_RFKILL
+	bool "Enable rfkill support"
+	default RFKILL_SUPPORT
+
+config USE_SPARSE
+	bool "Enable sparse check during kernel build"
+	default n
+
+config KERNEL_DEVTMPFS
+	bool "Compile the kernel with device tmpfs enabled"
+	default n
+	help
+	  devtmpfs is a simple, kernel-managed /dev filesystem. The kernel creates
+	  devices nodes for all registered devices to simplify boot, but leaves more
+	  complex tasks to userspace (e.g. udev).
+
+if KERNEL_DEVTMPFS
+
+	config KERNEL_DEVTMPFS_MOUNT
+		bool "Automatically mount devtmpfs after root filesystem is mounted"
+		default n
+
+endif
+
+config KERNEL_KEYS
+    bool "Enable kernel access key retention support"
+    default n
+
+config KERNEL_PERSISTENT_KEYRINGS
+    bool "Enable kernel persistent keyrings"
+    depends on KERNEL_KEYS
+    default n
+
+config KERNEL_BIG_KEYS
+    bool "Enable large payload keys on kernel keyrings"
+    depends on KERNEL_KEYS
+    default n
+
+config KERNEL_ENCRYPTED_KEYS
+    tristate "Enable keys with encrypted payloads on kernel keyrings"
+    depends on KERNEL_KEYS
+    default n
+
+#
+# CGROUP support symbols
+#
+
+config KERNEL_CGROUPS
+	bool "Enable kernel cgroups"
+	default n
+
+if KERNEL_CGROUPS
+
+	config KERNEL_CGROUP_DEBUG
+		bool "Example debug cgroup subsystem"
+		default n
+		help
+		  This option enables a simple cgroup subsystem that
+		  exports useful debugging information about the cgroups
+		  framework.
+
+	config KERNEL_FREEZER
+		bool
+		default y if KERNEL_CGROUP_FREEZER
+
+	config KERNEL_CGROUP_FREEZER
+		bool "Freezer cgroup subsystem"
+		default y
+		help
+		  Provides a way to freeze and unfreeze all tasks in a
+		  cgroup.
+
+	config KERNEL_CGROUP_DEVICE
+		bool "Device controller for cgroups"
+		default y
+		help
+		  Provides a cgroup implementing whitelists for devices which
+		  a process in the cgroup can mknod or open.
+
+	config KERNEL_CGROUP_PIDS
+		bool "PIDs cgroup subsystem"
+		default y
+		help
+		  Provides enforcement of process number limits in the scope of a
+		  cgroup.
+
+	config KERNEL_CPUSETS
+		bool "Cpuset support"
+		default n
+		help
+		  This option will let you create and manage CPUSETs which
+		  allow dynamically partitioning a system into sets of CPUs and
+		  Memory Nodes and assigning tasks to run only within those sets.
+		  This is primarily useful on large SMP or NUMA systems.
+
+	config KERNEL_PROC_PID_CPUSET
+		bool "Include legacy /proc/<pid>/cpuset file"
+		default n
+		depends on KERNEL_CPUSETS
+
+	config KERNEL_CGROUP_CPUACCT
+		bool "Simple CPU accounting cgroup subsystem"
+		default n
+		help
+		  Provides a simple Resource Controller for monitoring the
+		  total CPU consumed by the tasks in a cgroup.
+
+	config KERNEL_RESOURCE_COUNTERS
+		bool "Resource counters"
+		default n
+		help
+		  This option enables controller independent resource accounting
+		  infrastructure that works with cgroups.
+
+	config KERNEL_MM_OWNER
+		bool
+		default y if KERNEL_MEMCG
+
+	config KERNEL_MEMCG
+		bool "Memory Resource Controller for Control Groups"
+		default n
+		depends on KERNEL_RESOURCE_COUNTERS || !LINUX_3_18
+		help
+		  Provides a memory resource controller that manages both anonymous
+		  memory and page cache. (See Documentation/cgroups/memory.txt)
+
+		  Note that setting this option increases fixed memory overhead
+		  associated with each page of memory in the system. By this,
+		  20(40)bytes/PAGE_SIZE on 32(64)bit system will be occupied by memory
+		  usage tracking struct at boot. Total amount of this is printed out
+		  at boot.
+
+		  Only enable when you're ok with these tradeoffs and really
+		  sure you need the memory resource controller. Even when you enable
+		  this, you can set "cgroup_disable=memory" at your boot option to
+		  disable memory resource controller and you can avoid overheads
+		  (but lose benefits of memory resource controller).
+
+		  This config option also selects MM_OWNER config option, which
+		  could in turn add some fork/exit overhead.
+
+	config KERNEL_MEMCG_SWAP
+		bool "Memory Resource Controller Swap Extension"
+		default n
+		depends on KERNEL_MEMCG
+		help
+		  Add swap management feature to memory resource controller. When you
+		  enable this, you can limit mem+swap usage per cgroup. In other words,
+		  when you disable this, memory resource controller has no cares to
+		  usage of swap...a process can exhaust all of the swap. This extension
+		  is useful when you want to avoid exhaustion swap but this itself
+		  adds more overheads and consumes memory for remembering information.
+		  Especially if you use 32bit system or small memory system, please
+		  be careful about enabling this. When memory resource controller
+		  is disabled by boot option, this will be automatically disabled and
+		  there will be no overhead from this. Even when you set this config=y,
+		  if boot option "swapaccount=0" is set, swap will not be accounted.
+		  Now, memory usage of swap_cgroup is 2 bytes per entry. If swap page
+		  size is 4096bytes, 512k per 1Gbytes of swap.
+
+	config KERNEL_MEMCG_SWAP_ENABLED
+		bool "Memory Resource Controller Swap Extension enabled by default"
+		default n
+		depends on KERNEL_MEMCG_SWAP
+		help
+		  Memory Resource Controller Swap Extension comes with its price in
+		  a bigger memory consumption. General purpose distribution kernels
+		  which want to enable the feature but keep it disabled by default
+		  and let the user enable it by swapaccount boot command line
+		  parameter should have this option unselected.
+
+		  Those who want to have the feature enabled by default should
+		  select this option (if, for some reason, they need to disable it,
+		  then swapaccount=0 does the trick).
+
+
+	config KERNEL_MEMCG_KMEM
+		bool "Memory Resource Controller Kernel Memory accounting (EXPERIMENTAL)"
+		default n
+		depends on KERNEL_MEMCG
+		help
+		  The Kernel Memory extension for Memory Resource Controller can limit
+		  the amount of memory used by kernel objects in the system. Those are
+		  fundamentally different from the entities handled by the standard
+		  Memory Controller, which are page-based, and can be swapped. Users of
+		  the kmem extension can use it to guarantee that no group of processes
+		  will ever exhaust kernel resources alone.
+
+	config KERNEL_CGROUP_PERF
+		bool "Enable perf_event per-cpu per-container group (cgroup) monitoring"
+		select KERNEL_PERF_EVENTS
+		default n
+		help
+		  This option extends the per-cpu mode to restrict monitoring to
+		  threads which belong to the cgroup specified and run on the
+		  designated cpu.
+
+	menuconfig KERNEL_CGROUP_SCHED
+		bool "Group CPU scheduler"
+		default n
+		help
+		  This feature lets CPU scheduler recognize task groups and control CPU
+		  bandwidth allocation to such task groups. It uses cgroups to group
+		  tasks.
+
+	if KERNEL_CGROUP_SCHED
+
+		config KERNEL_FAIR_GROUP_SCHED
+			bool "Group scheduling for SCHED_OTHER"
+			default n
+
+		config KERNEL_CFS_BANDWIDTH
+			bool "CPU bandwidth provisioning for FAIR_GROUP_SCHED"
+			default n
+			depends on KERNEL_FAIR_GROUP_SCHED
+			help
+			  This option allows users to define CPU bandwidth rates (limits) for
+			  tasks running within the fair group scheduler.  Groups with no limit
+			  set are considered to be unconstrained and will run with no
+			  restriction.
+			  See tip/Documentation/scheduler/sched-bwc.txt for more information.
+
+		config KERNEL_RT_GROUP_SCHED
+			bool "Group scheduling for SCHED_RR/FIFO"
+			default n
+			help
+			  This feature lets you explicitly allocate real CPU bandwidth
+			  to task groups. If enabled, it will also make it impossible to
+			  schedule realtime tasks for non-root users until you allocate
+			  realtime bandwidth for them.
+
+	endif
+
+	config KERNEL_BLK_CGROUP
+		bool "Block IO controller"
+		default y
+		help
+		  Generic block IO controller cgroup interface. This is the common
+		  cgroup interface which should be used by various IO controlling
+		  policies.
+
+		  Currently, CFQ IO scheduler uses it to recognize task groups and
+		  control disk bandwidth allocation (proportional time slice allocation)
+		  to such task groups. It is also used by bio throttling logic in
+		  block layer to implement upper limit in IO rates on a device.
+
+		  This option only enables generic Block IO controller infrastructure.
+		  One needs to also enable actual IO controlling logic/policy. For
+		  enabling proportional weight division of disk bandwidth in CFQ, set
+		  CONFIG_CFQ_GROUP_IOSCHED=y; for enabling throttling policy, set
+		  CONFIG_BLK_DEV_THROTTLING=y.
+
+	config KERNEL_DEBUG_BLK_CGROUP
+		bool "Enable Block IO controller debugging"
+		default n
+		depends on KERNEL_BLK_CGROUP
+		help
+		  Enable some debugging help. Currently it exports additional stat
+		  files in a cgroup which can be useful for debugging.
+
+	config KERNEL_NET_CLS_CGROUP
+		bool "Control Group Classifier"
+		default y
+
+	config KERNEL_NETPRIO_CGROUP
+		bool "Network priority cgroup"
+		default y
+
+endif
+
+#
+# Namespace support symbols
+#
+
+config KERNEL_NAMESPACES
+	bool "Enable kernel namespaces"
+	default n
+
+if KERNEL_NAMESPACES
+
+	config KERNEL_UTS_NS
+		bool "UTS namespace"
+		default y
+		help
+		  In this namespace, tasks see different info provided
+		  with the uname() system call.
+
+	config KERNEL_IPC_NS
+		bool "IPC namespace"
+		default y
+		help
+		  In this namespace, tasks work with IPC ids which correspond to
+		  different IPC objects in different namespaces.
+
+	config KERNEL_USER_NS
+		bool "User namespace (EXPERIMENTAL)"
+		default y
+		help
+		  This allows containers, i.e. vservers, to use user namespaces
+		  to provide different user info for different servers.
+
+	config KERNEL_PID_NS
+		bool "PID Namespaces"
+		default y
+		help
+		  Support process id namespaces. This allows having multiple
+		  processes with the same pid as long as they are in different
+		  pid namespaces. This is a building block of containers.
+
+	config KERNEL_NET_NS
+		bool "Network namespace"
+		default y
+		help
+		  Allow user space to create what appear to be multiple instances
+		  of the network stack.
+
+endif
+
+#
+# LXC related symbols
+#
+
+config KERNEL_LXC_MISC
+	bool "Enable miscellaneous LXC related options"
+	default n
+
+if KERNEL_LXC_MISC
+
+	config KERNEL_DEVPTS_MULTIPLE_INSTANCES
+		bool "Support multiple instances of devpts"
+		default y
+		help
+		  Enable support for multiple instances of devpts filesystem.
+		  If you want to have isolated PTY namespaces (eg: in containers),
+		  say Y here. Otherwise, say N. If enabled, each mount of devpts
+		  filesystem with the '-o newinstance' option will create an
+		  independent PTY namespace.
+
+	config KERNEL_POSIX_MQUEUE
+		bool "POSIX Message Queues"
+		default y
+		help
+		  POSIX variant of message queues is a part of IPC. In POSIX message
+		  queues every message has a priority which decides about succession
+		  of receiving it by a process. If you want to compile and run
+		  programs written e.g. for Solaris with use of its POSIX message
+		  queues (functions mq_*) say Y here.
+
+		  POSIX message queues are visible as a filesystem called 'mqueue'
+		  and can be mounted somewhere if you want to do filesystem
+		  operations on message queues.
+
+endif
+
+config KERNEL_SECCOMP_FILTER
+	bool
+	default n
+
+config KERNEL_SECCOMP
+	bool "Enable seccomp support"
+		depends on !(TARGET_uml)
+		select KERNEL_SECCOMP_FILTER
+		default n
+		help
+		  Build kernel with support for seccomp.
+
+#
+# IPv4 configuration
+#
+
+config KERNEL_IP_MROUTE
+	bool "Enable IPv4 multicast routing"
+	default y
+	help
+	  Multicast routing requires a multicast routing daemon in
+	  addition to kernel support.
+
+#
+# IPv6 configuration
+#
+
+config KERNEL_IPV6
+	def_bool IPV6
+
+if KERNEL_IPV6
+
+	config KERNEL_IPV6_MULTIPLE_TABLES
+		def_bool y
+
+	config KERNEL_IPV6_SUBTREES
+		def_bool y
+
+	config KERNEL_IPV6_MROUTE
+		bool "Enable IPv6 multicast routing"
+		default y
+		help
+		  Multicast routing requires a multicast routing daemon in
+		  addition to kernel support.
+
+	config KERNEL_IPV6_PIMSM_V2
+		def_bool n
+
+endif
+
+#
+# NFS related symbols
+#
+config KERNEL_IP_PNP
+	bool "Compile the kernel with rootfs on NFS"
+	help
+	   If you want to make your kernel boot off a NFS server as root
+	   filesystem, select Y here.
+
+if KERNEL_IP_PNP
+
+	config KERNEL_IP_PNP_DHCP
+		def_bool y
+
+	config KERNEL_IP_PNP_BOOTP
+		def_bool n
+
+	config KERNEL_IP_PNP_RARP
+		def_bool n
+
+	config KERNEL_NFS_FS
+		def_bool y
+
+	config KERNEL_NFS_V2
+		def_bool y
+
+	config KERNEL_NFS_V3
+		def_bool y
+
+	config KERNEL_ROOT_NFS
+		def_bool y
+
+endif
+
+menu "Filesystem ACL and attr support options"
+	config USE_FS_ACL_ATTR
+		bool "Use filesystem ACL and attr support by default"
+		default n
+		help
+		  Make using ACLs (e.g. POSIX ACL, NFSv4 ACL) the default
+		  for kernel and packages, except tmpfs, flash filesystems,
+		  and old NFS.  Also enable userspace extended attribute support
+		  by default.  (libreCMC already has an expection it will be
+		  present in the kernel).
+
+	config KERNEL_FS_POSIX_ACL
+		bool "Enable POSIX ACL support"
+		default y if USE_FS_ACL_ATTR
+
+	config KERNEL_BTRFS_FS_POSIX_ACL
+		bool "Enable POSIX ACL for BtrFS Filesystems"
+		select KERNEL_FS_POSIX_ACL
+		default y if USE_FS_ACL_ATTR
+
+	config KERNEL_EXT4_FS_POSIX_ACL
+		bool "Enable POSIX ACL for Ext4 Filesystems"
+		select KERNEL_FS_POSIX_ACL
+		default y if USE_FS_ACL_ATTR
+
+	config KERNEL_F2FS_FS_POSIX_ACL
+		bool "Enable POSIX ACL for F2FS Filesystems"
+		select KERNEL_FS_POSIX_ACL
+		default n
+
+	config KERNEL_JFFS2_FS_POSIX_ACL
+		bool "Enable POSIX ACL for JFFS2 Filesystems"
+		select KERNEL_FS_POSIX_ACL
+		default n
+
+	config KERNEL_TMPFS_POSIX_ACL
+		bool "Enable POSIX ACL for TMPFS Filesystems"
+		select KERNEL_FS_POSIX_ACL
+		default n
+
+	config KERNEL_CIFS_ACL
+		bool "Enable CIFS ACLs"
+		select KERNEL_FS_POSIX_ACL
+		default y if USE_FS_ACL_ATTR
+
+	config KERNEL_HFS_FS_POSIX_ACL
+		bool "Enable POSIX ACL for HFS Filesystems"
+		select KERNEL_FS_POSIX_ACL
+		default y if USE_FS_ACL_ATTR
+
+	config KERNEL_HFSPLUG_FS_POSIX_ACL
+		bool "Enable POSIX ACL for HFS+ Filesystems"
+		select KERNEL_FS_POSIX_ACL
+		default y if USE_FS_ACL_ATTR
+
+	config KERNEL_NFS_ACL_SUPPORT
+		bool "Enable ACLs for NFS"
+		default y if USE_FS_ACL_ATTR
+
+	config KERNEL_NFS_V3_ACL_SUPPORT
+		bool "Enable ACLs for NFSv3"
+		default n
+
+	config KERNEL_NFSD_V2_ACL_SUPPORT
+		bool "Enable ACLs for NFSDv2"
+		default n
+
+	config KERNEL_NFSD_V3_ACL_SUPPORT
+		bool "Enable ACLs for NFSDv3"
+		default n
+
+	config KERNEL_REISER_FS_POSIX_ACL
+		bool "Enable POSIX ACLs for ReiserFS"
+		select KERNEL_FS_POSIX_ACL
+		default y if USE_FS_ACL_ATTR
+
+	config KERNEL_XFS_POSIX_ACL
+		bool "Enable POSIX ACLs for XFS"
+		select KERNEL_FS_POSIX_ACL
+		default y if USE_FS_ACL_ATTR
+
+	config KERNEL_JFS_POSIX_ACL
+		bool "Enable POSIX ACLs for JFS"
+		select KERNEL_FS_POSIX_ACL
+		default y if USE_FS_ACL_ATTR
+
+endmenu
+
+config KERNEL_DEVMEM
+	bool "/dev/mem virtual device support"
+	help
+	  Say Y here if you want to support the /dev/mem device.
+	  The /dev/mem device is used to access areas of physical
+	  memory.
+
+config KERNEL_DEVKMEM
+	bool "/dev/kmem virtual device support"
+	help
+	  Say Y here if you want to support the /dev/kmem device. The
+	  /dev/kmem device is rarely used, but can be used for certain
+	  kind of kernel debugging operations.
+
+config KERNEL_SQUASHFS_FRAGMENT_CACHE_SIZE
+	int "Number of squashfs fragments cached"
+	default 2 if (SMALL_FLASH && !LOW_MEMORY_FOOTPRINT)
+	default 3
+
+#
+# compile optimiziation setting
+#
+choice
+	prompt "Compiler optimization level"
+	default KERNEL_CC_OPTIMIZE_FOR_SIZE if SMALL_FLASH
+
+config KERNEL_CC_OPTIMIZE_FOR_PERFORMANCE
+	bool "Optimize for performance"
+	help
+	  This is the default optimization level for the kernel, building
+	  with the "-O2" compiler flag for best performance and most
+	  helpful compile-time warnings.
+
+config KERNEL_CC_OPTIMIZE_FOR_SIZE
+	bool "Optimize for size"
+	help
+	  Enabling this option will pass "-Os" instead of "-O2" to
+	  your compiler resulting in a smaller kernel.
+
+endchoice

+ 96 - 0
docs/Basic_Wireless_Settings.md

@@ -0,0 +1,96 @@
+# Basic Wireless Settings
+
+This document is only intended to cover the most basic details of
+Wi-Fi settings on LibreCMC, for people who do not know much about
+computer networking. Geeks are encouraged to simply log in
+to `192.168.10.1` and experiment with the settings.
+
+## Log in to the LuCi configuration interface
+
+First, you need a physical connection to the LibreCMC Wi-Fi
+router. The simplest way is to connect an Ethernet cable between the
+Ethernet port on your computer, and the LAN port on your router. An
+Ethernet cable is like a fat telephone cable; usually you get one
+included with your router. Tablets and smart phones usually don't have
+an Ethernet port, so you might need to borrow a laptop.
+
+* In the address bar of your Web browser, enter the address
+  `192.168.10.1` and press `Enter` or `Return`. You should see a page
+  appear called `Authorization Required`.
+
+* If you see instead a page complaining that the connection is not
+  secure, you will need to add a security exception. On Mozilla
+  Firefox, you press the `Advanced` button and then the `Add
+  Exception` button, and then the `Confirm Security Exception`
+  button.
+  
+* Enter the adminstrative Username and Password for your router. The
+  default is `root` for the Username and a blank password.
+
+![alt text](images/librecmc-default-login.png "Default login page for
+ LibreCMC")
+
+If a blank password does not work, and you cannot figure out what it
+is supposed to be, you may need to
+[reset the router](Router_Reset_Instructions.md).
+
+If you are unable to view the `Authorization Required` page, it may be
+that you do not have your Ethernet cable connected to the correct
+ports, or your computer is not set to allow use of the Ethernet
+cable. Find a tech savvy relative to help you out.
+
+## Change the name of your Wi-Fi network
+
+* Select the `Network` >> `Wireless` menu.
+
+* Select the `Edit` button to the right side of "libreCMC".
+
+* Scroll down to the `ESSID` text field under the `Interface
+  Configuration` section. and enter the name you would like for your
+  Wi-Fi network. This is the name people will see when they are
+  looking to connect to your Wi-Fi network.
+
+![alt text](images/librecmc-changing-essid.png "Changing ESSID on LibreCMC")
+
+* If that is all you wanted to do, press the `Save & Apply` button at
+  the bottom of the page, or go on to the next section.
+
+## Change your Wi-Fi password
+
+* If you haven't already, Select the `Network` >> `Wireless` menu, and
+  select the `Edit` button to the right side of "libreCMC".
+
+* Select the `Wireless Security` tab under the `Interface
+  Configuration` section.
+
+* In the `Encryption` drop down menu select `WPA2-PSK`. (If you have
+  some really old devices on your network, it may be necessary to
+  select `WPA-PSK` instead, to get them to connect, but don't do this
+  unless you really need to.)
+
+* In the `Key` text field, put in the password you want people to use
+  to connect to your Wi-Fi network. If you press the green arrows
+  button, it will make it easier to type in the password.
+
+![alt text](images/librecmc-changing-wifi-password.png "Changing Wi-Fi
+ password on LibreCMC")
+
+* Press the `Save & Apply` button at the bottom of the page.
+
+## Change your Administrator password
+
+* There is a password used for logging into the LuCi configuration
+  interface. You typically want this to be different than the Wi-Fi password you share with other people.
+
+* Select the `System` >> `Administration` menu.
+
+* Under `Router Password` section, type a new password into the
+  `Password` text field. Pressing the green arrows button makes it
+  easier to type in your password.
+
+* Type the exact same password into the `Confirmation` text field.
+
+![alt text](images/librecmc-changing-admin-password.png "Changing
+ admin password on LibreCMC")
+
+* Press the `Save & Apply` button at the bottom of the page.

+ 263 - 0
docs/Ben_Nanonote.md

@@ -0,0 +1,263 @@
+
+## Overview
+
+* [JZ4720](https://web.archive.org/web/20110904201104/http://en.ingenic.cn/product.aspx?ID=60) 336 MHz MIPS compatible processor from [Ingenic Semiconductor Co.](http://www.ingenic.cn)
+
+* 3.0" 320x240 pixels [[LCD|colour TFT LCD]] (40x15 character in a text console)
+
+* 32MB [[SDRAM]] 
+
+* 2GB [[NAND|NAND Flash]] Memory
+
+* 1 [[SD|microSDHC]] slot (SDIO capable)
+
+* 59 keys Keyboard
+
+* Stereo headphones connector, mono speaker and microphone [[Audio_IN_OUT|audio interfaces]].
+
+* [USB](http://wiki.qi-hardware.com/wiki/USB_host) 2.0 High-Speed Device, [Mini B](http://en.wikipedia.org/wiki/USB#Connector_types) connector
+
+* 3.7V 850mAh Li-ion Battery ( [[Compatible_batteries|Compatible batteries]]) and 5V 500mA [[Power_Supply_Circuit|DC input through USB port]]
+
+* Measured battery life time, idle, screen off: 12h59
+
+* Overall dimension (lid closed): 99 * 75 * 17.5mm. (display: 7.5mm, keyboard: 10mm)
+
+* Weight: 126g (includes battery)
+
+## Status
+
+* Flashing bootloader, kernel, and rootfs via USB works.
+* Serial console via GND/RXD/TXD pads under the battery works.
+* LCD works
+** After a few minutes of inactivity on the console, it will go blank. Pressing any key brings it back.
+* Keyboard works
+* Audio/ALSA works.
+* ...
+
+## Pinouts
+
+PCB 08.50 (ben)
+
+'''Micro-SD pins on testpads:'''
+
+ Pin  TP     note
+ ------------------
+ #1   TP14   data2
+ #2   TP15   cd/data3 / _CS
+ #3   TP17   cmd / mosi
+ #4   sdVCC  switched by Q4 (fet?) controlled via line from cpu (on TP11)
+ #5   TP16   clock
+ #6   GND
+ #7   TP12   data0 / miso
+ #8   TP13   data1
+
+'''Serial pins:'''
+
+See [[Ben_source_code#serial_console]].
+
+== System information ==
+
+ $ '''cat /proc/cpuinfo'''
+ system type             : JZ4740
+ processor               : 0
+ cpu model               : Ingenic JZRISC V4.15
+ BogoMIPS                : 335.05
+ wait instruction        : yes                                                   
+ microsecond timers      : no                                                    
+ tlb_entries             : 32                                                    
+ extra interrupt vector  : yes                                                   
+ hardware watchpoint     : yes, count: 1, address/irw mask: [0x0fff]             
+ ASEs implemented        :                                                       
+ shadow register sets    : 1                                                     
+ core                    : 0                                                     
+ VCED exceptions         : not available                                         
+ VCEI exceptions         : not available                                         
+
+ $ '''cat /proc/mtd'''
+ dev:    size   erasesize  name
+ mtd0: 00400000 00080000 "NAND BOOT partition"
+ mtd1: 00400000 00080000 "NAND KERNEL partition"
+ mtd2: 20000000 00080000 "NAND ROOTFS partition"
+ mtd3: 5f800000 00080000 "NAND DATA partition"
+
+ $ '''uname -a'''
+ Linux BenNanoNote 2.6.32.27 #1 PREEMPT Sat Mar 5 03:54:50 MSK 2011 mips GNU/Linux
+
+ $ '''cat /proc/iomem'''
+ 00000000-01ffffff : System RAM
+   00010000-0031162b : Kernel code
+   0031162c-0040877f : Kernel data
+ 10003000-10003037 : jz4740-rtc
+   10003000-10003037 : jz4740-rtc
+ 10020000-10020037 : jz4740-i2s
+   10020000-10020037 : jz4740-i2s
+ 10020080-10020087 : jz4740-codec
+   10020080-10020087 : jz4740-codec
+ 10021000-10030fff : jz4740-mmc.0
+   10021000-10030fff : jz4740-mmc
+ 10070000-10070030 : jz4740-adc
+   10070000-10070030 : jz4740-adc
+ 13010000-1301ffff : jz4740-nand.0
+   13010000-1301ffff : jz4740-nand
+ 13030000-1303ffff : jz-ohci.0
+ 13040000-1304ffff : jz-udc
+   13040000-1304ffff : jz-udc
+ 13050000-1305ffff : jz4740-fb
+   13050000-1305ffff : jz4740-fb
+
+ $ '''cat /proc/interrupts'''
+           CPU0       
+   2:      33611            MIPS  JZ4740 cascade interrupt
+  17:         20            INTC  serial
+  20:         56            INTC  jz4740-adc
+  22:         47            INTC  MMC/SD
+  23:          0            INTC  jz4740-rtc
+  28:          0            INTC  DMA
+  31:      32374            INTC  jz4740-timerirq
+  32:        527            INTC  jz-udc
+ 147:          0     GPIO Bank C  jz4740-battery
+ 152:          0     GPIO Bank D  MMC/SD detect changed
+ 170:          0     GPIO Bank D  matrix-keypad
+ 171:         94     GPIO Bank D  matrix-keypad
+ 172:         77     GPIO Bank D  matrix-keypad
+ 173:         17     GPIO Bank D  matrix-keypad
+ 174:        151     GPIO Bank D  matrix-keypad
+ 175:         13     GPIO Bank D  matrix-keypad
+ 176:        235     GPIO Bank D  matrix-keypad
+ 178:          0     GPIO Bank D  matrix-keypad
+ 180:          0     GPIO Bank D  gpio-charger.0
+ 181:          0     GPIO Bank D  Power
+ ERR:          0
+
+== GPIO pins ==
+
+The Jz4720 has only a limited number of pins as outputs to the board.  Furthermore, several functions take up gpio pins which are therefore not usable for other functions.  Those devices are the sdram and nand controller, lcd controller and mmc+sd controller.  Below is a table showing how they are used.  Please complete this table.  The missing entries are not connected to a pad in the Jz4720.
+
+'''Port A:'''
+* 01      sdram data 0
+* 03      sdram data 1
+* 05      sdram data 2
+* 07      sdram data 3
+* 08      sdram data 4
+* 09      sdram data 5
+* 10      sdram data 6
+* 11      sdram data 7
+* 12      sdram data 8
+* 13      sdram data 9
+* 15      sdram data 10
+* 17      sdram data 11
+* 22      sdram data 12
+* 26      sdram data 13
+* 28      sdram data 14
+* 30      sdram data 15
+
+'''Port B:'''
+* 00      sdram address 0
+* 01      sdram address 1
+* 02      sdram address 2
+* 03      sdram address 3
+* 04      sdram address 4
+* 05      sdram address 5
+* 06      sdram address 6
+* 07      sdram address 7
+* 08      sdram address 8
+* 09      sdram address 9
+* 10      sdram address 10
+* 11      sdram address 11
+* 12      sdram address 12
+* 13      sdram address 13
+* 14      sdram address 14
+* 15      nand command latch
+* 16      nand address latch
+* 17      not connected (was marked "SHDN_HOST???", but schematic disagrees)
+* 18      TP23 (free)
+* 19      sdram dcs
+* 20      sdram ras
+* 21      sdram cas
+* 22      sdram write enable
+* 23      sdram cke
+* 24      sdram cko
+* 25      sdram cs1
+* 26      sdram cs2
+* 27      not connected (was marked "USB ID", but schematic disagrees)
+* 28      not connected
+* 29      Audio output enable (anti-pop control)
+* 30      TP25 (free)
+* 31      sdram write enable 0
+
+'''Port C:'''
+* 00      lcd data 0
+* 01      lcd data 1
+* 02      lcd data 2
+* 03      lcd data 3
+* 04      lcd data 4
+* 05      lcd data 5
+* 06      lcd data 6
+* 07      lcd data 7
+* 08      TP 35 (free)
+* 09      TP 36 (free)
+* 10      keyboard out 1, TP59
+* 11      keyboard out 2, TP60
+* 12      keyboard out 3, TP61
+* 13      keyboard out 4, TP62
+* 14      keyboard out 5, TP63
+* 15      keyboard out 6, TP64
+* 16      keyboard out 7, TP65
+* 17      keyboard out 8, TP66
+* 18      lcd pixel clock
+* 19      lcd hsync
+* 20      lcd vsync
+* 21      lcd SPI chipselect
+* 22      lcd SPI data
+* 23      lcd SPI clock
+* 24      sdram write enable 1
+* 27      Charge detect (analog input to read battery voltage).
+* 28      nand read enable
+* 29      nand write enable
+* 30      nand flash ready/busy
+* 31      not connected to a pad; PCSEL31 selects jtag (PCSEL31==0) or uart0 (PCSEL31==1) on pad 147(TxD)+148(RxD) (TP5+TP4).
+
+'''Port D:'''
+* 00      SD Card detect
+* 02      SD Card power enable
+* 04      Speaker AMP enable (no audio unless this output is pulled low).
+* 06      Low power indicator (if 0, battery power is low).
+* 08      SD Card command
+* 09      SD Card clock
+* 10      SD Card data 1
+* 11      SD Card data 2
+* 12      SD Card data 3
+* 13      SD Card data 4
+* 15      TP 38 (free)
+* 18      Keyboard in 1, TP67
+* 19      Keyboard in 2, TP68
+* 20      Keyboard in 3, TP69
+* 21      Keyboard in 4, TP70
+* 22      Keyboard in 5, TP71
+* 23      Keyboard in 6, TP72
+* 24      Keyboard in 7, TP73
+* 25      uart0 transmit, TP75
+* 26      Keyboard in 8 (uart0 receive), TP74
+* 27      Buzzer, controlled with pwm4.  Piezo-electric buzzer; not related to soundcard output.
+* 28      USB detect (0 if usb power is present).
+* 29      power button (0 if pressed).
+
+=== Sorted by function ===
+* buzzer: D27
+* audio: B29, D4
+* power button: D29
+* keyboard: C10, C11, C12, C13, C14, C15, C16, C17, D18, D19, D20, D21, D22, D23, D24, D26(also uart receive)
+* uart: C31, D25, D26(also keyboard), uart is also available on jtag pads TP4+TP5 (without gpio overload).
+* sd/mmc: D0, D2, D8, D9, D10, D11, D12, D13
+* usb: D28
+* battery: C27, D6
+* sdram: A1, A3, A5, A7, A8, A9, A10, A11, A12, A13, A15, A17, A22, A26, A28, A30, B0, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13, B14, B19, B10, B21, B22, B23, B24, B25, B26, B31, C24
+* nand: B15, B16, C28, C29, C30
+* lcd: C0, C1, C2, C3, C4, C5, C6, C7, C18, C19, C20, C21, C22, C23
+* only test points: B18, B30, C8, C9, D15
+* unconnected pads: B17, B27, B28
+
+[[Category:Ben NanoNote]]
+
+This content is dual licensed under CC-BY-SA and GFDL and was obtained from [http://en.qi-hardware.com/wiki/Hardware-Ben](http://en.qi-hardware.com/wiki/Hardware-Ben)

+ 101 - 0
docs/Bridge_Mode.md

@@ -0,0 +1,101 @@
+# Bridge Mode
+
+A common feature of COTS Wi-Fi routers is to be able to set the router
+to bridge mode, where the devices stops acting like an IP router
+(layer 3) and starts acting like an ethernet switch (layer
+2). LibreCMC does not actually have a bridge mode, but the same effect
+is achievable with two easy steps.
+
+1. Add the WAN ethernet port to the LAN bridge interface
+2. Set the DHCP server to ignore the LAN interface
+
+## Adjust the LAN bridge interface
+
+Go to the Network >> Interfaces page and press the EDIT button next to
+the LAN Network. Select the Physical Settings tab.
+
+![alt text](images/librecmc-default-interfaces.png "LibreCMC default
+ interfaces view")
+
+Place a checkmark in the box for the "eth0" interface for wan and
+wan6. (I suppose the interface name might vary amongst different
+routers.)
+
+![alt text](images/librecmc-eth0-added-to-lan.png "Adjustments to
+ LibreCMC interface physical settings")
+
+You can also check the box for Enable STP if desired. There doesn't
+seem to be any downside from this, though I suppose it would use a
+little more CPU cycles and memory. STP is a protocol intended to
+prevent infinite communication loops from forming in a network of
+layer 2 switches.
+
+## Adjust DHCP server settings
+
+On the same page, scroll down a little to the DHCP Server section. In
+the General Setup tab, check the "Ignore interface" box.
+
+![alt text](images/librecmc-dhcp-server-ignore-lan.png "Setting
+ LibreCMC DHCP server to ignore LAN interface")
+
+Save and apply your changes.
+
+## Communicating with LibreCMC in "bridge mode"
+
+Now that the DHCP server is turned off, the next time you connect to
+the libreCMC device, you will not be able to communicate with it. You
+must set your connecting device manually to be on the same
+subnet. Since the default libreCMC LAN IP address is 192.168.10.1/24,
+it should work to set your connecting device to IP address
+192.168.10.2/24.On Gnu/Linux systems, the command is usually `ip addr
+add 192.168.10.2/24 dev eth0` or `dev wlan0` if connecting wirelessly.
+
+Alternatively, you may set the libreCMC device to receive an IP
+address from another DHCP server on your network: go to back to the
+Network >> Interfaces page, press the EDIT button again next to the
+LAN Network, select the General Setup tab, and switch the Protocol
+from "Static address" to "DHCP client". (It seems that in LibreCMC,
+bridging the LAN interface to the WAN port disables the operation of
+the DHCP client on the WAN interface.) Of course, if you do this, be
+sure that your DHCP server has reserved a memorable IP address for the
+LibreCMC device's MAC address, so you don't have trouble finding it.
+
+![alt text](images/librecmc-switch-lan-to-dhcp.png)
+
+## Advanced
+
+These adjustments are not required, but they lead to a configuration
+which will be more consistent and have cleaner logs.
+
+### Disabling odhcpd (DHCP daemon)
+
+In bridge mode, you aren't going to want to serve DHCP out any
+interface. So you might as well just shut down the whole DHCP
+server. Log in via SSH, and run the commands:
+
+```
+/etc/init.d/odhcpd stop
+/etc/init.d/odhcpd disable
+```
+
+### Delete the WAN(6) interfaces
+
+From `Network` >> `Interfaces`, you can delete the WAN and WAN6
+interfaces. See also the "Add a LAN6 interface" section below.
+
+### Delete the WAN Firewall Zone
+
+From `Network` >> `Firewall` you can delete the WAN zone. If you do
+need a WAN firewall, then you should not be running in bridge mode in
+the first place.
+
+### Add a LAN6 Interface
+
+If you have IPv6 access, you will want an interface which receives an
+IPv6 address. From `Network` >> `Interfaces` create a new interface
+called `LAN6` with `Protocol` set to `DHCPv6 client`.
+
+You will likely also want to disable `odhcpd` (see above). Otherwise
+your logs can get filled up with unnecessary IPv6 related messages, as
+libreCMC tries to act like an IPv6 router. `odhcpd` normally handles
+DHCPv6 as well as IPv6 Router Advertisements.

+ 24 - 0
docs/Flavors.md

@@ -0,0 +1,24 @@
+# Three Flavors of libreCMC : What are they for?
+
+The libreCMC project ships different flavored images to achieve a desired result and 
+for the continued support of hardware with limited resources. These different flavors
+include:
+
+## Main
+
+Provides an easier to use out of the box experience; includes
+the luci web interface, full package management support and basic IPv6 stack. 
+These images only run on routers with 8M of flash or more.
+
+## Core
+
+A bare-bones image with package management, basic IPv6 stack and no web interface.
+These images run on routers with <8M of flash, but package management is limited on 4M targets.
+
+## Legacy
+
+While similar to Main images, these images are targeted at routers with 4M of flash;
+provide the luci web-ui (no ssl support), basic IPv6 stack and no package management.
+
+As always, libreCMC can be built from [source](https://gogs.librecmc.org/libreCMC/libreCMC/src/v1.4/docs/How_To_Build_libreCMC.md) or you can submit an [issue](https://gogs.librecmc.org/libreCMC/libreCMC/issues) to request
+a missing feature.

+ 46 - 0
docs/GL-AR300M.md

@@ -0,0 +1,46 @@
+# GL.iNet AR300M
+
+## Hardware Specs
+
+* SoC : Qualcomm Atheros QCA9531
+* Flash ROM : 16 MB Nor + 128 MB Nand
+* RAM : 128 MB
+
+## Flashing from factory
+
+### Using GL.iNet's U-boot-mod and web UI
+
+1) Set computer IP address to 192.168.1.2
+
+2) Connect the enternet from the computer to "lan" port on the router
+
+3) Press and hold the reset button, and power on the router by plugging in the power
+
+4) Wait until the LED flashes once and red LED flashes 5 times before releasing the reset button.
+
+5) Open IP address in the browser 192.168.1.1
+
+6) Select the .img for NAND and .bin for NOR
+
+
+## Tested
+
+* v1.4.2 librecmc-ar71xx-nand-gl-ar300m-ubi-factory.img
+
+## Reset Instructions
+
+????
+
+## Notes:
+
+* This router is currently not officially supported by Librecmc
+
+* This router is dual flash and stock uboot attempts to boot nand flash first.
+
+* NOR flash uses .bin image and NAND flash uses .img image.
+
+* Use librecmc-ar71xx-nand-gl-ar300m-squashfs-sysupgrade.tar to update NAND installations
+
+* Default router ip is 192.168.10.1
+
+* On KDE, Disable change ipv4 method from automatic to manual to set the computer ip to 192.168.1.2.

+ 61 - 0
docs/How To Submit A Change To This Wiki.md

@@ -0,0 +1,61 @@
+How To Submit A Change To This Wiki
+===================================
+This wiki is written in Markdown and all wiki documenation is located in /docs.
+
+
+Clone this repo and:
+--------------------
+
+    git clone https://gogs.librecmc.org/libreCMC/libreCMC.git
+    
+    
+Make desired documenation changes in /docs
+
+
+then
+
+    git push
+
+or
+
+    git request-pull -p
+
+### git push ( In Gogs )
+
+Clone the upstream repo in Gogs, then clone to your computer:
+
+    git clone https://yourUserName@yourURL
+
+Add upstream repo to be able to rebase to upstream point commit:
+
+    git remote add upstream https://gogs.librecmc.org/libreCMC/libreCMC.git
+    (git checkout -b optionalBranchName)
+    git push (--all)
+
+Create Push Request in Gogs:
+
+* Press the little green PR button in your own repo
+* Or go to <https://gogs.librecmc.org/libreCMC/libreCMC-wiki/pulls>
+
+### git request-pull -p ( Anywhere )
+
+Clone the upstream repo to your computer.
+
+    git add changedFile.md
+    git commit ( -m Short info what changed )
+    git log ( copy commit id )
+    git request-pull -p (start) URL (end)
+    git request-pull -p (commit in upstream repo) URL master
+
+Example for piping output to haste:
+
+    git request-pull -p b3b8926484feb37c33e5150facf315ef12b4612e https://gogs.librecmc.org/jonasbits2/libreCMC.git master | haste
+
+* Send to hastebin.com or any site you like
+* Paste link in IRC channel
+
+#### Links
+
+* <https://www.git-scm.com/docs/git-request-pull>
+* <https://hastebin.com/about.md>
+

+ 81 - 0
docs/How_To_Build_libreCMC.md

@@ -0,0 +1,81 @@
+# libreCMC build HOWTO
+
+This generic documentation is to help aid those who want to build libreCMC firmware images from source code. While this 
+documentation is not an exhaustive source of information, it should help those who would like to build their own firmware images
+or would like to develop firmware based upon libreCMC.
+
+While libreCMC does allow for building for other targets, not all of them have been tested to work with libreCMC and are not officially supported if they are not mentioned on the libreCMC wiki.
+
+libreCMC is licensed under the GPLv2 and contains code from other free software projects. Some code may be licensed under other free software licenses and will be noted. All software is to be distributed under the terms of the GPLv2 or their respective free software licenses.
+
+## What do I need to get started?
+
+* GNU/Linux distro (Trisquel, *buntu, Fedora or others)
+* GNU GCC / GCC-C++
+* build-essential (Debian-based distro) or base-devel (Parabola)
+* flex
+* gawk
+* wget
+* unzip
+* ncurses-dev (ncurses5-devel, etc..)
+* libghc-zlib-dev
+* libssl-dev 
+* patch
+* perl5
+* subversion
+* git-core 
+* 8 - 10 GB of disk space
+* 4 GB of RAM (8 GB or more is recommended)
+
+## Building libreCMC
+
+1) Get the latest libreCMC source code:
+
+`git clone https://gogs.librecmc.org/libreCMC/libreCMC.git`
+
+or download a [release](https://gogs.librecmc.org/libreCMC/libreCMC/releases)
+
+If you want to build packages found in libreCMC's package feed, update and install the make files 
+by running the following from `$SRC_ROOT`:
+
+`./scripts/feeds update && ./scripts/feeds install -a`
+
+This will pull the makefiles for the package feed and make them available for selection 
+when configuring your build of libreCMC.
+
+2) Configure libreCMC for your device. 
+
+ `make menuconfig` 
+
+ When configuring libreCMC for your device, it is imperative that the right target and profile are selected. Currently, we only _officially_ support the AR71XX target and the TP-Link TL-MR3020 and Netgear WNDR3800. If you want other packages, please keep in mind that these devices don't have very much in terms of flash ROM and your selection of packages may not work properly. Generally, a good default configuration includes:
+
+
+ * luci : Collections -> luci  + luci -> protocols -> luci-proto-relayd
+ * Networking : wpa-cli + wpa-supplicant + iw
+ * Utilities : Editors -> Nano
+
+3) When done configuring, run:
+
+ `make`
+
+ If the build fails, type:
+
+ `make V=s`
+ 
+ The build process can be accelerated by running multiple concurrent job processes using the -j-option:
+ 
+ `make -j <your number of CPU cores + 1>`
+ 
+ To avoid build errors with -j option, it is advised to pre-fetch all source code for all dependencies before :
+ 
+ `make download`
+
+ if there are missing dependencies in your build environment, please install them and then run `make`.
+
+4) If the build exits without any errors, you should have a new image in:
+
+ `$SRC_ROOT/bin/$BUILD_TARGET/librecmc-$BUILD_TARGET-generic-$TARGET_PROFILE-$VERSION-$FS_TYPE-factory.bin`
+
+ Where `$BUILD_TARGET = target (ex. ar71xx)`, `$TARGET_PROFILE = device`, `$VERSION = device version (some don't any)`
+
+5) Flash the newly built image (if you are confident). libreCMC project is not responsible for bricked devices.

+ 15 - 0
docs/Image_Support.md

@@ -0,0 +1,15 @@
+# libreCMC image support
+
+libreCMC is distributed in 3 different flavors: main, core and legacy. 
+Each image type is for a specific use case or to extend support for a 
+specific class of devices.
+
+
+| image type | Web-ui support    |Package Management | Min. Flash Size | Target Examples     | Use Case |
+|-----------:|-------------:|------------------:|-----------:|--------------------:|---------:|
+| Main     | Yes          | Yes	        | 8M      |                  | Easy to use |
+| Core       | No           | Yes               | 4M      |            | Minimal, more control | 
+| Legacy    | No	    | No	        | 4M	     | TL-WR741ND, TL-WR841ND,TPE-NWIFIROUTER* | Easy to use for legacy targets... |
+
+
+# NOT READY YET!

+ 430 - 0
docs/LICENSE.md

@@ -0,0 +1,430 @@
+```
+Attribution-ShareAlike 4.0 International
+
+=======================================================================
+
+Creative Commons Corporation ("Creative Commons") is not a law firm and
+does not provide legal services or legal advice. Distribution of
+Creative Commons public licenses does not create a lawyer-client or
+other relationship. Creative Commons makes its licenses and related
+information available on an "as-is" basis. Creative Commons gives no
+warranties regarding its licenses, any material licensed under their
+terms and conditions, or any related information. Creative Commons
+disclaims all liability for damages resulting from their use to the
+fullest extent possible.
+
+Using Creative Commons Public Licenses
+
+Creative Commons public licenses provide a standard set of terms and
+conditions that creators and other rights holders may use to share
+original works of authorship and other material subject to copyright
+and certain other rights specified in the public license below. The
+following considerations are for informational purposes only, are not
+exhaustive, and do not form part of our licenses.
+
+     Considerations for licensors: Our public licenses are
+     intended for use by those authorized to give the public
+     permission to use material in ways otherwise restricted by
+     copyright and certain other rights. Our licenses are
+     irrevocable. Licensors should read and understand the terms
+     and conditions of the license they choose before applying it.
+     Licensors should also secure all rights necessary before
+     applying our licenses so that the public can reuse the
+     material as expected. Licensors should clearly mark any
+     material not subject to the license. This includes other CC-
+     licensed material, or material used under an exception or
+     limitation to copyright. More considerations for licensors:
+	wiki.creativecommons.org/Considerations_for_licensors
+
+     Considerations for the public: By using one of our public
+     licenses, a licensor grants the public permission to use the
+     licensed material under specified terms and conditions. If
+     the licensor's permission is not necessary for any reason--for
+     example, because of any applicable exception or limitation to
+     copyright--then that use is not regulated by the license. Our
+     licenses grant only permissions under copyright and certain
+     other rights that a licensor has authority to grant. Use of
+     the licensed material may still be restricted for other
+     reasons, including because others have copyright or other
+     rights in the material. A licensor may make special requests,
+     such as asking that all changes be marked or described.
+     Although not required by our licenses, you are encouraged to
+     respect those requests where reasonable. More_considerations
+     for the public: 
+	wiki.creativecommons.org/Considerations_for_licensees
+
+=======================================================================
+
+Creative Commons Attribution-ShareAlike 4.0 International Public
+License
+
+By exercising the Licensed Rights (defined below), You accept and agree
+to be bound by the terms and conditions of this Creative Commons
+Attribution-ShareAlike 4.0 International Public License ("Public
+License"). To the extent this Public License may be interpreted as a
+contract, You are granted the Licensed Rights in consideration of Your
+acceptance of these terms and conditions, and the Licensor grants You
+such rights in consideration of benefits the Licensor receives from
+making the Licensed Material available under these terms and
+conditions.
+
+
+Section 1 -- Definitions.
+
+  a. Adapted Material means material subject to Copyright and Similar
+     Rights that is derived from or based upon the Licensed Material
+     and in which the Licensed Material is translated, altered,
+     arranged, transformed, or otherwise modified in a manner requiring
+     permission under the Copyright and Similar Rights held by the
+     Licensor. For purposes of this Public License, where the Licensed
+     Material is a musical work, performance, or sound recording,
+     Adapted Material is always produced where the Licensed Material is
+     synched in timed relation with a moving image.
+
+  b. Adapter's License means the license You apply to Your Copyright
+     and Similar Rights in Your contributions to Adapted Material in
+     accordance with the terms and conditions of this Public License.
+
+  c. BY-SA Compatible License means a license listed at
+     creativecommons.org/compatiblelicenses, approved by Creative
+     Commons as essentially the equivalent of this Public License.
+
+  d. Copyright and Similar Rights means copyright and/or similar rights
+     closely related to copyright including, without limitation,
+     performance, broadcast, sound recording, and Sui Generis Database
+     Rights, without regard to how the rights are labeled or
+     categorized. For purposes of this Public License, the rights
+     specified in Section 2(b)(1)-(2) are not Copyright and Similar
+     Rights.
+
+  e. Effective Technological Measures means those measures that, in the
+     absence of proper authority, may not be circumvented under laws
+     fulfilling obligations under Article 11 of the WIPO Copyright
+     Treaty adopted on December 20, 1996, and/or similar international
+     agreements.
+
+  f. Exceptions and Limitations means fair use, fair dealing, and/or
+     any other exception or limitation to Copyright and Similar Rights
+     that applies to Your use of the Licensed Material.
+
+  g. License Elements means the license attributes listed in the name
+     of a Creative Commons Public License. The License Elements of this
+     Public License are Attribution and ShareAlike.
+
+  h. Licensed Material means the artistic or literary work, database,
+     or other material to which the Licensor applied this Public
+     License.
+
+  i. Licensed Rights means the rights granted to You subject to the
+     terms and conditions of this Public License, which are limited to
+     all Copyright and Similar Rights that apply to Your use of the
+     Licensed Material and that the Licensor has authority to license.
+
+  j. Licensor means the individual(s) or entity(ies) granting rights
+     under this Public License.
+
+  k. Share means to provide material to the public by any means or
+     process that requires permission under the Licensed Rights, such
+     as reproduction, public display, public performance, distribution,
+     dissemination, communication, or importation, and to make material
+     available to the public including in ways that members of the
+     public may access the material from a place and at a time
+     individually chosen by them.
+
+  l. Sui Generis Database Rights means rights other than copyright
+     resulting from Directive 96/9/EC of the European Parliament and of
+     the Council of 11 March 1996 on the legal protection of databases,
+     as amended and/or succeeded, as well as other essentially
+     equivalent rights anywhere in the world.
+
+  m. You means the individual or entity exercising the Licensed Rights
+     under this Public License. Your has a corresponding meaning.
+
+
+Section 2 -- Scope.
+
+  a. License grant.
+
+       1. Subject to the terms and conditions of this Public License,
+          the Licensor hereby grants You a worldwide, royalty-free,
+          non-sublicensable, non-exclusive, irrevocable license to
+          exercise the Licensed Rights in the Licensed Material to:
+
+            a. reproduce and Share the Licensed Material, in whole or
+               in part; and
+
+            b. produce, reproduce, and Share Adapted Material.
+
+       2. Exceptions and Limitations. For the avoidance of doubt, where
+          Exceptions and Limitations apply to Your use, this Public
+          License does not apply, and You do not need to comply with
+          its terms and conditions.
+
+       3. Term. The term of this Public License is specified in Section
+          6(a).
+
+       4. Media and formats; technical modifications allowed. The
+          Licensor authorizes You to exercise the Licensed Rights in
+          all media and formats whether now known or hereafter created,
+          and to make technical modifications necessary to do so. The
+          Licensor waives and/or agrees not to assert any right or
+          authority to forbid You from making technical modifications
+          necessary to exercise the Licensed Rights, including
+          technical modifications necessary to circumvent Effective
+          Technological Measures. For purposes of this Public License,
+          simply making modifications authorized by this Section 2(a)
+          (4) never produces Adapted Material.
+
+       5. Downstream recipients.
+
+            a. Offer from the Licensor -- Licensed Material. Every
+               recipient of the Licensed Material automatically
+               receives an offer from the Licensor to exercise the
+               Licensed Rights under the terms and conditions of this
+               Public License.
+
+            b. Additional offer from the Licensor -- Adapted Material.
+               Every recipient of Adapted Material from You
+               automatically receives an offer from the Licensor to
+               exercise the Licensed Rights in the Adapted Material
+               under the conditions of the Adapter's License You apply.
+
+            c. No downstream restrictions. You may not offer or impose
+               any additional or different terms or conditions on, or
+               apply any Effective Technological Measures to, the
+               Licensed Material if doing so restricts exercise of the
+               Licensed Rights by any recipient of the Licensed
+               Material.
+
+       6. No endorsement. Nothing in this Public License constitutes or
+          may be construed as permission to assert or imply that You
+          are, or that Your use of the Licensed Material is, connected
+          with, or sponsored, endorsed, or granted official status by,
+          the Licensor or others designated to receive attribution as
+          provided in Section 3(a)(1)(A)(i).
+
+  b. Other rights.
+
+       1. Moral rights, such as the right of integrity, are not
+          licensed under this Public License, nor are publicity,
+          privacy, and/or other similar personality rights; however, to
+          the extent possible, the Licensor waives and/or agrees not to
+          assert any such rights held by the Licensor to the limited
+          extent necessary to allow You to exercise the Licensed
+          Rights, but not otherwise.
+
+       2. Patent and trademark rights are not licensed under this
+          Public License.
+
+       3. To the extent possible, the Licensor waives any right to
+          collect royalties from You for the exercise of the Licensed
+          Rights, whether directly or through a collecting society
+          under any voluntary or waivable statutory or compulsory
+          licensing scheme. In all other cases the Licensor expressly
+          reserves any right to collect such royalties.
+
+
+Section 3 -- License Conditions.
+
+Your exercise of the Licensed Rights is expressly made subject to the
+following conditions.
+
+  a. Attribution.
+
+       1. If You Share the Licensed Material (including in modified
+          form), You must:
+
+            a. retain the following if it is supplied by the Licensor
+               with the Licensed Material:
+
+                 i. identification of the creator(s) of the Licensed
+                    Material and any others designated to receive
+                    attribution, in any reasonable manner requested by
+                    the Licensor (including by pseudonym if
+                    designated);
+
+                ii. a copyright notice;
+
+               iii. a notice that refers to this Public License;
+
+                iv. a notice that refers to the disclaimer of
+                    warranties;
+
+                 v. a URI or hyperlink to the Licensed Material to the
+                    extent reasonably practicable;
+
+            b. indicate if You modified the Licensed Material and
+               retain an indication of any previous modifications; and
+
+            c. indicate the Licensed Material is licensed under this
+               Public License, and include the text of, or the URI or
+               hyperlink to, this Public License.
+
+       2. You may satisfy the conditions in Section 3(a)(1) in any
+          reasonable manner based on the medium, means, and context in
+          which You Share the Licensed Material. For example, it may be
+          reasonable to satisfy the conditions by providing a URI or
+          hyperlink to a resource that includes the required
+          information.
+
+       3. If requested by the Licensor, You must remove any of the
+          information required by Section 3(a)(1)(A) to the extent
+          reasonably practicable.
+
+  b. ShareAlike.
+
+     In addition to the conditions in Section 3(a), if You Share
+     Adapted Material You produce, the following conditions also apply.
+
+       1. The Adapter's License You apply must be a Creative Commons
+          license with the same License Elements, this version or
+          later, or a BY-SA Compatible License.
+
+       2. You must include the text of, or the URI or hyperlink to, the
+          Adapter's License You apply. You may satisfy this condition
+          in any reasonable manner based on the medium, means, and
+          context in which You Share Adapted Material.
+
+       3. You may not offer or impose any additional or different terms
+          or conditions on, or apply any Effective Technological
+          Measures to, Adapted Material that restrict exercise of the
+          rights granted under the Adapter's License You apply.
+
+
+Section 4 -- Sui Generis Database Rights.
+
+Where the Licensed Rights include Sui Generis Database Rights that
+apply to Your use of the Licensed Material:
+
+  a. for the avoidance of doubt, Section 2(a)(1) grants You the right
+     to extract, reuse, reproduce, and Share all or a substantial
+     portion of the contents of the database;
+
+  b. if You include all or a substantial portion of the database
+     contents in a database in which You have Sui Generis Database
+     Rights, then the database in which You have Sui Generis Database
+     Rights (but not its individual contents) is Adapted Material,
+
+     including for purposes of Section 3(b); and
+  c. You must comply with the conditions in Section 3(a) if You Share
+     all or a substantial portion of the contents of the database.
+
+For the avoidance of doubt, this Section 4 supplements and does not
+replace Your obligations under this Public License where the Licensed
+Rights include other Copyright and Similar Rights.
+
+
+Section 5 -- Disclaimer of Warranties and Limitation of Liability.
+
+  a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
+     EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
+     AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
+     ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
+     IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
+     WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
+     PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
+     ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
+     KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
+     ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
+
+  b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
+     TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
+     NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
+     INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
+     COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
+     USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
+     ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
+     DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
+     IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
+
+  c. The disclaimer of warranties and limitation of liability provided
+     above shall be interpreted in a manner that, to the extent
+     possible, most closely approximates an absolute disclaimer and
+     waiver of all liability.
+
+
+Section 6 -- Term and Termination.
+
+  a. This Public License applies for the term of the Copyright and
+     Similar Rights licensed here. However, if You fail to comply with
+     this Public License, then Your rights under this Public License
+     terminate automatically.
+
+  b. Where Your right to use the Licensed Material has terminated under
+     Section 6(a), it reinstates:
+
+       1. automatically as of the date the violation is cured, provided
+          it is cured within 30 days of Your discovery of the
+          violation; or
+
+       2. upon express reinstatement by the Licensor.
+
+     For the avoidance of doubt, this Section 6(b) does not affect any
+     right the Licensor may have to seek remedies for Your violations
+     of this Public License.
+
+  c. For the avoidance of doubt, the Licensor may also offer the
+     Licensed Material under separate terms or conditions or stop
+     distributing the Licensed Material at any time; however, doing so
+     will not terminate this Public License.
+
+  d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
+     License.
+
+
+Section 7 -- Other Terms and Conditions.
+
+  a. The Licensor shall not be bound by any additional or different
+     terms or conditions communicated by You unless expressly agreed.
+
+  b. Any arrangements, understandings, or agreements regarding the
+     Licensed Material not stated herein are separate from and
+     independent of the terms and conditions of this Public License.
+
+
+Section 8 -- Interpretation.
+
+  a. For the avoidance of doubt, this Public License does not, and
+     shall not be interpreted to, reduce, limit, restrict, or impose
+     conditions on any use of the Licensed Material that could lawfully
+     be made without permission under this Public License.
+
+  b. To the extent possible, if any provision of this Public License is
+     deemed unenforceable, it shall be automatically reformed to the
+     minimum extent necessary to make it enforceable. If the provision
+     cannot be reformed, it shall be severed from this Public License
+     without affecting the enforceability of the remaining terms and
+     conditions.
+
+  c. No term or condition of this Public License will be waived and no
+     failure to comply consented to unless expressly agreed to by the
+     Licensor.
+
+  d. Nothing in this Public License constitutes or may be interpreted
+     as a limitation upon, or waiver of, any privileges and immunities
+     that apply to the Licensor or You, including from the legal
+     processes of any jurisdiction or authority.
+
+
+=======================================================================
+
+Creative Commons is not a party to its public
+licenses. Notwithstanding, Creative Commons may elect to apply one of
+its public licenses to material it publishes and in those instances
+will be considered the “Licensor.” The text of the Creative Commons
+public licenses is dedicated to the public domain under the CC0 Public
+Domain Dedication. Except for the limited purpose of indicating that
+material is shared under a Creative Commons public license or as
+otherwise permitted by the Creative Commons policies published at
+creativecommons.org/policies, Creative Commons does not authorize the
+use of the trademark "Creative Commons" or any other trademark or logo
+of Creative Commons without its prior written consent including,
+without limitation, in connection with any unauthorized modifications
+to any of its public licenses or any other arrangements,
+understandings, or agreements concerning use of licensed material. For
+the avoidance of doubt, this paragraph does not form part of the
+public licenses.
+
+Creative Commons may be contacted at creativecommons.org.
+
+```

+ 22 - 0
docs/List_of_Tested_Hardware.md

@@ -0,0 +1,22 @@
+# List of Tested Devices
+
+| Device Name  | Contributor |  Bootloader Flashed? |
+|-------------------------------------|:-------------:|------:|
+| Netgear WNDR3700 v1        |  orly_owl |  ??? |
+| TP-Link TL-WA901ND v3       |  jonasbits  |  ??? |
+| TP-Link TL-WR710N v2.0    |  jonasbits  |  ??? |
+| TP-Link TL-WR741ND v1.8  |  yang  |  ???|
+| TP-Link TL-WR841ND v5.2  |  orly_owl |  ??? |
+| TP-Link TL-WR841ND v8.2  | RISCi_ATOM, yang| Yes, u-boot_mod|
+| TP-Link TL-WR842ND v2.0  |  zeus |  No |
+| TP-Link TL-WR1043ND v1.8| orly_owl | ??? |
+| TP-Link TL-WR1043ND v2.1| RISCi_ATOM | ??? |
+| D-Link DGL-5500 vA1 rm' wifi card| RISCi_ATOM | ??? |
+| Western Digital MyNet N750 | orly_owl | ??? |
+
+Please note that not all of the devices on the above list are officially supported by the libreCMC
+project. In order for a device to be officially supported, it needs to meet the following rules:
+
+* libreCMC must be flashable from stock firmware (without the usage of non-free software).
+* The bootloader must be free software and flashable with a serial cable + Ethernet cable or from within libreCMC.
+* Components including( wifi, switch, video, etc..) must not require blobs to work.

+ 103 - 0
docs/OpenVPN_Layer_2_Server.md

@@ -0,0 +1,103 @@
+# OpenVPN Layer 2 Server
+
+## Introduction
+
+Librecmc can operate as an OpenVPN server. OpenVPN technology connects
+two networks via an encrypted tunnel. With proper server, network, and
+client configuration, OpenVPN allows a client outside of your LAN to
+see the LAN as though it were physically connected to the LAN.
+
+OpenVPN can run in layer 2 or layer 3 mode. In layer 3 mode, the
+remote client sees your LAN as though it is on the other side of an IP
+router. In layer 2 mode, the remote client sees your LAN as though
+they are both on the same Data Link segment (e.g., the same Ethernet
+link). Layer 3 mode is easier to set up, but layer 2 mode is sometimes
+desired to give clients a more direct exposure to services on the LAN.
+
+## Warnings
+
+This information is provided for educational purposes only and is not
+meant to be a guide to best network security practices. Readers are
+advised to study all relevant OpenVPN and network security
+documentation.
+
+## Required LibreCMC packages
+
+* openvpn-openssl
+* openvpn-easy-rsa
+* luci-app-openvpn
+
+## Interface Setup
+
+In LuCi, select `Network` >> `Interfaces` and then `Add New Interface`.
+
+- Set `Name of the new interface` to `myvpn` or anything else you would like.
+- Set `Protocol of the new interface` to unmanaged.
+- Set `Cover the following interface` to `Custom Interface: vpn0`.
+- In my current working system, the `firewall-zone` for the interface
+  is set to `lan`, but I don't think that really matters in this case.
+
+In my working configuration, I added tap0 into the LAN bridge
+interface, and deleted the WAN interface. However, my vpn server is a
+separate unit on my network, intended to operate in "bridge mode",
+where if you server is your gateway router, a different configuration
+might be necessary.
+
+## Certificate and Key Setup Instructions
+
+```
+cd /etc/easy-rsa
+source vars
+clean-all
+build-ca
+build-dh
+build-key-server myvpn
+openvpn --genkey --secret /etc/easy-rsa/keys/ta.key
+mkdir -m 700 /etc/openvpn/keys
+mv ca.crt myvpn.crt myvpn.key dh2018.pem /etc/openvpn/keys
+```
+
+N.B.: Using easy-rsa is a straightforward approach, but it may be
+possible to produce more secure certificates using openssl directly.
+
+## Server configuration
+
+For the `server bridge` option: The first two parameters are the ip
+and netmask of the gateway on the bridged subnet. The next two
+parameters indicate the pool-start-IP and pool-end-IP, which is the
+part of your IP address pool that you have reserved just for VPN
+clients. You must to make sure that the DHCP server for your LAN is
+not leasing out those IP addresses to local (non-vpn) clients.
+
+/etc/config/openvpn
+```
+config openvpn 'myvpn'
+	option enabled '1'
+	option dev 'tap0'
+	option port '1194'
+	option proto 'udp'
+	option keepalive '10 120'
+	option persist_key '1'
+	option persist_tun '1'
+	option user 'nobody'
+	option group 'nogroup'
+	option ca '/etc/openvpn/keys/ca.crt'
+	option cert '/etc/openvpn/keys/myvpn.crt'
+	option key '/etc/openvpn/keys/myvpn.key'
+	option dh '/etc/openvpn/keys/dh2048.pem'
+	option tls_server '1'
+	option tls_auth '/etc/openvpn/keys/ta.key 0'
+	option server_bridge '10.0.0.1 255.255.255.0 10.0.0.201 10.0.0.220'
+	option client_to_client '1'
+	list push 'persist-key'
+	list push 'persist-tun'
+	list push 'redirect-gateway def1'
+	list push 'route 10.0.0.0 255.255.255.0'
+	list push 'dhcp-option DNS 10.0.0.1'
+	option mute '15'
+	option verb '3'
+```
+
+## Client setup information
+
+TODO

+ 84 - 0
docs/Port_Forwards.md

@@ -0,0 +1,84 @@
+# Port Forwarding
+
+## What is port forwarding?
+
+Technically, port forwarding is the use of Network Address Translation
+(NAT) to map an IP address and port number to another IP address and
+port number. Typically you need this function to be able to expose a
+service running our your local network (LAN) to the Internet (WAN)
+which otherwise would be impossible because your LAN uses private,
+non-routable IP addresses; for example, if you are trying to run a
+gaming server or a Web page server from your home network.
+
+## Security Warnings
+
+Be aware that the use of port forwarding may create additional
+security holes into your local network. The local system(s) and
+service(s) you are exposing to the Internet must be free from security
+vulnerabilities, or this may allow a remote attacker to infiltrate
+your network.
+
+## LuCi Interface
+
+* Log into the LuCi Web interface, which by default is at address https://192.168.10.1
+
+* Select the `Network` >> `Firewall` menu.
+
+![alt text](images/librecmc-selecting-firewall-menu.png "Selecting the
+ Firewall menu entry")
+
+* Select the `Port Forwards` tab.
+
+![alt text](images/librecmc-selecting-port-forwards-tab.png "Selecting the
+ Port Forwards tab")
+
+* Under the `New Port forward` section, enter in the `Name` field a
+  brief description of the port forward, e.g., "HTTP server" for an
+  unencrypted Web page server.
+
+* Select a protocol from the `Protocol` field. Most services you can
+  run will be using the TCP protocol, but you can select `TCP+UDP` if
+  you aren't sure.
+
+* Usually, you will leave the `External zone` set to `wan`.
+
+* Enter a port number in the `External port` field. Typically this
+  will be the usual port number expected for a particular
+  service. E.g., HTTP servers use port 80. You are free to use
+  non-standard ports, but your remote clients may need to use special
+  techniques to connect to the correct port.
+
+* Usually, you will leave the `Internal zone` set to `lan`.
+
+* Select an IP address in the `Internal IP address` drop down menu. If
+  your server is using DHCP, you should see its hostname appear in the
+  list. If your server is has it's private IP address set statically,
+  select the `Custom` option at the bottom of the list, and enter in
+  the correct IP address in the text field that appears. Note that if
+  your server is using DHCP, you should be sure LibreCMC has a static
+  lease created for it (TODO: link to Static Leases documentation).
+
+* Enter a port number in the `Internal port` field. Typically this
+  will be the same as the external port, unless you have set your
+  server to work through a non-standard port, or you selected a
+  non-standard external port earlier.
+
+![alt text](images/librecmc-port-forwards-entering-parameters.png
+ "Entering parameters for port forwarding")
+
+* Press the `Add` button to the right.
+
+* Press the `Save & Apply` button at the bottom of the page.
+
+![alt text](images/librecmc-port-forwards-after-save-apply.png
+ "Port Forwards view after Save & Apply")
+
+## Port Numbers
+
+The official IANA port number list is available at
+
+[https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml]
+
+## Port Range
+
+(TODO: option for configuring a range of ports simultaneously)

+ 15 - 0
docs/README.md

@@ -0,0 +1,15 @@
+# libreCMC : The _libre_ Embedded GNU/Linux Distro.
+
+libreCMC is a set of fully [free](http://www.gnu.org/philosophy/free-sw.en.html) embedded Operating Systems for general purpose computers. It aims to give its users freedom and control over the software that runs on their hardware. Most of the hardware that libreCMC supports includes a wide range of routers and some small single board computers.
+
+## Useful links:
+
+* [Get libreCMC source code](https://gogs.librecmc.org/libreCMC/libreCMC) : Checkout the latest libreCMC sources.
+
+* [Supported Hardware](Supported_Hardware.md): Devices officially supported by libreCMC.
+
+* [Router reset instructions](Router_Reset_Instructions.md) : Generic libreCMC router reset instructions.
+
+* [Report a bug or issue](https://gogs.librecmc.org/libreCMC/libreCMC/issues) : Is something broken? Did you find a non-free component or do you want to make libreCMC better? Submit an issue.
+
+* [Build Documentation](How_To_Build_libreCMC.md) : Learn how to build libreCMC for your device. 

+ 53 - 0
docs/Router_Reset_Instructions.md

@@ -0,0 +1,53 @@
+# libreCMC Router Reset
+
+## Hard reset
+
+### Manual way (if you can’t access the web interface)
+
+1. Power off the router.
+
+2. Power on the router.
+
+3. As soon as the SYS light (the gear) flashes, hold down the reset button until the 
+SYS LED flashes faster.
+
+4. Stop Network-Manager or other network configuration services.
+
+5. Plug in an ethernet cable from your machine to one of the LAN ports.
+
+6. Set your computer’s IP address to 192.168.10.2
+
+7.  `telnet  192.168.10.1` (192.168.1.1 on pre v1.3.1 devices).
+    With v1.3.4+ devices, telnet is disabled. use ssh:
+    `ssh root@192.168.10.1`
+
+8. At the shell prompt, type:
+`firstboot`
+
+9. After you have confirmed that you want to reset everything your need to reboot the router:
+`reboot`  <- It can manually be turned off too.
+
+### Resetting via web interface
+
+1. Login into the router via : 192.168.10.1 (or 192.168.1.1, depending on your configuration).
+
+2. Navigate to: System -> Backup / Flash Firmware 
+
+3. Click : "Preform Reset"
+
+Note: After resetting the router, it will be in a default state (wireless will be disabled, no password
+is set, ip-forwarding is disabled and telnet is enabled and the default IP should be 192.168.10.1) 
+It is recommended that you re-load the default configuration:
+
+# Restoring old configurations
+
+1. Make sure you have your network-manager turned on
+
+2. Log into the router via : 192.168.10.1 
+
+3. Navigate to : System -> Backup / Flash Firmware
+
+4. By "Restore Backup" , click the browse button and select the libreCMC configuration backup (*.tar.gz).
+
+
+

+ 104 - 0
docs/Serial.md

@@ -0,0 +1,104 @@
+# Using a serial interface with U-boot and libreCMC
+
+A serial interface (console) provides a means of debugging or 
+unlocking features hidden from the user. Most computing devices 
+have a serial interface whether it is broken out by the manufacture or not.
+
+In the case of devices that run libreCMC, a serial console is used
+to configure U-boot and debug libreCMC if the network interface can't
+be brought up. These instructions outline the basics of using
+a serial console with a USB to serial cable.
+
+
+
+## The basics
+
+There are a few different standards for serial interfaces, but here we are
+providing just the basics. There are 3 different connections that we care 
+about : Transmit (TX), Receive (RX) and Ground (GND). Depending on the
+serial cable, the color coding could be different. The common coloration
+is RX is Green, TX is white and GND is black*.
+
+These three wires will be connected to a pin header on the board or might need
+to be soldered to pads. Many device manufactures are kind enough to provide a 
+header and indicate where the serial interface is. Look for silkscreen labeling
+with : GND, TX, RX. Sometimes additional work is needed to break out a stable
+serial interface.
+
+* Many serial cables ship with the color corresponding to the connection on the board, 
+so TX and RX are effectively reversed.
+
+Some routers use the following standard:
+```
+         __________________
+        |            |     |
+        | .   .   .  |  .  |              <- Inside of the router (you may need to do some soldering)
+        |____________|_____|
+                 
+          |   |    \     \
+          *  GND   RX    TX
+```
+
+In this case, transmit is in the marked off box.
+
+
+
+```
+         _________________
+        |                 |
+        | .   .   .    .  |             
+      * |_________________|
+
+          |   |    \     \
+        GND   RX    TX   Vcc
+
+```
+
+Some might use a dot to indicate GND, etc...
+
+TPE-R1100 example:
+
+![alt text](images/serial.png "TPE-R1100 Serial")
+
+Warning: NEVER connect the red wire to the device / router! You will most likely fry it because
+many routers use 3.3V for Vcc instead of the 5V provided by USB.
+
+## Getting a console
+
+In order to communicate with the device, we need a terminal application to interact with
+the serial port provided by the USB to serial cable. In this case, we are going to use GNU Screen.
+Make sure that the GNU Screen package is installed and make sure that your user is part of the 
+`dialout` group.
+
+Before we can use the terminal application, we need to know the baud rate at which the serial
+console will be provided. With most devices running libreCMC and u-boot, this most likely will
+be 115200
+
+## Putting it all together
+
+
+1) Plug in / wire up the serial cable to the board.
+
+2) Plug the USB part of the serial cable into an available USB port.
+
+3) run `screen /dev/ttyUSB0 115200` or (if you are NOT part of the `dialout` group) `sudo screen /dev/ttyUSB0 115200`
+Please note that the serial device might have a different name (ttyUSB(n), ttyS0, etc...).
+
+4) Power on the device you are connecting to.
+
+5) You should see ledgible ASCII text scroll by.
+
+If the device gets all the way through the boot process, the libreCMC banner will appear with
+a shell prompt:
+
+```
+                    ____  _____  ____
+  _ _ _            |  __||     ||  __|
+ | (_) |__ _ _ ___ | |   | | | || |
+ | | | '_ \ '_/ -_)| |__ | | | || |__
+ |_|_|_.__/_| \___||____||_|_|_||____|
+ -----------------------------------------
+
+root@libreCMC:~#
+
+```

+ 32 - 0
docs/Soft_Brick_Recovery_With_IPv6.md

@@ -0,0 +1,32 @@
+# Soft Brick Recovery With IPv6
+
+## Use Case
+
+If you recklessly experiment with your libreCMC networking settings, it is likely you will eventually cause a "soft brick". Typically, this means you have messed up your IPv4 network configuration in such as way that you cannot connect to the LuCi control panel, nor connect to the busybox shell via SSH. One option is to figure out how to reload the firmware and start over from scratch. Something that might be easier, though, is to instead use IPv6 to connect to the router. This is usually possible for two reasons: (1) libreCMC has IPv6 enabled by default; (2) IPv6 has link-level autoconfiguration.
+
+## Determine the router's link local IPv6 Address and interface name.
+
+Connect a Gnu/Linux computer to the LAN port of the libreCMC router. Then run the `ip neigh` command. You are looking for a `REACHABLE lladdr` address that starts with `fe80`. For example:
+
+```
+christopher@evenstar:~$ ip neigh
+fe80::280:aeff:fece:5a21 dev eth0 lladdr 00:80:ae:ce:5a:21 router REACHABLE
+```
+
+Here, `fe80::280:aeff:fece:5a21` is the IPv6 address, and `eth0` is the name of the interface.
+
+## Log in to the router
+
+Unforunately, a link local IPv6 address usually cannot be used to directly connect to the LuCi control panel. This is because Web browsers are usually programmed not to process such addresses. However, you can use SSH to connect to the busybox shell, with a command like so:
+
+```
+ssh root@fe80::280:aeff:fece:5a21%eth0
+```
+
+Replace `fe80::280:aeff:fece:5a21` with the IPv6 address of your router, and `eth0` with the correct interface name.
+
+## What next?
+
+Once you are logged into the busybox shell, you can use the `ip addr` command to see what is the actual state of your IPv4 network configuration. If you understand IPv4, it may be sufficient to use `ip addr add` to add an IPv4 address, which you can then use to connect to the LuCi control panel. If the IPv4 configuration is okay, you may be having a problem with the dnsmasq dhcp server, or the LuCi Web service itself may be down, for some reason. Use the `logread` command to look for errors or warnings.
+
+If you are still not sure what to do, you can ask for help on the libreCMC IRC channel or libreCMC email list.

+ 37 - 0
docs/Supported_Hardware.md

@@ -0,0 +1,37 @@
+# libreCMC supported Hardware
+
+### Buffalo
+* [WZR-HP-G300NH](/WZR_HP_G300NH.md)
+* WHR-HP-G300NH
+
+### Netgear 
+
+* [WNDR3800](/WNDR3800.md)
+
+### TP-link 
+
+* [TL-MR3020 v1](/TL_MR3020.md) 
+* [TL-WR741ND](/TL_WR741ND.md)
+* [TL-WR841ND](/TL_WR841ND.md)
+* [TL-WR842ND](/TL_WR842ND.md)
+* [TL-WR1043ND](/TL_WR1043ND.md)
+
+### ThinkPenguin
+* [TPE-NWIFIROUTER2](/TPE_NWIFIROUTER2.md)
+* [TPE-R1100](/TPE_R1100.md)
+
+### Qi-Hardware
+
+* [Ben Nanonote](/Ben_Nanonote.md)
+
+## Tested Hardware
+
+[List of tested hardware](/List_of_Tested_Hardware.md)
+
+# libreCMC unofficially supported Hardware
+
+### D-Link
+
+* DGL-5500 a1 : Ships with non-free wifi card, but can be replaced with a free one. Has a mini-pci-e card slot.
+
+#####Please note that other targets may work; we are **NOT** responsible for **ANY** _bricked_ devices.

+ 67 - 0
docs/System_Log.md

@@ -0,0 +1,67 @@
+# System Log
+
+## Viewing the system log from LuCi
+
+Select the `Status >> System Log` menu entry.
+
+![alt text](images/librecmc-luci-selecting-system-log.png "Selecting
+ the System Log page in LuCi")
+
+![alt text](images/librecmc-luci-system-log.png "The System Log page
+ in LuCi")
+
+The `System Log` page in LuCi does not have an interface for filtering
+output. Therefore, you will likely want to use the shell interface.
+
+## Viewing the system log from the shell
+
+Once logged in via SSH, use the `logread` command
+
+```bash
+Usage: logread [options]
+Options:
+    -s <path>		Path to ubus socket
+    -l	<count>		Got only the last 'count' messages
+    -e	<pattern>	Filter messages with a regexp
+    -r	<server> <port>	Stream message to a server
+    -F	<file>		Log file
+    -S	<bytes>		Log size
+    -p	<file>		PID file
+    -h	<hostname>	Add hostname to the message
+    -P	<prefix>	Prefix custom text to streamed messages
+    -f			Follow log messages
+    -u			Use UDP as the protocol
+    -t			Add an extra timestamp
+    -0			Use \0 instead of \n as trailer when using TCP
+```
+
+For example:
+
+```bash
+root@libreCMC:~$ logread | grep 'kern\.warn'
+Mon Jan 15 20:22:01 2018 kern.warn kernel: [    0.000000] No valid device tree found, continuing without
+Mon Jan 15 20:22:01 2018 kern.warn kernel: [    0.000000] Primary instruction cache 64kB, VIPT, 4-way, linesize 32 bytes.
+Mon Jan 15 20:22:01 2018 kern.warn kernel: [    0.000000] Primary data cache 32kB, 4-way, VIPT, cache aliases, linesize 32 bytes
+Mon Jan 15 20:22:01 2018 kern.warn kernel: [    0.669305] Crashlog allocated RAM at address 0x3f00000
+Mon Jan 15 20:22:01 2018 kern.warn kernel: [    0.752178] m25p80 spi0.0: found mx25l12805d, expected m25p80
+```
+
+One should be able to use `logread -e` instead of `grep`, but it seems
+that not all the same regular expressions work for both:
+
+```bash
+root@libreCMC:~$ logread -e 'kern\.warn' # and other similar variations
+(no output)
+```
+
+The system log is contained in a limited size, circular buffer in
+memory. So, if you have some process writing messages periodically,
+this will eventually erase messages that were only written once.
+
+## Configuring the system log
+
+TODO
+
+## Monitoring the system log
+
+TODO

+ 42 - 0
docs/TL_MR3020.md

@@ -0,0 +1,42 @@
+# TP-Link : TL-MR3020
+
+The TL-MR3020 is a versatile device with the following specs:
+
+* SoC : Atheros AR7240 
+* RAM: 32 MB 
+* Flash: 4MB 
+* NIC: 100BASE-X
+
+Please see the libreCMC [build documentation](/wiki/How-To-Build-libreCMC) for build instructions.
+
+## Flashing from factory (virgin)
+
+### Using Web GUI (Recommended)
+
+1) Set TL-MR3020 Mode Switch to either 3G/4G or WISP
+
+2) Connect to the TL-MR3020 router via Ethernet cable
+
+3) Open IP address 192.168.0.254
+
+4) log in to the router's web GUI (default login/password: admin / admin)
+
+5) overwrite the factory firmware by installing the openwrt-ar71xx-generic-tl-mr3020-v1-squashfs-factory.bin firmware image like a regular firmware update.
+
+Wait for the progress bar to finish twice (the device will reset itself in the process), and proceed with basic configuration as with any fresh libreCMC install.
+
+### Flashing from libreCMC Web GUI
+
+1) Connect device to ethernet port on your computer and set the ip address of your machine to 192.168.1.10
+
+2) Open 192.168.1.1 in a browser.
+
+3) Go to: System -> Backup/Flash Firmware
+
+4) Click the "browse" button under the _Flash New Firmware image_ section.
+
+5) Upload a firmware image with : librecmc-_target_-generic-_profile_-squashfs-factory.bin
+
+6) wait for the web interface to appear again (unless you chose to flash an image without it).
+
+# Needs more editing ;)

+ 120 - 0
docs/TL_WR1043ND.md

@@ -0,0 +1,120 @@
+# TL-WR1043ND
+
+## Hardware Specs:
+
+v1.x
+
+* SoC : Atheros AR9103
+* Flash ROM : 8 MiB
+* RAM : 32 MB
+* USB : 1
+* Special: GbE Switch
+
+v2.x
+
+* SoC : Qualcomm Atheros QCA9558
+* Flash ROM : 8 MiB
+* RAM : 64 MB
+* USB : 1
+* Special: GbE Switch
+
+v3.x
+
+Similar to v2.x
+
+v4.x
+
+* SoC : Qualcomm Atheros QCA9563
+* Flash ROM : 16 MB
+* RAM : 64 MB
+* USB : 1
+* Special: GbE Switch
+* May need to be TFTP flashed, depending on stock firmware version.
+
+v5.x (TL-WR1043N v5)
+
+Similar to v4.x
+
+* No USB
+* libreCMC images available but have *Not* been tested!
+* Most likely needs to be TFTP flashed
+
+## Supported Versions:
+
+* v1.x
+* v2.x
+* v3.x
+* v4.x
+* v5.x : images available, *Not Tested*
+
+# Reset instructions
+
+???
+
+# Firmware Images
+
+See our [flavors](https://librecmc.org/flavors.html) page for a description of each type of libreCMC image.
+
+## Main Images
+
+[TL-WR1043ND v1 Factory](https://librecmc.org/librecmc/downloads/snapshots/current/main/ar71xx/generic/librecmc-ar71xx-generic-tl-wr1043nd-v1-squashfs-factory.bin)
+
+[TL-WR1043ND v1 Sysupgrade](https://librecmc.org/librecmc/downloads/snapshots/current/main/ar71xx/generic/librecmc-ar71xx-generic-tl-wr1043nd-v1-squashfs-sysupgrade.bin)
+
+
+[TL-WR1043ND v2 Factory](https://librecmc.org/librecmc/downloads/snapshots/current/main/ar71xx/generic/librecmc-ar71xx-generic-tl-wr1043nd-v2-squashfs-factory.bin)
+
+[TL-WR1043ND v2 Sysupgrade](https://librecmc.org/librecmc/downloads/snapshots/current/main/ar71xx/generic/librecmc-ar71xx-generic-tl-wr1043nd-v2-squashfs-sysupgrade.bin)
+
+
+[TL-WR1043ND v3 Factory](https://librecmc.org/librecmc/downloads/snapshots/current/main/ar71xx/generic/librecmc-ar71xx-generic-tl-wr1043nd-v3-squashfs-factory.bin)
+
+[TL-WR1043ND v3 Sysupgrade](https://librecmc.org/librecmc/downloads/snapshots/current/main/ar71xx/generic/librecmc-ar71xx-generic-tl-wr1043nd-v3-squashfs-sysupgrade.bin)
+
+
+[TL-WR1043ND v4 Factory](https://librecmc.org/librecmc/downloads/snapshots/current/main/ar71xx/generic/librecmc-ar71xx-generic-tl-wr1043nd-v4-squashfs-factory.bin)
+
+[TL-WR1043ND v4 Sysupgrade](https://librecmc.org/librecmc/downloads/snapshots/current/main/ar71xx/generic/librecmc-ar71xx-generic-tl-wr1043nd-v4-squashfs-sysupgrade.bin)
+
+
+[TL-WR1043N v5 Factory](https://librecmc.org/librecmc/downloads/snapshots/current/main/ar71xx/generic/librecmc-ar71xx-generic-tl-wr1043n-v5-squashfs-factory.bin) *NOT TESTED!!
+
+[TL-WR1043N v5 Sysupgrade](https://librecmc.org/librecmc/downloads/snapshots/current/main/ar71xx/generic/librecmc-ar71xx-generic-tl-wr1043n-v5-squashfs-sysupgrade.bin) *NOT TESTED!!
+
+## Core Images
+
+[TL-WR1043ND v1 Factory](https://librecmc.org/librecmc/downloads/snapshots/current/core/ar71xx/generic/librecmc-ar71xx-generic-tl-wr1043nd-v1-squashfs-factory.bin)
+
+[TL-WR1043ND v1 Sysupgrade](https://librecmc.org/librecmc/downloads/snapshots/current/core/ar71xx/generic/librecmc-ar71xx-generic-tl-wr1043nd-v1-squashfs-sysupgrade.bin)
+
+
+[TL-WR1043ND v2 Factory](https://librecmc.org/librecmc/downloads/snapshots/current/core/ar71xx/generic/librecmc-ar71xx-generic-tl-wr1043nd-v2-squashfs-factory.bin)
+
+[TL-WR1043ND v2 Sysupgrade](https://librecmc.org/librecmc/downloads/snapshots/current/core/ar71xx/generic/librecmc-ar71xx-generic-tl-wr1043nd-v2-squashfs-sysupgrade.bin)
+
+
+[TL-WR1043ND v3 Factory](https://librecmc.org/librecmc/downloads/snapshots/current/core/ar71xx/generic/librecmc-ar71xx-generic-tl-wr1043nd-v3-squashfs-factory.bin)
+
+[TL-WR1043ND v3 Sysupgrade](https://librecmc.org/librecmc/downloads/snapshots/current/core/ar71xx/generic/librecmc-ar71xx-generic-tl-wr1043nd-v3-squashfs-sysupgrade.bin)
+
+
+[TL-WR1043ND v4 Factory](https://librecmc.org/librecmc/downloads/snapshots/current/core/ar71xx/generic/librecmc-ar71xx-generic-tl-wr1043nd-v4-squashfs-factory.bin)
+
+[TL-WR1043ND v4 Sysupgrade](https://librecmc.org/librecmc/downloads/snapshots/current/core/ar71xx/generic/librecmc-ar71xx-generic-tl-wr1043nd-v4-squashfs-sysupgrade.bin)
+
+
+[TL-WR1043N v5 Factory](https://librecmc.org/librecmc/downloads/snapshots/current/core/ar71xx/generic/librecmc-ar71xx-generic-tl-wr1043n-v5-squashfs-factory.bin) *NOT TESTED!!
+
+[TL-WR1043N v5 Sysupgrade](https://librecmc.org/librecmc/downloads/snapshots/current/core/ar71xx/generic/librecmc-ar71xx-generic-tl-wr1043n-v5-squashfs-sysupgrade.bin) *NOT TESTED!!
+
+## Image File Signatures 
+
+[Main sha256sums](https://librecmc.org/librecmc/downloads/snapshots/current/main/ar71xx/generic/sha256sums)
+
+[Main sha256sums.asc](https://librecmc.org/librecmc/downloads/snapshots/current/main/ar71xx/generic/sha256sums.asc)
+
+
+[Core sha256sums](https://librecmc.org/librecmc/downloads/snapshots/current/core/ar71xx/generic/sha256sums)
+
+[Core sha256sums.asc](https://librecmc.org/librecmc/downloads/snapshots/current/core/ar71xx/generic/sha256sums.asc)
+

+ 37 - 0
docs/TL_WR741ND.md

@@ -0,0 +1,37 @@
+# TP-Link TL-WR741ND
+
+## Specs
+
+* SoC : Atheros AR7240 @ 350 MHz
+* RAM: 32 MB
+* Flash : 4 MB
+
+## Versions Supported 
+
+* v1 - v2, v4.20 - 4.27 
+
+## Versions **NOT** supported
+
+* v2.1 - v3.1 + v4.0
+
+# Firmware Images
+
+See our [flavors](https://librecmc.org/flavors.html) page for a description of each type of libreCMC image.
+
+## Legacy
+
+[TL-WR741ND v4.20+ Factory](https://librecmc.org/librecmc/downloads/snapshots/current/legacy/ar71xx/generic/librecmc-ar71xx-generic-tl-wr741nd-v4-squashfs-factory.bin)
+
+[TL-WR741ND v4.20+ Sysupgrade](https://librecmc.org/librecmc/downloads/snapshots/current/legacy/ar71xx/generic/librecmc-ar71xx-generic-tl-wr741nd-v4-squashfs-sysupgrade.bin)
+
+[TL-WR741ND v5 Factory](https://librecmc.org/librecmc/downloads/snapshots/current/legacy/ar71xx/generic/librecmc-ar71xx-generic-tl-wr741nd-v5-squashfs-factory.bin)
+
+[TL-WR741ND v5 Sysupgrade](https://librecmc.org/librecmc/downloads/snapshots/current/legacy/ar71xx/generic/librecmc-ar71xx-generic-tl-wr741nd-v5-squashfs-sysupgrade.bin)
+
+
+## Image File Signatures
+
+[Legacy sha256sums](https://librecmc.org/librecmc/downloads/snapshots/current/legacy/ar71xx/generic/sha256sums)
+
+[Legacy sha256sums.asc](https://librecmc.org/librecmc/downloads/snapshots/current/legacy/ar71xx/generic/sha256sums.asc)
+

+ 60 - 0
docs/TL_WR841ND.md

@@ -0,0 +1,60 @@
+# TP-WR841ND
+
+## Specs
+
+* SoC : Atheros AR9341
+* RAM: 32 MB
+* Flash: 4 MB
+
+## Versions Supported
+
+* v5.x
+* v8.x
+* v9.x
+* v10.x <-- may need to be tftp flashed
+* v11.x <--
+* v12.x <--
+
+
+DO NOT BUY v13!!! V13 contains a mediatek
+chipset, which requires a non-free firmware
+blob.
+
+## Reset instructions
+
+???
+
+# Firmware Images
+
+See our [flavors](https://librecmc.org/flavors.html) page for a description of each type of libreCMC image.
+
+## Legacy
+[TL-WR841n[d] v8 Factory](https://librecmc.org/librecmc/downloads/snapshots/current/legacy/ar71xx/generic/librecmc-ar71xx-generic-tl-wr841-v8-squashfs-factory.bin)
+
+[TL-WR841n[d] v8 Sysupgrade](https://librecmc.org/librecmc/downloads/snapshots/current/legacy/ar71xx/generic/librecmc-ar71xx-generic-tl-wr841-v8-squashfs-sysupgrade.bin)
+
+
+[TL-WR841n[d] v9 Factory](https://librecmc.org/librecmc/downloads/snapshots/current/legacy/ar71xx/generic/librecmc-ar71xx-generic-tl-wr841-v9-squashfs-factory.bin)
+
+[TL-WR841n[d] v9 Sysupgrade](https://librecmc.org/librecmc/downloads/snapshots/current/legacy/ar71xx/generic/librecmc-ar71xx-generic-tl-wr841-v9-squashfs-sysupgrade.bin)
+
+
+[TL-WR841n[d] v10 Factory](https://librecmc.org/librecmc/downloads/snapshots/current/legacy/ar71xx/generic/librecmc-ar71xx-generic-tl-wr841-v10-squashfs-factory.bin)
+
+[TL-WR841n[d] v10 Sysupgrade](https://librecmc.org/librecmc/downloads/snapshots/current/legacy/ar71xx/generic/librecmc-ar71xx-generic-tl-wr841-v10-squashfs-sysupgrade.bin)
+
+
+[TL-WR841n[d] v11 Factory EU](https://librecmc.org/librecmc/downloads/snapshots/current/legacy/ar71xx/generic/librecmc-ar71xx-generic-tl-wr841-v11-squashfs-factory-eu.bin)
+
+[TL-WR841n[d] v11 Factory US](https://librecmc.org/librecmc/downloads/snapshots/current/legacy/ar71xx/generic/librecmc-ar71xx-generic-tl-wr841-v11-squashfs-factory-us.bin)
+
+[TL-WR841n[d] v11 Factory](https://librecmc.org/librecmc/downloads/snapshots/current/legacy/ar71xx/generic/librecmc-ar71xx-generic-tl-wr841-v11-squashfs-factory.bin)
+
+[TL-WR841n[d] v11 Sysupgrade](https://librecmc.org/librecmc/downloads/snapshots/current/legacy/ar71xx/generic/librecmc-ar71xx-generic-tl-wr841-v11-squashfs-sysupgrade.bin)
+
+## Image File Signatures 
+
+[Legacy sha256sums](https://librecmc.org/librecmc/downloads/snapshots/current/legacy/ar71xx/generic/sha256sums)
+
+[Legacy sha256sums.asc](https://librecmc.org/librecmc/downloads/snapshots/current/legacy/ar71xx/generic/sha256sums.asc)
+

+ 41 - 0
docs/TL_WR842ND.md

@@ -0,0 +1,41 @@
+# TL-WR842ND
+
+## Specs
+
+* SoC : AR7241 (v1) AR9341 (v2)
+* RAM: 32 MB
+* Flash: 8 MB
+
+## Versions Supported
+
+* v1
+* v2
+
+## Flashing TL-WR842ND using tftp recovery mode
+
+* Press and hold WPS/Reset button, and power on router
+* Wait until Lock LED lights up before releasing WPS/Reset button
+* Router has IP address: 192.168.0.86
+* Router is standing by for a tftp server to appear with `wr842nv2_tp_recovery.bin` file using IP address: 192.168.0.66
+
+### Example commands using [Parabola GNU/Linux](https://www.parabola.nu/)
+
+Configure PC IP address to `192.168.0.66`
+
+    ip addr add 192.168.0.66/24 dev enp3s0
+    
+Copy downloaded image into tftp server directory also renaming it to `wr842nv2_tp_recovery.bin`
+
+    cp librecmc-ar71xx-generic-tl-wr842n-v2-squashfs-factory.bin /srv/tftp/wr842nv2_tp_recovery.bin
+
+Start tftpd
+
+`systemctl start tftpd.socket`
+
+`systemctl start tftpd.service`
+
+* After a short time all LEDs will flash once then router will reboot normally
+
+## Reset instructions
+
+???

+ 48 - 0
docs/TPE_NWIFIROUTER2.md

@@ -0,0 +1,48 @@
+# ThinkPenguin  [TPE-NWIFIROUTER2](https://www.thinkpenguin.com/gnu-linux/free-software-wireless-n-broadband-router-gnu-linux-tpe-nwifirouter2)
+
+## Specs
+
+* SoC : Atheros AR9341
+* RAM: 32 MB
+* Flash: 4 MB
+
+## Versions Supported
+
+* v2
+
+## Notes:
+
+* This router is a re-branded and re-flashed Rosewill RNX-N300RT. The Rosewill RNX-N300RT uses the same board found in the 
+TL-WR841N[D] v8.x. The stock RNX-N300RT ships with DRM and CAN NOT be flashed without non-free software (unless you have 
+a chip clip and SPI flasher). Some versions (v1) requires the flash chip to be removed before an SPI programmer can be used. 
+ThinkPenguin's offering ships with libreCMC, does not ship with DRM and can be fully re-programmed.
+
+* The names of the firmware images for this device are `librecmc-ar71xx-generic-tl-wr841-v8-squashfs-*`
+
+# Firmware Images
+
+See our [flavors](https://librecmc.org/flavors.html) page for a description of each type of libreCMC image.
+
+## Legacy
+
+[TL-WR841n[d] v8 Factory](https://librecmc.org/librecmc/downloads/snapshots/current/legacy/ar71xx/generic/librecmc-ar71xx-generic-tl-wr841-v8-squashfs-factory.bin)
+
+[TL-WR841n[d] v8 Sysupgrade](https://librecmc.org/librecmc/downloads/snapshots/current/legacy/ar71xx/generic/librecmc-ar71xx-generic-tl-wr841-v8-squashfs-sysupgrade.bin)
+
+## Core
+
+[TL-WR841n[d] v8 Factory](https://librecmc.org/librecmc/downloads/snapshots/current/core/ar71xx/generic/librecmc-ar71xx-generic-tl-wr841-v8-squashfs-factory.bin)
+
+[TL-WR841n[d] v8 Sysupgrade](https://librecmc.org/librecmc/downloads/snapshots/current/core/ar71xx/generic/librecmc-ar71xx-generic-tl-wr841-v8-squashfs-sysupgrade.bin)
+
+
+## Image File Signatures 
+
+[Legacy sha256sums](https://librecmc.org/librecmc/downloads/snapshots/current/legacy/ar71xx/generic/sha256sums)
+
+[Legacy sha256sums.asc](https://librecmc.org/librecmc/downloads/snapshots/current/legacy/ar71xx/generic/sha256sums.asc)
+
+
+[Core sha256sums](https://librecmc.org/librecmc/downloads/snapshots/current/core/ar71xx/generic/sha256sums)
+
+[Core sha256sums.asc](https://librecmc.org/librecmc/downloads/snapshots/current/core/ar71xx/generic/sha256sums.asc)

+ 47 - 0
docs/TPE_R1100.md

@@ -0,0 +1,47 @@
+# Think Penguin [TPE-R1100 mini WiFi Router](https://www.thinkpenguin.com/gnu-linux/free-software-wireless-n-mini-vpn-router-tpe-r1100)
+
+## Specs
+
+* SoC: Atheros AR9331
+* RAM: 64M
+* Flash: 16M
+* NIC: 2 10/100 Ethernet Ports
+* USB: 1
+* WiFi: Atheros 802.11b/g/n 2.4Ghz
+* GPIO: 3 General Purpose and one switch.
+* Power: 5v USB
+
+The TPE-R1100 is a general purpose mini WiFi router
+that can be used for a wide range of applications. 
+Some common uses include:
+
+* Route all traffic over a VPN when on the go.
+* WiFi to ethernet bridge.
+* A small web server.
+* IRC bouncer.
+* Meshnet node (CJDNS, Batman...).
+
+
+# Firmware Images
+
+See our [flavors](https://librecmc.org/flavors.html) page for a description of each type of libreCMC image.
+
+## Main
+
+[TPE-R1100](https://librecmc.org/librecmc/downloads/snapshots/current/main/ar71xx/generic/librecmc-ar71xx-generic-tpe-r1100-squashfs-sysupgrade.bin)
+
+## Core
+
+[TPE-R1100](https://librecmc.org/librecmc/downloads/snapshots/current/core/ar71xx/generic/librecmc-ar71xx-generic-tpe-r1100-squashfs-sysupgrade.bin)
+
+## Image File Signatures 
+
+[Main sha256sums](https://librecmc.org/librecmc/downloads/snapshots/current/main/ar71xx/generic/sha256sums)
+
+[Main sha256sums.asc](https://librecmc.org/librecmc/downloads/snapshots/current/main/ar71xx/generic/sha256sums.asc)
+
+
+[Core sha256sums](https://librecmc.org/librecmc/downloads/snapshots/current/core/ar71xx/generic/sha256sums)
+
+[Core sha256sums.asc](https://librecmc.org/librecmc/downloads/snapshots/current/core/ar71xx/generic/sha256sums.asc)
+

+ 47 - 0
docs/WNDR3800.md

@@ -0,0 +1,47 @@
+# Netgear WNDR3800
+
+## Specs
+
+* SoC : Atheros AR7161 rev 2
+* RAM: 128 MB
+* Flash: 16 MB
+
+## Versions Supported
+
+* v1.x
+
+# Firmware Images
+
+See our [flavors](https://librecmc.org/flavors.html) page for a description of each type of libreCMC image.
+
+## Main
+
+[WNDR3800 Factory](https://librecmc.org/librecmc/downloads/snapshots/current/main/ar71xx/generic/librecmc-ar71xx-generic-wndr3800-squashfs-factory.img)
+
+[WNDR3800 Sysupgrade](https://librecmc.org/librecmc/downloads/snapshots/current/main/ar71xx/generic/librecmc-ar71xx-generic-wndr3800-squashfs-sysupgrade.bin)
+
+[WNDR3800ch Factory](https://librecmc.org/librecmc/downloads/snapshots/current/main/ar71xx/generic/librecmc-ar71xx-generic-wndr3800ch-squashfs-factory.img)
+
+[WNDR3800ch Sysupgrade](https://librecmc.org/librecmc/downloads/snapshots/current/main/ar71xx/generic/librecmc-ar71xx-generic-wndr3800ch-squashfs-sysupgrade.bin)
+
+## Core
+
+[WNDR3800 Factory](https://librecmc.org/librecmc/downloads/snapshots/current/core/ar71xx/generic/librecmc-ar71xx-generic-wndr3800-squashfs-factory.img)
+
+[WNDR3800 Sysupgrade](https://librecmc.org/librecmc/downloads/snapshots/current/core/ar71xx/generic/librecmc-ar71xx-generic-wndr3800-squashfs-sysupgrade.bin)
+
+[WNDR3800ch Factory](https://librecmc.org/librecmc/downloads/snapshots/current/core/ar71xx/generic/librecmc-ar71xx-generic-wndr3800ch-squashfs-factory.img)
+
+[WNDR3800ch Sysupgrade](https://librecmc.org/librecmc/downloads/snapshots/current/core/ar71xx/generic/librecmc-ar71xx-generic-wndr3800ch-squashfs-sysupgrade.bin) 
+
+## Image File Signatures 
+
+[Main sha256sums](https://librecmc.org/librecmc/downloads/snapshots/current/main/ar71xx/generic/sha256sums)
+
+[Main sha256sums.asc](https://librecmc.org/librecmc/downloads/snapshots/current/main/ar71xx/generic/sha256sums.asc)
+
+
+[Core sha256sums](https://librecmc.org/librecmc/downloads/snapshots/current/core/ar71xx/generic/sha256sums)
+
+[Core sha256sums.asc](https://librecmc.org/librecmc/downloads/snapshots/current/core/ar71xx/generic/sha256sums.asc)
+

+ 13 - 0
docs/WZR_HP_G300NH.md

@@ -0,0 +1,13 @@
+# Buffalo WZR-HP-G300NH
+This device is scheduled to be supported in the upcoming version 1.3.1 of libreCMC.
+
+## Specs
+
+* SoC : Atheros AR9132
+* RAM: 64 MB
+* Flash: 32 MB
+
+## Versions Supported
+
+More info soon.
+

+ 71 - 0
docs/Welcome.md

@@ -0,0 +1,71 @@
+# libreCMC : The libre Embedded GNU/Linux Distro
+
+The libreCMC project is a set of fully [free](https://www.gnu.org/philosophy/free-sw.en.html) [embedded](/wiki/embedded) Operating Systems
+that give users the freedom to control their computing. Our primary project is an embedded GNU/Linux-libre 
+distro that is based upon the upstream OpenWRT/LEDE project. The main difference between OpenWRT/LEDE and libreCMC
+are the fact that the project removes all [non-free](https://www.gnu.org/philosophy/categories.en.html#non-freeSoftware) packages, drivers and firmware blobs where the sources are not available under a free software license.
+
+## Why would I use libreCMC?
+
+Full control over your computing! In many cases, a variety of embedded devices require components where the sources
+are not available to the community under a Free Software license. These non-free parts mean that the community can't
+fix bugs, security flaws or even use a newer kernel because drivers don't work with newer versions of the kernel. By using these non-free parts,the user is at the mercy of the OEM or manufacture to maintain support for newer drivers that work with newer versions of the Linux™ kernel.
+
+# Quick Start Build Guide
+
+1) Checkout libreCMC
+
+`git clone https://gogs.librecmc.org/libreCMC/libreCMC.git`
+
+2) Enter the libreCMC directory (from now on referred by `$SRC_ROOT`)
+
+`cd $SRC_ROOT`
+
+3) Configure the build for the [supported device](/wiki/Supported-Hardware) and
+the packages that you may want to have. Some targets may have a very limited amount
+of flash (primary storage) and may not have the room for certain configurations of 
+packages.
+
+Also, in order to build libreCMC, make sure that you have all needed [dependencies](/wiki/How-To-Build-libreCMC#what-do-i-need-to-get-started).
+After having installed all the necessary dependencies run:
+
+`make menuconfig`
+
+This will bring up the ncurses menuconfig interface for configuring libreCMC.
+
+A good default configuration for many people would be to include:
+
+* Luci -> luci, luci-ssl
+* Base System -> ca-bundle, sqm-scripts[-extra]
+
+4) Actually start the build:
+
+`make` : To speed things up, you can add a few more threads to the build by using `make -j4`
+
+5) Wait....
+
+Depending on the machine you have access to and the configuration you selected, it will take sometime to build libreCMC. 
+
+a) What if something goes wrong with the build? Run:
+
+`make V=s` : This will allow for the build to be debugged. Sometimes a source package mirror is down or a dependency is missing. This
+will allow us to figure out what is going wrong.
+
+
+b) The build finished, but there is no image for my device! If you select more packages than can fit in flash, then some packages will
+need to be removed from the configuration. After removing some packages, start the build again. Be careful when removing packages from
+the configuration. Some packages are very important for basic functionality or are needed for other packages in the base system.
+
+If you have a device that has <8M of flash, then try removing `Base System -> opkg*, ca-bundle`.
+
+
+6) If everything went OK, there should be a new image in `$SRC_ROOT/bin/targets/$TARGET/generic/`
+
+
+# Where do I go from here?
+
+Well, it depends on many factors. libreCMC can be used for many different use cases. If you need help with libreCMC, help can be found on IRC using:
+
+server :`FreeNode`
+
+channel : `#libreCMC`

+ 15 - 0
docs/embedded.md

@@ -0,0 +1,15 @@
+# Embedded Systems
+Embedded can mean different things to many people. The Wikipedia [definition](https://en.wikipedia.org/wiki/Embedded_system) is:
+
+> An embedded system is a computer system with a dedicated function within a larger mechanical or electrical system, often with real-time computing constraints.
+> ...
+> Examples of properties of typically embedded computers when compared with general-purpose counterparts are low power consumption, small size, rugged operating ranges, and low per-unit cost.
+
+The libreCMC project's definition is:
+
+>
+A device or system with very few resources and is designed to be run for long stretches of time without user intervention. 
+
+One of the main goals of the libreCMC project is to keep things really small in terms of operating footprint (storage and RAM used). Many of the devices that the project supports have as little as 4M of flash and 16M of RAM. In this scope, many SBCs (Single Board Computers) are well outside this range with some having more resources than an average desktop 10+ years ago. 
+
+# Page needs more editing!

BIN
docs/images/librecmc-changing-admin-password.png


BIN
docs/images/librecmc-changing-essid.png


BIN
docs/images/librecmc-changing-wifi-password.png


BIN
docs/images/librecmc-default-interfaces.png


BIN
docs/images/librecmc-default-login.png


BIN
docs/images/librecmc-dhcp-server-ignore-lan.png


BIN
docs/images/librecmc-eth0-added-to-lan.png


BIN
docs/images/librecmc-luci-selecting-system-log.png


BIN
docs/images/librecmc-luci-system-log.png


BIN
docs/images/librecmc-port-forwards-after-save-apply.png


BIN
docs/images/librecmc-port-forwards-entering-parameters.png


BIN
docs/images/librecmc-selecting-firewall-menu.png


BIN
docs/images/librecmc-selecting-port-forwards-tab.png


BIN
docs/images/librecmc-switch-lan-to-dhcp.png


BIN
docs/images/serial.png


+ 24 - 0
docs/old/Save_WiFi.md

@@ -0,0 +1,24 @@
+# Will you help us save WiFi ?
+
+For as long as the libreCMC  and LibreWRT projects have existed, their core focus has been to
+bring Free Software to embedded devices, some of which have WiFi chipsets. While the project(s) 
+core goals have not changed very much over the last few years, the landscape of WiFi enabled devices
+has exploded. Many of the radios in these devices went from being single-purpose radios that can only
+operate within certain ranges to modifiable SDRs that can be changed. While having the freedom to change
+one's own hardware is important, it is also important to operate radio equipment within regulatory laws. 
+
+Since a few individuals have operated devices outside of regulations, the FCC and other regulatory bodies are proposing tighter
+restrictions on hardware that has WiFi or SDRs. These new restrictions would include a full lockout of third-party software
+and prevent users from updating or running new software on hardware they own. With these new digital locks, hardware vendors
+will exercise control over the user by preventing new innovative functionality or even preventing users from applying critical security patches.
+ 
+These new regulations won't work the way they are intended to and they should not be required. Users with the technical knowledge
+will still be able to get around the restrictions and load their own software. Most free software projects
+already put safeguards in place so that users can't accidentally violate regulatory rules that apply to their WiFi or SDR devices, unless
+they choose to remove them on purpose. Instead of punishing everyone in the Free Software community for the actions of a few, individuals 
+who operate devices outside of regulations should be fined instead of taking away everyone's freedom.
+
+The libreCMC project and other members of the Free Software community would like to ask everyone to send a comment
+to the FCC about these new proposals and why they won't help fix the misuse of WiFi or SDRs. More information
+about this issue and how to submit comments can be found at [SaveWiFi.org](http://savewifi.org).
+

+ 12 - 0
docs/testing.md

@@ -0,0 +1,12 @@
+# This is a sample file!
+
+Just testing a symlink'ed wiki!
+
+```
+ Testing
+;alkdfj;a
+alksdjf;lka `
+```
+
+` another block of text `
+

+ 26 - 0
docs/unbrick_with_uboot_mod.md

@@ -0,0 +1,26 @@
+Unbrick libreCMC routers from u-boot_mod
+======================================================
+
+1. Make sure the router is powered off.
+
+2. On the host machine, disable network management (NetworkManager, wicd, etc..)
+
+3. Set the host machine IP address to 192.168.1.2
+
+4. Hold down the reset button.
+
+5. Power on the router with the reset button held.
+
+6. The red LED will light up, then flash every second.
+After the 3rd flash, release the reset button (it may
+take some coordination. From power on to the release of
+the button is exactly 3 sec.
+
+7. Open a web browser and go to 192.168.1.1/index.html
+
+8. Click the "browse" button and select the firmware image for your router
+
+`librecmc-ar71xx-generic-*-squashfs-*.bin`
+
+
+# WIP

+ 1 - 0
feeds.conf.default

@@ -0,0 +1 @@
+src-git packages https://gogs.librecmc.org/libreCMC/package-feed.git;v1.5

+ 170 - 0
include/autotools.mk

@@ -0,0 +1,170 @@
+#
+# Copyright (C) 2007-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+autoconf_bool = $(patsubst %,$(if $($(1)),--enable,--disable)-%,$(2))
+
+# delete *.la-files from staging_dir - we can not yet remove respective lines within all package
+# Makefiles, since backfire still uses libtool v1.5.x which (may) require those files
+define libtool_remove_files
+	find $(1) -name '*.la' | $(XARGS) rm -f;
+endef
+
+
+AM_TOOL_PATHS:= \
+	AUTOM4TE=$(STAGING_DIR_HOST)/bin/autom4te \
+	AUTOCONF=$(STAGING_DIR_HOST)/bin/autoconf \
+	AUTOMAKE=$(STAGING_DIR_HOST)/bin/automake \
+	ACLOCAL=$(STAGING_DIR_HOST)/bin/aclocal \
+	AUTOHEADER=$(STAGING_DIR_HOST)/bin/autoheader \
+	LIBTOOLIZE=$(STAGING_DIR_HOST)/bin/libtoolize \
+	LIBTOOL=$(STAGING_DIR_HOST)/bin/libtool \
+	M4=$(STAGING_DIR_HOST)/bin/m4 \
+	AUTOPOINT=true
+
+# 1: build dir
+# 2: remove files
+# 3: automake paths
+# 4: libtool paths
+# 5: extra m4 dirs
+define autoreconf
+	(cd $(1); \
+		$(patsubst %,rm -f %;,$(2)) \
+		$(foreach p,$(3), \
+			if [ -f $(p)/configure.ac ] || [ -f $(p)/configure.in ]; then \
+				[ -d $(p)/autom4te.cache ] && rm -rf autom4te.cache; \
+				[ -e $(p)/config.rpath ] || \
+						ln -s $(SCRIPT_DIR)/config.rpath $(p)/config.rpath; \
+				touch NEWS AUTHORS COPYING ABOUT-NLS ChangeLog; \
+				$(AM_TOOL_PATHS) $(STAGING_DIR_HOST)/bin/autoreconf -v -f -i -s \
+					$(if $(word 2,$(3)),--no-recursive) \
+					-B $(STAGING_DIR_HOST)/share/aclocal \
+					$(patsubst %,-I %,$(5)) \
+					$(patsubst %,-I %,$(4)) $(p) || true; \
+			fi; \
+		) \
+	);
+endef
+
+# 1: build dir
+define patch_libtool
+	@(cd $(1); \
+		for lt in $$$$($$(STAGING_DIR_HOST)/bin/find . -name ltmain.sh); do \
+			lt_version="$$$$($$(STAGING_DIR_HOST)/bin/sed -ne 's,^[[:space:]]*VERSION="\?\([0-9]\.[0-9]\+\).*,\1,p' $$$$lt)"; \
+			case "$$$$lt_version" in \
+				1.5|2.2|2.4) echo "autotools.mk: Found libtool v$$$$lt_version - applying patch to $$$$lt"; \
+					(cd $$$$(dirname $$$$lt) && $$(PATCH) -N -s -p1 < $$(TOPDIR)/tools/libtool/files/libtool-v$$$$lt_version.patch || true) ;; \
+				*) echo "autotools.mk: error: Unsupported libtool version v$$$$lt_version - cannot patch $$$$lt"; exit 1 ;; \
+			esac; \
+		done; \
+	);
+endef
+
+
+PKG_LIBTOOL_PATHS?=$(CONFIGURE_PATH)
+PKG_AUTOMAKE_PATHS?=$(CONFIGURE_PATH)
+PKG_MACRO_PATHS?=m4
+PKG_REMOVE_FILES?=aclocal.m4
+
+Hooks/InstallDev/Post += libtool_remove_files
+
+define autoreconf_target
+  $(strip $(call autoreconf, \
+    $(PKG_BUILD_DIR), $(PKG_REMOVE_FILES), \
+    $(PKG_AUTOMAKE_PATHS), $(PKG_LIBTOOL_PATHS), \
+    $(STAGING_DIR)/host/share/aclocal $(STAGING_DIR_HOSTPKG)/share/aclocal $(STAGING_DIR)/usr/share/aclocal $(PKG_MACRO_PATHS)))
+endef
+
+define patch_libtool_target
+  $(strip $(call patch_libtool, \
+    $(PKG_BUILD_DIR)))
+endef
+
+define gettext_version_target
+	(cd $(PKG_BUILD_DIR) && \
+		GETTEXT_VERSION=$(shell $(STAGING_DIR_HOSTPKG)/bin/gettext -V | $(STAGING_DIR_HOST)/bin/sed -ne '1s/.*\([0-9]\.[0-9]\{2\}\.[0-9]\).*/\1/p' ) && \
+		$(STAGING_DIR_HOST)/bin/sed \
+			-i $(PKG_BUILD_DIR)/configure.ac \
+			-e "s/AM_GNU_GETTEXT_VERSION(.*)/AM_GNU_GETTEXT_VERSION(\[$$$$GETTEXT_VERSION\])/g" && \
+		$(STAGING_DIR_HOSTPKG)/bin/autopoint --force \
+	);
+endef
+
+ifneq ($(filter gettext-version,$(PKG_FIXUP)),)
+  Hooks/Configure/Pre += gettext_version_target
+ ifeq ($(filter no-autoreconf,$(PKG_FIXUP)),)
+  Hooks/Configure/Pre += autoreconf_target
+ endif
+endif
+
+ifneq ($(filter patch-libtool,$(PKG_FIXUP)),)
+  Hooks/Configure/Pre += patch_libtool_target
+endif
+
+ifneq ($(filter libtool,$(PKG_FIXUP)),)
+  PKG_BUILD_DEPENDS += libtool gettext libiconv
+ ifeq ($(filter no-autoreconf,$(PKG_FIXUP)),)
+  Hooks/Configure/Pre += autoreconf_target
+ endif
+endif
+
+ifneq ($(filter libtool-ucxx,$(PKG_FIXUP)),)
+  PKG_BUILD_DEPENDS += libtool gettext libiconv
+ ifeq ($(filter no-autoreconf,$(PKG_FIXUP)),)
+  Hooks/Configure/Pre += autoreconf_target
+ endif
+endif
+
+ifneq ($(filter autoreconf,$(PKG_FIXUP)),)
+  ifeq ($(filter autoreconf,$(Hooks/Configure/Pre)),)
+    Hooks/Configure/Pre += autoreconf_target
+  endif
+endif
+
+
+HOST_FIXUP?=$(PKG_FIXUP)
+HOST_LIBTOOL_PATHS?=$(if $(PKG_LIBTOOL_PATHS),$(PKG_LIBTOOL_PATHS),.)
+HOST_AUTOMAKE_PATHS?=$(if $(PKG_AUTOMAKE_PATHS),$(PKG_AUTOMAKE_PATHS),.)
+HOST_MACRO_PATHS?=$(if $(PKG_MACRO_PATHS),$(PKG_MACRO_PATHS),m4)
+HOST_REMOVE_FILES?=$(PKG_REMOVE_FILES)
+
+define autoreconf_host
+  $(strip $(call autoreconf, \
+    $(HOST_BUILD_DIR), $(HOST_REMOVE_FILES), \
+    $(HOST_AUTOMAKE_PATHS), $(HOST_LIBTOOL_PATHS), \
+    $(HOST_MACRO_PATHS)))
+endef
+
+define patch_libtool_host
+  $(strip $(call patch_libtool, \
+    $(HOST_BUILD_DIR)))
+endef
+
+ifneq ($(filter patch-libtool,$(PKG_FIXUP)),)
+  Hooks/HostConfigure/Pre += patch_libtool_host
+endif
+
+ifneq ($(filter patch-libtool,$(HOST_FIXUP)),)
+  Hooks/HostConfigure/Pre += $(strip $(call patch_libtool,$(HOST_BUILD_DIR)))
+endif
+
+ifneq ($(filter libtool,$(HOST_FIXUP)),)
+ ifeq ($(filter no-autoreconf,$(HOST_FIXUP)),)
+  Hooks/HostConfigure/Pre += autoreconf_host
+ endif
+endif
+
+ifneq ($(filter libtool-ucxx,$(HOST_FIXUP)),)
+ ifeq ($(filter no-autoreconf,$(HOST_FIXUP)),)
+  Hooks/HostConfigure/Pre += autoreconf_host
+ endif
+endif
+
+ifneq ($(filter autoreconf,$(HOST_FIXUP)),)
+  ifeq ($(filter autoreconf,$(Hooks/HostConfigure/Pre)),)
+    Hooks/HostConfigure/Pre += autoreconf_host
+  endif
+endif

+ 113 - 0
include/cmake.mk

@@ -0,0 +1,113 @@
+cmake_bool = $(patsubst %,-D%:BOOL=$(if $($(1)),ON,OFF),$(2))
+
+PKG_INSTALL:=1
+
+ifneq ($(findstring c,$(LIBRECMC_VERBOSE)),)
+  MAKE_FLAGS+=VERBOSE=1
+endif
+
+CMAKE_BINARY_DIR = $(PKG_BUILD_DIR)$(if $(CMAKE_BINARY_SUBDIR),/$(CMAKE_BINARY_SUBDIR))
+CMAKE_SOURCE_DIR = $(PKG_BUILD_DIR)$(if $(CMAKE_SOURCE_SUBDIR),/$(CMAKE_SOURCE_SUBDIR))
+HOST_CMAKE_SOURCE_DIR = $(HOST_BUILD_DIR)$(if $(CMAKE_SOURCE_SUBDIR),/$(CMAKE_SOURCE_SUBDIR))
+MAKE_PATH = $(firstword $(CMAKE_BINARY_SUBDIR) .)
+
+ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
+  cmake_tool=$(TOOLCHAIN_DIR)/bin/$(1)
+else
+  cmake_tool=$(shell which $(1))
+endif
+
+ifeq ($(CONFIG_CCACHE),)
+ CMAKE_C_COMPILER:=$(call cmake_tool,$(TARGET_CC))
+ CMAKE_CXX_COMPILER:=$(call cmake_tool,$(TARGET_CXX))
+ CMAKE_C_COMPILER_ARG1:=
+ CMAKE_CXX_COMPILER_ARG1:=
+else
+  CCACHE:=$(STAGING_DIR_HOST)/bin/ccache
+  CMAKE_C_COMPILER:=$(CCACHE)
+  CMAKE_C_COMPILER_ARG1:=$(TARGET_CC_NOCACHE)
+  CMAKE_CXX_COMPILER:=$(CCACHE)
+  CMAKE_CXX_COMPILER_ARG1:=$(TARGET_CXX_NOCACHE)
+endif
+CMAKE_AR:=$(call cmake_tool,$(TARGET_AR))
+CMAKE_NM:=$(call cmake_tool,$(TARGET_NM))
+CMAKE_RANLIB:=$(call cmake_tool,$(TARGET_RANLIB))
+
+CMAKE_FIND_ROOT_PATH:=$(STAGING_DIR)/usr;$(TOOLCHAIN_DIR)$(if $(CONFIG_EXTERNAL_TOOLCHAIN),;$(CONFIG_TOOLCHAIN_ROOT))
+CMAKE_HOST_FIND_ROOT_PATH:=$(STAGING_DIR)/host;$(STAGING_DIR_HOSTPKG);$(STAGING_DIR_HOST)
+CMAKE_SHARED_LDFLAGS:=-Wl,-Bsymbolic-functions
+
+define Build/Configure/Default
+	mkdir -p $(CMAKE_BINARY_DIR)
+	(cd $(CMAKE_BINARY_DIR); \
+		CFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS)" \
+		CXXFLAGS="$(TARGET_CXXFLAGS) $(EXTRA_CXXFLAGS)" \
+		LDFLAGS="$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS)" \
+		cmake \
+			-DCMAKE_SYSTEM_NAME=Linux \
+			-DCMAKE_SYSTEM_VERSION=1 \
+			-DCMAKE_SYSTEM_PROCESSOR=$(ARCH) \
+			-DCMAKE_BUILD_TYPE=Release \
+			-DCMAKE_C_FLAGS_RELEASE="-DNDEBUG" \
+			-DCMAKE_CXX_FLAGS_RELEASE="-DNDEBUG" \
+			-DCMAKE_C_COMPILER="$(CMAKE_C_COMPILER)" \
+			-DCMAKE_C_COMPILER_ARG1="$(CMAKE_C_COMPILER_ARG1)" \
+			-DCMAKE_CXX_COMPILER="$(CMAKE_CXX_COMPILER)" \
+			-DCMAKE_CXX_COMPILER_ARG1="$(CMAKE_CXX_COMPILER_ARG1)" \
+			-DCMAKE_ASM_COMPILER="$(CMAKE_C_COMPILER)" \
+			-DCMAKE_ASM_COMPILER_ARG1="$(CMAKE_C_COMPILER_ARG1)" \
+			-DCMAKE_EXE_LINKER_FLAGS:STRING="$(TARGET_LDFLAGS)" \
+			-DCMAKE_MODULE_LINKER_FLAGS:STRING="$(TARGET_LDFLAGS) $(CMAKE_SHARED_LDFLAGS)" \
+			-DCMAKE_SHARED_LINKER_FLAGS:STRING="$(TARGET_LDFLAGS) $(CMAKE_SHARED_LDFLAGS)" \
+			-DCMAKE_AR="$(CMAKE_AR)" \
+			-DCMAKE_NM="$(CMAKE_NM)" \
+			-DCMAKE_RANLIB="$(CMAKE_RANLIB)" \
+			-DCMAKE_FIND_ROOT_PATH="$(CMAKE_FIND_ROOT_PATH)" \
+			-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=BOTH \
+			-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
+			-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
+			-DCMAKE_STRIP=: \
+			-DCMAKE_INSTALL_PREFIX=/usr \
+			-DDL_LIBRARY=$(STAGING_DIR) \
+			-DCMAKE_PREFIX_PATH=$(STAGING_DIR) \
+			-DCMAKE_SKIP_RPATH=TRUE  \
+			$(CMAKE_OPTIONS) \
+		$(CMAKE_SOURCE_DIR) \
+	)
+endef
+
+define Build/InstallDev/cmake
+	$(INSTALL_DIR) $(1)
+	$(CP) $(PKG_INSTALL_DIR)/* $(1)/
+endef
+
+Build/InstallDev = $(if $(CMAKE_INSTALL),$(Build/InstallDev/cmake))
+
+define Host/Configure/Default
+	(cd $(HOST_BUILD_DIR); \
+		CFLAGS="$(HOST_CFLAGS)" \
+		CXXFLAGS="$(HOST_CFLAGS)" \
+		LDFLAGS="$(HOST_LDFLAGS)" \
+		cmake \
+			-DCMAKE_BUILD_TYPE=Release \
+			-DCMAKE_C_FLAGS_RELEASE="-DNDEBUG" \
+			-DCMAKE_CXX_FLAGS_RELEASE="-DNDEBUG" \
+			-DCMAKE_EXE_LINKER_FLAGS:STRING="$(HOST_LDFLAGS)" \
+			-DCMAKE_MODULE_LINKER_FLAGS:STRING="$(HOST_LDFLAGS)" \
+			-DCMAKE_SHARED_LINKER_FLAGS:STRING="$(HOST_LDFLAGS)" \
+			-DCMAKE_FIND_ROOT_PATH="$(CMAKE_HOST_FIND_ROOT_PATH)" \
+			-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=BOTH \
+			-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
+			-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
+			-DCMAKE_STRIP=: \
+			-DCMAKE_INSTALL_PREFIX=$(HOST_BUILD_PREFIX) \
+			-DCMAKE_PREFIX_PATH=$(HOST_BUILD_PREFIX) \
+			-DCMAKE_SKIP_RPATH=TRUE  \
+			$(CMAKE_HOST_OPTIONS) \
+		$(HOST_CMAKE_SOURCE_DIR) \
+	)
+endef
+
+MAKE_FLAGS += \
+	CMAKE_COMMAND='$$(if $$(CMAKE_DISABLE_$$@),:,$(STAGING_DIR_HOST)/bin/cmake)' \
+	CMAKE_DISABLE_cmake_check_build_system=1

+ 51 - 0
include/debug.mk

@@ -0,0 +1,51 @@
+#
+# Copyright (C) 2007 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+# debug flags:
+#
+# d: show subdirectory tree
+# t: show added targets
+# l: show legacy targets
+# r: show autorebuild messages
+# v: verbose (no .SILENCE for common targets)
+
+ifeq ($(DUMP),)
+  ifeq ($(DEBUG),all)
+    build_debug:=dltvr
+  else
+    build_debug:=$(DEBUG)
+  endif
+endif
+
+ifneq ($(DEBUG),)
+
+define debug
+$$(findstring $(2),$$(if $$(DEBUG_SCOPE_DIR),$$(if $$(filter $$(DEBUG_SCOPE_DIR)%,$(1)),$(build_debug)),$(build_debug)))
+endef
+
+define warn
+$$(if $(call debug,$(1),$(2)),$$(warning $(3)))
+endef
+
+define debug_eval
+$$(if $(call debug,$(1),$(2)),$(3))
+endef
+
+define warn_eval
+$(call warn,$(1),$(2),$(3)	$(4))
+$(4)
+endef
+
+else
+
+debug:=
+warn:=
+debug_eval:=
+warn_eval = $(4)
+
+endif
+

+ 54 - 0
include/depends.mk

@@ -0,0 +1,54 @@
+#
+# Copyright (C) 2007 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+# define a dependency on a subtree
+# parameters:
+#	1: directories/files
+#	2: directory dependency
+#	3: tempfile for file listings
+#	4: find options
+
+DEP_FINDPARAMS := -x "*/.svn*" -x ".*" -x "*:*" -x "*\!*" -x "* *" -x "*\\\#*" -x "*/.*_check" -x "*/.*.swp" -x "*/.pkgdir*"
+
+find_md5=find $(wildcard $(1)) -type f $(patsubst -x,-and -not -path,$(DEP_FINDPARAMS) $(2)) | mkhash md5
+
+define rdep
+  .PRECIOUS: $(2)
+  .SILENT: $(2)_check
+
+  $(2): $(2)_check
+  check-depends: $(2)_check
+
+ifneq ($(wildcard $(2)),)
+  $(2)_check::
+	$(if $(3), \
+		$(call find_md5,$(1),$(4)) > $(3).1; \
+		{ [ \! -f "$(3)" ] || diff $(3) $(3).1 >/dev/null; } && \
+	) \
+	{ \
+		[ -f "$(2)_check.1" ] && mv "$(2)_check.1"; \
+	    $(TOPDIR)/scripts/timestamp.pl $(DEP_FINDPARAMS) $(4) -n $(2) $(1) && { \
+			$(call debug_eval,$(SUBDIR),r,echo "No need to rebuild $(2)";) \
+			touch -r "$(2)" "$(2)_check"; \
+		} \
+	} || { \
+		$(call debug_eval,$(SUBDIR),r,echo "Need to rebuild $(2)";) \
+		touch "$(2)_check"; \
+	}
+	$(if $(3), mv $(3).1 $(3))
+else
+  $(2)_check::
+	$(if $(3), rm -f $(3) $(3).1)
+	$(call debug_eval,$(SUBDIR),r,echo "Target $(2) not built")
+endif
+
+endef
+
+ifeq ($(filter .%,$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),$(MAKECMDGOALS),x))
+  define rdep
+    $(2): $(2)_check
+  endef
+endif

+ 5 - 0
include/device_table.txt

@@ -0,0 +1,5 @@
+# minimal device table file for libreCMC
+
+#<name>		<type>	<mode>	<uid>	<gid>	<major>	<minor>	<start>	<inc>	<count>
+/dev		d	755	0	0	-	-	-	-	-
+/dev/console	c	600	0	0	5	1	0	0	-

+ 324 - 0
include/download.mk

@@ -0,0 +1,324 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+# Copyright (C) 2016 LEDE project
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+PROJECT_GIT = https://git.openwrt.org
+
+LIBRECMC_GIT = $(PROJECT_GIT)
+LEDE_GIT = $(PROJECT_GIT)
+
+ifdef PKG_SOURCE_VERSION
+PKG_VERSION ?= $(if $(PKG_SOURCE_DATE),$(PKG_SOURCE_DATE)-)$(call version_abbrev,$(PKG_SOURCE_VERSION))
+PKG_SOURCE_SUBDIR ?= $(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE ?= $(PKG_SOURCE_SUBDIR).tar.xz
+endif
+
+DOWNLOAD_RDEP=$(STAMP_PREPARED) $(HOST_STAMP_PREPARED)
+
+define dl_method_git
+$(if $(filter https://github.com/% git://github.com/%,$(1)),github_archive,git)
+endef
+
+# Try to guess the download method from the URL
+define dl_method
+$(strip \
+  $(if $(filter git,$(2)),$(call dl_method_git,$(1),$(2)),
+    $(if $(2),$(2), \
+      $(if $(filter @APACHE/% @GITHUB/% @GNOME/% @GNU/% @KERNEL_LIBRE/% @KERNEL/% @SF/% @SAVANNAH/% ftp://% http://% https://% file://%,$(1)),default, \
+        $(if $(filter git://%,$(1)),$(call dl_method_git,$(1),$(2)), \
+          $(if $(filter svn://%,$(1)),svn, \
+            $(if $(filter cvs://%,$(1)),cvs, \
+              $(if $(filter hg://%,$(1)),hg, \
+                $(if $(filter sftp://%,$(1)),bzr, \
+                  unknown \
+                ) \
+              ) \
+            ) \
+          ) \
+        ) \
+      ) \
+    ) \
+  ) \
+)
+endef
+
+# code for creating tarballs from cvs/svn/git/bzr/hg/darcs checkouts - useful for mirror support
+dl_pack/bz2=bzip2 -c > $(1)
+dl_pack/gz=gzip -nc > $(1)
+dl_pack/xz=xz -zc -7e > $(1)
+dl_pack/unknown=$(error ERROR: Unknown pack format for file $(1))
+define dl_pack
+	$(if $(dl_pack/$(call ext,$(1))),$(dl_pack/$(call ext,$(1))),$(dl_pack/unknown))
+endef
+define dl_tar_pack
+	$(TAR) --numeric-owner --owner=0 --group=0 --sort=name $$$${TAR_TIMESTAMP:+--mtime="$$$$TAR_TIMESTAMP"} -c $(2) | $(call dl_pack,$(1))
+endef
+
+ifdef CHECK
+check_escape=$(subst ','\'',$(1))
+#')
+
+# $(1): suffix of the F_, C_ variables, e.g. hash_deprecated, hash_mismatch, etc.
+# $(2): filename
+# $(3): expected hash value
+# $(4): var name of the the form: {PKG_,Download/<name>:}{,MIRROR_}{HASH,MIRROR_HASH}
+check_warn_nofix = $(info $(shell printf "$(_R)WARNING: %s$(_N)" '$(call check_escape,$(call C_$(1),$(2),$(3),$(4)))'))
+ifndef FIXUP
+  check_warn = $(check_warn_nofix)
+else
+  check_warn = $(if $(filter-out undefined,$(origin F_$(1))),$(filter ,$(shell $(call F_$(1),$(2),$(3),$(4)) >&2)),$(check_warn_nofix))
+endif
+
+gen_sha256sum = $(shell mkhash sha256 $(DL_DIR)/$(1))
+
+ifdef FIXUP
+F_hash_deprecated = $(SCRIPT_DIR)/fixup-makefile.pl $(CURDIR)/Makefile fix-hash $(3) $(call gen_sha256sum,$(1)) $(2)
+F_hash_mismatch = $(F_hash_deprecated)
+F_hash_missing = $(SCRIPT_DIR)/fixup-makefile.pl $(CURDIR)/Makefile add-hash $(3) $(call gen_sha256sum,$(1))
+endif
+
+# $(1): filename
+# $(2): expected hash value
+# $(3): var name of the the form: {PKG_,Download/<name>:}{,MIRROR_}{HASH,MIRROR_HASH}
+C_download_missing = $(1) is missing, please run make download before re-running this check
+C_hash_mismatch = $(3) does not match $(1) hash $(call gen_sha256sum,$(1))
+C_hash_deprecated = $(3) uses deprecated hash, set to $(call gen_sha256sum,$(1))
+C_hash_missing = $(3) is missing, set to $(call gen_sha256sum,$(1))
+
+# $(1): filename
+# $(2): expected hash value
+# $(3): var name of the the form: {PKG_,Download/<name>:}{,MIRROR_}{HASH,MIRROR_HASH}
+check_hash = \
+  $(if $(wildcard $(DL_DIR)/$(1)), \
+    $(if $(filter-out x,$(2)), \
+      $(if $(filter 64,$(shell printf '%s' '$(2)' | wc -c)), \
+        $(if $(filter $(2),$(call gen_sha256sum,$(1))),, \
+          $(call check_warn,hash_mismatch,$(1),$(2),$(3)) \
+        ), \
+        $(call check_warn,hash_deprecated,$(1),$(2),$(3)), \
+      ), \
+      $(call check_warn,hash_missing,$(1),$(2),$(3)) \
+    ), \
+    $(call check_warn,download_missing,$(1),$(2),$(3)) \
+  )
+
+ifdef FIXUP
+F_md5_deprecated = $(SCRIPT_DIR)/fixup-makefile.pl $(CURDIR)/Makefile rename-var $(2) $(3)
+endif
+
+C_md5_deprecated = Use of $(2) is deprecated, switch to $(3)
+
+check_md5 = \
+  $(if $(filter-out x,$(1)), \
+    $(call check_warn,md5_deprecated,$(1),$(2),$(3)) \
+  )
+
+hash_var = $(if $(filter-out x,$(1)),MD5SUM,HASH)
+endif
+
+define DownloadMethod/unknown
+	echo "ERROR: No download method available"; false
+endef
+
+define DownloadMethod/default
+	$(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(FILE)" "$(HASH)" "$(URL_FILE)" $(foreach url,$(URL),"$(url)") \
+	$(if $(filter check,$(1)), \
+		$(call check_hash,$(FILE),$(HASH),$(2)$(call hash_var,$(MD5SUM))) \
+		$(call check_md5,$(MD5SUM),$(2)MD5SUM,$(2)HASH) \
+	)
+endef
+
+# $(1): "check"
+# $(2): "PKG_" if <name> as in Download/<name> is "default", otherwise "Download/<name>:"
+# $(3): shell command sequence to do the download
+define wrap_mirror
+$(if $(if $(MIRROR),$(filter-out x,$(MIRROR_HASH))),$(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(FILE)" "$(MIRROR_HASH)" "" || ( $(3) ),$(3)) \
+$(if $(filter check,$(1)), \
+	$(call check_hash,$(FILE),$(MIRROR_HASH),$(2)MIRROR_$(call hash_var,$(MIRROR_MD5SUM))) \
+	$(call check_md5,$(MIRROR_MD5SUM),$(2)MIRROR_MD5SUM,$(2)MIRROR_HASH) \
+)
+endef
+
+define DownloadMethod/cvs
+	$(call wrap_mirror,$(1),$(2), \
+		echo "Checking out files from the cvs repository..."; \
+		mkdir -p $(TMP_DIR)/dl && \
+		cd $(TMP_DIR)/dl && \
+		rm -rf $(SUBDIR) && \
+		[ \! -d $(SUBDIR) ] && \
+		cvs -d $(URL) export $(VERSION) $(SUBDIR) && \
+		echo "Packing checkout..." && \
+		$(call dl_tar_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \
+		mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/ && \
+		rm -rf $(SUBDIR); \
+	)
+endef
+
+define DownloadMethod/svn
+	$(call wrap_mirror,$(1),$(2), \
+		echo "Checking out files from the svn repository..."; \
+		mkdir -p $(TMP_DIR)/dl && \
+		cd $(TMP_DIR)/dl && \
+		rm -rf $(SUBDIR) && \
+		[ \! -d $(SUBDIR) ] && \
+		( svn help export | grep -q trust-server-cert && \
+		svn export --non-interactive --trust-server-cert -r$(VERSION) $(URL) $(SUBDIR) || \
+		svn export --non-interactive -r$(VERSION) $(URL) $(SUBDIR) ) && \
+		echo "Packing checkout..." && \
+		export TAR_TIMESTAMP="" && \
+		$(call dl_tar_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \
+		mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/ && \
+		rm -rf $(SUBDIR); \
+	)
+endef
+
+define DownloadMethod/git
+	$(call wrap_mirror,$(1),$(2), \
+		$(call DownloadMethod/rawgit) \
+	)
+endef
+
+define DownloadMethod/github_archive
+	$(call wrap_mirror,$(1),$(2), \
+		$(SCRIPT_DIR)/dl_github_archive.py \
+			--dl-dir="$(DL_DIR)" \
+			--url="$(URL)" \
+			--version="$(VERSION)" \
+			--subdir="$(SUBDIR)" \
+			--source="$(FILE)" \
+			--hash="$(MIRROR_HASH)" \
+		|| ( $(call DownloadMethod/rawgit) ); \
+	)
+endef
+
+# Only intends to be called as a submethod from other DownloadMethod
+define DownloadMethod/rawgit
+	echo "Checking out files from the git repository..."; \
+	mkdir -p $(TMP_DIR)/dl && \
+	cd $(TMP_DIR)/dl && \
+	rm -rf $(SUBDIR) && \
+	[ \! -d $(SUBDIR) ] && \
+	git clone $(OPTS) $(URL) $(SUBDIR) && \
+	(cd $(SUBDIR) && git checkout $(VERSION) && \
+	git submodule update --init --recursive) && \
+	echo "Packing checkout..." && \
+	export TAR_TIMESTAMP=`cd $(SUBDIR) && git log -1 --format='@%ct'` && \
+	rm -rf $(SUBDIR)/.git && \
+	$(call dl_tar_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \
+	mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/ && \
+	rm -rf $(SUBDIR);
+endef
+
+define DownloadMethod/bzr
+	$(call wrap_mirror,$(1),$(2), \
+		echo "Checking out files from the bzr repository..."; \
+		mkdir -p $(TMP_DIR)/dl && \
+		cd $(TMP_DIR)/dl && \
+		rm -rf $(SUBDIR) && \
+		[ \! -d $(SUBDIR) ] && \
+		bzr export --per-file-timestamps -r$(VERSION) $(SUBDIR) $(URL) && \
+		echo "Packing checkout..." && \
+		export TAR_TIMESTAMP="" && \
+		$(call dl_tar_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \
+		mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/ && \
+		rm -rf $(SUBDIR); \
+	)
+endef
+
+define DownloadMethod/hg
+	$(call wrap_mirror,$(1),$(2), \
+		echo "Checking out files from the hg repository..."; \
+		mkdir -p $(TMP_DIR)/dl && \
+		cd $(TMP_DIR)/dl && \
+		rm -rf $(SUBDIR) && \
+		[ \! -d $(SUBDIR) ] && \
+		hg clone -r $(VERSION) $(URL) $(SUBDIR) && \
+		export TAR_TIMESTAMP=`cd $(SUBDIR) && hg log --template '@{date}' -l 1` && \
+		find $(SUBDIR) -name .hg | xargs rm -rf && \
+		echo "Packing checkout..." && \
+		$(call dl_tar_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \
+		mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/ && \
+		rm -rf $(SUBDIR); \
+	)
+endef
+
+define DownloadMethod/darcs
+	$(call wrap_mirror, $(1), $(2), \
+		echo "Checking out files from the darcs repository..."; \
+		mkdir -p $(TMP_DIR)/dl && \
+		cd $(TMP_DIR)/dl && \
+		rm -rf $(SUBDIR) && \
+		[ \! -d $(SUBDIR) ] && \
+		darcs get -t $(VERSION) $(URL) $(SUBDIR) && \
+		export TAR_TIMESTAMP=`cd $(SUBDIR) && LC_ALL=C darcs log --last 1 | sed -ne 's!^Date: \+!!p'` && \
+		find $(SUBDIR) -name _darcs | xargs rm -rf && \
+		echo "Packing checkout..." && \
+		$(call dl_tar_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \
+		mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/ && \
+		rm -rf $(SUBDIR); \
+	)
+endef
+
+Validate/cvs=VERSION SUBDIR
+Validate/svn=VERSION SUBDIR
+Validate/git=VERSION SUBDIR
+Validate/bzr=VERSION SUBDIR
+Validate/hg=VERSION SUBDIR
+Validate/darcs=VERSION SUBDIR
+
+define Download/Defaults
+  URL:=
+  FILE:=
+  URL_FILE:=
+  PROTO:=
+  HASH=$$(MD5SUM)
+  MD5SUM:=x
+  SUBDIR:=
+  MIRROR:=1
+  MIRROR_HASH=$$(MIRROR_MD5SUM)
+  MIRROR_MD5SUM:=x
+  VERSION:=
+  OPTS:=
+endef
+
+define Download/default
+  FILE:=$(PKG_SOURCE)
+  URL:=$(PKG_SOURCE_URL)
+  SUBDIR:=$(PKG_SOURCE_SUBDIR)
+  PROTO:=$(PKG_SOURCE_PROTO)
+  $(if $(PKG_SOURCE_MIRROR),MIRROR:=$(filter 1,$(PKG_MIRROR)))
+  $(if $(PKG_MIRROR_MD5SUM),MIRROR_MD5SUM:=$(PKG_MIRROR_MD5SUM))
+  $(if $(PKG_MIRROR_HASH),MIRROR_HASH:=$(PKG_MIRROR_HASH))
+  VERSION:=$(PKG_SOURCE_VERSION)
+  $(if $(PKG_MD5SUM),MD5SUM:=$(PKG_MD5SUM))
+  $(if $(PKG_HASH),HASH:=$(PKG_HASH))
+endef
+
+define Download
+  $(eval $(Download/Defaults))
+  $(eval $(Download/$(1)))
+  $(foreach FIELD,URL FILE $(Validate/$(call dl_method,$(URL),$(PROTO))),
+    ifeq ($($(FIELD)),)
+      $$(error Download/$(1) is missing the $(FIELD) field.)
+    endif
+  )
+
+  $(foreach dep,$(DOWNLOAD_RDEP),
+    $(dep): $(DL_DIR)/$(FILE)
+  )
+  download: $(DL_DIR)/$(FILE)
+
+  $(DL_DIR)/$(FILE):
+	mkdir -p $(DL_DIR)
+	$(call locked, \
+		$(if $(DownloadMethod/$(call dl_method,$(URL),$(PROTO))), \
+			$(call DownloadMethod/$(call dl_method,$(URL),$(PROTO)),check,$(if $(filter default,$(1)),PKG_,Download/$(1):)), \
+			$(DownloadMethod/unknown) \
+		),\
+		$(FILE))
+
+endef

+ 43 - 0
include/feeds.mk

@@ -0,0 +1,43 @@
+#
+# Copyright (C) 2014 OpenWrt.org
+# Copyright (C) 2016 LEDE Project
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+-include $(TMP_DIR)/.packagesubdirs
+
+FEEDS_INSTALLED:=$(notdir $(wildcard $(TOPDIR)/package/feeds/*))
+FEEDS_AVAILABLE:=$(sort $(FEEDS_INSTALLED) $(shell $(SCRIPT_DIR)/feeds list -n))
+
+PACKAGE_SUBDIRS=$(PACKAGE_DIR)
+ifneq ($(CONFIG_PER_FEED_REPO),)
+  PACKAGE_SUBDIRS += $(OUTPUT_DIR)/packages/$(ARCH_PACKAGES)/base
+  PACKAGE_SUBDIRS += $(foreach FEED,$(FEEDS_AVAILABLE),$(OUTPUT_DIR)/packages/$(ARCH_PACKAGES)/$(FEED))
+endif
+
+opkg_package_files = $(wildcard \
+	$(foreach dir,$(PACKAGE_SUBDIRS), \
+	  $(foreach pkg,$(1), $(dir)/$(pkg)_*.ipk)))
+
+# 1: package name
+define FeedPackageDir
+$(strip $(if $(CONFIG_PER_FEED_REPO), \
+  $(if $(Package/$(1)/subdir), \
+    $(abspath $(OUTPUT_DIR)/packages/$(ARCH_PACKAGES)/$(Package/$(1)/subdir)), \
+    $(PACKAGE_DIR)), \
+  $(PACKAGE_DIR)))
+endef
+
+# 1: destination file
+define FeedSourcesAppend
+( \
+  echo 'src/gz %d_core %U/targets/%S/packages'; \
+  $(strip $(if $(CONFIG_PER_FEED_REPO), \
+	echo 'src/gz %d_base %U/packages/%A/base'; \
+	$(foreach feed,$(FEEDS_AVAILABLE), \
+		$(if $(CONFIG_FEED_$(feed)), \
+			echo '$(if $(filter m,$(CONFIG_FEED_$(feed))),# )src/gz %d_$(feed) %U/packages/%A/$(feed)';)))) \
+) >> $(1)
+endef

+ 2 - 0
include/hardened-ld-pie.specs

@@ -0,0 +1,2 @@
+*self_spec:
++ %{no-pie|static|r|shared:;:-pie}

+ 57 - 0
include/hardening.mk

@@ -0,0 +1,57 @@
+#
+# Copyright (C) 2015 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+PKG_CHECK_FORMAT_SECURITY ?= 1
+PKG_ASLR_PIE ?= 1
+PKG_SSP ?= 1
+PKG_FORTIFY_SOURCE ?= 1
+PKG_RELRO ?= 1
+
+ifdef CONFIG_PKG_CHECK_FORMAT_SECURITY
+  ifeq ($(strip $(PKG_CHECK_FORMAT_SECURITY)),1)
+    TARGET_CFLAGS += -Wformat -Werror=format-security
+  endif
+endif
+ifdef CONFIG_PKG_ASLR_PIE
+  ifeq ($(strip $(PKG_ASLR_PIE)),1)
+    TARGET_CFLAGS += $(FPIC)
+    TARGET_LDFLAGS += $(FPIC) -specs=$(INCLUDE_DIR)/hardened-ld-pie.specs
+  endif
+endif
+ifdef CONFIG_PKG_CC_STACKPROTECTOR_REGULAR
+  ifeq ($(strip $(PKG_SSP)),1)
+    TARGET_CFLAGS += -fstack-protector
+  endif
+endif
+ifdef CONFIG_PKG_CC_STACKPROTECTOR_STRONG
+  ifeq ($(strip $(PKG_SSP)),1)
+    TARGET_CFLAGS += -fstack-protector-strong
+  endif
+endif
+ifdef CONFIG_PKG_FORTIFY_SOURCE_1
+  ifeq ($(strip $(PKG_FORTIFY_SOURCE)),1)
+    TARGET_CFLAGS += -D_FORTIFY_SOURCE=1
+  endif
+endif
+ifdef CONFIG_PKG_FORTIFY_SOURCE_2
+  ifeq ($(strip $(PKG_FORTIFY_SOURCE)),1)
+    TARGET_CFLAGS += -D_FORTIFY_SOURCE=2
+  endif
+endif
+ifdef CONFIG_PKG_RELRO_PARTIAL
+  ifeq ($(strip $(PKG_RELRO)),1)
+    TARGET_CFLAGS += -Wl,-z,relro
+    TARGET_LDFLAGS += -zrelro
+  endif
+endif
+ifdef CONFIG_PKG_RELRO_FULL
+  ifeq ($(strip $(PKG_RELRO)),1)
+    TARGET_CFLAGS += -Wl,-z,now -Wl,-z,relro
+    TARGET_LDFLAGS += -znow -zrelro
+  endif
+endif
+

+ 211 - 0
include/host-build.mk

@@ -0,0 +1,211 @@
+#
+# Copyright (C) 2006-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(INCLUDE_DIR)/download.mk
+
+HOST_BUILD_DIR ?= $(BUILD_DIR_HOST)/$(PKG_NAME)$(if $(PKG_VERSION),-$(PKG_VERSION))
+HOST_INSTALL_DIR ?= $(HOST_BUILD_DIR)/host-install
+HOST_BUILD_PARALLEL ?=
+
+HOST_MAKE_J:=$(if $(MAKE_JOBSERVER),$(MAKE_JOBSERVER) $(if $(filter 3.% 4.0 4.1,$(MAKE_VERSION)),-j))
+
+ifeq ($(strip $(HOST_BUILD_PARALLEL)),0)
+HOST_JOBS?=-j1
+else
+HOST_JOBS?=$(if $(HOST_BUILD_PARALLEL),$(HOST_MAKE_J),-j1)
+endif
+
+include $(INCLUDE_DIR)/unpack.mk
+include $(INCLUDE_DIR)/depends.mk
+include $(INCLUDE_DIR)/quilt.mk
+
+BUILD_TYPES += host
+HOST_STAMP_PREPARED=$(HOST_BUILD_DIR)/.prepared$(if $(HOST_QUILT)$(DUMP),,$(shell $(call find_md5,${CURDIR} $(PKG_FILE_DEPENDS),))_$(call confvar,CONFIG_AUTOREMOVE $(HOST_PREPARED_DEPENDS)))
+HOST_STAMP_CONFIGURED:=$(HOST_BUILD_DIR)/.configured
+HOST_STAMP_BUILT:=$(HOST_BUILD_DIR)/.built
+HOST_BUILD_PREFIX?=$(if $(IS_PACKAGE_BUILD),$(STAGING_DIR_HOSTPKG),$(STAGING_DIR_HOST))
+HOST_STAMP_INSTALLED:=$(HOST_BUILD_PREFIX)/stamp/.$(PKG_NAME)_installed
+
+override MAKEFLAGS=
+
+include $(INCLUDE_DIR)/autotools.mk
+
+_host_target:=$(if $(HOST_QUILT),,.)
+
+Host/Patch:=$(Host/Patch/Default)
+ifneq ($(strip $(HOST_UNPACK)),)
+  define Host/Prepare/Default
+	$(HOST_UNPACK)
+	[ ! -d ./src/ ] || $(CP) ./src/* $(HOST_BUILD_DIR)
+	$(Host/Patch)
+  endef
+endif
+
+define Host/Prepare
+  $(call Host/Prepare/Default)
+endef
+
+HOST_CONFIGURE_VARS = \
+	CC="$(HOSTCC)" \
+	CFLAGS="$(HOST_CFLAGS)" \
+	CXX="$(HOSTCXX)" \
+	CPPFLAGS="$(HOST_CPPFLAGS)" \
+	LDFLAGS="$(HOST_LDFLAGS)" \
+	CONFIG_SHELL="$(SHELL)"
+
+HOST_CONFIGURE_ARGS = \
+	--target=$(GNU_HOST_NAME) \
+	--host=$(GNU_HOST_NAME) \
+	--build=$(GNU_HOST_NAME) \
+	--program-prefix="" \
+	--program-suffix="" \
+	--prefix=$(HOST_BUILD_PREFIX) \
+	--exec-prefix=$(HOST_BUILD_PREFIX) \
+	--sysconfdir=$(HOST_BUILD_PREFIX)/etc \
+	--localstatedir=$(HOST_BUILD_PREFIX)/var \
+	--sbindir=$(HOST_BUILD_PREFIX)/bin
+
+HOST_MAKE_VARS = \
+	CFLAGS="$(HOST_CFLAGS)" \
+	CPPFLAGS="$(HOST_CPPFLAGS)" \
+	CXXFLAGS="$(HOST_CXXFLAGS)" \
+	LDFLAGS="$(HOST_LDFLAGS)"
+
+HOST_MAKE_FLAGS =
+
+HOST_CONFIGURE_CMD = $(BASH) ./configure
+
+ifeq ($(HOST_OS),Darwin)
+  HOST_CONFIG_SITE:=$(INCLUDE_DIR)/site/darwin
+endif
+
+define Host/Configure/Default
+	$(if $(HOST_CONFIGURE_PARALLEL),+)(cd $(HOST_BUILD_DIR)/$(3); \
+		if [ -x configure ]; then \
+			$(CP) $(SCRIPT_DIR)/config.{guess,sub} $(HOST_BUILD_DIR)/$(3)/ && \
+			$(HOST_CONFIGURE_VARS) \
+			$(2) \
+			$(HOST_CONFIGURE_CMD) \
+			$(HOST_CONFIGURE_ARGS) \
+			$(1); \
+		fi \
+	)
+endef
+
+define Host/Configure
+  $(call Host/Configure/Default)
+endef
+
+define Host/Compile/Default
+	+$(HOST_MAKE_VARS) \
+	$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) \
+		$(HOST_MAKE_FLAGS) \
+		$(1)
+endef
+
+define Host/Compile
+  $(call Host/Compile/Default)
+endef
+
+define Host/Install/Default
+	$(call Host/Compile/Default,install)
+endef
+
+define Host/Install
+  $(call Host/Install/Default,$(HOST_BUILD_PREFIX))
+endef
+
+
+ifneq ($(if $(HOST_QUILT),,$(CONFIG_AUTOREBUILD)),)
+  define HostHost/Autoclean
+    $(call rdep,${CURDIR} $(PKG_FILE_DEPENDS),$(HOST_STAMP_PREPARED))
+    $(if $(if $(Host/Compile),$(filter prepare,$(MAKECMDGOALS)),1),,$(call rdep,$(HOST_BUILD_DIR),$(HOST_STAMP_BUILT)))
+  endef
+endif
+
+define Host/Exports/Default
+  $(1) : export ACLOCAL_INCLUDE=$$(foreach p,$$(wildcard $$(STAGING_DIR_HOST)/share/aclocal $$(STAGING_DIR_HOST)/share/aclocal-* $(if $(IS_PACKAGE_BUILD),$$(STAGING_DIR)/host/share/aclocal $$(STAGING_DIR_HOSTPKG)/share/aclocal $$(STAGING_DIR)/host/share/aclocal-*)),-I $$(p))
+  $(1) : export STAGING_PREFIX=$$(HOST_BUILD_PREFIX)
+  $(1) : export PKG_CONFIG_PATH=$$(STAGING_DIR_HOST)/lib/pkgconfig:$$(HOST_BUILD_PREFIX)/lib/pkgconfig
+  $(1) : export PKG_CONFIG_LIBDIR=$$(HOST_BUILD_PREFIX)/lib/pkgconfig
+  $(if $(CONFIG_CCACHE),$(1) : export CCACHE_DIR:=$(STAGING_DIR_HOST)/ccache)
+  $(if $(HOST_CONFIG_SITE),$(1) : export CONFIG_SITE:=$(HOST_CONFIG_SITE))
+  $(if $(IS_PACKAGE_BUILD),$(1) : export PATH=$$(TARGET_PATH_PKG))
+endef
+Host/Exports=$(Host/Exports/Default)
+
+.NOTPARALLEL:
+
+ifndef DUMP
+  define HostBuild/Core
+  $(if $(HOST_QUILT),$(Host/Quilt))
+  $(if $(DUMP),,$(call HostHost/Autoclean))
+
+  $(HOST_STAMP_PREPARED):
+	@-rm -rf $(HOST_BUILD_DIR)
+	@mkdir -p $(HOST_BUILD_DIR)
+	$(foreach hook,$(Hooks/HostPrepare/Pre),$(call $(hook))$(sep))
+	$(call Host/Prepare)
+	$(foreach hook,$(Hooks/HostPrepare/Post),$(call $(hook))$(sep))
+	touch $$@
+
+  $(call Host/Exports,$(HOST_STAMP_CONFIGURED))
+  $(HOST_STAMP_CONFIGURED): $(HOST_STAMP_PREPARED)
+	$(foreach hook,$(Hooks/HostConfigure/Pre),$(call $(hook))$(sep))
+	$(call Host/Configure)
+	$(foreach hook,$(Hooks/HostConfigure/Post),$(call $(hook))$(sep))
+	touch $$@
+
+  $(call Host/Exports,$(HOST_STAMP_BUILT))
+  $(HOST_STAMP_BUILT): $(HOST_STAMP_CONFIGURED)
+		$(foreach hook,$(Hooks/HostCompile/Pre),$(call $(hook))$(sep))
+		$(call Host/Compile)
+		$(foreach hook,$(Hooks/HostCompile/Post),$(call $(hook))$(sep))
+		touch $$@
+
+  $(call Host/Exports,$(HOST_STAMP_INSTALLED))
+  $(HOST_STAMP_INSTALLED): $(HOST_STAMP_BUILT) $(if $(FORCE_HOST_INSTALL),FORCE)
+		$(call Host/Install,$(HOST_BUILD_PREFIX))
+		$(foreach hook,$(Hooks/HostInstall/Post),$(call $(hook))$(sep))
+		mkdir -p $$(shell dirname $$@)
+		touch $(HOST_STAMP_BUILT)
+		touch $$@
+
+  $(call DefaultTargets,$(patsubst %,host-%,$(DEFAULT_SUBDIR_TARGETS)))
+  ifndef STAMP_BUILT
+    $(foreach t,$(DEFAULT_SUBDIR_TARGETS),
+      $(t): host-$(t)
+      .$(t): .host-$(t)
+    )
+    clean-build: host-clean-build
+  endif
+
+  $(_host_target)host-prepare: $(HOST_STAMP_PREPARED)
+  $(_host_target)host-configure: $(HOST_STAMP_CONFIGURED)
+  $(_host_target)host-compile: $(HOST_STAMP_BUILT) $(HOST_STAMP_INSTALLED)
+  host-install: host-compile
+
+  host-clean-build: FORCE
+	rm -rf $(HOST_BUILD_DIR) $(HOST_STAMP_BUILT)
+
+  host-clean: host-clean-build
+	$(call Host/Clean)
+	$(call Host/Uninstall)
+	rm -rf $(HOST_STAMP_INSTALLED)
+
+    ifneq ($(CONFIG_AUTOREMOVE),)
+      host-compile:
+		$(FIND) $(HOST_BUILD_DIR) -mindepth 1 -maxdepth 1 -not '(' -type f -and -name '.*' -and -size 0 ')' | \
+			$(XARGS) rm -rf
+    endif
+  endef
+endif
+
+define HostBuild
+  $(HostBuild/Core)
+  $(if $(if $(PKG_HOST_ONLY),,$(STAMP_PREPARED)),,$(if $(strip $(PKG_SOURCE_URL)),$(call Download,default)))
+endef

+ 362 - 0
include/image-commands.mk

@@ -0,0 +1,362 @@
+# Build commands that can be called from Device/* templates
+
+IMAGE_KERNEL = $(word 1,$^)
+IMAGE_ROOTFS = $(word 2,$^)
+
+define Build/uImage
+	mkimage -A $(LINUX_KARCH) \
+		-O linux -T kernel \
+		-C $(1) -a $(KERNEL_LOADADDR) -e $(if $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \
+		-n '$(if $(UIMAGE_NAME),$(UIMAGE_NAME),$(call toupper,$(LINUX_KARCH)) $(VERSION_DIST) Linux-$(LINUX_VERSION))' -d $@ $@.new
+	mv $@.new $@
+endef
+
+define Build/buffalo-enc
+	$(eval product=$(word 1,$(1)))
+	$(eval version=$(word 2,$(1)))
+	$(eval args=$(wordlist 3,$(words $(1)),$(1)))
+	$(STAGING_DIR_HOST)/bin/buffalo-enc \
+		-p $(product) -v $(version) $(args) \
+		-i $@ -o $@.new
+	mv $@.new $@
+endef
+
+define Build/buffalo-enc-tag
+	$(call Build/buffalo-enc,'' '' -S 152 $(1))
+endef
+
+define Build/buffalo-tag-dhp
+	$(eval product=$(word 1,$(1)))
+	$(eval region=$(word 2,$(1)))
+	$(eval language=$(word 3,$(1)))
+	$(STAGING_DIR_HOST)/bin/buffalo-tag \
+		-d 0x01000000 -w 1 \
+		-a $(BUFFALO_TAG_PLATFORM) \
+		-v $(BUFFALO_TAG_VERSION) -m $(BUFFALO_TAG_MINOR) \
+		-b $(product) -p $(product) \
+		-r $(region) -r $(region) -l $(language) \
+		-I $@ -o $@.new
+	mv $@.new $@
+endef
+
+define Build/buffalo-dhp-image
+	$(STAGING_DIR_HOST)/bin/mkdhpimg $@ $@.new
+	mv $@.new $@
+endef
+
+# blow up binary to given size and put a given string at its end:
+# cameo-factory <size[k]> <string>
+define Build/cameo-factory
+	factory_stamp=$(word 2,$(1)); \
+	((reduced_size=$(subst k,*1024,$(word 1,$(1)))-$${#factory_stamp})); \
+	( \
+		dd if=$@ bs=$$reduced_size conv=sync; \
+		echo -n $$factory_stamp; \
+	) > $@.new && \
+	mv $@.new $@
+endef
+
+# blow up binary to given size and put a given string at its end:
+# cameo-factory <size[k]> <string>
+define Build/cameo-factory
+	factory_stamp=$(word 2,$(1)); \
+	((reduced_size=$(subst k,*1024,$(word 1,$(1)))-$${#factory_stamp})); \
+	( \
+		dd if=$@ bs=$$reduced_size conv=sync; \
+		echo -n $$factory_stamp; \
+	) > $@.new && \
+	mv $@.new $@
+endef
+
+define Build/eva-image
+	$(STAGING_DIR_HOST)/bin/lzma2eva $(KERNEL_LOADADDR) $(KERNEL_LOADADDR) $@ $@.new
+	mv $@.new $@
+endef
+
+define Build/zyxel-ras-image
+	let \
+		newsize="$(subst k,* 1024,$(RAS_ROOTFS_SIZE))"; \
+		$(STAGING_DIR_HOST)/bin/mkrasimage \
+			-b $(RAS_BOARD) \
+			-v $(RAS_VERSION) \
+			-r $@ \
+			-s $$newsize \
+			-o $@.new \
+			$(if $(findstring separate-kernel,$(word 1,$(1))),-k $(IMAGE_KERNEL)) \
+		&& mv $@.new $@
+endef
+
+define Build/netgear-chk
+	$(STAGING_DIR_HOST)/bin/mkchkimg \
+		-o $@.new \
+		-k $@ \
+		-b $(NETGEAR_BOARD_ID) \
+		$(if $(NETGEAR_REGION),-r $(NETGEAR_REGION),)
+	mv $@.new $@
+endef
+
+define Build/netgear-dni
+	$(STAGING_DIR_HOST)/bin/mkdniimg \
+		-B $(NETGEAR_BOARD_ID) -v $(VERSION_DIST).$(firstword $(subst -, ,$(REVISION))) \
+		$(if $(NETGEAR_HW_ID),-H $(NETGEAR_HW_ID)) \
+		-r "$(1)" \
+		-i $@ -o $@.new
+	mv $@.new $@
+endef
+
+define Build/append-squashfs-fakeroot-be
+	rm -rf $@.fakefs $@.fakesquashfs
+	mkdir $@.fakefs
+	$(STAGING_DIR_HOST)/bin/mksquashfs-lzma \
+		$@.fakefs $@.fakesquashfs \
+		-noappend -root-owned -be -nopad -b 65536 \
+		$(if $(SOURCE_DATE_EPOCH),-fixed-time $(SOURCE_DATE_EPOCH))
+	cat $@.fakesquashfs >> $@
+endef
+
+# append a fake/empty uImage header, to fool bootloaders rootfs integrity check
+# for example
+define Build/append-uImage-fakehdr
+	touch $@.fakehdr
+	$(STAGING_DIR_HOST)/bin/mkimage \
+		-A $(LINUX_KARCH) -O linux -T $(1) -C none \
+		-n '$(VERSION_DIST) fake $(1)' \
+		-d $@.fakehdr \
+		-s \
+		$@.fakehdr
+	cat $@.fakehdr >> $@
+endef
+
+define Build/tplink-safeloader
+       -$(STAGING_DIR_HOST)/bin/tplink-safeloader \
+		-B $(TPLINK_BOARD_ID) \
+		-V $(REVISION) \
+		-k $(IMAGE_KERNEL) \
+		-r $@ \
+		-o $@.new \
+		-j \
+		$(wordlist 2,$(words $(1)),$(1)) \
+		$(if $(findstring sysupgrade,$(word 1,$(1))),-S) && mv $@.new $@ || rm -f $@
+endef
+
+define Build/mksercommfw
+	-$(STAGING_DIR_HOST)/bin/mksercommfw \
+		$@ \
+		$(KERNEL_OFFSET) \
+		$(HWID) \
+		$(HWVER) \
+		$(SWVER)
+endef
+
+
+define Build/append-dtb
+	cat $(KDIR)/image-$(firstword $(DEVICE_DTS)).dtb >> $@
+endef
+
+define Build/install-dtb
+	$(foreach dts,$(DEVICE_DTS), \
+		$(CP) \
+			$(DTS_DIR)/$(dts).dtb \
+			$(BIN_DIR)/$(IMG_PREFIX)-$(dts).dtb; \
+	)
+endef
+
+define Build/fit
+	$(TOPDIR)/scripts/mkits.sh \
+		-D $(DEVICE_NAME) -o $@.its -k $@ \
+		$(if $(word 2,$(1)),-d $(word 2,$(1))) -C $(word 1,$(1)) \
+		-a $(KERNEL_LOADADDR) -e $(if $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \
+		-c $(if $(DEVICE_DTS_CONFIG),$(DEVICE_DTS_CONFIG),"config@1") \
+		-A $(LINUX_KARCH) -v $(LINUX_VERSION)
+	PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $@.its $@.new
+	@mv $@.new $@
+endef
+
+define Build/lzma
+	$(call Build/lzma-no-dict,-lc1 -lp2 -pb2 $(1))
+endef
+
+define Build/lzma-no-dict
+	$(STAGING_DIR_HOST)/bin/lzma e $@ $(1) $@.new
+	@mv $@.new $@
+endef
+
+define Build/gzip
+	gzip -f -9n -c $@ $(1) > $@.new
+	@mv $@.new $@
+endef
+
+define Build/jffs2
+	rm -rf $(KDIR_TMP)/$(DEVICE_NAME)/jffs2 && \
+		mkdir -p $(KDIR_TMP)/$(DEVICE_NAME)/jffs2/$$(dirname $(1)) && \
+		cp $@ $(KDIR_TMP)/$(DEVICE_NAME)/jffs2/$(1) && \
+		$(STAGING_DIR_HOST)/bin/mkfs.jffs2 --pad \
+			$(if $(CONFIG_BIG_ENDIAN),--big-endian,--little-endian) \
+			--squash-uids -v -e $(patsubst %k,%KiB,$(BLOCKSIZE)) \
+			-o $@.new \
+			-d $(KDIR_TMP)/$(DEVICE_NAME)/jffs2 \
+			2>&1 1>/dev/null | awk '/^.+$$$$/' && \
+		$(STAGING_DIR_HOST)/bin/padjffs2 $@.new -J $(patsubst %k,,$(BLOCKSIZE))
+	-rm -rf $(KDIR_TMP)/$(DEVICE_NAME)/jffs2/
+	@mv $@.new $@
+endef
+
+define Build/kernel-bin
+	rm -f $@
+	cp $< $@
+endef
+
+define Build/patch-cmdline
+	$(STAGING_DIR_HOST)/bin/patch-cmdline $@ '$(CMDLINE)'
+endef
+
+define Build/append-kernel
+	dd if=$(IMAGE_KERNEL) >> $@
+endef
+
+define Build/append-rootfs
+	dd if=$(IMAGE_ROOTFS) >> $@
+endef
+
+define Build/append-ubi
+	sh $(TOPDIR)/scripts/ubinize-image.sh \
+		$(if $(UBOOTENV_IN_UBI),--uboot-env) \
+		$(if $(KERNEL_IN_UBI),--kernel $(IMAGE_KERNEL)) \
+		$(foreach part,$(UBINIZE_PARTS),--part $(part)) \
+		$(IMAGE_ROOTFS) \
+		$@.tmp \
+		-p $(BLOCKSIZE:%k=%KiB) -m $(PAGESIZE) \
+		$(if $(SUBPAGESIZE),-s $(SUBPAGESIZE)) \
+		$(if $(VID_HDR_OFFSET),-O $(VID_HDR_OFFSET)) \
+		$(UBINIZE_OPTS)
+	cat $@.tmp >> $@
+	rm $@.tmp
+endef
+
+define Build/append-uboot
+	dd if=$(UBOOT_PATH) >> $@
+endef
+
+define Build/pad-to
+	dd if=$@ of=$@.new bs=$(1) conv=sync
+	mv $@.new $@
+endef
+
+define Build/pad-extra
+	dd if=/dev/zero bs=$(1) count=1 >> $@
+endef
+
+define Build/pad-rootfs
+	$(STAGING_DIR_HOST)/bin/padjffs2 $@ $(1) \
+		$(if $(BLOCKSIZE),$(BLOCKSIZE:%k=%),4 8 16 64 128 256)
+endef
+
+define Build/pad-offset
+	let \
+		size="$$(stat -c%s $@)" \
+		pad="$(subst k,* 1024,$(word 1, $(1)))" \
+		offset="$(subst k,* 1024,$(word 2, $(1)))" \
+		pad="(pad - ((size + offset) % pad)) % pad" \
+		newsize='size + pad'; \
+		dd if=$@ of=$@.new bs=$$newsize count=1 conv=sync
+	mv $@.new $@
+endef
+
+define Build/check-size
+	@[ $$(($(subst k,* 1024,$(subst m, * 1024k,$(1))))) -ge "$$(stat -c%s $@)" ] || { \
+		echo "WARNING: Image file $@ is too big" >&2; \
+		rm -f $@; \
+	}
+endef
+
+define Build/combined-image
+	-sh $(TOPDIR)/scripts/combined-image.sh \
+		"$(IMAGE_KERNEL)" \
+		"$@" \
+		"$@.new"
+	@mv $@.new $@
+endef
+
+define Build/openmesh-image
+	$(TOPDIR)/scripts/om-fwupgradecfg-gen.sh \
+		"$(call param_get_default,ce_type,$(1),$(DEVICE_NAME))" \
+		"$@-fwupgrade.cfg" \
+		"$(call param_get_default,kernel,$(1),$(IMAGE_KERNEL))" \
+		"$(call param_get_default,rootfs,$(1),$@)"
+	$(TOPDIR)/scripts/combined-ext-image.sh \
+		"$(call param_get_default,ce_type,$(1),$(DEVICE_NAME))" "$@" \
+		"$@-fwupgrade.cfg" "fwupgrade.cfg" \
+		"$(call param_get_default,kernel,$(1),$(IMAGE_KERNEL))" "kernel" \
+		"$(call param_get_default,rootfs,$(1),$@)" "rootfs"
+endef
+
+define Build/senao-header
+	$(STAGING_DIR_HOST)/bin/mksenaofw $(1) -e $@ -o $@.new
+	mv $@.new $@
+endef
+
+define Build/sysupgrade-tar
+	sh $(TOPDIR)/scripts/sysupgrade-tar.sh \
+		--board $(if $(BOARD_NAME),$(BOARD_NAME),$(DEVICE_NAME)) \
+		--kernel $(call param_get_default,kernel,$(1),$(IMAGE_KERNEL)) \
+		--rootfs $(call param_get_default,rootfs,$(1),$(IMAGE_ROOTFS)) \
+		$@
+endef
+
+define Build/tplink-v1-header
+	$(STAGING_DIR_HOST)/bin/mktplinkfw \
+		-c -H $(TPLINK_HWID) -W $(TPLINK_HWREV) -L $(KERNEL_LOADADDR) \
+		-E $(if $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \
+		-m $(TPLINK_HEADER_VERSION) -N "$(VERSION_DIST)" -V $(REVISION) \
+		-k $@ -o $@.new $(1)
+	@mv $@.new $@
+endef
+
+define Build/tplink-v2-header
+	$(STAGING_DIR_HOST)/bin/mktplinkfw2 \
+		-c -H $(TPLINK_HWID) -W $(TPLINK_HWREV) -L $(KERNEL_LOADADDR) \
+		-E $(if $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR))  \
+		-w $(TPLINK_HWREVADD) -F "$(TPLINK_FLASHLAYOUT)" \
+		-T $(TPLINK_HVERSION) -V "ver. 2.0" \
+		-k $@ -o $@.new $(1)
+	@mv $@.new $@
+endef
+
+define Build/tplink-v2-image
+	$(STAGING_DIR_HOST)/bin/mktplinkfw2 \
+		-H $(TPLINK_HWID) -W $(TPLINK_HWREV) \
+		-w $(TPLINK_HWREVADD) -F "$(TPLINK_FLASHLAYOUT)" \
+		-T $(TPLINK_HVERSION) -V "ver. 2.0" -a 0x4 -j \
+		-k $(IMAGE_KERNEL) -r $(IMAGE_ROOTFS) -o $@.new $(1)
+	cat $@.new >> $@
+	rm -rf $@.new
+endef
+
+json_quote=$(subst ','\'',$(subst ",\",$(1)))
+#")')
+metadata_devices=$(if $(1),$(subst "$(space)","$(comma)",$(strip $(foreach v,$(1),"$(call json_quote,$(v))"))))
+metadata_json = \
+	'{ $(if $(IMAGE_METADATA),$(IMAGE_METADATA)$(comma)) \
+		"supported_devices":[$(call metadata_devices,$(1))], \
+		"version": { \
+			"dist": "$(call json_quote,$(VERSION_DIST))", \
+			"version": "$(call json_quote,$(VERSION_NUMBER))", \
+			"revision": "$(call json_quote,$(REVISION))", \
+			"board": "$(call json_quote,$(BOARD))" \
+		} \
+	}'
+
+define Build/append-metadata
+	$(if $(SUPPORTED_DEVICES),-echo $(call metadata_json,$(SUPPORTED_DEVICES)) | fwtool -I - $@)
+	[ ! -s "$(BUILD_KEY)" -o ! -s "$(BUILD_KEY).ucert" -o ! -s "$@" ] || { \
+		cp "$(BUILD_KEY).ucert" "$@.ucert" ;\
+		usign -S -m "$@" -s "$(BUILD_KEY)" -x "$@.sig" ;\
+		ucert -A -c "$@.ucert" -x "$@.sig" ;\
+		fwtool -S "$@.ucert" "$@" ;\
+	}
+endef
+
+define Build/kernel2minor
+	kernel2minor -k $@ -r $@.new $(1)
+	mv $@.new $@
+endef

+ 93 - 0
include/image-legacy.mk

@@ -0,0 +1,93 @@
+ifneq ($(CONFIG_TARGET_ROOTFS_UBIFS),)
+    define Image/mkfs/ubifs/generate
+	$(CP) ./ubinize$(1).cfg $(KDIR)
+	( cd $(KDIR); \
+		$(STAGING_DIR_HOST)/bin/ubinize \
+		$(if $($(PROFILE)_UBI_OPTS),$($(PROFILE)_UBI_OPTS),$(shell echo $(UBI_OPTS))) \
+		-o $(KDIR)/root$(1).ubi \
+		ubinize$(1).cfg \
+	)
+    endef
+
+    define Image/mkfs/ubifs/legacy
+
+        $(if $($(PROFILE)_UBIFS_OPTS)$(UBIFS_OPTS),
+		$(STAGING_DIR_HOST)/bin/mkfs.ubifs \
+			$(if $($(PROFILE)_UBIFS_OPTS),$($(PROFILE)_UBIFS_OPTS),$(UBIFS_OPTS)) \
+			$(if $(CONFIG_TARGET_UBIFS_FREE_SPACE_FIXUP),--space-fixup) \
+			$(if $(CONFIG_TARGET_UBIFS_COMPRESSION_NONE),--compr=none) \
+			$(if $(CONFIG_TARGET_UBIFS_COMPRESSION_LZO),--compr=lzo) \
+			$(if $(CONFIG_TARGET_UBIFS_COMPRESSION_ZLIB),--compr=zlib) \
+			$(if $(shell echo $(CONFIG_TARGET_UBIFS_JOURNAL_SIZE)),--jrn-size=$(CONFIG_TARGET_UBIFS_JOURNAL_SIZE)) \
+			--squash-uids \
+			-o $(KDIR)/root.ubifs \
+			-d $(TARGET_DIR)
+	)
+	$(call Image/Build,ubifs)
+
+        $(if $($(PROFILE)_UBI_OPTS)$(UBI_OPTS),
+		$(if $(wildcard ./ubinize.cfg),$(call Image/mkfs/ubifs/generate,))
+		$(if $(wildcard ./ubinize-overlay.cfg),$(call Image/mkfs/ubifs/generate,-overlay))
+	)
+	$(if $(wildcard ./ubinize.cfg),$(call Image/Build,ubi))
+    endef
+endif
+
+LegacyDevice/Dump = $(Device/Dump)
+
+define LegacyDevice/Check
+  $(Device/Check/Common)
+  _TARGET_PREPARE := $$(if $$(_PROFILE_SET),legacy-images-prepare,prepare-disabled)
+  _TARGET := $$(if $$(_PROFILE_SET),legacy-images,install-disabled)
+  $$(if $$(_PROFILE_SET),install: legacy-images-make)
+  ifndef IB
+    $$(if $$(_PROFILE_SET),kernel_prepare: legacy-images-prepare-make)
+  endif
+endef
+
+ifdef TARGET_PER_DEVICE_ROOTFS
+  define Image/Build/Profile/Filesystem
+	cp $(KDIR)/root.$(2)+pkg=$(3) $(KDIR)/root.$(2)
+	$(call Image/Build/$(2),$(2))
+	$(call Image/Build/Profile,$(1),$(2))
+  endef
+else
+  Image/Build/Profile/Filesystem = $(Image/Build/Profile)
+endif
+
+define LegacyDevice/Build
+  $$(_TARGET): legacy-image-$(1)
+  $$(_TARGET_PREPARE): legacy-image-prepare-$(1)
+  .PHONY: legacy-image-prepare-$(1) legacy-image-$(1)
+
+  legacy-image-prepare-$(1):
+	$$(call Image/Prepare/Profile,$(1))
+
+  ifndef IB
+    ifdef CONFIG_TARGET_PER_DEVICE_ROOTFS
+      ROOTFS/$(1) := $(foreach fs,$(TARGET_FILESYSTEMS), \
+        $(KDIR)/root.$(fs)$$(strip $(if $(CONFIG_TARGET_PER_DEVICE_ROOTFS),+pkg=$$(ROOTFS_ID/$(1)))) \
+      )
+
+      $$(ROOTFS/$(1)): target-dir-$$(ROOTFS_ID/$(1))
+      legacy-images-make: $$(if $$(_PROFILE_SET),$$(ROOTFS/$(1)))
+    endif
+  endif
+
+  legacy-image-$(1):
+	$$(call Image/BuildKernel/Profile,$(1))
+	$(foreach fs,$(TARGET_FILESYSTEMS),
+		$$(call Image/Build/Profile/Filesystem,$(1),$(fs),$$(ROOTFS_ID/$(1)))
+	)
+
+endef
+
+define LegacyDevice
+  $(call Device/InitProfile,$(1))
+  $(call Device/Default,$(1))
+  $(call LegacyDevice/Default,$(1))
+  $(call LegacyDevice/$(1),$(1))
+  $(call LegacyDevice/Check,$(1))
+  $(call LegacyDevice/$(if $(DUMP),Dump,Build),$(1))
+
+endef

+ 613 - 0
include/image.mk

@@ -0,0 +1,613 @@
+#
+# Copyright (C) 2006-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+override TARGET_BUILD=
+include $(INCLUDE_DIR)/prereq.mk
+include $(INCLUDE_DIR)/kernel.mk
+include $(INCLUDE_DIR)/version.mk
+include $(INCLUDE_DIR)/image-commands.mk
+
+ifndef IB
+  ifdef CONFIG_TARGET_PER_DEVICE_ROOTFS
+    TARGET_PER_DEVICE_ROOTFS := 1
+  endif
+endif
+
+include $(INCLUDE_DIR)/image-legacy.mk
+include $(INCLUDE_DIR)/feeds.mk
+include $(INCLUDE_DIR)/rootfs.mk
+
+override MAKE:=$(_SINGLE)$(SUBMAKE)
+override NO_TRACE_MAKE:=$(_SINGLE)$(NO_TRACE_MAKE)
+
+target_params = $(subst +,$(space),$*)
+param_get = $(patsubst $(1)=%,%,$(filter $(1)=%,$(2)))
+param_get_default = $(firstword $(call param_get,$(1),$(2)) $(3))
+param_mangle = $(subst $(space),_,$(strip $(1)))
+param_unmangle = $(subst _,$(space),$(1))
+
+mkfs_packages_id = $(shell echo $(sort $(1)) | mkhash md5 | head -c 8)
+mkfs_target_dir = $(if $(call param_get,pkg,$(1)),$(KDIR)/target-dir-$(call param_get,pkg,$(1)),$(TARGET_DIR))
+
+KDIR=$(KERNEL_BUILD_DIR)
+KDIR_TMP=$(KDIR)/tmp
+DTS_DIR:=$(LINUX_DIR)/arch/$(LINUX_KARCH)/boot/dts
+
+IMG_PREFIX_EXTRA:=$(if $(EXTRA_IMAGE_NAME),$(call sanitize,$(EXTRA_IMAGE_NAME))-)
+IMG_PREFIX_VERNUM:=$(if $(CONFIG_VERSION_FILENAMES),$(call sanitize,$(VERSION_NUMBER))-)
+IMG_PREFIX_VERCODE:=$(if $(CONFIG_VERSION_CODE_FILENAMES),$(call sanitize,$(VERSION_CODE))-)
+
+IMG_PREFIX:=$(VERSION_DIST_SANITIZED)-$(IMG_PREFIX_VERNUM)$(IMG_PREFIX_VERCODE)$(IMG_PREFIX_EXTRA)$(BOARD)$(if $(SUBTARGET),-$(SUBTARGET))
+
+MKFS_DEVTABLE_OPT := -D $(INCLUDE_DIR)/device_table.txt
+
+ifneq ($(CONFIG_BIG_ENDIAN),)
+  JFFS2OPTS     :=  --big-endian --squash-uids -v
+else
+  JFFS2OPTS     :=  --little-endian --squash-uids -v
+endif
+
+ifeq ($(CONFIG_JFFS2_RTIME),y)
+  JFFS2OPTS += -X rtime
+endif
+ifeq ($(CONFIG_JFFS2_ZLIB),y)
+  JFFS2OPTS += -X zlib
+endif
+ifeq ($(CONFIG_JFFS2_LZMA),y)
+  JFFS2OPTS += -X lzma --compression-mode=size
+endif
+ifneq ($(CONFIG_JFFS2_RTIME),y)
+  JFFS2OPTS += -x rtime
+endif
+ifneq ($(CONFIG_JFFS2_ZLIB),y)
+  JFFS2OPTS += -x zlib
+endif
+ifneq ($(CONFIG_JFFS2_LZMA),y)
+  JFFS2OPTS += -x lzma
+endif
+
+JFFS2OPTS += $(MKFS_DEVTABLE_OPT)
+
+SQUASHFS_BLOCKSIZE := $(CONFIG_TARGET_SQUASHFS_BLOCK_SIZE)k
+SQUASHFSOPT := -b $(SQUASHFS_BLOCKSIZE)
+SQUASHFSOPT += -p '/dev d 755 0 0' -p '/dev/console c 600 0 0 5 1'
+SQUASHFSCOMP := gzip
+LZMA_XZ_OPTIONS := -Xpreset 9 -Xe -Xlc 0 -Xlp 2 -Xpb 2
+ifeq ($(CONFIG_SQUASHFS_XZ),y)
+  ifneq ($(filter arm x86 powerpc sparc,$(LINUX_KARCH)),)
+    BCJ_FILTER:=-Xbcj $(LINUX_KARCH)
+  endif
+  SQUASHFSCOMP := xz $(LZMA_XZ_OPTIONS) $(BCJ_FILTER)
+endif
+
+JFFS2_BLOCKSIZE ?= 64k 128k
+
+fs-types-$(CONFIG_TARGET_ROOTFS_SQUASHFS) += squashfs
+fs-types-$(CONFIG_TARGET_ROOTFS_JFFS2) += $(addprefix jffs2-,$(JFFS2_BLOCKSIZE))
+fs-types-$(CONFIG_TARGET_ROOTFS_JFFS2_NAND) += $(addprefix jffs2-nand-,$(NAND_BLOCKSIZE))
+fs-types-$(CONFIG_TARGET_ROOTFS_EXT4FS) += ext4
+fs-types-$(CONFIG_TARGET_ROOTFS_ISO) += iso
+fs-types-$(CONFIG_TARGET_ROOTFS_UBIFS) += ubifs
+fs-subtypes-$(CONFIG_TARGET_ROOTFS_JFFS2) += $(addsuffix -raw,$(addprefix jffs2-,$(JFFS2_BLOCKSIZE)))
+
+TARGET_FILESYSTEMS := $(fs-types-y)
+
+FS_64K := $(filter-out jffs2-%,$(TARGET_FILESYSTEMS)) jffs2-64k
+FS_128K := $(filter-out jffs2-%,$(TARGET_FILESYSTEMS)) jffs2-128k
+FS_256K := $(filter-out jffs2-%,$(TARGET_FILESYSTEMS)) jffs2-256k
+
+define add_jffs2_mark
+	echo -ne '\xde\xad\xc0\xde' >> $(1)
+endef
+
+PROFILE_SANITIZED := $(call sanitize,$(PROFILE))
+
+define split_args
+$(foreach data, \
+	$(subst |,$(space),\
+		$(subst $(space),^,$(1))), \
+	$(call $(2),$(strip $(subst ^,$(space),$(data)))))
+endef
+
+define build_cmd
+$(if $(Build/$(word 1,$(1))),,$(error Missing Build/$(word 1,$(1))))
+$(call Build/$(word 1,$(1)),$(wordlist 2,$(words $(1)),$(1)))
+
+endef
+
+define concat_cmd
+$(call split_args,$(1),build_cmd)
+endef
+
+# pad to 4k, 8k, 16k, 64k, 128k, 256k and add jffs2 end-of-filesystem mark
+define prepare_generic_squashfs
+	$(STAGING_DIR_HOST)/bin/padjffs2 $(1) 4 8 16 64 128 256
+endef
+
+define Image/BuildKernel/Initramfs
+	$(call Image/Build/Initramfs)
+endef
+
+define Image/BuildKernel/MkuImage
+	mkimage -A $(ARCH) -O linux -T kernel -C $(1) -a $(2) -e $(3) \
+		-n '$(call toupper,$(ARCH)) $(VERSION_DIST) Linux-$(LINUX_VERSION)' -d $(4) $(5)
+endef
+
+define Image/BuildKernel/MkFIT
+	$(TOPDIR)/scripts/mkits.sh \
+		-D $(1) -o $(KDIR)/fit-$(1).its -k $(2) $(if $(3),-d $(3)) -C $(4) -a $(5) -e $(6) \
+		-c $(if $(DEVICE_DTS_CONFIG),$(DEVICE_DTS_CONFIG),"config@1") \
+		-A $(LINUX_KARCH) -v $(LINUX_VERSION)
+	PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $(KDIR)/fit-$(1).its $(KDIR)/fit-$(1)$(7).itb
+endef
+
+ifdef CONFIG_TARGET_IMAGES_GZIP
+  define Image/Gzip
+	rm -f $(1).gz
+	gzip -9n $(1)
+  endef
+endif
+
+# $(1) source dts file
+# $(2) target dtb file
+# $(3) extra CPP flags
+# $(4) extra DTC flags
+define Image/BuildDTB
+	$(TARGET_CROSS)cpp -nostdinc -x assembler-with-cpp \
+		-I$(DTS_DIR) \
+		-I$(DTS_DIR)/include \
+		-I$(LINUX_DIR)/include/ \
+		-undef -D__DTS__ $(3) \
+		-o $(2).tmp $(1)
+	$(LINUX_DIR)/scripts/dtc/dtc -O dtb \
+		-i$(dir $(1)) $(4) \
+		-o $(2) $(2).tmp
+	$(RM) $(2).tmp
+endef
+
+define Image/mkfs/jffs2/sub-raw
+	$(STAGING_DIR_HOST)/bin/mkfs.jffs2 \
+		$(2) \
+		-e $(patsubst %k,%KiB,$(1)) \
+		-o $@ -d $(call mkfs_target_dir,$(3)) \
+		-v 2>&1 1>/dev/null | awk '/^.+$$$$/'
+endef
+
+define Image/mkfs/jffs2/sub
+	$(call Image/mkfs/jffs2/sub-raw,$(1),--pad $(2),$(3))
+	$(call add_jffs2_mark,$@)
+endef
+
+define Image/mkfs/jffs2/template
+  Image/mkfs/jffs2-$(1) = $$(call Image/mkfs/jffs2/sub,$(1),$(JFFS2OPTS),$$(1))
+  Image/mkfs/jffs2-$(1)-raw = $$(call Image/mkfs/jffs2/sub-raw,$(1),$(JFFS2OPTS),$$(1))
+
+endef
+
+define Image/mkfs/jffs2-nand/template
+  Image/mkfs/jffs2-nand-$(1) = \
+	$$(call Image/mkfs/jffs2/sub, \
+		$(word 2,$(subst -, ,$(1))), \
+			$(JFFS2OPTS) --no-cleanmarkers --pagesize=$(word 1,$(subst -, ,$(1))),$$(1))
+
+endef
+
+$(eval $(foreach S,$(JFFS2_BLOCKSIZE),$(call Image/mkfs/jffs2/template,$(S))))
+$(eval $(foreach S,$(NAND_BLOCKSIZE),$(call Image/mkfs/jffs2-nand/template,$(S))))
+
+define Image/mkfs/squashfs
+	$(STAGING_DIR_HOST)/bin/mksquashfs4 $(call mkfs_target_dir,$(1)) $@ \
+		-nopad -noappend -root-owned \
+		-comp $(SQUASHFSCOMP) $(SQUASHFSOPT) \
+		-processors 1 \
+		$(if $(SOURCE_DATE_EPOCH),-fixed-time $(SOURCE_DATE_EPOCH))
+endef
+
+# $(1): board name
+# $(2): rootfs type
+# $(3): kernel image
+# $(4): compat string
+ifneq ($(CONFIG_NAND_SUPPORT),)
+   define Image/Build/SysupgradeNAND
+	mkdir -p "$(KDIR_TMP)/sysupgrade-$(if $(4),$(4),$(1))/"
+	echo "BOARD=$(if $(4),$(4),$(1))" > "$(KDIR_TMP)/sysupgrade-$(if $(4),$(4),$(1))/CONTROL"
+	[ -z "$(2)" ] || $(CP) "$(KDIR)/root.$(2)" "$(KDIR_TMP)/sysupgrade-$(if $(4),$(4),$(1))/root"
+	[ -z "$(3)" ] || $(CP) "$(3)" "$(KDIR_TMP)/sysupgrade-$(if $(4),$(4),$(1))/kernel"
+	(cd "$(KDIR_TMP)"; $(TAR) cvf \
+		"$(BIN_DIR)/$(IMG_PREFIX)-$(1)-$(2)-sysupgrade.tar" sysupgrade-$(if $(4),$(4),$(1)) \
+			$(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \
+	)
+   endef
+
+# $(1) board name
+# $(2) ubinize-image options (e.g. --uboot-env and/or --kernel kernelimage)
+# $(3) rootfstype (e.g. squashfs or ubifs)
+# $(4) options to pass-through to ubinize (i.e. $($(PROFILE)_UBI_OPTS)))
+   define Image/Build/UbinizeImage
+	sh $(TOPDIR)/scripts/ubinize-image.sh $(2) \
+		"$(KDIR)/root.$(3)" \
+		"$(KDIR)/$(IMG_PREFIX)-$(1)-$(3)-ubinized.bin" \
+		$(4)
+   endef
+
+endif
+
+define Image/mkfs/ubifs
+	$(STAGING_DIR_HOST)/bin/mkfs.ubifs \
+		$(UBIFS_OPTS) $(call param_unmangle,$(call param_get,fs,$(1))) \
+		$(if $(CONFIG_TARGET_UBIFS_FREE_SPACE_FIXUP),--space-fixup) \
+		$(if $(CONFIG_TARGET_UBIFS_COMPRESSION_NONE),--compr=none) \
+		$(if $(CONFIG_TARGET_UBIFS_COMPRESSION_LZO),--compr=lzo) \
+		$(if $(CONFIG_TARGET_UBIFS_COMPRESSION_ZLIB),--compr=zlib) \
+		$(if $(shell echo $(CONFIG_TARGET_UBIFS_JOURNAL_SIZE)),--jrn-size=$(CONFIG_TARGET_UBIFS_JOURNAL_SIZE)) \
+		--squash-uids \
+		-o $@ -d $(call mkfs_target_dir,$(1))
+endef
+
+E2SIZE=$(shell echo $$(($(CONFIG_TARGET_ROOTFS_PARTSIZE)*1024*1024)))
+
+define Image/mkfs/ext4
+	$(STAGING_DIR_HOST)/bin/make_ext4fs \
+		-l $(E2SIZE) -b $(CONFIG_TARGET_EXT4_BLOCKSIZE) \
+		$(if $(CONFIG_TARGET_EXT4_RESERVED_PCT),-m $(CONFIG_TARGET_EXT4_RESERVED_PCT)) \
+		$(if $(CONFIG_TARGET_EXT4_JOURNAL),,-J) \
+		$(if $(SOURCE_DATE_EPOCH),-T $(SOURCE_DATE_EPOCH)) \
+		$@ $(call mkfs_target_dir,$(1))/
+endef
+
+define Image/Manifest
+	$(call opkg,$(TARGET_DIR_ORIG)) list-installed > \
+		$(BIN_DIR)/$(IMG_PREFIX)$(if $(PROFILE_SANITIZED),-$(PROFILE_SANITIZED)).manifest
+endef
+
+ifdef CONFIG_TARGET_ROOTFS_TARGZ
+  define Image/Build/targz
+	$(TAR) -cp --numeric-owner --owner=0 --group=0 --sort=name \
+		$(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \
+		-C $(TARGET_DIR)/ . | gzip -9n > $(BIN_DIR)/$(IMG_PREFIX)$(if $(PROFILE_SANITIZED),-$(PROFILE_SANITIZED))-rootfs.tar.gz
+  endef
+endif
+
+ifdef CONFIG_TARGET_ROOTFS_CPIOGZ
+  define Image/Build/cpiogz
+	( cd $(TARGET_DIR); find . | cpio -o -H newc -R root:root | gzip -9n >$(BIN_DIR)/$(IMG_PREFIX)-rootfs.cpio.gz )
+  endef
+endif
+
+mkfs_packages = $(filter-out @%,$(PACKAGES_$(call param_get,pkg,pkg=$(target_params))))
+mkfs_packages_add = $(filter-out -%,$(mkfs_packages))
+mkfs_packages_remove = $(patsubst -%,%,$(filter -%,$(mkfs_packages)))
+mkfs_cur_target_dir = $(call mkfs_target_dir,pkg=$(target_params))
+
+opkg_target = \
+	$(call opkg,$(mkfs_cur_target_dir)) \
+		-f $(mkfs_cur_target_dir).conf
+
+target-dir-%: FORCE
+	rm -rf $(mkfs_cur_target_dir) $(mkfs_cur_target_dir).opkg
+	$(CP) $(TARGET_DIR_ORIG) $(mkfs_cur_target_dir)
+	-mv $(mkfs_cur_target_dir)/etc/opkg $(mkfs_cur_target_dir).opkg
+	echo 'src default file://$(PACKAGE_DIR_ALL)' > $(mkfs_cur_target_dir).conf
+	$(if $(mkfs_packages_remove), \
+		-$(call opkg,$(mkfs_cur_target_dir)) remove \
+			$(mkfs_packages_remove))
+	$(if $(call opkg_package_files,$(mkfs_packages_add)), \
+		$(opkg_target) update && \
+		$(opkg_target) install \
+			$(call opkg_package_files,$(mkfs_packages_add)))
+	-$(CP) -T $(mkfs_cur_target_dir).opkg/ $(mkfs_cur_target_dir)/etc/opkg/
+	rm -rf $(mkfs_cur_target_dir).opkg $(mkfs_cur_target_dir).conf
+	$(call prepare_rootfs,$(mkfs_cur_target_dir),$(TOPDIR)/files)
+
+$(KDIR)/root.%: kernel_prepare
+	$(call Image/mkfs/$(word 1,$(target_params)),$(target_params))
+
+define Device/InitProfile
+  PROFILES := $(PROFILE)
+  DEVICE_TITLE :=
+  DEVICE_PACKAGES :=
+  DEVICE_DESCRIPTION = Build firmware images for $$(DEVICE_TITLE)
+endef
+
+define Device/Init
+  DEVICE_NAME := $(1)
+  KERNEL:=
+  KERNEL_INITRAMFS = $$(KERNEL)
+  KERNEL_SIZE:=
+  CMDLINE:=
+
+  IMAGES :=
+  ARTIFACTS :=
+  IMAGE_PREFIX := $(IMG_PREFIX)-$(1)
+  IMAGE_NAME = $$(IMAGE_PREFIX)-$$(1)-$$(2)
+  KERNEL_PREFIX = $$(IMAGE_PREFIX)
+  KERNEL_SUFFIX := -kernel.bin
+  KERNEL_INITRAMFS_SUFFIX = $$(KERNEL_SUFFIX)
+  KERNEL_IMAGE = $$(KERNEL_PREFIX)$$(KERNEL_SUFFIX)
+  KERNEL_INITRAMFS_PREFIX = $$(IMAGE_PREFIX)-initramfs
+  KERNEL_INITRAMFS_IMAGE = $$(KERNEL_INITRAMFS_PREFIX)$$(KERNEL_INITRAMFS_SUFFIX)
+  KERNEL_INITRAMFS_NAME = $$(KERNEL_NAME)-initramfs
+  KERNEL_INSTALL :=
+  KERNEL_NAME := vmlinux
+  KERNEL_DEPENDS :=
+  KERNEL_SIZE :=
+
+  UBOOTENV_IN_UBI :=
+  KERNEL_IN_UBI :=
+  BLOCKSIZE :=
+  PAGESIZE :=
+  SUBPAGESIZE :=
+  VID_HDR_OFFSET :=
+  UBINIZE_OPTS :=
+  UBINIZE_PARTS :=
+  MKUBIFS_OPTS :=
+
+  FS_OPTIONS/ubifs = $$(MKUBIFS_OPTS)
+
+  DEVICE_DTS :=
+  DEVICE_DTS_CONFIG :=
+  DEVICE_DTS_DIR :=
+
+  BOARD_NAME :=
+  UIMAGE_NAME :=
+  SUPPORTED_DEVICES :=
+  IMAGE_METADATA :=
+
+  FILESYSTEMS := $(TARGET_FILESYSTEMS)
+endef
+
+DEFAULT_DEVICE_VARS := \
+  DEVICE_NAME KERNEL KERNEL_INITRAMFS KERNEL_SIZE KERNEL_INITRAMFS_IMAGE \
+  KERNEL_LOADADDR DEVICE_DTS DEVICE_DTS_CONFIG DEVICE_DTS_DIR BOARD_NAME \
+  CMDLINE UBOOTENV_IN_UBI KERNEL_IN_UBI \
+  BLOCKSIZE PAGESIZE SUBPAGESIZE VID_HDR_OFFSET \
+  UBINIZE_OPTS UIMAGE_NAME UBINIZE_PARTS \
+  SUPPORTED_DEVICES IMAGE_METADATA
+
+define Device/ExportVar
+  $(1) : $(2):=$$($(2))
+
+endef
+define Device/Export
+  $(foreach var,$(DEVICE_VARS) $(DEFAULT_DEVICE_VARS),$(call Device/ExportVar,$(1),$(var)))
+  $(1) : FILESYSTEM:=$(2)
+endef
+
+ifdef IB
+  DEVICE_CHECK_PROFILE = $(filter $(1),DEVICE_$(PROFILE) $(PROFILE))
+else
+  DEVICE_CHECK_PROFILE = $(CONFIG_TARGET_$(if $(CONFIG_TARGET_MULTI_PROFILE),DEVICE_)$(call target_conf,$(BOARD)$(if $(SUBTARGET),_$(SUBTARGET)))_$(1))
+endif
+
+DEVICE_EXTRA_PACKAGES = $(call qstrip,$(CONFIG_TARGET_DEVICE_PACKAGES_$(call target_conf,$(BOARD)$(if $(SUBTARGET),_$(SUBTARGET)))_DEVICE_$(1)))
+
+define merge_packages
+  $(1) :=
+  $(foreach pkg,$(2),
+    $(1) := $$(strip $$(filter-out -$$(patsubst -%,%,$(pkg)) $$(patsubst -%,%,$(pkg)),$$($(1))) $(pkg))
+  )
+endef
+
+define Device/Check/Common
+  _PROFILE_SET = $$(strip $$(foreach profile,$$(PROFILES) DEVICE_$(1),$$(call DEVICE_CHECK_PROFILE,$$(profile))))
+  DEVICE_PACKAGES += $$(call extra_packages,$$(DEVICE_PACKAGES))
+  ifdef TARGET_PER_DEVICE_ROOTFS
+    $$(eval $$(call merge_packages,_PACKAGES,$$(DEVICE_PACKAGES) $$(call DEVICE_EXTRA_PACKAGES,$(1))))
+    ROOTFS_ID/$(1) := $$(if $$(_PROFILE_SET),$$(call mkfs_packages_id,$$(_PACKAGES)))
+    PACKAGES_$$(ROOTFS_ID/$(1)) := $$(_PACKAGES)
+  endif
+endef
+
+define Device/Check
+  $(Device/Check/Common)
+  KDIR_KERNEL_IMAGE := $(KDIR)/$(1)$$(KERNEL_SUFFIX)
+  _TARGET := $$(if $$(_PROFILE_SET),install-images,install-disabled)
+  ifndef IB
+    _COMPILE_TARGET := $$(if $(CONFIG_IB)$$(_PROFILE_SET),compile,compile-disabled)
+  endif
+endef
+
+ifndef IB
+define Device/Build/initramfs
+  $(call Device/Export,$(KDIR)/tmp/$$(KERNEL_INITRAMFS_IMAGE),$(1))
+  $$(_TARGET): $$(if $$(KERNEL_INITRAMFS),$(BIN_DIR)/$$(KERNEL_INITRAMFS_IMAGE))
+
+  $(KDIR)/$$(KERNEL_INITRAMFS_NAME):: image_prepare
+  $(BIN_DIR)/$$(KERNEL_INITRAMFS_IMAGE): $(KDIR)/tmp/$$(KERNEL_INITRAMFS_IMAGE)
+	cp $$^ $$@
+
+  $(KDIR)/tmp/$$(KERNEL_INITRAMFS_IMAGE): $(KDIR)/$$(KERNEL_INITRAMFS_NAME) $(CURDIR)/Makefile $$(KERNEL_DEPENDS) image_prepare
+	@rm -f $$@
+	$$(call concat_cmd,$$(KERNEL_INITRAMFS))
+endef
+endif
+
+define Device/Build/compile
+  $$(_COMPILE_TARGET): $(KDIR)/$(1)
+  $(eval $(call Device/Export,$(KDIR)/$(1)))
+  $(KDIR)/$(1):
+	$$(call concat_cmd,$(COMPILE/$(1)))
+
+endef
+
+ifndef IB
+define Device/Build/dtb
+  ifndef BUILD_DTS_$(1)
+  BUILD_DTS_$(1) := 1
+  $(KDIR)/image-$(1).dtb: FORCE
+	$(call Image/BuildDTB,$(strip $(2))/$(strip $(3)).dts,$$@)
+
+  image_prepare: $(KDIR)/image-$(1).dtb
+  endif
+
+endef
+endif
+
+define Device/Build/kernel
+  $$(eval $$(foreach dts,$$(DEVICE_DTS), \
+	$$(call Device/Build/dtb,$$(notdir $$(dts)), \
+		$$(if $$(DEVICE_DTS_DIR),$$(DEVICE_DTS_DIR),$$(DTS_DIR)), \
+		$$(dts) \
+	) \
+  ))
+
+  $(KDIR)/$$(KERNEL_NAME):: image_prepare
+  $$(_TARGET): $$(if $$(KERNEL_INSTALL),$(BIN_DIR)/$$(KERNEL_IMAGE))
+  $(call Device/Export,$$(KDIR_KERNEL_IMAGE),$(1))
+  $(BIN_DIR)/$$(KERNEL_IMAGE): $$(KDIR_KERNEL_IMAGE)
+	cp $$^ $$@
+  ifndef IB
+    ifdef CONFIG_IB
+      install: $$(KDIR_KERNEL_IMAGE)
+    endif
+    $$(KDIR_KERNEL_IMAGE): $(KDIR)/$$(KERNEL_NAME) $(CURDIR)/Makefile $$(KERNEL_DEPENDS) image_prepare
+	@rm -f $$@
+	$$(call concat_cmd,$$(KERNEL))
+	$$(if $$(KERNEL_SIZE),$$(call Build/check-size,$$(KERNEL_SIZE)))
+  endif
+endef
+
+define Device/Build/image
+  GZ_SUFFIX := $(if $(filter %dtb %gz,$(2)),,$(if $(and $(findstring ext4,$(1)),$(CONFIG_TARGET_IMAGES_GZIP)),.gz))
+  $$(_TARGET): $(BIN_DIR)/$(call IMAGE_NAME,$(1),$(2))$$(GZ_SUFFIX)
+  $(eval $(call Device/Export,$(KDIR)/tmp/$(call IMAGE_NAME,$(1),$(2)),$(1)))
+  ROOTFS/$(1)/$(3) := \
+	$(KDIR)/root.$(1)$$(strip \
+		$$(if $$(FS_OPTIONS/$(1)),+fs=$$(call param_mangle,$$(FS_OPTIONS/$(1)))) \
+	)$$(strip \
+		$(if $(TARGET_PER_DEVICE_ROOTFS),+pkg=$$(ROOTFS_ID/$(3))) \
+	)
+  ifndef IB
+    $$(ROOTFS/$(1)/$(3)): $(if $(TARGET_PER_DEVICE_ROOTFS),target-dir-$$(ROOTFS_ID/$(3)))
+  endif
+  $(KDIR)/tmp/$(call IMAGE_NAME,$(1),$(2)): $$(KDIR_KERNEL_IMAGE) $$(ROOTFS/$(1)/$(3))
+	@rm -f $$@
+	[ -f $$(word 1,$$^) -a -f $$(word 2,$$^) ]
+	$$(call concat_cmd,$(if $(IMAGE/$(2)/$(1)),$(IMAGE/$(2)/$(1)),$(IMAGE/$(2))))
+
+  .IGNORE: $(BIN_DIR)/$(call IMAGE_NAME,$(1),$(2))
+
+  $(BIN_DIR)/$(call IMAGE_NAME,$(1),$(2)).gz: $(KDIR)/tmp/$(call IMAGE_NAME,$(1),$(2))
+	gzip -c -9n $$^ > $$@
+
+  $(BIN_DIR)/$(call IMAGE_NAME,$(1),$(2)): $(KDIR)/tmp/$(call IMAGE_NAME,$(1),$(2))
+	cp $$^ $$@
+
+endef
+
+define Device/Build/artifact
+  $$(_TARGET): $(BIN_DIR)/$(IMAGE_PREFIX)-$(1)
+  $(KDIR)/tmp/$(IMAGE_PREFIX)-$(1): $$(KDIR_KERNEL_IMAGE)
+	@rm -f $$@
+	$$(call concat_cmd,$(ARTIFACT/$(1)))
+
+  .IGNORE: $(BIN_DIR)/$(IMAGE_PREFIX)-$(1)
+
+  $(BIN_DIR)/$(IMAGE_PREFIX)-$(1): $(KDIR)/tmp/$(IMAGE_PREFIX)-$(1)
+	cp $$^ $$@
+
+endef
+
+define Device/Build
+  $(if $(CONFIG_TARGET_ROOTFS_INITRAMFS),$(call Device/Build/initramfs,$(1)))
+  $(call Device/Build/kernel,$(1))
+
+  $$(eval $$(foreach compile,$$(COMPILE), \
+    $$(call Device/Build/compile,$$(compile),$(1))))
+
+  $$(eval $$(foreach image,$$(IMAGES), \
+    $$(foreach fs,$$(filter $(TARGET_FILESYSTEMS),$$(FILESYSTEMS)), \
+      $$(call Device/Build/image,$$(fs),$$(image),$(1)))))
+
+  $$(eval $$(foreach artifact,$$(ARTIFACTS), \
+    $$(call Device/Build/artifact,$$(artifact))))
+
+endef
+
+define Device/DumpInfo
+Target-Profile: DEVICE_$(1)
+Target-Profile-Name: $(DEVICE_TITLE)
+Target-Profile-Packages: $(DEVICE_PACKAGES)
+Target-Profile-Description:
+$(DEVICE_DESCRIPTION)
+@@
+
+endef
+
+define Device/Dump
+$$(eval $$(if $$(DEVICE_TITLE),$$(info $$(call Device/DumpInfo,$(1)))))
+endef
+
+define Device
+  $(call Device/InitProfile,$(1))
+  $(call Device/Init,$(1))
+  $(call Device/Default,$(1))
+  $(call Device/$(1),$(1))
+  $(call Device/Check,$(1))
+  $(call Device/$(if $(DUMP),Dump,Build),$(1))
+
+endef
+
+define BuildImage
+
+  ifneq ($(DUMP),)
+    all: dumpinfo
+    dumpinfo: FORCE
+	@true
+  endif
+
+  download:
+  prepare:
+  compile:
+  clean:
+  legacy-images-prepare:
+  legacy-images:
+  image_prepare:
+
+  ifeq ($(IB),)
+    .PHONY: download prepare compile clean image_prepare kernel_prepare install install-images
+    compile:
+		$(call Build/Compile)
+
+    clean:
+		$(call Build/Clean)
+
+    image_prepare: compile
+		mkdir -p $(BIN_DIR) $(KDIR)/tmp
+		$(call Image/Prepare)
+
+    legacy-images-prepare-make: image_prepare
+		$(MAKE) legacy-images-prepare
+
+  else
+    image_prepare:
+		mkdir -p $(BIN_DIR) $(KDIR)/tmp
+  endif
+
+  kernel_prepare: image_prepare
+	$(call Image/Build/targz)
+	$(call Image/Build/cpiogz)
+	$(call Image/BuildKernel)
+	$(if $(CONFIG_TARGET_ROOTFS_INITRAMFS),$(if $(IB),,$(call Image/BuildKernel/Initramfs)))
+	$(call Image/InstallKernel)
+
+  $(foreach device,$(TARGET_DEVICES),$(call Device,$(device)))
+  $(foreach device,$(LEGACY_DEVICES),$(call LegacyDevice,$(device)))
+
+  install-images: kernel_prepare $(foreach fs,$(filter-out $(if $(UBIFS_OPTS),,ubifs),$(TARGET_FILESYSTEMS) $(fs-subtypes-y)),$(KDIR)/root.$(fs))
+	$(foreach fs,$(TARGET_FILESYSTEMS),
+		$(call Image/Build,$(fs))
+	)
+
+  legacy-images-make: install-images
+	$(call Image/mkfs/ubifs/legacy)
+	$(MAKE) legacy-images
+
+  install: install-images
+	$(call Image/Manifest)
+
+endef

+ 174 - 0
include/kernel-build.mk

@@ -0,0 +1,174 @@
+#
+# Copyright (C) 2006-2007 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+include $(INCLUDE_DIR)/prereq.mk
+include $(INCLUDE_DIR)/depends.mk
+
+ifneq ($(DUMP),1)
+  all: compile
+endif
+
+KERNEL_FILE_DEPENDS=$(GENERIC_BACKPORT_DIR) $(GENERIC_PATCH_DIR) $(GENERIC_HACK_DIR) $(PATCH_DIR) $(GENERIC_FILES_DIR) $(FILES_DIR)
+STAMP_PREPARED=$(LINUX_DIR)/.prepared$(if $(QUILT)$(DUMP),,_$(shell $(call find_md5,$(KERNEL_FILE_DEPENDS),)))
+STAMP_CONFIGURED:=$(LINUX_DIR)/.configured
+include $(INCLUDE_DIR)/download.mk
+include $(INCLUDE_DIR)/quilt.mk
+include $(INCLUDE_DIR)/kernel-defaults.mk
+
+define Kernel/Prepare
+	$(call Kernel/Prepare/Default)
+endef
+
+define Kernel/Configure
+	$(call Kernel/Configure/Default)
+endef
+
+define Kernel/CompileModules
+	$(call Kernel/CompileModules/Default)
+endef
+
+define Kernel/CompileImage
+	$(call Kernel/CompileImage/Default)
+	$(call Kernel/CompileImage/Initramfs)
+endef
+
+define Kernel/Clean
+	$(call Kernel/Clean/Default)
+endef
+
+define Download/kernel
+  URL:=$(LINUX_SITE)
+  FILE:=$(LINUX_SOURCE)
+  HASH:=$(LINUX_KERNEL_HASH)
+endef
+
+KERNEL_GIT_OPTS:=
+ifneq ($(strip $(CONFIG_KERNEL_GIT_LOCAL_REPOSITORY)),"")
+  KERNEL_GIT_OPTS+=--reference $(CONFIG_KERNEL_GIT_LOCAL_REPOSITORY)
+endif
+
+define Download/git-kernel
+  URL:=$(call qstrip,$(CONFIG_KERNEL_GIT_CLONE_URI))
+  PROTO:=git
+  VERSION:=$(CONFIG_KERNEL_GIT_REF)
+  FILE:=$(LINUX_SOURCE)
+  SUBDIR:=linux-$(LINUX_VERSION)
+  OPTS:=$(KERNEL_GIT_OPTS)
+endef
+
+ifdef CONFIG_COLLECT_KERNEL_DEBUG
+  define Kernel/CollectDebug
+	rm -rf $(KERNEL_BUILD_DIR)/debug
+	mkdir -p $(KERNEL_BUILD_DIR)/debug/modules
+	$(CP) $(LINUX_DIR)/vmlinux $(KERNEL_BUILD_DIR)/debug/
+	-$(CP) \
+		$(STAGING_DIR_ROOT)/lib/modules/$(LINUX_VERSION)/* \
+		$(KERNEL_BUILD_DIR)/debug/modules/
+	$(FIND) $(KERNEL_BUILD_DIR)/debug -type f | $(XARGS) $(KERNEL_CROSS)strip --only-keep-debug
+	$(TAR) c -C $(KERNEL_BUILD_DIR) debug \
+		$(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \
+		| bzip2 -c -9 > $(BIN_DIR)/kernel-debug.tar.bz2
+  endef
+endif
+
+ifeq ($(DUMP)$(filter prereq clean refresh update,$(MAKECMDGOALS)),)
+  ifneq ($(if $(QUILT),,$(CONFIG_AUTOREBUILD)),)
+    define Kernel/Autoclean
+      $(PKG_BUILD_DIR)/.dep_files: $(STAMP_PREPARED)
+      $(call rdep,$(KERNEL_FILE_DEPENDS),$(STAMP_PREPARED),$(PKG_BUILD_DIR)/.dep_files,-x "*/.dep_*")
+    endef
+  endif
+endif
+
+define BuildKernel
+  $(if $(QUILT),$(Build/Quilt))
+  $(if $(LINUX_SITE),$(call Download,kernel))
+  $(if $(call qstrip,$(CONFIG_KERNEL_GIT_CLONE_URI)),$(call Download,git-kernel))
+
+  .NOTPARALLEL:
+
+  $(Kernel/Autoclean)
+  $(STAMP_PREPARED): $(if $(LINUX_SITE),$(DL_DIR)/$(LINUX_SOURCE))
+	-rm -rf $(KERNEL_BUILD_DIR)
+	-mkdir -p $(KERNEL_BUILD_DIR)
+	$(Kernel/Prepare)
+	touch $$@
+
+  $(KERNEL_BUILD_DIR)/symtab.h: FORCE
+	rm -f $(KERNEL_BUILD_DIR)/symtab.h
+	touch $(KERNEL_BUILD_DIR)/symtab.h
+	+$(KERNEL_MAKE) vmlinux
+	find $(LINUX_DIR) $(STAGING_DIR_ROOT)/lib/modules -name \*.ko | \
+		xargs $(TARGET_CROSS)nm | \
+		awk '$$$$1 == "U" { print $$$$2 } ' | \
+		sort -u > $(KERNEL_BUILD_DIR)/mod_symtab.txt
+	$(TARGET_CROSS)nm -n $(LINUX_DIR)/vmlinux.o | grep ' [rR] __ksymtab' | sed -e 's,........ [rR] __ksymtab_,,' > $(KERNEL_BUILD_DIR)/kernel_symtab.txt
+	grep -Ff $(KERNEL_BUILD_DIR)/mod_symtab.txt $(KERNEL_BUILD_DIR)/kernel_symtab.txt > $(KERNEL_BUILD_DIR)/sym_include.txt
+	grep -Fvf $(KERNEL_BUILD_DIR)/mod_symtab.txt $(KERNEL_BUILD_DIR)/kernel_symtab.txt > $(KERNEL_BUILD_DIR)/sym_exclude.txt
+	( \
+		echo '#define SYMTAB_KEEP \'; \
+		cat $(KERNEL_BUILD_DIR)/sym_include.txt | \
+			awk '{print "KEEP(*(___ksymtab+" $$$$1 ")) \\" }'; \
+		echo; \
+		echo '#define SYMTAB_KEEP_GPL \'; \
+		cat $(KERNEL_BUILD_DIR)/sym_include.txt | \
+			awk '{print "KEEP(*(___ksymtab_gpl+" $$$$1 ")) \\" }'; \
+		echo; \
+		echo '#define SYMTAB_DISCARD \'; \
+		cat $(KERNEL_BUILD_DIR)/sym_exclude.txt | \
+			awk '{print "*(___ksymtab+" $$$$1 ") \\" }'; \
+		echo; \
+		echo '#define SYMTAB_DISCARD_GPL \'; \
+		cat $(KERNEL_BUILD_DIR)/sym_exclude.txt | \
+			awk '{print "*(___ksymtab_gpl+" $$$$1 ") \\" }'; \
+		echo; \
+	) > $$@
+
+  $(STAMP_CONFIGURED): $(STAMP_PREPARED) $(LINUX_KCONFIG_LIST) $(TOPDIR)/.config FORCE
+	$(Kernel/Configure)
+	touch $$@
+
+  $(LINUX_DIR)/.modules: $(STAMP_CONFIGURED) $(LINUX_DIR)/.config FORCE
+	$(Kernel/CompileModules)
+	touch $$@
+
+  $(LINUX_DIR)/.image: $(STAMP_CONFIGURED) $(if $(CONFIG_STRIP_KERNEL_EXPORTS),$(KERNEL_BUILD_DIR)/symtab.h) FORCE
+	$(Kernel/CompileImage)
+	$(Kernel/CollectDebug)
+	touch $$@
+	
+  mostlyclean: FORCE
+	$(Kernel/Clean)
+
+  define BuildKernel
+  endef
+
+  download: $(if $(LINUX_SITE),$(DL_DIR)/$(LINUX_SOURCE))
+  prepare: $(STAMP_PREPARED)
+  compile: $(LINUX_DIR)/.modules
+	$(MAKE) -C image compile TARGET_BUILD=
+
+  oldconfig menuconfig nconfig: $(STAMP_PREPARED) $(STAMP_CHECKED) FORCE
+	rm -f $(LINUX_DIR)/.config.prev
+	rm -f $(STAMP_CONFIGURED)
+	$(LINUX_RECONF_CMD) > $(LINUX_DIR)/.config
+	$(_SINGLE)$(KERNEL_MAKE) \
+		$(if $(findstring Darwin,$(HOST_OS)),HOST_LOADLIBES="-L$(STAGING_DIR_HOST)/lib -lncurses") \
+		$$@
+	$(LINUX_RECONF_DIFF) $(LINUX_DIR)/.config > $(LINUX_RECONFIG_TARGET)
+
+  install: $(LINUX_DIR)/.image
+	+$(MAKE) -C image compile install TARGET_BUILD=
+
+  clean: FORCE
+	rm -rf $(KERNEL_BUILD_DIR)
+
+  image-prereq:
+	@+$(NO_TRACE_MAKE) -s -C image prereq TARGET_BUILD=
+
+  prereq: image-prereq
+
+endef

+ 164 - 0
include/kernel-defaults.mk

@@ -0,0 +1,164 @@
+#
+# Copyright (C) 2006-2015 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+ifdef CONFIG_STRIP_KERNEL_EXPORTS
+  KERNEL_MAKEOPTS += \
+	EXTRA_LDSFLAGS="-I$(KERNEL_BUILD_DIR) -include symtab.h"
+endif
+
+INITRAMFS_EXTRA_FILES ?= $(GENERIC_PLATFORM_DIR)/image/initramfs-base-files.txt
+
+ifneq (,$(KERNEL_CC))
+  KERNEL_MAKEOPTS += CC="$(KERNEL_CC)"
+endif
+
+export HOST_EXTRACFLAGS=-I$(STAGING_DIR_HOST)/include
+
+# defined in quilt.mk
+Kernel/Patch:=$(Kernel/Patch/Default)
+
+ifneq (,$(findstring .xz,$(LINUX_SOURCE)))
+  LINUX_CAT:=xzcat
+else
+  LINUX_CAT:=zcat
+endif
+
+ifeq ($(strip $(CONFIG_EXTERNAL_KERNEL_TREE)),"")
+  ifeq ($(strip $(CONFIG_KERNEL_GIT_CLONE_URI)),"")
+    define Kernel/Prepare/Default
+	$(LINUX_CAT) $(DL_DIR)/$(LINUX_SOURCE) | $(TAR) -C $(KERNEL_BUILD_DIR) $(TAR_OPTIONS)
+	$(Kernel/Patch)
+	$(if $(QUILT),touch $(LINUX_DIR)/.quilt_used)
+    endef
+  else
+    define Kernel/Prepare/Default
+	$(LINUX_CAT) $(DL_DIR)/$(LINUX_SOURCE) | $(TAR) -C $(KERNEL_BUILD_DIR) $(TAR_OPTIONS)
+    endef
+  endif
+else
+  define Kernel/Prepare/Default
+	mkdir -p $(KERNEL_BUILD_DIR)
+	if [ -d $(LINUX_DIR) ]; then \
+		rmdir $(LINUX_DIR); \
+	fi
+	ln -s $(CONFIG_EXTERNAL_KERNEL_TREE) $(LINUX_DIR)
+  endef
+endif
+
+ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
+  ifeq ($(strip $(CONFIG_EXTERNAL_CPIO)),"")
+    define Kernel/SetInitramfs/PreConfigure
+	grep -v -e INITRAMFS -e CONFIG_RD_ -e CONFIG_BLK_DEV_INITRD $(LINUX_DIR)/.config.old > $(LINUX_DIR)/.config
+	echo 'CONFIG_BLK_DEV_INITRD=y' >> $(LINUX_DIR)/.config
+	echo 'CONFIG_INITRAMFS_SOURCE="$(strip $(TARGET_DIR) $(INITRAMFS_EXTRA_FILES))"' >> $(LINUX_DIR)/.config
+    endef
+  else
+    define Kernel/SetInitramfs/PreConfigure
+	grep -v INITRAMFS $(LINUX_DIR)/.config.old > $(LINUX_DIR)/.config
+	echo 'CONFIG_INITRAMFS_SOURCE="$(call qstrip,$(CONFIG_EXTERNAL_CPIO))"' >> $(LINUX_DIR)/.config
+    endef
+  endif
+
+  define Kernel/SetInitramfs
+	rm -f $(LINUX_DIR)/.config.prev
+	mv $(LINUX_DIR)/.config $(LINUX_DIR)/.config.old
+	$(call Kernel/SetInitramfs/PreConfigure)
+	echo 'CONFIG_INITRAMFS_ROOT_UID=$(shell id -u)' >> $(LINUX_DIR)/.config
+	echo 'CONFIG_INITRAMFS_ROOT_GID=$(shell id -g)' >> $(LINUX_DIR)/.config
+	echo "$(if $(CONFIG_TARGET_INITRAMFS_FORCE),CONFIG_INITRAMFS_FORCE=y,# CONFIG_INITRAMFS_FORCE is not set)" >> $(LINUX_DIR)/.config
+	echo "$(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_NONE),CONFIG_INITRAMFS_COMPRESSION_NONE=y,# CONFIG_INITRAMFS_COMPRESSION_NONE is not set)" >> $(LINUX_DIR)/.config
+	echo -e "$(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_GZIP),CONFIG_INITRAMFS_COMPRESSION_GZIP=y\nCONFIG_RD_GZIP=y,# CONFIG_INITRAMFS_COMPRESSION_GZIP is not set\n# CONFIG_RD_GZIP is not set)" >> $(LINUX_DIR)/.config
+	echo -e "$(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_BZIP2),CONFIG_INITRAMFS_COMPRESSION_BZIP2=y\nCONFIG_RD_BZIP2=y,# CONFIG_INITRAMFS_COMPRESSION_BZIP2 is not set\n# CONFIG_RD_BZIP2 is not set)" >> $(LINUX_DIR)/.config
+	echo -e "$(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_LZMA),CONFIG_INITRAMFS_COMPRESSION_LZMA=y\nCONFIG_RD_LZMA=y,# CONFIG_INITRAMFS_COMPRESSION_LZMA is not set\n# CONFIG_RD_LZMA is not set)" >> $(LINUX_DIR)/.config
+	echo -e "$(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_LZO),CONFIG_INITRAMFS_COMPRESSION_LZO=y\nCONFIG_RD_LZO=y,# CONFIG_INITRAMFS_COMPRESSION_LZO is not set\n# CONFIG_RD_LZO is not set)" >> $(LINUX_DIR)/.config
+	echo -e "$(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_XZ),CONFIG_INITRAMFS_COMPRESSION_XZ=y\nCONFIG_RD_XZ=y,# CONFIG_INITRAMFS_COMPRESSION_XZ is not set\n# CONFIG_RD_XZ is not set)" >> $(LINUX_DIR)/.config
+	echo -e "$(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_LZ4),CONFIG_INITRAMFS_COMPRESSION_LZ4=y\nCONFIG_RD_LZ4=y,# CONFIG_INITRAMFS_COMPRESSION_LZ4 is not set\n# CONFIG_RD_LZ4 is not set)" >> $(LINUX_DIR)/.config
+  endef
+else
+endif
+
+define Kernel/SetNoInitramfs
+	mv $(LINUX_DIR)/.config.set $(LINUX_DIR)/.config.old
+	grep -v INITRAMFS $(LINUX_DIR)/.config.old > $(LINUX_DIR)/.config.set
+	echo 'CONFIG_INITRAMFS_SOURCE=""' >> $(LINUX_DIR)/.config.set
+	echo '# CONFIG_INITRAMFS_FORCE is not set' >> $(LINUX_DIR)/.config.set
+endef
+
+define Kernel/Configure/Default
+	rm -f $(LINUX_DIR)/localversion
+	$(LINUX_CONF_CMD) > $(LINUX_DIR)/.config.target
+# copy CONFIG_KERNEL_* settings over to .config.target
+	awk '/^(#[[:space:]]+)?CONFIG_KERNEL/{sub("CONFIG_KERNEL_","CONFIG_");print}' $(TOPDIR)/.config >> $(LINUX_DIR)/.config.target
+	echo "# CONFIG_KALLSYMS_EXTRA_PASS is not set" >> $(LINUX_DIR)/.config.target
+	echo "# CONFIG_KALLSYMS_ALL is not set" >> $(LINUX_DIR)/.config.target
+	echo "CONFIG_KALLSYMS_UNCOMPRESSED=y" >> $(LINUX_DIR)/.config.target
+	$(SCRIPT_DIR)/package-metadata.pl kconfig $(TMP_DIR)/.packageinfo $(TOPDIR)/.config $(KERNEL_PATCHVER) > $(LINUX_DIR)/.config.override
+	$(SCRIPT_DIR)/kconfig.pl 'm+' '+' $(LINUX_DIR)/.config.target /dev/null $(LINUX_DIR)/.config.override > $(LINUX_DIR)/.config.set
+	$(call Kernel/SetNoInitramfs)
+	rm -rf $(KERNEL_BUILD_DIR)/modules
+	cmp -s $(LINUX_DIR)/.config.set $(LINUX_DIR)/.config.prev || { \
+		cp $(LINUX_DIR)/.config.set $(LINUX_DIR)/.config; \
+		cp $(LINUX_DIR)/.config.set $(LINUX_DIR)/.config.prev; \
+	}
+	$(_SINGLE) [ -d $(LINUX_DIR)/user_headers ] || $(KERNEL_MAKE) INSTALL_HDR_PATH=$(LINUX_DIR)/user_headers headers_install
+	grep '=[ym]' $(LINUX_DIR)/.config.set | LC_ALL=C sort | mkhash md5 > $(LINUX_DIR)/.vermagic
+endef
+
+define Kernel/Configure/Initramfs
+	$(call Kernel/SetInitramfs)
+endef
+
+define Kernel/CompileModules/Default
+	rm -f $(LINUX_DIR)/vmlinux $(LINUX_DIR)/System.map
+	+$(KERNEL_MAKE) modules
+endef
+
+OBJCOPY_STRIP = -R .reginfo -R .notes -R .note -R .comment -R .mdebug -R .note.gnu.build-id
+
+# AMD64 shares the location with x86
+ifeq ($(LINUX_KARCH),x86_64)
+IMAGES_DIR:=../../x86/boot
+endif
+
+define Kernel/CopyImage
+	cmp -s $(LINUX_DIR)/vmlinux $(KERNEL_BUILD_DIR)/vmlinux$(1).debug || { \
+		$(KERNEL_CROSS)objcopy -O binary $(OBJCOPY_STRIP) -S $(LINUX_DIR)/vmlinux $(LINUX_KERNEL)$(1); \
+		$(KERNEL_CROSS)objcopy $(OBJCOPY_STRIP) -S $(LINUX_DIR)/vmlinux $(KERNEL_BUILD_DIR)/vmlinux$(1).elf; \
+		$(CP) $(LINUX_DIR)/vmlinux $(KERNEL_BUILD_DIR)/vmlinux$(1).debug; \
+		$(foreach k, \
+			$(if $(KERNEL_IMAGES),$(KERNEL_IMAGES),$(filter-out vmlinux dtbs,$(KERNELNAME))), \
+			$(CP) $(LINUX_DIR)/arch/$(LINUX_KARCH)/boot/$(IMAGES_DIR)/$(k) $(KERNEL_BUILD_DIR)/$(k)$(1); \
+		) \
+	}
+endef
+
+define Kernel/CompileImage/Default
+	rm -f $(TARGET_DIR)/init
+	+$(KERNEL_MAKE) $(if $(KERNELNAME),$(KERNELNAME),all) modules
+	$(call Kernel/CopyImage)
+endef
+
+ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
+define Kernel/CompileImage/Initramfs
+	$(call Kernel/Configure/Initramfs)
+	$(CP) $(GENERIC_PLATFORM_DIR)/other-files/init $(TARGET_DIR)/init
+	rm -rf $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)/usr/initramfs_data.cpio*
+	+$(KERNEL_MAKE) $(if $(KERNELNAME),$(KERNELNAME),all) modules
+	$(call Kernel/CopyImage,-initramfs)
+endef
+else
+define Kernel/CompileImage/Initramfs
+endef
+endif
+
+define Kernel/Clean/Default
+	rm -f $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)/.configured
+	rm -f $(LINUX_KERNEL)
+	$(_SINGLE)$(MAKE) -C $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION) clean
+endef
+
+

+ 38 - 0
include/kernel-version.mk

@@ -0,0 +1,38 @@
+# Use the default kernel version if the Makefile doesn't override it
+
+LINUX_RELEASE?=1
+
+LINUX_VERSION-3.18 = .129
+LINUX_VERSION-4.9 = .145
+LINUX_VERSION-4.14 = .88
+LINUX_VERSION-4.19 = .9
+
+LINUX_KERNEL_HASH-3.18.129 = 8d420b58593a74109175be781da2320a341baec9aaa186da31ad508d3f377e72
+LINUX_KERNEL_HASH-4.9.145 = 6901ca37e8c305a2f26c598952338b4dc2481ca5a9d0bf71e2b71730a5b5bc5e
+LINUX_KERNEL_HASH-4.14.88 = cacce178c6ad9367269018127b916306c4c79242316d6618852caf49b8e256e3
+LINUX_KERNEL_HASH-4.19.9 = fc116cc6829c73944215d3b3ac0fc368dde9e8235b456744afffde001269dbf2
+
+remove_uri_prefix=$(subst git://,,$(subst http://,,$(subst https://,,$(1))))
+sanitize_uri=$(call qstrip,$(subst @,_,$(subst :,_,$(subst .,_,$(subst -,_,$(subst /,_,$(1)))))))
+
+ifneq ($(call qstrip,$(CONFIG_KERNEL_GIT_CLONE_URI)),)
+  LINUX_VERSION:=$(call sanitize_uri,$(call remove_uri_prefix,$(CONFIG_KERNEL_GIT_CLONE_URI)))
+  ifeq ($(call qstrip,$(CONFIG_KERNEL_GIT_REF)),)
+    CONFIG_KERNEL_GIT_REF:=HEAD
+  endif
+  LINUX_VERSION:=$(LINUX_VERSION)-$(call sanitize_uri,$(CONFIG_KERNEL_GIT_REF))
+else
+ifdef KERNEL_PATCHVER
+  LINUX_VERSION:=$(KERNEL_PATCHVER)$(strip $(LINUX_VERSION-$(KERNEL_PATCHVER)))
+endif
+endif
+
+split_version=$(subst ., ,$(1))
+merge_version=$(subst $(space),.,$(1))
+KERNEL_BASE=$(firstword $(subst -, ,$(LINUX_VERSION)))
+KERNEL=$(call merge_version,$(wordlist 1,2,$(call split_version,$(KERNEL_BASE))))
+KERNEL_PATCHVER ?= $(KERNEL)
+
+# disable the md5sum check for unknown kernel versions
+LINUX_KERNEL_HASH:=$(LINUX_KERNEL_HASH-$(strip $(LINUX_VERSION)))
+LINUX_KERNEL_HASH?=x

+ 297 - 0
include/kernel.mk

@@ -0,0 +1,297 @@
+#
+# Copyright (C) 2006-2015 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+ifneq ($(filter check,$(MAKECMDGOALS)),)
+CHECK:=1
+DUMP:=1
+endif
+
+ifneq ($(SOURCE_DATE_EPOCH),)
+  ifndef DUMP
+    KBUILD_BUILD_TIMESTAMP:=$(shell perl -e 'print scalar gmtime($(SOURCE_DATE_EPOCH))')
+  endif
+endif
+
+ifeq ($(__target_inc),)
+  ifndef CHECK
+    include $(INCLUDE_DIR)/target.mk
+  endif
+endif
+
+ifeq ($(DUMP),1)
+  KERNEL?=<KERNEL>
+  BOARD?=<BOARD>
+  LINUX_VERSION?=<LINUX_VERSION>
+  LINUX_VERMAGIC?=<LINUX_VERMAGIC>
+else
+  ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
+    export GCC_HONOUR_COPTS=s
+  endif
+
+  LINUX_KMOD_SUFFIX=ko
+
+  ifneq (,$(findstring uml,$(BOARD)))
+    KERNEL_CC?=$(HOSTCC)
+    KERNEL_CROSS?=
+  else
+    KERNEL_CC?=$(TARGET_CC)
+    KERNEL_CROSS?=$(TARGET_CROSS)
+  endif
+
+  ifeq ($(TARGET_BUILD),1)
+    PATCH_DIR ?= $(CURDIR)/patches$(if $(wildcard ./patches-$(KERNEL_PATCHVER)),-$(KERNEL_PATCHVER))
+    FILES_DIR ?= $(foreach dir,$(wildcard $(CURDIR)/files $(CURDIR)/files-$(KERNEL_PATCHVER)),"$(dir)")
+  endif
+  KERNEL_BUILD_DIR ?= $(BUILD_DIR)/linux-$(BOARD)$(if $(SUBTARGET),_$(SUBTARGET))
+  LINUX_DIR ?= $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)
+  LINUX_UAPI_DIR=uapi/
+  LINUX_VERMAGIC:=$(strip $(shell cat $(LINUX_DIR)/.vermagic 2>/dev/null))
+  LINUX_VERMAGIC:=$(if $(LINUX_VERMAGIC),$(LINUX_VERMAGIC),unknown)
+
+  LINUX_UNAME_VERSION:=$(KERNEL_BASE)
+  ifneq ($(findstring -rc,$(LINUX_VERSION)),)
+    LINUX_UNAME_VERSION:=$(LINUX_UNAME_VERSION)-$(strip $(lastword $(subst -, ,$(LINUX_VERSION))))
+  endif
+
+  LINUX_KERNEL:=$(KERNEL_BUILD_DIR)/vmlinux
+
+  ifneq (,$(findstring -rc,$(LINUX_VERSION)))
+      LINUX_SOURCE:=linux-linux-$(LINUX_VERSION)-gnu.tar.gz
+  else
+      LINUX_SOURCE:=linux-libre-$(LINUX_VERSION)-gnu.tar.xz
+  endif
+
+  ifneq (,$(findstring -rc,$(LINUX_VERSION)))
+ #     LINUX_SITE:=https://git.kernel.org/torvalds/t
+  else ifeq ($(call qstrip,$(CONFIG_EXTERNAL_KERNEL_TREE))$(call qstrip,$(CONFIG_KERNEL_GIT_CLONE_URI)),)
+      LINUX_SITE:=@KERNEL_LIBRE/$(LINUX_VERSION)-gnu$(TESTING)
+  else
+      LINUX_UNAME_VERSION:=$(strip $(shell cat $(LINUX_DIR)/include/config/kernel.release 2>/dev/null))
+  endif
+
+  MODULES_SUBDIR:=lib/modules/$(LINUX_UNAME_VERSION)
+  TARGET_MODULES_DIR:=$(LINUX_TARGET_DIR)/$(MODULES_SUBDIR)
+
+  ifneq ($(TARGET_BUILD),1)
+    PKG_BUILD_DIR ?= $(KERNEL_BUILD_DIR)/$(PKG_NAME)$(if $(PKG_VERSION),-$(PKG_VERSION))
+  endif
+endif
+
+ifneq (,$(findstring uml,$(BOARD)))
+  LINUX_KARCH=um
+else ifneq (,$(findstring $(ARCH) , aarch64 aarch64_be ))
+  LINUX_KARCH := arm64
+else ifneq (,$(findstring $(ARCH) , arceb ))
+  LINUX_KARCH := arc
+else ifneq (,$(findstring $(ARCH) , armeb ))
+  LINUX_KARCH := arm
+else ifneq (,$(findstring $(ARCH) , mipsel mips64 mips64el ))
+  LINUX_KARCH := mips
+else ifneq (,$(findstring $(ARCH) , powerpc64 ))
+  LINUX_KARCH := powerpc
+else ifneq (,$(findstring $(ARCH) , sh2 sh3 sh4 ))
+  LINUX_KARCH := sh
+else ifneq (,$(findstring $(ARCH) , i386 x86_64 ))
+  LINUX_KARCH := x86
+else
+  LINUX_KARCH := $(ARCH)
+endif
+
+KERNEL_MAKE = $(MAKE) $(KERNEL_MAKEOPTS)
+
+KERNEL_MAKE_FLAGS = \
+	HOSTCFLAGS="$(HOST_CFLAGS) -Wall -Wmissing-prototypes -Wstrict-prototypes" \
+	CROSS_COMPILE="$(KERNEL_CROSS)" \
+	ARCH="$(LINUX_KARCH)" \
+	KBUILD_HAVE_NLS=no \
+	KBUILD_BUILD_USER="$(call qstrip,$(CONFIG_KERNEL_BUILD_USER))" \
+	KBUILD_BUILD_HOST="$(call qstrip,$(CONFIG_KERNEL_BUILD_DOMAIN))" \
+	KBUILD_BUILD_TIMESTAMP="$(KBUILD_BUILD_TIMESTAMP)" \
+	KBUILD_BUILD_VERSION="0" \
+	HOST_LOADLIBES="-L$(STAGING_DIR_HOST)/lib" \
+	CONFIG_SHELL="$(BASH)" \
+	$(if $(findstring c,$(LIBRECMC_VERBOSE)),V=1,V='') \
+	$(if $(PKG_BUILD_ID),LDFLAGS_MODULE=--build-id=0x$(PKG_BUILD_ID)) \
+	cmd_syscalls=
+
+ifeq ($(call qstrip,$(CONFIG_EXTERNAL_KERNEL_TREE))$(call qstrip,$(CONFIG_KERNEL_GIT_CLONE_URI)),)
+  KERNEL_MAKE_FLAGS += \
+	KERNELRELEASE=$(LINUX_VERSION)
+endif
+
+KERNEL_MAKEOPTS := -C $(LINUX_DIR) $(KERNEL_MAKE_FLAGS)
+
+ifdef CONFIG_USE_SPARSE
+  KERNEL_MAKEOPTS += C=1 CHECK=$(STAGING_DIR_HOST)/bin/sparse
+endif
+
+PKG_EXTMOD_SUBDIRS ?= .
+
+define populate_module_symvers
+	@mkdir -p $(PKG_INFO_DIR)
+	cat /dev/null > $(PKG_INFO_DIR)/$(PKG_NAME).symvers; \
+	for subdir in $(PKG_EXTMOD_SUBDIRS); do \
+		cat $(PKG_INFO_DIR)/*.symvers 2>/dev/null > $(PKG_BUILD_DIR)/$$$$subdir/Module.symvers; \
+	done
+endef
+
+define collect_module_symvers
+	for subdir in $(PKG_EXTMOD_SUBDIRS); do \
+		grep -F $$$$(readlink -f $(PKG_BUILD_DIR)) $(PKG_BUILD_DIR)/$$$$subdir/Module.symvers >> $(PKG_BUILD_DIR)/Module.symvers.tmp; \
+	done; \
+	sort -u $(PKG_BUILD_DIR)/Module.symvers.tmp > $(PKG_BUILD_DIR)/Module.symvers; \
+	mv $(PKG_BUILD_DIR)/Module.symvers $(PKG_INFO_DIR)/$(PKG_NAME).symvers
+endef
+
+define KernelPackage/hooks
+  ifneq ($(PKG_NAME),kernel)
+    Hooks/Compile/Pre += populate_module_symvers
+    Hooks/Compile/Post += collect_module_symvers
+  endif
+  define KernelPackage/hooks
+  endef
+endef
+
+define KernelPackage/Defaults
+  FILES:=
+  AUTOLOAD:=
+  MODPARAMS:=
+  PKGFLAGS+=nonshared
+endef
+
+# 1: name
+# 2: install prefix
+# 3: module priority prefix
+# 4: required for boot
+# 5: module list
+define ModuleAutoLoad
+  $(if $(5), \
+    mkdir -p $(2)/etc/modules.d; \
+    ($(foreach mod,$(5), \
+      echo "$(mod)$(if $(MODPARAMS.$(mod)), $(MODPARAMS.$(mod)),$(if $(MODPARAMS), $(MODPARAMS)))"; )) > $(2)/etc/modules.d/$(3)$(1); \
+    $(if $(4), \
+      mkdir -p $(2)/etc/modules-boot.d; \
+      ln -sf ../modules.d/$(3)$(1) $(2)/etc/modules-boot.d/;))
+endef
+
+ifeq ($(DUMP)$(TARGET_BUILD),)
+  -include $(LINUX_DIR)/.config
+endif
+
+define KernelPackage/depends
+  $(STAMP_BUILT): $(LINUX_DIR)/.config
+  define KernelPackage/depends
+  endef
+endef
+
+define KernelPackage
+  NAME:=$(1)
+  $(eval $(call Package/Default))
+  $(eval $(call KernelPackage/Defaults))
+  $(eval $(call KernelPackage/$(1)))
+  $(eval $(call KernelPackage/$(1)/$(BOARD)))
+  $(eval $(call KernelPackage/$(1)/$(BOARD)/$(if $(SUBTARGET),$(SUBTARGET),generic)))
+
+  define Package/kmod-$(1)
+    TITLE:=$(TITLE)
+    SECTION:=kernel
+    CATEGORY:=Kernel modules
+    DESCRIPTION:=$(DESCRIPTION)
+    EXTRA_DEPENDS:=kernel (=$(LINUX_VERSION)-$(LINUX_RELEASE)-$(LINUX_VERMAGIC))
+    VERSION:=$(LINUX_VERSION)$(if $(PKG_VERSION),+$(PKG_VERSION))-$(if $(PKG_RELEASE),$(PKG_RELEASE),$(LINUX_RELEASE))
+    PKGFLAGS:=$(PKGFLAGS)
+    $(call KernelPackage/$(1))
+    $(call KernelPackage/$(1)/$(BOARD))
+    $(call KernelPackage/$(1)/$(BOARD)/$(if $(SUBTARGET),$(SUBTARGET),generic))
+  endef
+
+  ifdef KernelPackage/$(1)/conffiles
+    define Package/kmod-$(1)/conffiles
+$(call KernelPackage/$(1)/conffiles)
+    endef
+  endif
+
+  ifdef KernelPackage/$(1)/description
+    define Package/kmod-$(1)/description
+$(call KernelPackage/$(1)/description)
+    endef
+  endif
+
+  ifdef KernelPackage/$(1)/config
+    define Package/kmod-$(1)/config
+$(call KernelPackage/$(1)/config)
+    endef
+  endif
+
+  $(call KernelPackage/depends)
+  $(call KernelPackage/hooks)
+
+  ifneq ($(if $(filter-out %=y %=n %=m,$(KCONFIG)),$(filter m y,$(foreach c,$(filter-out %=y %=n %=m,$(KCONFIG)),$($(c)))),.),)
+    define Package/kmod-$(1)/install
+		  @for mod in $$(call version_filter,$$(FILES)); do \
+			if grep -q "$$$$$$$${mod##$(LINUX_DIR)/}" "$(LINUX_DIR)/modules.builtin"; then \
+				echo "NOTICE: module '$$$$$$$$mod' is built-in."; \
+			elif [ -e $$$$$$$$mod ]; then \
+				mkdir -p $$(1)/$(MODULES_SUBDIR) ; \
+				$(CP) -L $$$$$$$$mod $$(1)/$(MODULES_SUBDIR)/ ; \
+			else \
+				echo "ERROR: module '$$$$$$$$mod' is missing." >&2; \
+				exit 1; \
+			fi; \
+		  done;
+		  $(call ModuleAutoLoad,$(1),$$(1),$(filter-out 0-,$(word 1,$(AUTOLOAD))-),$(filter-out 0,$(word 2,$(AUTOLOAD))),$(wordlist 3,99,$(AUTOLOAD)))
+		  $(call KernelPackage/$(1)/install,$$(1))
+    endef
+  $(if $(CONFIG_PACKAGE_kmod-$(1)),
+    else
+      compile: $(1)-disabled
+      $(1)-disabled:
+		@echo "WARNING: kmod-$(1) is not available in the kernel config - generating empty package" >&2
+
+      define Package/kmod-$(1)/install
+		true
+      endef
+  )
+  endif
+  $$(eval $$(call BuildPackage,kmod-$(1)))
+
+  $$(IPKG_kmod-$(1)): $$(wildcard $$(FILES))
+
+endef
+
+version_filter=$(if $(findstring @,$(1)),$(shell $(SCRIPT_DIR)/package-metadata.pl version_filter $(KERNEL_PATCHVER) $(1)),$(1))
+
+# 1: priority (optional)
+# 2: module list
+# 3: boot flag
+define AutoLoad
+  $(if $(1),$(1),0) $(if $(3),1,0) $(call version_filter,$(2))
+endef
+
+# 1: module list
+# 2: boot flag
+define AutoProbe
+  $(call AutoLoad,,$(1),$(2))
+endef
+
+version_field=$(if $(word $(1),$(2)),$(word $(1),$(2)),0)
+kernel_version_merge=$$(( ($(call version_field,1,$(1)) << 24) + ($(call version_field,2,$(1)) << 16) + ($(call version_field,3,$(1)) << 8) + $(call version_field,4,$(1)) ))
+
+ifdef DUMP
+  kernel_version_cmp=
+else
+  kernel_version_cmp=$(shell [ $(call kernel_version_merge,$(call split_version,$(2))) $(1) $(call kernel_version_merge,$(call split_version,$(3))) ] && echo 1 )
+endif
+
+CompareKernelPatchVer=$(if $(call kernel_version_cmp,-$(2),$(1),$(3)),1,0)
+
+kernel_patchver_gt=$(call kernel_version_cmp,-gt,$(KERNEL_PATCHVER),$(1))
+kernel_patchver_ge=$(call kernel_version_cmp,-ge,$(KERNEL_PATCHVER),$(1))
+kernel_patchver_eq=$(call kernel_version_cmp,-eq,$(KERNEL_PATCHVER),$(1))
+kernel_patchver_le=$(call kernel_version_cmp,-le,$(KERNEL_PATCHVER),$(1))
+kernel_patchver_lt=$(call kernel_version_cmp,-lt,$(KERNEL_PATCHVER),$(1))
+

+ 414 - 0
include/netfilter.mk

@@ -0,0 +1,414 @@
+#
+# Copyright (C) 2006-2014 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+ifneq ($(__inc_netfilter),1)
+__inc_netfilter:=1
+
+ifeq ($(NF_KMOD),1)
+P_V4:=ipv4/netfilter/
+P_V6:=ipv6/netfilter/
+P_XT:=netfilter/
+P_EBT:=bridge/netfilter/
+endif
+
+# 1: variable
+# 2: kconfig symbols
+# 3: file list
+# 4: version dependency
+define nf_add
+ $(if $(4),ifeq ($$(strip $$(call CompareKernelPatchVer,$$(KERNEL_PATCHVER),$(firstword $(4)),$(lastword $(4)))),1))
+  $(1)-$$($(2)) += $(3)
+ $(if $(4),endif)
+ KCONFIG_$(1) = $(filter-out $(2),$(KCONFIG_$(1))) $(2)
+endef
+
+
+# core
+
+# kernel only
+$(eval $(if $(NF_KMOD),$(call nf_add,NF_REJECT,CONFIG_NF_REJECT_IPV4, $(P_V4)nf_reject_ipv4),))
+
+$(eval $(if $(NF_KMOD),$(call nf_add,NF_IPT,CONFIG_IP_NF_IPTABLES, $(P_V4)ip_tables),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NF_IPT,CONFIG_NETFILTER_XTABLES, $(P_XT)x_tables),))
+
+$(eval $(if $(NF_KMOD),$(call nf_add,IPT_CORE,CONFIG_NETFILTER_XTABLES, $(P_XT)xt_tcpudp),))
+$(eval $(if $(NF_KMOD),$(call nf_add,IPT_CORE,CONFIG_IP_NF_FILTER, $(P_V4)iptable_filter),))
+$(eval $(if $(NF_KMOD),$(call nf_add,IPT_CORE,CONFIG_IP_NF_MANGLE, $(P_V4)iptable_mangle),))
+
+# userland only
+$(eval $(if $(NF_KMOD),,$(call nf_add,IPT_CORE,CONFIG_IP_NF_IPTABLES, xt_standard ipt_icmp xt_tcp xt_udp xt_comment xt_set xt_SET)))
+
+$(eval $(call nf_add,IPT_CORE,CONFIG_NETFILTER_XT_MATCH_LIMIT, $(P_XT)xt_limit))
+$(eval $(call nf_add,IPT_CORE,CONFIG_NETFILTER_XT_MATCH_MAC, $(P_XT)xt_mac))
+$(eval $(call nf_add,IPT_CORE,CONFIG_NETFILTER_XT_MATCH_MULTIPORT, $(P_XT)xt_multiport))
+$(eval $(call nf_add,IPT_CORE,CONFIG_NETFILTER_XT_MATCH_COMMENT, $(P_XT)xt_comment))
+
+#cluster
+$(eval $(call nf_add,IPT_CLUSTER,CONFIG_NETFILTER_XT_MATCH_CLUSTER, $(P_XT)xt_cluster))
+
+$(eval $(call nf_add,IPT_CORE,CONFIG_NETFILTER_XT_TARGET_LOG, $(P_XT)xt_LOG))
+$(eval $(call nf_add,IPT_CORE,CONFIG_NETFILTER_XT_TARGET_LOG, $(P_XT)nf_log_common))
+$(eval $(call nf_add,IPT_CORE,CONFIG_NETFILTER_XT_TARGET_LOG, $(P_V4)nf_log_ipv4))
+$(eval $(call nf_add,IPT_CORE,CONFIG_NETFILTER_XT_TARGET_TCPMSS, $(P_XT)xt_TCPMSS))
+$(eval $(call nf_add,IPT_CORE,CONFIG_IP_NF_TARGET_REJECT, $(P_V4)ipt_REJECT))
+$(eval $(call nf_add,IPT_CORE,CONFIG_NETFILTER_XT_MATCH_TIME, $(P_XT)xt_time))
+$(eval $(call nf_add,IPT_CORE,CONFIG_NETFILTER_XT_MARK, $(P_XT)xt_mark))
+
+# kernel has xt_MARK.ko merged into xt_mark.ko, userspace is still separate
+# userland: xt_MARK.so
+$(eval $(if $(NF_KMOD),,$(call nf_add,IPT_CORE,CONFIG_NETFILTER_XT_MARK, $(P_XT)xt_MARK)))
+
+
+# conntrack
+
+# kernel only
+$(eval $(if $(NF_KMOD),$(call nf_add,NF_CONNTRACK,CONFIG_NF_CONNTRACK, $(P_XT)nf_conntrack),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NF_CONNTRACK,CONFIG_NF_CONNTRACK_RTCACHE, $(P_XT)nf_conntrack_rtcache),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NF_CONNTRACK,CONFIG_NF_DEFRAG_IPV4, $(P_V4)nf_defrag_ipv4),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NF_CONNTRACK,CONFIG_NF_CONNTRACK_IPV4, $(P_V4)nf_conntrack_ipv4),))
+
+$(eval $(call nf_add,IPT_CONNTRACK,CONFIG_NETFILTER_XT_MATCH_STATE, $(P_XT)xt_state))
+$(eval $(call nf_add,IPT_CONNTRACK,CONFIG_NETFILTER_XT_TARGET_CT, $(P_XT)xt_CT))
+$(eval $(call nf_add,IPT_CONNTRACK,CONFIG_NETFILTER_XT_MATCH_CONNTRACK, $(P_XT)xt_conntrack))
+
+
+# conntrack-extra
+
+$(eval $(call nf_add,IPT_CONNTRACK_EXTRA,CONFIG_NETFILTER_XT_MATCH_CONNBYTES, $(P_XT)xt_connbytes))
+$(eval $(call nf_add,IPT_CONNTRACK_EXTRA,CONFIG_NETFILTER_XT_MATCH_CONNLIMIT, $(P_XT)xt_connlimit))
+$(eval $(call nf_add,IPT_CONNTRACK_EXTRA,CONFIG_NETFILTER_CONNCOUNT, $(P_XT)nf_conncount))
+$(eval $(call nf_add,IPT_CONNTRACK_EXTRA,CONFIG_NETFILTER_XT_CONNMARK, $(P_XT)xt_connmark))
+$(eval $(call nf_add,IPT_CONNTRACK_EXTRA,CONFIG_NETFILTER_XT_MATCH_HELPER, $(P_XT)xt_helper))
+$(eval $(call nf_add,IPT_CONNTRACK_EXTRA,CONFIG_NETFILTER_XT_MATCH_RECENT, $(P_XT)xt_recent))
+
+$(eval $(if $(NF_KMOD),,$(call nf_add,IPT_CONNTRACK_EXTRA,CONFIG_NETFILTER_XT_CONNMARK, $(P_XT)xt_CONNMARK)))
+
+#conntrack-label
+
+$(eval $(call nf_add,IPT_CONNTRACK_LABEL,CONFIG_NETFILTER_XT_MATCH_CONNLABEL, $(P_XT)xt_connlabel))
+
+# extra
+
+$(eval $(call nf_add,IPT_EXTRA,CONFIG_NETFILTER_XT_MATCH_ADDRTYPE, $(if $(NF_KMOD),$(P_XT)xt_addrtype,$(P_XT)ipt_addrtype)))
+$(eval $(call nf_add,IPT_EXTRA,CONFIG_NETFILTER_XT_MATCH_OWNER, $(P_XT)xt_owner))
+$(eval $(call nf_add,IPT_EXTRA,CONFIG_NETFILTER_XT_MATCH_PKTTYPE, $(P_XT)xt_pkttype))
+$(eval $(call nf_add,IPT_EXTRA,CONFIG_NETFILTER_XT_MATCH_QUOTA, $(P_XT)xt_quota))
+
+#$(eval $(call nf_add,IPT_EXTRA,CONFIG_IP_NF_TARGET_ROUTE, $(P_V4)ipt_ROUTE))
+
+# physdev
+
+$(eval $(call nf_add,IPT_PHYSDEV,CONFIG_NETFILTER_XT_MATCH_PHYSDEV, $(P_XT)xt_physdev))
+
+# filter
+
+$(eval $(call nf_add,IPT_FILTER,CONFIG_NETFILTER_XT_MATCH_STRING, $(P_XT)xt_string))
+$(eval $(call nf_add,IPT_FILTER,CONFIG_NETFILTER_XT_MATCH_BPF, $(P_XT)xt_bpf))
+
+
+# ipopt
+
+$(eval $(call nf_add,IPT_IPOPT,CONFIG_NETFILTER_XT_MATCH_DSCP, $(P_XT)xt_dscp))
+$(eval $(call nf_add,IPT_IPOPT,CONFIG_NETFILTER_XT_TARGET_DSCP, $(P_XT)xt_DSCP))
+$(eval $(call nf_add,IPT_HASHLIMIT,CONFIG_NETFILTER_XT_MATCH_HASHLIMIT, $(P_XT)xt_hashlimit))
+$(eval $(call nf_add,IPT_RPFILTER,CONFIG_IP_NF_MATCH_RPFILTER, $(P_V4)ipt_rpfilter))
+$(eval $(call nf_add,IPT_RPFILTER,CONFIG_IP6_NF_MATCH_RPFILTER, $(P_V6)ip6t_rpfilter))
+$(eval $(call nf_add,IPT_IPOPT,CONFIG_NETFILTER_XT_MATCH_LENGTH, $(P_XT)xt_length))
+$(eval $(call nf_add,IPT_IPOPT,CONFIG_NETFILTER_XT_MATCH_STATISTIC, $(P_XT)xt_statistic))
+$(eval $(call nf_add,IPT_IPOPT,CONFIG_NETFILTER_XT_MATCH_TCPMSS, $(P_XT)xt_tcpmss))
+
+$(eval $(call nf_add,IPT_IPOPT,CONFIG_NETFILTER_XT_TARGET_CLASSIFY, $(P_XT)xt_CLASSIFY))
+$(eval $(call nf_add,IPT_IPOPT,CONFIG_IP_NF_MATCH_DSCP, $(P_V4)ipt_dscp))
+$(eval $(call nf_add,IPT_IPOPT,CONFIG_IP_NF_TARGET_ECN, $(P_V4)ipt_ECN))
+
+$(eval $(call nf_add,IPT_IPOPT,CONFIG_NETFILTER_XT_MATCH_ECN, $(P_XT)xt_ecn))
+
+# userland only
+$(eval $(if $(NF_KMOD),,$(call nf_add,IPT_IPOPT,CONFIG_NETFILTER_XT_MATCH_DSCP, xt_tos)))
+$(eval $(if $(NF_KMOD),,$(call nf_add,IPT_IPOPT,CONFIG_NETFILTER_XT_TARGET_DSCP, xt_TOS)))
+$(eval $(if $(NF_KMOD),,$(call nf_add,IPT_IPOPT,CONFIG_NETFILTER_XT_MATCH_HL, ipt_ttl)))
+$(eval $(if $(NF_KMOD),,$(call nf_add,IPT_IPOPT,CONFIG_NETFILTER_XT_TARGET_HL, ipt_TTL)))
+
+$(eval $(call nf_add,IPT_IPOPT,CONFIG_NETFILTER_XT_MATCH_HL, $(P_XT)xt_hl))
+$(eval $(call nf_add,IPT_IPOPT,CONFIG_NETFILTER_XT_TARGET_HL, $(P_XT)xt_HL))
+
+# iprange
+$(eval $(call nf_add,IPT_IPRANGE,CONFIG_NETFILTER_XT_MATCH_IPRANGE, $(P_XT)xt_iprange))
+
+#clusterip
+$(eval $(call nf_add,IPT_CLUSTERIP,CONFIG_IP_NF_TARGET_CLUSTERIP, $(P_V4)ipt_CLUSTERIP))
+
+# ipsec
+$(eval $(call nf_add,IPT_IPSEC,CONFIG_IP_NF_MATCH_AH, $(P_V4)ipt_ah))
+$(eval $(call nf_add,IPT_IPSEC,CONFIG_NETFILTER_XT_MATCH_ESP, $(P_XT)xt_esp))
+$(eval $(call nf_add,IPT_IPSEC,CONFIG_NETFILTER_XT_MATCH_POLICY, $(P_XT)xt_policy))
+
+# flow offload support
+$(eval $(call nf_add,IPT_FLOW,CONFIG_NETFILTER_XT_TARGET_FLOWOFFLOAD, $(P_XT)xt_FLOWOFFLOAD))
+
+# IPv6
+
+# kernel only
+$(eval $(if $(NF_KMOD),$(call nf_add,NF_REJECT6,CONFIG_NF_REJECT_IPV6, $(P_V6)nf_reject_ipv6),))
+
+$(eval $(if $(NF_KMOD),$(call nf_add,NF_IPT6,CONFIG_IP6_NF_IPTABLES, $(P_V6)ip6_tables),))
+
+$(eval $(if $(NF_KMOD),$(call nf_add,NF_CONNTRACK,CONFIG_NF_DEFRAG_IPV6, $(P_V6)nf_defrag_ipv6, ge 4.19),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NF_CONNTRACK6,CONFIG_NF_DEFRAG_IPV6, $(P_V6)nf_defrag_ipv6, lt 4.19),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NF_CONNTRACK6,CONFIG_NF_CONNTRACK_IPV6, $(P_V6)nf_conntrack_ipv6),))
+
+$(eval $(if $(NF_KMOD),$(call nf_add,IPT_IPV6,CONFIG_IP6_NF_FILTER, $(P_V6)ip6table_filter),))
+$(eval $(if $(NF_KMOD),$(call nf_add,IPT_IPV6,CONFIG_IP6_NF_MANGLE, $(P_V6)ip6table_mangle),))
+$(eval $(if $(NF_KMOD),$(call nf_add,IPT_IPV6,CONFIG_IP6_NF_QUEUE, $(P_V6)ip6_queue),))
+$(eval $(if $(NF_KMOD),$(call nf_add,IPT_IPV6,CONFIG_NF_LOG_IPV6, $(P_V6)nf_log_ipv6),))
+
+$(eval $(if $(NF_KMOD),,$(call nf_add,IPT_IPV6,CONFIG_IP6_NF_IPTABLES, ip6t_icmp6)))
+
+
+$(eval $(call nf_add,IPT_IPV6,CONFIG_IP6_NF_TARGET_LOG, $(P_V6)ip6t_LOG))
+$(eval $(call nf_add,IPT_IPV6,CONFIG_IP6_NF_TARGET_REJECT, $(P_V6)ip6t_REJECT))
+
+# ipv6 extra
+$(eval $(call nf_add,IPT_IPV6_EXTRA,CONFIG_IP6_NF_MATCH_IPV6HEADER, $(P_V6)ip6t_ipv6header))
+$(eval $(call nf_add,IPT_IPV6_EXTRA,CONFIG_IP6_NF_MATCH_AH, $(P_V6)ip6t_ah))
+$(eval $(call nf_add,IPT_IPV6_EXTRA,CONFIG_IP6_NF_MATCH_MH, $(P_V6)ip6t_mh))
+$(eval $(call nf_add,IPT_IPV6_EXTRA,CONFIG_IP6_NF_MATCH_EUI64, $(P_V6)ip6t_eui64))
+$(eval $(call nf_add,IPT_IPV6_EXTRA,CONFIG_IP6_NF_MATCH_OPTS, $(P_V6)ip6t_hbh))
+$(eval $(call nf_add,IPT_IPV6_EXTRA,CONFIG_IP6_NF_MATCH_FRAG, $(P_V6)ip6t_frag))
+$(eval $(call nf_add,IPT_IPV6_EXTRA,CONFIG_IP6_NF_MATCH_RT, $(P_V6)ip6t_rt))
+
+# nat
+
+# kernel only
+$(eval $(if $(NF_KMOD),$(call nf_add,NF_NAT,CONFIG_NF_NAT, $(P_XT)nf_nat),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NF_NAT,CONFIG_NF_NAT_REDIRECT, $(P_XT)nf_nat_redirect, ge 3.19.0),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NF_NAT,CONFIG_NF_NAT_IPV4, $(P_V4)nf_nat_ipv4),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NF_NAT,CONFIG_NF_NAT_MASQUERADE_IPV4, $(P_V4)nf_nat_masquerade_ipv4, lt 4.18),))
+
+$(eval $(if $(NF_KMOD),$(call nf_add,NF_NAT6,CONFIG_NF_NAT_IPV6, $(P_V6)nf_nat_ipv6),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NF_NAT6,CONFIG_NF_NAT_MASQUERADE_IPV6, $(P_V6)nf_nat_masquerade_ipv6, lt 4.18),))
+
+$(eval $(if $(NF_KMOD),$(call nf_add,IPT_NAT,CONFIG_NETFILTER_XT_NAT, $(P_XT)xt_nat),))
+$(eval $(if $(NF_KMOD),$(call nf_add,IPT_NAT,CONFIG_IP_NF_NAT, $(P_V4)iptable_nat),))
+$(eval $(if $(NF_KMOD),$(call nf_add,IPT_NAT6,CONFIG_IP6_NF_NAT, $(P_V6)ip6table_nat),))
+$(eval $(if $(NF_KMOD),$(call nf_add,IPT_NAT6,CONFIG_IP6_NF_TARGET_MASQUERADE, $(P_V6)ip6t_MASQUERADE),))
+$(eval $(if $(NF_KMOD),$(call nf_add,IPT_NAT6,CONFIG_IP6_NF_TARGET_NPT, $(P_V6)ip6t_NPT),))
+
+# userland only
+$(eval $(if $(NF_KMOD),,$(call nf_add,IPT_NAT,CONFIG_NF_NAT, ipt_SNAT ipt_DNAT)))
+$(eval $(if $(NF_KMOD),,$(call nf_add,IPT_NAT6,CONFIG_IP6_NF_TARGET_NPT, ip6t_DNPT ip6t_SNPT)))
+
+$(eval $(call nf_add,IPT_NAT,CONFIG_IP_NF_TARGET_MASQUERADE, $(P_V4)ipt_MASQUERADE))
+$(eval $(call nf_add,IPT_NAT,CONFIG_IP_NF_TARGET_REDIRECT, $(P_XT)xt_REDIRECT))
+
+
+# nat-extra
+
+$(eval $(call nf_add,IPT_NAT_EXTRA,CONFIG_IP_NF_TARGET_NETMAP, $(P_XT)xt_NETMAP))
+
+
+# nathelper
+
+$(eval $(call nf_add,NF_NATHELPER,CONFIG_NF_CONNTRACK_FTP, $(P_XT)nf_conntrack_ftp))
+$(eval $(call nf_add,NF_NATHELPER,CONFIG_NF_NAT_FTP, $(P_XT)nf_nat_ftp))
+
+
+# nathelper-extra
+
+$(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_CONNTRACK_BROADCAST, $(P_XT)nf_conntrack_broadcast))
+$(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_CONNTRACK_AMANDA, $(P_XT)nf_conntrack_amanda))
+$(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_NAT_AMANDA, $(P_XT)nf_nat_amanda))
+$(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_CT_PROTO_GRE, $(P_XT)nf_conntrack_proto_gre))
+$(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_NAT_PROTO_GRE, $(P_V4)nf_nat_proto_gre))
+$(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_CONNTRACK_H323, $(P_XT)nf_conntrack_h323))
+$(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_NAT_H323, $(P_V4)nf_nat_h323))
+$(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_CONNTRACK_PPTP, $(P_XT)nf_conntrack_pptp))
+$(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_NAT_PPTP, $(P_V4)nf_nat_pptp))
+$(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_CONNTRACK_SIP, $(P_XT)nf_conntrack_sip))
+$(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_NAT_SIP, $(P_XT)nf_nat_sip))
+$(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_CONNTRACK_SNMP, $(P_XT)nf_conntrack_snmp))
+$(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_NAT_SNMP_BASIC, $(P_V4)nf_nat_snmp_basic))
+$(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_CONNTRACK_TFTP, $(P_XT)nf_conntrack_tftp))
+$(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_NAT_TFTP, $(P_XT)nf_nat_tftp))
+$(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_CONNTRACK_IRC, $(P_XT)nf_conntrack_irc))
+$(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_NAT_IRC, $(P_XT)nf_nat_irc))
+
+
+# ulog
+
+$(eval $(call nf_add,IPT_ULOG,CONFIG_IP_NF_TARGET_ULOG, $(P_V4)ipt_ULOG))
+
+
+# nflog
+
+$(eval $(call nf_add,IPT_NFLOG,CONFIG_NETFILTER_XT_TARGET_NFLOG, $(P_XT)xt_NFLOG))
+
+
+# nfqueue
+
+$(eval $(call nf_add,IPT_NFQUEUE,CONFIG_NETFILTER_XT_TARGET_NFQUEUE, $(P_XT)xt_NFQUEUE))
+
+
+# debugging
+
+$(eval $(call nf_add,IPT_DEBUG,CONFIG_NETFILTER_XT_TARGET_TRACE, $(P_XT)xt_TRACE))
+
+# tproxy
+
+$(eval $(call nf_add,IPT_TPROXY,CONFIG_NETFILTER_XT_MATCH_SOCKET, $(P_XT)xt_socket))
+$(eval $(call nf_add,IPT_TPROXY,CONFIG_NF_SOCKET_IPV4, $(P_V4)nf_socket_ipv4, ge 4.10))
+$(eval $(call nf_add,IPT_TPROXY,CONFIG_NF_SOCKET_IPV6, $(P_V6)nf_socket_ipv6, ge 4.10))
+$(eval $(call nf_add,IPT_TPROXY,CONFIG_NETFILTER_XT_TARGET_TPROXY, $(P_XT)xt_TPROXY))
+$(eval $(call nf_add,IPT_TPROXY,CONFIG_NF_TPROXY_IPV4, $(P_V4)nf_tproxy_ipv4, ge 4.18))
+$(eval $(call nf_add,IPT_TPROXY,CONFIG_NF_TPROXY_IPV6, $(P_V6)nf_tproxy_ipv6, ge 4.18))
+
+# led
+$(eval $(call nf_add,IPT_LED,CONFIG_NETFILTER_XT_TARGET_LED, $(P_XT)xt_LED))
+
+# tee
+
+$(eval $(call nf_add,IPT_TEE,CONFIG_NETFILTER_XT_TARGET_TEE, $(P_XT)xt_TEE))
+$(eval $(if $(NF_KMOD),$(call nf_add,IPT_TEE,CONFIG_NF_DUP_IPV4, $(P_V4)nf_dup_ipv4, ge 4.3),))
+$(eval $(if $(NF_KMOD),$(call nf_add,IPT_TEE,CONFIG_NF_DUP_IPV6, $(P_V6)nf_dup_ipv6, ge 4.3),))
+
+# u32
+
+$(eval $(call nf_add,IPT_U32,CONFIG_NETFILTER_XT_MATCH_U32, $(P_XT)xt_u32))
+
+# checksum
+
+$(eval $(call nf_add,IPT_CHECKSUM,CONFIG_NETFILTER_XT_TARGET_CHECKSUM, $(P_XT)xt_CHECKSUM))
+
+
+# netlink
+
+$(eval $(call nf_add,NFNETLINK,CONFIG_NETFILTER_NETLINK, $(P_XT)nfnetlink))
+
+# nflog
+
+$(eval $(call nf_add,NFNETLINK_LOG,CONFIG_NETFILTER_NETLINK_LOG, $(P_XT)nfnetlink_log))
+
+# nfqueue
+
+$(eval $(call nf_add,NFNETLINK_QUEUE,CONFIG_NETFILTER_NETLINK_QUEUE, $(P_XT)nfnetlink_queue))
+
+#
+# ebtables
+#
+
+$(eval $(if $(NF_KMOD),$(call nf_add,EBTABLES,CONFIG_BRIDGE_NF_EBTABLES, $(P_EBT)ebtables),))
+
+# ebtables: tables
+$(eval $(call nf_add,EBTABLES,CONFIG_BRIDGE_EBT_BROUTE, $(P_EBT)ebtable_broute))
+$(eval $(call nf_add,EBTABLES,CONFIG_BRIDGE_EBT_T_FILTER, $(P_EBT)ebtable_filter))
+$(eval $(call nf_add,EBTABLES,CONFIG_BRIDGE_EBT_T_NAT, $(P_EBT)ebtable_nat))
+
+# ebtables: matches
+$(eval $(call nf_add,EBTABLES,CONFIG_BRIDGE_EBT_802_3, $(P_EBT)ebt_802_3))
+$(eval $(call nf_add,EBTABLES,CONFIG_BRIDGE_EBT_AMONG, $(P_EBT)ebt_among))
+$(eval $(call nf_add,EBTABLES_IP4,CONFIG_BRIDGE_EBT_ARP, $(P_EBT)ebt_arp))
+$(eval $(call nf_add,EBTABLES_IP4,CONFIG_BRIDGE_EBT_IP, $(P_EBT)ebt_ip))
+$(eval $(call nf_add,EBTABLES_IP6,CONFIG_BRIDGE_EBT_IP6, $(P_EBT)ebt_ip6))
+$(eval $(call nf_add,EBTABLES,CONFIG_BRIDGE_EBT_LIMIT, $(P_EBT)ebt_limit))
+$(eval $(call nf_add,EBTABLES,CONFIG_BRIDGE_EBT_MARK, $(P_EBT)ebt_mark_m))
+$(eval $(call nf_add,EBTABLES,CONFIG_BRIDGE_EBT_PKTTYPE, $(P_EBT)ebt_pkttype))
+$(eval $(call nf_add,EBTABLES,CONFIG_BRIDGE_EBT_STP, $(P_EBT)ebt_stp))
+$(eval $(call nf_add,EBTABLES,CONFIG_BRIDGE_EBT_VLAN, $(P_EBT)ebt_vlan))
+
+# targets
+$(eval $(call nf_add,EBTABLES_IP4,CONFIG_BRIDGE_EBT_ARPREPLY, $(P_EBT)ebt_arpreply))
+$(eval $(call nf_add,EBTABLES,CONFIG_BRIDGE_EBT_MARK_T, $(P_EBT)ebt_mark))
+$(eval $(call nf_add,EBTABLES_IP4,CONFIG_BRIDGE_EBT_DNAT, $(P_EBT)ebt_dnat))
+$(eval $(call nf_add,EBTABLES,CONFIG_BRIDGE_EBT_REDIRECT, $(P_EBT)ebt_redirect))
+$(eval $(call nf_add,EBTABLES_IP4,CONFIG_BRIDGE_EBT_SNAT, $(P_EBT)ebt_snat))
+
+# watchers
+$(eval $(call nf_add,EBTABLES_WATCHERS,CONFIG_BRIDGE_EBT_LOG, $(P_EBT)ebt_log))
+$(eval $(call nf_add,EBTABLES_WATCHERS,CONFIG_BRIDGE_EBT_ULOG, $(P_EBT)ebt_ulog))
+$(eval $(call nf_add,EBTABLES_WATCHERS,CONFIG_BRIDGE_EBT_NFLOG, $(P_EBT)ebt_nflog))
+$(eval $(call nf_add,EBTABLES_WATCHERS,CONFIG_BRIDGE_EBT_NFQUEUE, $(P_EBT)ebt_nfqueue))
+
+# nftables
+$(eval $(if $(NF_KMOD),$(call nf_add,NFT_CORE,CONFIG_NF_TABLES, $(P_XT)nf_tables),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NFT_CORE,CONFIG_NF_TABLES_INET, $(P_XT)nf_tables_inet, lt 4.17),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NFT_CORE,CONFIG_NFT_EXTHDR, $(P_XT)nft_exthdr),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NFT_CORE,CONFIG_NFT_META, $(P_XT)nft_meta),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NFT_CORE,CONFIG_NFT_NUMGEN, $(P_XT)nft_numgen, ge 4.9.0),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NFT_CORE,CONFIG_NFT_CT, $(P_XT)nft_ct),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NFT_CORE,CONFIG_NFT_SET_RBTREE, $(P_XT)nft_set_rbtree, ge 4.9.0),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NFT_CORE,CONFIG_NFT_RBTREE, $(P_XT)nft_rbtree, lt 4.9.0),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NFT_CORE,CONFIG_NFT_SET_HASH, $(P_XT)nft_set_hash, ge 4.9.0),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NFT_CORE,CONFIG_NFT_HASH, $(P_XT)nft_hash, lt 4.9.0),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NFT_CORE,CONFIG_NFT_COUNTER, $(P_XT)nft_counter),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NFT_CORE,CONFIG_NFT_LOG, $(P_XT)nft_log),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NFT_CORE,CONFIG_NFT_LIMIT, $(P_XT)nft_limit),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NFT_CORE,CONFIG_NFT_REJECT, $(P_XT)nft_reject $(P_V4)nft_reject_ipv4 $(P_V6)nft_reject_ipv6),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NFT_CORE,CONFIG_NFT_REJECT_INET, $(P_XT)nft_reject_inet),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NFT_CORE,CONFIG_NF_TABLES_IPV4, $(P_V4)nf_tables_ipv4, lt 4.17),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NFT_CORE,CONFIG_NFT_CHAIN_ROUTE_IPV4, $(P_V4)nft_chain_route_ipv4),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NFT_CORE,CONFIG_NF_TABLES_IPV6, $(P_V6)nf_tables_ipv6, lt 4.17),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NFT_CORE,CONFIG_NFT_CHAIN_ROUTE_IPV6, $(P_V6)nft_chain_route_ipv6),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NFT_CORE,CONFIG_NFT_REDIR, $(P_XT)nft_redir, ge 3.19.0),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NFT_CORE,CONFIG_NFT_QUOTA, $(P_XT)nft_quota, ge 4.9.0),))
+
+$(eval $(if $(NF_KMOD),$(call nf_add,NFT_ARP,CONFIG_NF_TABLES_ARP, $(P_V4)nf_tables_arp, lt 4.17),))
+
+$(eval $(if $(NF_KMOD),$(call nf_add,NFT_BRIDGE,CONFIG_NF_TABLES_BRIDGE, $(P_EBT)nf_tables_bridge, lt 4.17),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NFT_BRIDGE,CONFIG_NFT_BRIDGE_META, $(P_EBT)nft_meta_bridge),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NFT_BRIDGE,CONFIG_NFT_BRIDGE_REJECT, $(P_EBT)nft_reject_bridge),))
+
+$(eval $(if $(NF_KMOD),$(call nf_add,NFT_NAT,CONFIG_NFT_NAT, $(P_XT)nft_nat),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NFT_NAT,CONFIG_NFT_CHAIN_NAT_IPV4, $(P_V4)nft_chain_nat_ipv4),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NFT_NAT,CONFIG_NFT_REDIR_IPV4, $(P_V4)nft_redir_ipv4, ge 3.19.0),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NFT_NAT,CONFIG_NFT_MASQ, $(P_XT)nft_masq),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NFT_NAT,CONFIG_NFT_MASQ_IPV4, $(P_V4)nft_masq_ipv4),))
+
+$(eval $(if $(NF_KMOD),$(call nf_add,NFT_NAT6,CONFIG_NFT_REDIR_IPV6, $(P_V6)nft_redir_ipv6, ge 3.19.0),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NFT_NAT6,CONFIG_NFT_CHAIN_NAT_IPV6, $(P_V6)nft_chain_nat_ipv6),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NFT_NAT6,CONFIG_NFT_MASQ_IPV6, $(P_V6)nft_masq_ipv6),))
+
+$(eval $(if $(NF_KMOD),$(call nf_add,NFT_FIB,CONFIG_NFT_FIB, $(P_XT)nft_fib),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NFT_FIB,CONFIG_NFT_FIB_INET, $(P_XT)nft_fib_inet),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NFT_FIB,CONFIG_NFT_FIB_IPV4, $(P_V4)nft_fib_ipv4),))
+$(eval $(if $(NF_KMOD),$(call nf_add,NFT_FIB,CONFIG_NFT_FIB_IPV6, $(P_V6)nft_fib_ipv6),))
+
+
+# userland only
+IPT_BUILTIN += $(NF_IPT-y) $(NF_IPT-m)
+IPT_BUILTIN += $(IPT_CORE-y) $(IPT_CORE-m)
+IPT_BUILTIN += $(NF_CONNTRACK-y)
+IPT_BUILTIN += $(NF_CONNTRACK6-y)
+IPT_BUILTIN += $(IPT_CONNTRACK-y)
+IPT_BUILTIN += $(IPT_CONNTRACK_EXTRA-y)
+IPT_BUILTIN += $(IPT_EXTRA-y)
+IPT_BUILTIN += $(IPT_PHYSDEV-y)
+IPT_BUILTIN += $(IPT_FILTER-y)
+IPT_BUILTIN += $(IPT_FLOW-y) $(IPT_FLOW-m)
+IPT_BUILTIN += $(IPT_IPOPT-y)
+IPT_BUILTIN += $(IPT_IPRANGE-y)
+IPT_BUILTIN += $(IPT_CLUSTER-y)
+IPT_BUILTIN += $(IPT_CLUSTERIP-y)
+IPT_BUILTIN += $(IPT_IPSEC-y)
+IPT_BUILTIN += $(IPT_IPV6-y) $(IPT_IPV6-m)
+IPT_BUILTIN += $(NF_NAT-y)
+IPT_BUILTIN += $(NF_NAT6-y)
+IPT_BUILTIN += $(IPT_NAT-y)
+IPT_BUILTIN += $(IPT_NAT6-y)
+IPT_BUILTIN += $(IPT_NAT_EXTRA-y)
+IPT_BUILTIN += $(NF_NATHELPER-y)
+IPT_BUILTIN += $(NF_NATHELPER_EXTRA-y)
+IPT_BUILTIN += $(IPT_ULOG-y)
+IPT_BUILTIN += $(IPT_TPROXY-y)
+IPT_BUILTIN += $(NFNETLINK-y)
+IPT_BUILTIN += $(NFNETLINK_LOG-y)
+IPT_BUILTIN += $(NFNETLINK_QUEUE-y)
+IPT_BUILTIN += $(EBTABLES-y)
+IPT_BUILTIN += $(EBTABLES_IP4-y)
+IPT_BUILTIN += $(EBTABLES_IP6-y)
+IPT_BUILTIN += $(EBTABLES_WATCHERS-y)
+
+endif # __inc_netfilter

+ 40 - 0
include/nls.mk

@@ -0,0 +1,40 @@
+#
+# Copyright (C) 2011-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+# iconv full
+ifeq ($(CONFIG_BUILD_NLS),y)
+	ICONV_PREFIX:=$(STAGING_DIR)/usr/lib/libiconv-full
+	ICONV_FULL:=1
+
+	INTL_PREFIX:=$(STAGING_DIR)/usr/lib/libintl-full
+	INTL_FULL:=1
+
+# iconv stub
+else
+	ICONV_PREFIX:=$(STAGING_DIR)/usr/lib/libiconv-stub
+	ICONV_FULL:=
+
+	INTL_PREFIX:=$(STAGING_DIR)/usr/lib/libintl-stub
+	INTL_FULL:=
+endif
+
+PKG_CONFIG_DEPENDS += CONFIG_BUILD_NLS
+PKG_BUILD_DEPENDS += !BUILD_NLS:libiconv !BUILD_NLS:gettext
+
+ICONV_DEPENDS:=+BUILD_NLS:libiconv-full
+ICONV_CFLAGS:=-I$(ICONV_PREFIX)/include
+ICONV_CPPFLAGS:=-I$(ICONV_PREFIX)/include
+ICONV_LDFLAGS:=-L$(ICONV_PREFIX)/lib -Wl,-rpath-link=$(ICONV_PREFIX)/lib
+
+INTL_DEPENDS:=+BUILD_NLS:libintl-full
+INTL_CFLAGS:=-I$(INTL_PREFIX)/include
+INTL_CPPFLAGS:=-I$(INTL_PREFIX)/include
+INTL_LDFLAGS:=-L$(INTL_PREFIX)/lib -Wl,-rpath-link=$(INTL_PREFIX)/lib
+
+TARGET_CFLAGS += $(ICONV_CFLAGS) $(INTL_CFLAGS)
+TARGET_CPPFLAGS += $(ICONV_CPPFLAGS) $(INTL_CPPFLAGS)
+TARGET_LDFLAGS += $(ICONV_LDFLAGS) $(INTL_LDFLAGS)

+ 43 - 0
include/package-bin.mk

@@ -0,0 +1,43 @@
+#
+# Copyright (C) 2007-2014 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+ifeq ($(DUMP),)
+  define BuildTarget/bin
+    ifeq ($(if $(VARIANT),$(BUILD_VARIANT)),$(VARIANT))
+    ifdef Package/$(1)/install
+      ifneq ($(CONFIG_PACKAGE_$(1))$(DEVELOPER),)
+        $(_pkg_target)compile: $(PKG_BUILD_DIR)/.pkgdir/$(1).installed
+        compile: install-bin-$(1)
+      else
+        compile: $(1)-disabled
+        $(1)-disabled:
+		@echo "WARNING: skipping $(1) -- package not selected" >&2
+      endif
+    endif
+    endif
+
+    $(PKG_BUILD_DIR)/.pkgdir/$(1).installed: $(STAMP_BUILT)
+		rm -rf $(PKG_BUILD_DIR)/.pkgdir/$(1) $$@
+		mkdir -p $(PKG_BUILD_DIR)/.pkgdir/$(1)
+		$(call Package/$(1)/install,$(PKG_BUILD_DIR)/.pkgdir/$(1))
+		touch $$@
+
+    install-bin-$(1): $(PKG_BUILD_DIR)/.pkgdir/$(1).installed
+	rm -rf $(BIN_DIR)/$(1)
+	-rmdir $(PKG_BUILD_DIR)/.pkgdir/$(1) >/dev/null 2>/dev/null
+	if [ -d $(PKG_BUILD_DIR)/.pkgdir/$(1) ]; then \
+		$(INSTALL_DIR) $(BIN_DIR)/$(1) && \
+		$(CP) $(PKG_BUILD_DIR)/.pkgdir/$(1)/. $(BIN_DIR)/$(1)/; \
+	fi
+
+    clean-$(1):
+	  rm -rf $(BIN_DIR)/$(1)
+
+    clean: clean-$(1)
+    .PHONY: install-bin-$(1)
+  endef
+endif

+ 164 - 0
include/package-defaults.mk

@@ -0,0 +1,164 @@
+#
+# Copyright (C) 2006 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+PKG_DEFAULT_DEPENDS = +libc +GCC_LIBSSP:libssp +USE_GLIBC:librt +USE_GLIBC:libpthread
+
+ifneq ($(PKG_NAME),toolchain)
+  PKG_FIXUP_DEPENDS = $(if $(filter kmod-%,$(1)),$(2),$(PKG_DEFAULT_DEPENDS) $(filter-out $(PKG_DEFAULT_DEPENDS),$(2)))
+else
+  PKG_FIXUP_DEPENDS = $(2)
+endif
+
+define Package/Default
+  CONFIGFILE:=
+  SECTION:=opt
+  CATEGORY:=Extra packages
+  DEPENDS:=
+  MDEPENDS:=
+  CONFLICTS:=
+  PROVIDES:=
+  EXTRA_DEPENDS:=
+  MAINTAINER:=$(PKG_MAINTAINER)
+  SOURCE:=$(patsubst $(TOPDIR)/%,%,$(CURDIR))
+  ifneq ($(PKG_VERSION),)
+    ifneq ($(PKG_RELEASE),)
+      VERSION:=$(PKG_VERSION)-$(PKG_RELEASE)
+    else
+      VERSION:=$(PKG_VERSION)
+    endif
+  else
+    VERSION:=$(PKG_RELEASE)
+  endif
+  ABI_VERSION:=
+  ifneq ($(PKG_FLAGS),)
+    PKGFLAGS:=$(PKG_FLAGS)
+  else
+    PKGFLAGS:=
+  endif
+  ifneq ($(ARCH_PACKAGES),)
+    PKGARCH:=$(ARCH_PACKAGES)
+  else
+    PKGARCH:=$(BOARD)
+  endif
+  DEFAULT:=
+  MENU:=
+  SUBMENU:=
+  SUBMENUDEP:=
+  TITLE:=
+  KCONFIG:=
+  BUILDONLY:=
+  HIDDEN:=
+  URL:=
+  VARIANT:=
+  DEFAULT_VARIANT:=
+  USERID:=
+  ALTERNATIVES:=
+  LICENSE:=$(PKG_LICENSE)
+  LICENSE_FILES:=$(PKG_LICENSE_FILES)
+endef
+
+Build/Patch:=$(Build/Patch/Default)
+ifneq ($(strip $(PKG_UNPACK)),)
+  define Build/Prepare/Default
+	$(PKG_UNPACK)
+	[ ! -d ./src/ ] || $(CP) ./src/. $(PKG_BUILD_DIR)
+	$(Build/Patch)
+  endef
+endif
+
+EXTRA_CXXFLAGS = $(EXTRA_CFLAGS)
+ifeq ($(CONFIG_BUILD_NLS),y)
+    DISABLE_NLS:=
+else
+    DISABLE_NLS:=--disable-nls
+endif
+
+CONFIGURE_PREFIX:=/usr
+CONFIGURE_ARGS = \
+		--target=$(GNU_TARGET_NAME) \
+		--host=$(GNU_TARGET_NAME) \
+		--build=$(GNU_HOST_NAME) \
+		--program-prefix="" \
+		--program-suffix="" \
+		--prefix=$(CONFIGURE_PREFIX) \
+		--exec-prefix=$(CONFIGURE_PREFIX) \
+		--bindir=$(CONFIGURE_PREFIX)/bin \
+		--sbindir=$(CONFIGURE_PREFIX)/sbin \
+		--libexecdir=$(CONFIGURE_PREFIX)/lib \
+		--sysconfdir=/etc \
+		--datadir=$(CONFIGURE_PREFIX)/share \
+		--localstatedir=/var \
+		--mandir=$(CONFIGURE_PREFIX)/man \
+		--infodir=$(CONFIGURE_PREFIX)/info \
+		$(DISABLE_NLS) \
+		$(DISABLE_IPV6)
+
+CONFIGURE_VARS = \
+		$(TARGET_CONFIGURE_OPTS) \
+		CFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS)" \
+		CXXFLAGS="$(TARGET_CXXFLAGS) $(EXTRA_CXXFLAGS)" \
+		CPPFLAGS="$(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS)" \
+		LDFLAGS="$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS)" \
+
+CONFIGURE_PATH = .
+CONFIGURE_CMD = ./configure
+
+replace_script=$(FIND) $(1) -name $(2) | $(XARGS) chmod u+w; \
+	       $(FIND) $(1) -name $(2) | $(XARGS) -n1 cp --remove-destination \
+	       $(SCRIPT_DIR)/$(2);
+
+define Build/Configure/Default
+	(cd $(PKG_BUILD_DIR)/$(CONFIGURE_PATH)/$(strip $(3)); \
+	if [ -x $(CONFIGURE_CMD) ]; then \
+		$(call replace_script,$(PKG_BUILD_DIR)/$(3),config.guess) \
+		$(call replace_script,$(PKG_BUILD_DIR)/$(3),config.sub) \
+		$(CONFIGURE_VARS) \
+		$(2) \
+		$(CONFIGURE_CMD) \
+		$(CONFIGURE_ARGS) \
+		$(1); \
+	fi; \
+	)
+endef
+
+MAKE_VARS = \
+	CFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS) $(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS)" \
+	CXXFLAGS="$(TARGET_CXXFLAGS) $(EXTRA_CXXFLAGS) $(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS)" \
+	LDFLAGS="$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS)"
+
+MAKE_FLAGS = \
+	$(TARGET_CONFIGURE_OPTS) \
+	CROSS="$(TARGET_CROSS)" \
+	ARCH="$(ARCH)"
+
+MAKE_INSTALL_FLAGS = \
+	$(MAKE_FLAGS) \
+	DESTDIR="$(PKG_INSTALL_DIR)"
+
+MAKE_PATH ?= .
+
+define Build/Compile/Default
+	+$(MAKE_VARS) \
+	$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) \
+		$(MAKE_FLAGS) \
+		$(1);
+endef
+
+define Build/Install/Default
+	$(MAKE_VARS) \
+	$(MAKE) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) \
+		$(MAKE_INSTALL_FLAGS) \
+		$(if $(1), $(1), install);
+endef
+
+define Build/Dist/Default
+	$(call Build/Compile/Default, DESTDIR="$(PKG_BUILD_DIR)/tmp" CC="$(TARGET_CC)" dist)
+endef
+
+define Build/DistCheck/Default
+	$(call Build/Compile/Default, DESTDIR="$(PKG_BUILD_DIR)/tmp" CC="$(TARGET_CC)" distcheck)
+endef

+ 60 - 0
include/package-dumpinfo.mk

@@ -0,0 +1,60 @@
+#
+# Copyright (C) 2006 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+ifneq ($(DUMP),)
+
+
+define SOURCE_INFO
+$(if $(PKG_BUILD_DEPENDS),Build-Depends: $(PKG_BUILD_DEPENDS)
+)$(if $(HOST_BUILD_DEPENDS),Build-Depends/host: $(HOST_BUILD_DEPENDS)
+)$(if $(BUILD_TYPES),Build-Types: $(BUILD_TYPES)
+)
+
+endef
+
+define Dumpinfo/Package
+$(info $(SOURCE_INFO)Package: $(1)
+$(if $(MENU),Menu: $(MENU)
+)$(if $(SUBMENU),Submenu: $(SUBMENU)
+)$(if $(SUBMENUDEP),Submenu-Depends: $(SUBMENUDEP)
+)$(if $(DEFAULT),Default: $(DEFAULT)
+)$(if $(findstring $(PREREQ_CHECK),1),Prereq-Check: 1
+)Version: $(VERSION)
+Depends: $(call PKG_FIXUP_DEPENDS,$(1),$(DEPENDS))
+Conflicts: $(CONFLICTS)
+Menu-Depends: $(MDEPENDS)
+Provides: $(PROVIDES)
+$(if $(VARIANT),Build-Variant: $(VARIANT)
+$(if $(DEFAULT_VARIANT),Default-Variant: $(VARIANT)
+))Section: $(SECTION)
+Category: $(CATEGORY)
+$(if $(filter nonshared,$(PKGFLAGS)),,Repository: $(if $(FEED),$(FEED),base)
+)Title: $(TITLE)
+Maintainer: $(MAINTAINER)
+$(if $(USERID),Require-User: $(USERID)
+)Source: $(PKG_SOURCE)
+$(if $(LICENSE),License: $(LICENSE)
+)$(if $(LICENSE_FILES),LicenseFiles: $(LICENSE_FILES)
+)Type: $(if $(Package/$(1)/targets),$(Package/$(1)/targets),$(if $(PKG_TARGETS),$(PKG_TARGETS),ipkg))
+$(if $(KCONFIG),Kernel-Config: $(KCONFIG)
+)$(if $(BUILDONLY),Build-Only: $(BUILDONLY)
+)$(if $(HIDDEN),Hidden: $(HIDDEN)
+)Description: $(if $(Package/$(1)/description),$(Package/$(1)/description),$(TITLE))
+$(if $(URL),$(URL)
+)$(MAINTAINER)
+@@
+$(if $(Package/$(1)/config),Config:
+$(Package/$(1)/config)
+@@
+))
+SOURCE_INFO :=
+endef
+
+dumpinfo: FORCE
+	$(if $(SOURCE_INFO),$(info $(SOURCE_INFO)))
+
+endif

+ 243 - 0
include/package-ipkg.mk

@@ -0,0 +1,243 @@
+#
+# Copyright (C) 2006-2014 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+ifndef DUMP
+  include $(INCLUDE_DIR)/feeds.mk
+endif
+
+# invoke ipkg-build with some default options
+IPKG_BUILD:= \
+  $(SCRIPT_DIR)/ipkg-build -c -o 0 -g 0
+
+IPKG_STATE_DIR:=$(TARGET_DIR)/usr/lib/opkg
+
+# 1: package name
+# 2: variable name
+# 3: variable suffix
+# 4: file is a script
+define BuildIPKGVariable
+ifdef Package/$(1)/$(2)
+  $$(IPKG_$(1)) : VAR_$(2)$(3)=$$(Package/$(1)/$(2))
+  $(call shexport,Package/$(1)/$(2))
+  $(1)_COMMANDS += echo "$$$$$$$$$(call shvar,Package/$(1)/$(2))" > $(2)$(3); $(if $(4),chmod 0755 $(2)$(3);)
+endif
+endef
+
+PARENL :=(
+PARENR :=)
+
+dep_split=$(subst :,$(space),$(1))
+dep_rem=$(subst !,,$(subst $(strip $(PARENL)),,$(subst $(strip $(PARENR)),,$(word 1,$(call dep_split,$(1))))))
+dep_confvar=$(strip $(foreach cond,$(subst ||, ,$(call dep_rem,$(1))),$(CONFIG_$(cond))))
+dep_pos=$(if $(call dep_confvar,$(1)),$(call dep_val,$(1)))
+dep_neg=$(if $(call dep_confvar,$(1)),,$(call dep_val,$(1)))
+dep_if=$(if $(findstring !,$(1)),$(call dep_neg,$(1)),$(call dep_pos,$(1)))
+dep_val=$(word 2,$(call dep_split,$(1)))
+strip_deps=$(strip $(subst +,,$(filter-out @%,$(1))))
+filter_deps=$(foreach dep,$(call strip_deps,$(1)),$(if $(findstring :,$(dep)),$(call dep_if,$(dep)),$(dep)))
+
+define AddDependency
+  $$(if $(1),$$(if $(2),$$(foreach pkg,$(1),$$(IPKG_$$(pkg))): $$(foreach pkg,$(2),$$(IPKG_$$(pkg)))))
+endef
+
+define FixupReverseDependencies
+  DEPS := $$(filter %:$(1),$$(IDEPEND))
+  DEPS := $$(patsubst %:$(1),%,$$(DEPS))
+  DEPS := $$(filter $$(DEPS),$$(IPKGS))
+  $(call AddDependency,$$(DEPS),$(1))
+endef
+
+define FixupDependencies
+  DEPS := $$(filter $(1):%,$$(IDEPEND))
+  DEPS := $$(patsubst $(1):%,%,$$(DEPS))
+  DEPS := $$(filter $$(DEPS),$$(IPKGS))
+  $(call AddDependency,$(1),$$(DEPS))
+endef
+
+ifneq ($(PKG_NAME),toolchain)
+  define CheckDependencies
+	@( \
+		rm -f $(PKG_INFO_DIR)/$(1).missing; \
+		( \
+			export \
+				READELF=$(TARGET_CROSS)readelf \
+				OBJCOPY=$(TARGET_CROSS)objcopy \
+				XARGS="$(XARGS)"; \
+			$(SCRIPT_DIR)/gen-dependencies.sh "$$(IDIR_$(1))"; \
+		) | while read FILE; do \
+			grep -qxF "$$$$FILE" $(PKG_INFO_DIR)/$(1).provides || \
+				echo "$$$$FILE" >> $(PKG_INFO_DIR)/$(1).missing; \
+		done; \
+		if [ -f "$(PKG_INFO_DIR)/$(1).missing" ]; then \
+			echo "Package $(1) is missing dependencies for the following libraries:" >&2; \
+			cat "$(PKG_INFO_DIR)/$(1).missing" >&2; \
+			false; \
+		fi; \
+	)
+  endef
+endif
+
+_addsep=$(word 1,$(1))$(foreach w,$(wordlist 2,$(words $(1)),$(1)),$(strip $(2) $(w)))
+_cleansep=$(subst $(space)$(2)$(space),$(2)$(space),$(1))
+mergelist=$(call _cleansep,$(call _addsep,$(1),$(comma)),$(comma))
+addfield=$(if $(strip $(2)),$(1): $(2))
+_define=define
+_endef=endef
+
+ifeq ($(DUMP),)
+  define BuildTarget/ipkg
+    PDIR_$(1):=$(call FeedPackageDir,$(1))
+    IPKG_$(1):=$$(PDIR_$(1))/$(1)_$(VERSION)_$(PKGARCH).ipk
+    IDIR_$(1):=$(PKG_BUILD_DIR)/ipkg-$(PKGARCH)/$(1)
+    KEEP_$(1):=$(strip $(call Package/$(1)/conffiles))
+
+    ifeq ($(BUILD_VARIANT),$$(if $$(VARIANT),$$(VARIANT),$(BUILD_VARIANT)))
+    do_install=
+    ifdef Package/$(1)/install
+      do_install=yes
+    endif
+    ifdef Package/$(1)/install-overlay
+      do_install=yes
+    endif
+    ifdef do_install
+      ifneq ($(CONFIG_PACKAGE_$(1))$(DEVELOPER),)
+        IPKGS += $(1)
+        $(_pkg_target)compile: $$(IPKG_$(1)) $(PKG_INFO_DIR)/$(1).provides $(PKG_BUILD_DIR)/.pkgdir/$(1).installed
+        prepare-package-install: $$(IPKG_$(1))
+        compile: $(STAGING_DIR_ROOT)/stamp/.$(1)_installed
+      else
+        $(if $(CONFIG_PACKAGE_$(1)),$$(info WARNING: skipping $(1) -- package not selected))
+      endif
+
+      .PHONY: $(PKG_INSTALL_STAMP).$(1)
+      ifeq ($(CONFIG_PACKAGE_$(1)),y)
+        compile: $(PKG_INSTALL_STAMP).$(1)
+      endif
+      $(PKG_INSTALL_STAMP).$(1): prepare-package-install
+		echo "$(1)" >> $(PKG_INSTALL_STAMP)
+    endif
+    endif
+
+    DEPENDS:=$(call PKG_FIXUP_DEPENDS,$(1),$(DEPENDS))
+    IDEPEND_$(1):=$$(call filter_deps,$$(DEPENDS))
+    IDEPEND += $$(patsubst %,$(1):%,$$(IDEPEND_$(1)))
+    $(FixupDependencies)
+    $(FixupReverseDependencies)
+
+    $(eval $(call BuildIPKGVariable,$(1),conffiles))
+    $(eval $(call BuildIPKGVariable,$(1),preinst,,1))
+    $(eval $(call BuildIPKGVariable,$(1),postinst,-pkg,1))
+    $(eval $(call BuildIPKGVariable,$(1),prerm,-pkg,1))
+    $(eval $(call BuildIPKGVariable,$(1),postrm,,1))
+
+    $(PKG_BUILD_DIR)/.pkgdir/$(1).installed : export PATH=$$(TARGET_PATH_PKG)
+    $(PKG_BUILD_DIR)/.pkgdir/$(1).installed: $(STAMP_BUILT)
+	rm -rf $$@ $(PKG_BUILD_DIR)/.pkgdir/$(1)
+	mkdir -p $(PKG_BUILD_DIR)/.pkgdir/$(1)
+	$(call Package/$(1)/install,$(PKG_BUILD_DIR)/.pkgdir/$(1))
+	$(call Package/$(1)/install_lib,$(PKG_BUILD_DIR)/.pkgdir/$(1))
+	touch $$@
+
+    $(STAGING_DIR_ROOT)/stamp/.$(1)_installed: $(PKG_BUILD_DIR)/.pkgdir/$(1).installed
+	mkdir -p $(STAGING_DIR_ROOT)/stamp
+	$(if $(ABI_VERSION),echo '$(ABI_VERSION)' | cmp -s - $(PKG_INFO_DIR)/$(1).version || echo '$(ABI_VERSION)' > $(PKG_INFO_DIR)/$(1).version)
+	$(call locked,$(CP) $(PKG_BUILD_DIR)/.pkgdir/$(1)/. $(STAGING_DIR_ROOT)/,root-copy)
+	touch $$@
+
+    Package/$(1)/DEPENDS := $$(call mergelist,$$(filter-out @%,$$(IDEPEND_$(1))))
+    ifneq ($$(EXTRA_DEPENDS),)
+      Package/$(1)/DEPENDS := $$(EXTRA_DEPENDS)$$(if $$(Package/$(1)/DEPENDS),$$(comma) $$(Package/$(1)/DEPENDS))
+    endif
+
+$(_define) Package/$(1)/CONTROL
+Package: $(1)
+Version: $(VERSION)
+$$(call addfield,Depends,$$(Package/$(1)/DEPENDS)
+)$$(call addfield,Conflicts,$$(call mergelist,$(CONFLICTS))
+)$$(call addfield,Provides,$$(call mergelist,$(PROVIDES))
+)$$(call addfield,Alternatives,$$(call mergelist,$(ALTERNATIVES))
+)$$(call addfield,Source,$(SOURCE)
+)$$(call addfield,License,$(LICENSE)
+)$$(call addfield,LicenseFiles,$(LICENSE_FILES)
+)$$(call addfield,Section,$(SECTION)
+)$$(call addfield,Require-User,$(USERID)
+)$(if $(filter hold,$(PKG_FLAGS)),Status: unknown hold not-installed
+)$(if $(filter essential,$(PKG_FLAGS)),Essential: yes
+)$(if $(MAINTAINER),Maintainer: $(MAINTAINER)
+)Architecture: $(PKGARCH)
+Installed-Size: 0
+$(_endef)
+
+    $$(IPKG_$(1)) : export CONTROL=$$(Package/$(1)/CONTROL)
+    $$(IPKG_$(1)) : export DESCRIPTION=$$(Package/$(1)/description)
+    $$(IPKG_$(1)) : export PATH=$$(TARGET_PATH_PKG)
+    $(PKG_INFO_DIR)/$(1).provides $$(IPKG_$(1)): $(STAMP_BUILT) $(INCLUDE_DIR)/package-ipkg.mk
+	@rm -rf $$(IDIR_$(1)) $$(call opkg_package_files,$(1))
+	mkdir -p $(PACKAGE_DIR) $$(IDIR_$(1))/CONTROL $(PKG_INFO_DIR)
+	$(call Package/$(1)/install,$$(IDIR_$(1)))
+	$(if $(Package/$(1)/install-overlay),mkdir -p $(PACKAGE_DIR) $$(IDIR_$(1))/rootfs-overlay)
+	$(call Package/$(1)/install-overlay,$$(IDIR_$(1))/rootfs-overlay)
+	-find $$(IDIR_$(1)) -name 'CVS' -o -name '.svn' -o -name '.#*' -o -name '*~'| $(XARGS) rm -rf
+	@( \
+		find $$(IDIR_$(1)) -name lib\*.so\* -or -name \*.ko | awk -F/ '{ print $$$$NF }'; \
+		for file in $$(patsubst %,$(PKG_INFO_DIR)/%.provides,$$(IDEPEND_$(1))); do \
+			if [ -f "$$$$file" ]; then \
+				cat $$$$file; \
+			fi; \
+		done; $(Package/$(1)/extra_provides) \
+	) | sort -u > $(PKG_INFO_DIR)/$(1).provides
+	$(if $(PROVIDES),@for pkg in $(filter-out $(1),$(PROVIDES)); do cp $(PKG_INFO_DIR)/$(1).provides $(PKG_INFO_DIR)/$$$$pkg.provides; done)
+	$(CheckDependencies)
+
+	$(RSTRIP) $$(IDIR_$(1))
+	(cd $$(IDIR_$(1))/CONTROL; \
+		( \
+			echo "$$$$CONTROL"; \
+			printf "Description: "; echo "$$$$DESCRIPTION" | sed -e 's,^[[:space:]]*, ,g'; \
+		) > control; \
+		chmod 644 control; \
+		( \
+			echo "#!/bin/sh"; \
+			echo "[ \"\$$$${IPKG_NO_SCRIPT}\" = \"1\" ] && exit 0"; \
+			echo "[ -x "\$$$${IPKG_INSTROOT}/lib/functions.sh" ] || exit 0"; \
+			echo ". \$$$${IPKG_INSTROOT}/lib/functions.sh"; \
+			echo "default_postinst \$$$$0 \$$$$@"; \
+		) > postinst; \
+		( \
+			echo "#!/bin/sh"; \
+			echo "[ -x "\$$$${IPKG_INSTROOT}/lib/functions.sh" ] || exit 0"; \
+			echo ". \$$$${IPKG_INSTROOT}/lib/functions.sh"; \
+			echo "default_prerm \$$$$0 \$$$$@"; \
+		) > prerm; \
+		chmod 0755 postinst prerm; \
+		$($(1)_COMMANDS) \
+	)
+
+    ifneq ($$(KEEP_$(1)),)
+		@( \
+			keepfiles=""; \
+			for x in $$(KEEP_$(1)); do \
+				[ -f "$$(IDIR_$(1))/$$$$x" ] || keepfiles="$$$${keepfiles:+$$$$keepfiles }$$$$x"; \
+			done; \
+			[ -z "$$$$keepfiles" ] || { \
+				mkdir -p $$(IDIR_$(1))/lib/upgrade/keep.d; \
+				for x in $$$$keepfiles; do echo $$$$x >> $$(IDIR_$(1))/lib/upgrade/keep.d/$(1); done; \
+			}; \
+		)
+    endif
+
+	$(INSTALL_DIR) $$(PDIR_$(1))
+	$(IPKG_BUILD) $$(IDIR_$(1)) $$(PDIR_$(1))
+	@[ -f $$(IPKG_$(1)) ]
+
+    $(1)-clean:
+	$$(if $$(call opkg_package_files,$(1)),rm -f $$(call opkg_package_files,$(1)))
+
+    clean: $(1)-clean
+
+  endef
+endif

+ 15 - 0
include/package-seccomp.mk

@@ -0,0 +1,15 @@
+#
+# Copyright (C) 2015 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+PKG_CONFIG_DEPENDS+= CONFIG_KERNEL_SECCOMP
+
+ifeq ($(CONFIG_KERNEL_SECCOMP),y)
+  define InstallSeccomp
+	$(INSTALL_DIR) $(1)/etc/seccomp
+	$(INSTALL_DATA) $(2) $(1)/etc/seccomp/
+  endef
+endif

+ 324 - 0
include/package.mk

@@ -0,0 +1,324 @@
+#
+# Copyright (C) 2006-2008 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+__package_mk:=1
+
+all: $(if $(DUMP),dumpinfo,$(if $(CHECK),check,compile))
+
+include $(INCLUDE_DIR)/download.mk
+
+PKG_BUILD_DIR ?= $(BUILD_DIR)/$(PKG_NAME)$(if $(PKG_VERSION),-$(PKG_VERSION))
+PKG_INSTALL_DIR ?= $(PKG_BUILD_DIR)/ipkg-install
+PKG_BUILD_PARALLEL ?=
+PKG_USE_MIPS16 ?= 1
+PKG_IREMAP ?= 1
+
+MAKE_J:=$(if $(MAKE_JOBSERVER),$(MAKE_JOBSERVER) $(if $(filter 3.% 4.0 4.1,$(MAKE_VERSION)),-j))
+
+ifeq ($(strip $(PKG_BUILD_PARALLEL)),0)
+PKG_JOBS?=-j1
+else
+PKG_JOBS?=$(if $(PKG_BUILD_PARALLEL),$(MAKE_J),-j1)
+endif
+ifdef CONFIG_USE_MIPS16
+  ifeq ($(strip $(PKG_USE_MIPS16)),1)
+    TARGET_ASFLAGS_DEFAULT = $(filter-out -mips16 -minterlink-mips16,$(TARGET_CFLAGS))
+    TARGET_CFLAGS += -mips16 -minterlink-mips16
+  endif
+endif
+ifeq ($(strip $(PKG_IREMAP)),1)
+  IREMAP_CFLAGS = $(call iremap,$(PKG_BUILD_DIR),$(notdir $(PKG_BUILD_DIR)))
+  TARGET_CFLAGS += $(IREMAP_CFLAGS)
+endif
+
+include $(INCLUDE_DIR)/hardening.mk
+include $(INCLUDE_DIR)/prereq.mk
+include $(INCLUDE_DIR)/unpack.mk
+include $(INCLUDE_DIR)/depends.mk
+
+ifneq ($(if $(CONFIG_SRC_TREE_OVERRIDE),$(wildcard ./git-src)),)
+  USE_GIT_TREE:=1
+  QUILT:=1
+endif
+ifdef USE_SOURCE_DIR
+  QUILT:=1
+endif
+ifneq ($(wildcard $(PKG_BUILD_DIR)/.source_dir),)
+  QUILT:=1
+endif
+
+include $(INCLUDE_DIR)/quilt.mk
+
+find_library_dependencies = $(wildcard $(patsubst %,$(STAGING_DIR)/pkginfo/%.version, \
+	$(filter-out $(BUILD_PACKAGES),$(foreach dep, \
+		$(filter-out @%, $(patsubst +%,%,$(1))), \
+		$(if $(findstring :,$(dep)), \
+			$(word 2,$(subst :,$(space),$(dep))), \
+			$(dep) \
+		) \
+	))))
+
+PKG_DIR_NAME:=$(lastword $(subst /,$(space),$(CURDIR)))
+STAMP_NO_AUTOREBUILD=$(wildcard $(PKG_BUILD_DIR)/.no_autorebuild)
+PREV_STAMP_PREPARED:=$(if $(STAMP_NO_AUTOREBUILD),$(wildcard $(PKG_BUILD_DIR)/.prepared*))
+ifneq ($(PREV_STAMP_PREPARED),)
+  STAMP_PREPARED:=$(PREV_STAMP_PREPARED)
+  CONFIG_AUTOREBUILD:=
+else
+  STAMP_PREPARED=$(PKG_BUILD_DIR)/.prepared$(if $(QUILT)$(DUMP),,_$(shell $(call find_md5,${CURDIR} $(PKG_FILE_DEPENDS),))_$(call confvar,CONFIG_AUTOREMOVE $(PKG_PREPARED_DEPENDS)))
+endif
+STAMP_CONFIGURED=$(PKG_BUILD_DIR)/.configured$(if $(DUMP),,_$(call confvar,$(PKG_CONFIG_DEPENDS)))
+STAMP_CONFIGURED_WILDCARD=$(PKG_BUILD_DIR)/.configured_*
+STAMP_BUILT:=$(PKG_BUILD_DIR)/.built
+STAMP_INSTALLED:=$(STAGING_DIR)/stamp/.$(PKG_DIR_NAME)$(if $(BUILD_VARIANT),.$(BUILD_VARIANT),)_installed
+
+STAGING_FILES_LIST:=$(PKG_DIR_NAME)$(if $(BUILD_VARIANT),.$(BUILD_VARIANT),).list
+
+define CleanStaging
+	rm -f $(STAMP_INSTALLED)
+	@-(\
+		cd "$(STAGING_DIR)"; \
+		if [ -f packages/$(STAGING_FILES_LIST) ]; then \
+			cat packages/$(STAGING_FILES_LIST) | xargs -r rm -f 2>/dev/null; \
+		fi; \
+	)
+endef
+
+
+PKG_INSTALL_STAMP:=$(PKG_INFO_DIR)/$(PKG_DIR_NAME).$(if $(BUILD_VARIANT),$(BUILD_VARIANT),default).install
+
+include $(INCLUDE_DIR)/package-defaults.mk
+include $(INCLUDE_DIR)/package-dumpinfo.mk
+include $(INCLUDE_DIR)/package-ipkg.mk
+include $(INCLUDE_DIR)/package-bin.mk
+include $(INCLUDE_DIR)/autotools.mk
+
+_pkg_target:=$(if $(QUILT),,.)
+
+override MAKEFLAGS=
+CONFIG_SITE:=$(INCLUDE_DIR)/site/$(ARCH)
+CUR_MAKEFILE:=$(filter-out Makefile,$(firstword $(MAKEFILE_LIST)))
+SUBMAKE:=$(NO_TRACE_MAKE) $(if $(CUR_MAKEFILE),-f $(CUR_MAKEFILE))
+PKG_CONFIG_PATH=$(STAGING_DIR)/usr/lib/pkgconfig:$(STAGING_DIR)/usr/share/pkgconfig
+unexport QUIET CONFIG_SITE
+
+ifeq ($(DUMP)$(filter prereq clean refresh update,$(MAKECMDGOALS)),)
+  ifneq ($(if $(QUILT),,$(CONFIG_AUTOREBUILD)),)
+    define Build/Autoclean
+      $(PKG_BUILD_DIR)/.dep_files: $(STAMP_PREPARED)
+      $(call rdep,${CURDIR} $(PKG_FILE_DEPENDS),$(STAMP_PREPARED),$(PKG_BUILD_DIR)/.dep_files,-x "*/.dep_*")
+      $(if $(filter prepare,$(MAKECMDGOALS)),,$(call rdep,$(PKG_BUILD_DIR),$(STAMP_BUILT),,-x "*/.dep_*" -x "*/ipkg*"))
+    endef
+  endif
+endif
+
+ifdef USE_GIT_TREE
+  define Build/Prepare/Default
+	mkdir -p $(PKG_BUILD_DIR)
+	ln -s $(CURDIR)/git-src $(PKG_BUILD_DIR)/.git
+	( cd $(PKG_BUILD_DIR); \
+		git checkout .; \
+		git submodule update --recursive; \
+		git submodule foreach git config --unset core.worktree; \
+		git submodule foreach git checkout .; \
+	)
+  endef
+endif
+ifdef USE_SOURCE_DIR
+  define Build/Prepare/Default
+	rm -rf $(PKG_BUILD_DIR)
+	$(if $(wildcard $(USE_SOURCE_DIR)/*),,@echo "Error: USE_SOURCE_DIR=$(USE_SOURCE_DIR) path not found"; false)
+	ln -snf $(USE_SOURCE_DIR) $(PKG_BUILD_DIR)
+	touch $(PKG_BUILD_DIR)/.source_dir
+  endef
+endif
+
+define Build/Exports/Default
+  $(1) : export ACLOCAL_INCLUDE=$$(foreach p,$$(wildcard $$(STAGING_DIR)/usr/share/aclocal $$(STAGING_DIR)/usr/share/aclocal-* $$(STAGING_DIR_HOSTPKG)/share/aclocal $$(STAGING_DIR_HOSTPKG)/share/aclocal-* $$(STAGING_DIR)/host/share/aclocal $$(STAGING_DIR)/host/share/aclocal-*),-I $$(p))
+  $(1) : export STAGING_PREFIX=$$(STAGING_DIR)/usr
+  $(1) : export PATH=$$(TARGET_PATH_PKG)
+  $(1) : export CONFIG_SITE:=$$(CONFIG_SITE)
+  $(1) : export PKG_CONFIG_PATH:=$$(PKG_CONFIG_PATH)
+  $(1) : export PKG_CONFIG_LIBDIR:=$$(PKG_CONFIG_PATH)
+  $(if $(CONFIG_CCACHE),$(1) : export CCACHE_DIR:=$(STAGING_DIR)/ccache)
+endef
+Build/Exports=$(Build/Exports/Default)
+
+define Build/CoreTargets
+  STAMP_PREPARED:=$$(STAMP_PREPARED)
+  STAMP_CONFIGURED:=$$(STAMP_CONFIGURED)
+
+  $(if $(QUILT),$(Build/Quilt))
+  $(call Build/Autoclean)
+  $(call DefaultTargets)
+
+  download:
+	$(foreach hook,$(Hooks/Download),
+		$(call $(hook))$(sep)
+	)
+
+  $(STAMP_PREPARED) : export PATH=$$(TARGET_PATH_PKG)
+  $(STAMP_PREPARED): $(STAMP_PREPARED_DEPENDS)
+	@-rm -rf $(PKG_BUILD_DIR)
+	@mkdir -p $(PKG_BUILD_DIR)
+	touch $$@_check
+	$(foreach hook,$(Hooks/Prepare/Pre),$(call $(hook))$(sep))
+	$(Build/Prepare)
+	$(foreach hook,$(Hooks/Prepare/Post),$(call $(hook))$(sep))
+	touch $$@
+
+  $(call Build/Exports,$(STAMP_CONFIGURED))
+  $(STAMP_CONFIGURED): $(STAMP_PREPARED) $(STAMP_CONFIGURED_DEPENDS)
+	rm -f $(STAMP_CONFIGURED_WILDCARD)
+	$(CleanStaging)
+	$(foreach hook,$(Hooks/Configure/Pre),$(call $(hook))$(sep))
+	$(Build/Configure)
+	$(foreach hook,$(Hooks/Configure/Post),$(call $(hook))$(sep))
+	touch $$@
+
+  $(call Build/Exports,$(STAMP_BUILT))
+  $(STAMP_BUILT): $(STAMP_CONFIGURED) $(STAMP_BUILT_DEPENDS)
+	rm -f $$@
+	touch $$@_check
+	$(foreach hook,$(Hooks/Compile/Pre),$(call $(hook))$(sep))
+	$(Build/Compile)
+	$(foreach hook,$(Hooks/Compile/Post),$(call $(hook))$(sep))
+	$(Build/Install)
+	$(foreach hook,$(Hooks/Install/Post),$(call $(hook))$(sep))
+	touch $$@
+
+  $(STAMP_INSTALLED) : export PATH=$$(TARGET_PATH_PKG)
+  $(STAMP_INSTALLED): $(STAMP_BUILT)
+	rm -rf $(TMP_DIR)/stage-$(PKG_DIR_NAME)
+	mkdir -p $(TMP_DIR)/stage-$(PKG_DIR_NAME)/host $(STAGING_DIR)/packages $(STAGING_DIR_HOST)/packages
+	$(foreach hook,$(Hooks/InstallDev/Pre),\
+		$(call $(hook),$(TMP_DIR)/stage-$(PKG_DIR_NAME),$(TMP_DIR)/stage-$(PKG_DIR_NAME)/host)$(sep)\
+	)
+	$(call Build/InstallDev,$(TMP_DIR)/stage-$(PKG_DIR_NAME),$(TMP_DIR)/stage-$(PKG_DIR_NAME)/host)
+	$(foreach hook,$(Hooks/InstallDev/Post),\
+		$(call $(hook),$(TMP_DIR)/stage-$(PKG_DIR_NAME),$(TMP_DIR)/stage-$(PKG_DIR_NAME)/host)$(sep)\
+	)
+	if [ -f $(STAGING_DIR)/packages/$(STAGING_FILES_LIST) ]; then \
+		$(SCRIPT_DIR)/clean-package.sh \
+			"$(STAGING_DIR)/packages/$(STAGING_FILES_LIST)" \
+			"$(STAGING_DIR)"; \
+	fi
+	if [ -d $(TMP_DIR)/stage-$(PKG_DIR_NAME) ]; then \
+		(cd $(TMP_DIR)/stage-$(PKG_DIR_NAME); find ./ > $(TMP_DIR)/stage-$(PKG_DIR_NAME).files); \
+		$(call locked, \
+			mv $(TMP_DIR)/stage-$(PKG_DIR_NAME).files $(STAGING_DIR)/packages/$(STAGING_FILES_LIST) && \
+			$(CP) $(TMP_DIR)/stage-$(PKG_DIR_NAME)/* $(STAGING_DIR)/; \
+		,staging-dir); \
+	fi
+	rm -rf $(TMP_DIR)/stage-$(PKG_DIR_NAME)
+	touch $$@
+
+  ifdef Build/InstallDev
+    $(_pkg_target)compile: $(STAMP_INSTALLED)
+  endif
+
+  $(_pkg_target)prepare: $(STAMP_PREPARED)
+  $(_pkg_target)configure: $(STAMP_CONFIGURED)
+  $(_pkg_target)dist: $(STAMP_CONFIGURED)
+  $(_pkg_target)distcheck: $(STAMP_CONFIGURED)
+
+  ifneq ($(CONFIG_AUTOREMOVE),)
+    compile:
+		-touch -r $(PKG_BUILD_DIR)/.built $(PKG_BUILD_DIR)/.autoremove 2>/dev/null >/dev/null
+		$(FIND) $(PKG_BUILD_DIR) -mindepth 1 -maxdepth 1 -not '(' -type f -and -name '.*' -and -size 0 ')' -and -not -name '.pkgdir' | \
+			$(XARGS) rm -rf
+  endif
+endef
+
+define Build/DefaultTargets
+  $(if $(USE_SOURCE_DIR)$(USE_GIT_TREE),,$(if $(strip $(PKG_SOURCE_URL)),$(call Download,default)))
+  $(if $(DUMP),,$(Build/CoreTargets))
+
+  define Build/DefaultTargets
+  endef
+endef
+
+define BuildPackage
+  $(eval $(Package/Default))
+  $(eval $(Package/$(1)))
+
+ifdef DESCRIPTION
+$$(error DESCRIPTION:= is obsolete, use Package/PKG_NAME/description)
+endif
+
+ifndef Package/$(1)/description
+define Package/$(1)/description
+	$(TITLE)
+endef
+endif
+
+  BUILD_PACKAGES += $(1)
+  $(STAMP_PREPARED): $$(if $(QUILT)$(DUMP),,$(call find_library_dependencies,$(DEPENDS)))
+
+  $(foreach FIELD, TITLE CATEGORY SECTION VERSION,
+    ifeq ($($(FIELD)),)
+      $$(error Package/$(1) is missing the $(FIELD) field)
+    endif
+  )
+
+  $(if $(DUMP), \
+    $(if $(CHECK),,$(Dumpinfo/Package)), \
+    $(foreach target, \
+      $(if $(Package/$(1)/targets),$(Package/$(1)/targets), \
+        $(if $(PKG_TARGETS),$(PKG_TARGETS), ipkg) \
+      ), $(BuildTarget/$(target)) \
+    ) \
+  )
+  $(if $(PKG_HOST_ONLY),,$(call Build/DefaultTargets,$(1)))
+endef
+
+define pkg_install_files
+	$(foreach install_file,$(1),$(INSTALL_DIR) $(3)/`dirname $(install_file)`; $(INSTALL_DATA) $(2)/$(install_file) $(3)/`dirname $(install_file)`;)
+endef
+
+define pkg_install_bin
+	$(foreach install_apps,$(1),$(INSTALL_DIR) $(3)/`dirname $(install_apps)`; $(INSTALL_BIN) $(2)/$(install_apps) $(3)/`dirname $(install_apps)`;)
+endef
+
+Build/Prepare=$(call Build/Prepare/Default,)
+Build/Configure=$(call Build/Configure/Default,)
+Build/Compile=$(call Build/Compile/Default,)
+Build/Install=$(if $(PKG_INSTALL),$(call Build/Install/Default,))
+Build/Dist=$(call Build/Dist/Default,)
+Build/DistCheck=$(call Build/DistCheck/Default,)
+
+.NOTPARALLEL:
+
+.PHONY: prepare-package-install
+prepare-package-install:
+	@mkdir -p $(PKG_INFO_DIR)
+	@rm -f $(PKG_INSTALL_STAMP)
+	@echo "$(filter-out essential nonshared,$(PKG_FLAGS))" > $(PKG_INSTALL_STAMP).flags
+
+$(PACKAGE_DIR):
+	mkdir -p $@
+
+compile:
+.install: .compile
+install: compile
+
+force-clean-build: FORCE
+	rm -rf $(PKG_BUILD_DIR)
+
+clean-build: $(if $(wildcard $(PKG_BUILD_DIR)/.autoremove),force-clean-build)
+
+clean: force-clean-build
+	$(CleanStaging)
+	$(call Build/UninstallDev,$(STAGING_DIR),$(STAGING_DIR_HOST))
+	$(Build/Clean)
+	rm -f $(STAGING_DIR)/packages/$(STAGING_FILES_LIST) $(STAGING_DIR_HOST)/packages/$(STAGING_FILES_LIST)
+
+dist:
+	$(Build/Dist)
+
+distcheck:
+	$(Build/DistCheck)

+ 164 - 0
include/prereq-build.mk

@@ -0,0 +1,164 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/prereq.mk
+
+SHELL:=sh
+PKG_NAME:=Build dependency
+
+
+# Required for the toolchain
+$(eval $(call TestHostCommand,working-make, \
+	Please install GNU make v3.81 or later. (This version has bugs), \
+	$(MAKE) -v | grep -E 'Make (3\.8[1-9]|3\.9[0-9]|[4-9]\.)'))
+
+$(eval $(call TestHostCommand,case-sensitive-fs, \
+	libreCMC can only be built on a case-sensitive filesystem, \
+	rm -f $(TMP_DIR)/test.*; touch $(TMP_DIR)/test.fs; \
+		test ! -f $(TMP_DIR)/test.FS))
+
+$(eval $(call TestHostCommand,proper-umask, \
+	Please build with umask 022 - other values produce broken packages, \
+	umask | grep -xE 00[012][012]))
+
+$(eval $(call SetupHostCommand,gcc, \
+	Please install the GNU C Compiler (gcc) 4.8 or later, \
+	$(CC) -dumpversion | grep -E '^(4\.[8-9]|[5-9]\.?)', \
+	gcc -dumpversion | grep -E '^(4\.[8-9]|[5-9]\.?)', \
+	gcc48 --version | grep gcc, \
+	gcc49 --version | grep gcc, \
+	gcc5 --version | grep gcc, \
+	gcc6 --version | grep gcc, \
+	gcc7 --version | grep gcc, \
+	gcc8 --version | grep gcc, \
+	gcc9 --version | grep gcc, \
+	gcc --version | grep Apple.LLVM ))
+
+$(eval $(call TestHostCommand,working-gcc, \
+	\nPlease reinstall the GNU C Compiler (4.8 or later) - \
+	it appears to be broken, \
+	echo 'int main(int argc, char **argv) { return 0; }' | \
+		gcc -x c -o $(TMP_DIR)/a.out -))
+
+$(eval $(call SetupHostCommand,g++, \
+	Please install the GNU C++ Compiler (g++) 4.8 or later, \
+	$(CXX) -dumpversion | grep -E '^(4\.[8-9]|[5-9]\.?)', \
+	g++ -dumpversion | grep -E '^(4\.[8-9]|[5-9]\.?)', \
+	g++48 --version | grep g++, \
+	g++49 --version | grep g++, \
+	g++5 --version | grep g++, \
+	g++6 --version | grep g++, \
+	g++7 --version | grep g++, \
+	g++8 --version | grep g++, \
+	g++9 --version | grep g++, \
+	g++ --version | grep Apple.LLVM ))
+
+$(eval $(call TestHostCommand,working-g++, \
+	\nPlease reinstall the GNU C++ Compiler (4.8 or later) - \
+	it appears to be broken, \
+	echo 'int main(int argc, char **argv) { return 0; }' | \
+		g++ -x c++ -o $(TMP_DIR)/a.out - -lstdc++ && \
+		$(TMP_DIR)/a.out))
+
+$(eval $(call TestHostCommand,ncurses, \
+	Please install ncurses. (Missing libncurses.so or ncurses.h), \
+	echo 'int main(int argc, char **argv) { initscr(); return 0; }' | \
+		gcc -include ncurses.h -x c -o $(TMP_DIR)/a.out - -lncurses))
+
+ifeq ($(HOST_OS),Linux)
+  zlib_link_flags := -Wl,-Bstatic -lz -Wl,-Bdynamic
+else
+  zlib_link_flags := -lz
+endif
+
+$(eval $(call TestHostCommand,perl-thread-queue, \
+	Please install the Perl Thread::Queue module, \
+	perl -MThread::Queue -e 1))
+
+
+$(eval $(call SetupHostCommand,tar,Please install GNU 'tar', \
+	gtar --version 2>&1 | grep GNU, \
+	gnutar --version 2>&1 | grep GNU, \
+	tar --version 2>&1 | grep GNU))
+
+$(eval $(call SetupHostCommand,find,Please install GNU 'find', \
+	gfind --version 2>&1 | grep GNU, \
+	find --version 2>&1 | grep GNU))
+
+$(eval $(call SetupHostCommand,bash,Please install GNU 'bash', \
+	bash --version 2>&1 | grep GNU))
+
+$(eval $(call SetupHostCommand,patch,Please install GNU 'patch', \
+	gpatch --version 2>&1 | grep 'Free Software Foundation', \
+	patch --version 2>&1 | grep 'Free Software Foundation'))
+
+$(eval $(call SetupHostCommand,diff,Please install diffutils, \
+	gdiff --version 2>&1 | grep diff, \
+	diff --version 2>&1 | grep diff))
+
+$(eval $(call SetupHostCommand,cp,Please install GNU fileutils, \
+	gcp --help 2>&1 | grep 'Copy SOURCE', \
+	cp --help 2>&1 | grep 'Copy SOURCE'))
+
+$(eval $(call SetupHostCommand,seq,, \
+	gseq --version, \
+	seq --version))
+
+$(eval $(call SetupHostCommand,awk,Please install GNU 'awk', \
+	gawk --version 2>&1 | grep GNU, \
+	awk --version 2>&1 | grep GNU))
+
+$(eval $(call SetupHostCommand,grep,Please install GNU 'grep', \
+	ggrep --version 2>&1 | grep GNU, \
+	grep --version 2>&1 | grep GNU))
+
+$(eval $(call SetupHostCommand,getopt, \
+	Please install an extended getopt version that supports --long, \
+	gnugetopt -o t --long test -- --test | grep '^ *--test *--', \
+	/usr/local/bin/getopt -o t --long test -- --test | grep '^ *--test *--', \
+	getopt -o t --long test -- --test | grep '^ *--test *--'))
+
+$(eval $(call SetupHostCommand,stat,Cannot find a file stat utility, \
+	gnustat -c%s $(TOPDIR)/Makefile, \
+	gstat -c%s $(TOPDIR)/Makefile, \
+	stat -c%s $(TOPDIR)/Makefile))
+
+$(eval $(call SetupHostCommand,unzip,Please install 'unzip', \
+	unzip 2>&1 | grep zipfile, \
+	unzip))
+
+$(eval $(call SetupHostCommand,bzip2,Please install 'bzip2', \
+	bzip2 --version </dev/null))
+
+$(eval $(call SetupHostCommand,wget,Please install GNU 'wget', \
+	wget --version | grep GNU))
+
+$(eval $(call SetupHostCommand,perl,Please install Perl 5.x, \
+	perl --version | grep "perl.*v5"))
+
+$(eval $(call SetupHostCommand,python,Please install Python 2.x, \
+	python2.7 -V 2>&1 | grep Python, \
+	python2 -V 2>&1 | grep Python, \
+	python -V 2>&1 | grep Python))
+
+$(eval $(call SetupHostCommand,git,Please install Git (git-core) >= 1.7.12.2, \
+	git --exec-path | xargs -I % -- grep -q -- --recursive %/git-submodule))
+
+$(eval $(call SetupHostCommand,file,Please install the 'file' package, \
+	file --version 2>&1 | grep file))
+
+$(STAGING_DIR_HOST)/bin/mkhash: $(SCRIPT_DIR)/mkhash.c
+	mkdir -p $(dir $@)
+	$(CC) -O2 -I$(TOPDIR)/tools/include -o $@ $<
+
+prereq: $(STAGING_DIR_HOST)/bin/mkhash
+
+# Install ldconfig stub
+$(eval $(call TestHostCommand,ldconfig-stub,Failed to install stub, \
+	touch $(STAGING_DIR_HOST)/bin/ldconfig && \
+	chmod +x $(STAGING_DIR_HOST)/bin/ldconfig))

+ 109 - 0
include/prereq.mk

@@ -0,0 +1,109 @@
+#
+# Copyright (C) 2006-2015 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+ifneq ($(__prereq_inc),1)
+__prereq_inc:=1
+
+prereq:
+	if [ -f $(TMP_DIR)/.prereq-error ]; then \
+		echo; \
+		cat $(TMP_DIR)/.prereq-error; \
+		rm -f $(TMP_DIR)/.prereq-error; \
+		echo; \
+		false; \
+	fi
+
+.SILENT: prereq
+endif
+
+PREREQ_PREV=
+
+# 1: display name
+# 2: error message
+define Require
+  export PREREQ_CHECK=1
+  ifeq ($$(CHECK_$(1)),)
+    prereq: prereq-$(1)
+
+    prereq-$(1): $(if $(PREREQ_PREV),prereq-$(PREREQ_PREV)) FORCE
+		printf "Checking '$(1)'... "
+		if $(NO_TRACE_MAKE) -f $(firstword $(MAKEFILE_LIST)) check-$(1) >/dev/null 2>/dev/null; then \
+			echo 'ok.'; \
+		else \
+			echo 'failed.'; \
+			echo "$(PKG_NAME): $(strip $(2))" >> $(TMP_DIR)/.prereq-error; \
+		fi
+
+    check-$(1): FORCE
+	  $(call Require/$(1))
+    CHECK_$(1):=1
+
+    .SILENT: prereq-$(1) check-$(1)
+    .NOTPARALLEL:
+  endif
+
+  PREREQ_PREV=$(1)
+endef
+
+
+define RequireCommand
+  define Require/$(1)
+    which $(1)
+  endef
+
+  $$(eval $$(call Require,$(1),$(2)))
+endef
+
+define RequireHeader
+  define Require/$(1)
+    [ -e "$(1)" ]
+  endef
+
+  $$(eval $$(call Require,$(1),$(2)))
+endef
+
+define QuoteHostCommand
+'$(subst ','"'"',$(strip $(1)))'
+endef
+
+# 1: display name
+# 2: failure message
+# 3: test
+define TestHostCommand
+  define Require/$(1)
+	($(3)) >/dev/null 2>/dev/null
+  endef
+
+  $$(eval $$(call Require,$(1),$(2)))
+endef
+
+# 1: canonical name
+# 2: failure message
+# 3+: candidates
+define SetupHostCommand
+  define Require/$(1)
+	[ -f "$(STAGING_DIR_HOST)/bin/$(strip $(1))" ] && exit 0; \
+	for cmd in $(call QuoteHostCommand,$(3)) $(call QuoteHostCommand,$(4)) \
+	           $(call QuoteHostCommand,$(5)) $(call QuoteHostCommand,$(6)) \
+	           $(call QuoteHostCommand,$(7)) $(call QuoteHostCommand,$(8)) \
+	           $(call QuoteHostCommand,$(9)) $(call QuoteHostCommand,$(10)) \
+	           $(call QuoteHostCommand,$(11)) $(call QuoteHostCommand,$(12)); do \
+		if [ -n "$$$$$$$$cmd" ]; then \
+			bin="$$$$$$$$(PATH="$(subst $(space),:,$(filter-out $(STAGING_DIR_HOST)/%,$(subst :,$(space),$(PATH))))" \
+				which "$$$$$$$${cmd%% *}")"; \
+			if [ -x "$$$$$$$$bin" ] && eval "$$$$$$$$cmd" >/dev/null 2>/dev/null; then \
+				mkdir -p "$(STAGING_DIR_HOST)/bin"; \
+				ln -sf "$$$$$$$$bin" "$(STAGING_DIR_HOST)/bin/$(strip $(1))"; \
+				exit 0; \
+			fi; \
+		fi; \
+	done; \
+	exit 1
+  endef
+
+  $$(eval $$(call Require,$(1),$(if $(2),$(2),Missing $(1) command)))
+endef

+ 183 - 0
include/quilt.mk

@@ -0,0 +1,183 @@
+#
+# Copyright (C) 2007-2009 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+ifeq ($(TARGET_BUILD),1)
+  PKG_BUILD_DIR:=$(LINUX_DIR)
+endif
+
+ifneq ($(filter host-refresh refresh,$(MAKECMDGOALS)),)
+  override QUILT=1
+  override HOST_QUILT=1
+endif
+
+ifneq ($(PKG_BUILD_DIR),)
+  QUILT?=$(if $(wildcard $(PKG_BUILD_DIR)/.quilt_used),y)
+  ifneq ($(QUILT),)
+    STAMP_CHECKED:=$(PKG_BUILD_DIR)/.quilt_checked
+    override CONFIG_AUTOREBUILD=
+    override CONFIG_AUTOREMOVE=
+    quilt-check: $(STAMP_CHECKED)
+  endif
+endif
+
+ifneq ($(HOST_BUILD_DIR),)
+  HOST_QUILT?=$(if $(findstring command,$(origin QUILT)),$(QUILT),$(if $(wildcard $(HOST_BUILD_DIR)/.quilt_used),y))
+  ifneq ($(HOST_QUILT),)
+    HOST_STAMP_CHECKED:=$(HOST_BUILD_DIR)/.quilt_checked
+    override CONFIG_AUTOREBUILD=
+    override CONFIG_AUTOREMOVE=
+    host-quilt-check: $(HOST_STAMP_CHECKED)
+  endif
+endif
+
+ifneq ($(if $(DUMP),1,$(__quilt_inc)),1)
+__quilt_inc:=1
+
+PATCH_DIR?=./patches
+FILES_DIR?=./files
+HOST_PATCH_DIR?=$(PATCH_DIR)
+HOST_FILES_DIR?=$(FILES_DIR)
+
+QUILT_CMD:=quilt --quiltrc=-
+
+define filter_series
+sed -e s,\\\#.*,, $(1) | grep -E \[a-zA-Z0-9\]
+endef
+
+define PatchDir/Quilt
+	@mkdir -p "$(1)/patches$(if $(3),/$(patsubst %/,%,$(3)))"
+	@if [ -s "$(2)/series" ]; then \
+		mkdir -p "$(1)/patches/$(3)"; \
+		cp "$(2)/series" "$(1)/patches/$(3)"; \
+	fi
+	@for patch in $$$$( (cd "$(2)" && if [ -f series ]; then $(call filter_series,series); else ls | sort; fi; ) 2>/dev/null ); do ( \
+		cp "$(2)/$$$$patch" "$(1)/patches/$(3)"; \
+		echo "$(3)$$$$patch" >> "$(1)/patches/series"; \
+	); done
+	$(if $(3),@echo $(3) >> "$(1)/patches/.subdirs")
+endef
+
+define PatchDir/Default
+	@if [ -d "$(2)" ] && [ "$$$$(ls $(2) | wc -l)" -gt 0 ]; then \
+		export PATCH="$(PATCH)"; \
+		if [ -s "$(2)/series" ]; then \
+			$(call filter_series,$(2)/series) | xargs -n1 \
+				$(KPATCH) "$(1)" "$(2)"; \
+		else \
+			$(KPATCH) "$(1)" "$(2)"; \
+		fi; \
+	fi
+endef
+
+define PatchDir
+$(call PatchDir/$(if $(strip $(QUILT)),Quilt,Default),$(strip $(1)),$(strip $(2)),$(strip $(3)))
+endef
+
+define HostPatchDir
+$(call PatchDir/$(if $(strip $(HOST_QUILT)),Quilt,Default),$(strip $(1)),$(strip $(2)),$(strip $(3)))
+endef
+
+define Host/Patch/Default
+	$(if $(HOST_QUILT),rm -rf $(HOST_BUILD_DIR)/patches; mkdir -p $(HOST_BUILD_DIR)/patches)
+	$(call HostPatchDir,$(HOST_BUILD_DIR),$(HOST_PATCH_DIR),)
+	$(if $(HOST_QUILT),touch $(HOST_BUILD_DIR)/.quilt_used)
+endef
+
+define Build/Patch/Default
+	$(if $(QUILT),rm -rf $(PKG_BUILD_DIR)/patches; mkdir -p $(PKG_BUILD_DIR)/patches)
+	$(call PatchDir,$(PKG_BUILD_DIR),$(PATCH_DIR),)
+	$(if $(QUILT),touch $(PKG_BUILD_DIR)/.quilt_used)
+endef
+
+kernel_files=$(foreach fdir,$(GENERIC_FILES_DIR) $(FILES_DIR),$(fdir)/.)
+define Kernel/Patch/Default
+	$(if $(QUILT),rm -rf $(PKG_BUILD_DIR)/patches; mkdir -p $(PKG_BUILD_DIR)/patches)
+	$(if $(kernel_files),$(CP) $(kernel_files) $(LINUX_DIR)/)
+	find $(LINUX_DIR)/ -name \*.rej -or -name \*.orig | $(XARGS) rm -f
+	if [ -d $(GENERIC_PLATFORM_DIR)/patches$(if $(wildcard $(GENERIC_PLATFORM_DIR)/patches-$(KERNEL_PATCHVER)),-$(KERNEL_PATCHVER)) ]; then \
+		echo "generic patches directory is present. please move your patches to the pending directory" ; \
+		exit 1; \
+	fi
+	$(call PatchDir,$(PKG_BUILD_DIR),$(GENERIC_BACKPORT_DIR),generic-backport/)
+	$(call PatchDir,$(PKG_BUILD_DIR),$(GENERIC_PATCH_DIR),generic/)
+	$(call PatchDir,$(PKG_BUILD_DIR),$(GENERIC_HACK_DIR),generic-hack/)
+	$(call PatchDir,$(PKG_BUILD_DIR),$(PATCH_DIR),platform/)
+endef
+
+define Quilt/RefreshDir
+	mkdir -p $(2)
+	-rm -f $(2)/* 2>/dev/null >/dev/null
+	@( \
+		for patch in $$$$($(if $(3),grep "^$(3)",cat) $(1)/patches/series | awk '{print $$$$1}'); do \
+			$(CP) -v "$(1)/patches/$$$$patch" $(2); \
+		done; \
+	)
+endef
+
+define Quilt/Refresh/Host
+	$(call Quilt/RefreshDir,$(HOST_BUILD_DIR),$(PATCH_DIR))
+endef
+
+define Quilt/Refresh/Package
+	$(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(PATCH_DIR))
+endef
+
+define Quilt/Refresh/Kernel
+	@[ -z "$$(grep -v '^generic/' $(PKG_BUILD_DIR)/patches/series | grep -v '^platform/')" ] || { \
+		echo "All kernel patches must start with either generic/ or platform/"; \
+		false; \
+	}
+	$(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(GENERIC_BACKPORT_DIR),generic-backport/)
+	$(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(GENERIC_PATCH_DIR),generic/)
+	$(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(GENERIC_HACK_DIR),generic-hack/)
+	$(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(PATCH_DIR),platform/)
+endef
+
+define Quilt/Template
+  $($(2)STAMP_CONFIGURED): $($(2)STAMP_CHECKED)
+  $(if $(NO_RECONFIGURE),$($(2)STAMP_BUILT),$($(2)STAMP_CONFIGURED)): FORCE
+  $($(2)STAMP_CHECKED): $($(2)STAMP_PREPARED)
+	if [ -s "$(1)/patches/series" ]; then \
+		(cd "$(1)"; \
+			if $(QUILT_CMD) next >/dev/null 2>&1; then \
+				$(QUILT_CMD) push -a; \
+			else \
+				$(QUILT_CMD) top >/dev/null 2>&1; \
+			fi \
+		); \
+	fi
+	touch "$$@"
+
+  $(3)quilt-check: $($(2)STAMP_PREPARED) FORCE
+	@[ -f "$(1)/.quilt_used" ] || { \
+		echo "The source directory was not unpacked using quilt. Please rebuild with QUILT=1"; \
+		false; \
+	}
+	@[ -f "$(1)/patches/series" ] || { \
+		echo "The source directory contains no quilt patches."; \
+		false; \
+	}
+	@[ -n "$$$$(ls $(1)/patches/series)" -o \
+	   "$$$$(cat $(1)/patches/series | mkhash md5)" = "$$(sort $(1)/patches/series | mkhash md5)" ] || { \
+		echo "The patches are not sorted in the right order. Please fix."; \
+		false; \
+	}
+
+  $(3)refresh: $(3)quilt-check
+	@cd "$(1)"; $(QUILT_CMD) pop -a -f >/dev/null 2>/dev/null
+	@cd "$(1)"; while $(QUILT_CMD) next 2>/dev/null >/dev/null && $(QUILT_CMD) push; do \
+		QUILT_DIFF_OPTS="-p" $(QUILT_CMD) refresh -p ab --no-index --no-timestamps; \
+	done; ! $(QUILT_CMD) next 2>/dev/null >/dev/null
+	$(Quilt/Refresh/$(4))
+	
+  $(3)update: $(3)quilt-check
+	$(Quilt/Refresh/$(4))
+endef
+
+Build/Quilt=$(call Quilt/Template,$(PKG_BUILD_DIR),,,$(if $(TARGET_BUILD),Kernel,Package))
+Host/Quilt=$(call Quilt/Template,$(HOST_BUILD_DIR),HOST_,host-,Host)
+
+endif

+ 96 - 0
include/rootfs.mk

@@ -0,0 +1,96 @@
+ifdef CONFIG_USE_MKLIBS
+  define mklibs
+	rm -rf $(TMP_DIR)/mklibs-progs $(TMP_DIR)/mklibs-out
+	# first find all programs and add them to the mklibs list
+	find $(STAGING_DIR_ROOT) -type f -perm /100 -exec \
+		file -r -N -F '' {} + | \
+		awk ' /executable.*dynamically/ { print $$1 }' > $(TMP_DIR)/mklibs-progs
+	# find all loadable objects that are not regular libraries and add them to the list as well
+	find $(STAGING_DIR_ROOT) -type f -name \*.so\* -exec \
+		file -r -N -F '' {} + | \
+		awk ' /shared object/ { print $$1 }' > $(TMP_DIR)/mklibs-libs
+	mkdir -p $(TMP_DIR)/mklibs-out
+	$(STAGING_DIR_HOST)/bin/mklibs -D \
+		-d $(TMP_DIR)/mklibs-out \
+		--sysroot $(STAGING_DIR_ROOT) \
+		`cat $(TMP_DIR)/mklibs-libs | sed 's:/*[^/]\+/*$$::' | uniq | sed 's:^$(STAGING_DIR_ROOT):-L :'` \
+		--ldlib $(patsubst $(STAGING_DIR_ROOT)/%,/%,$(firstword $(wildcard \
+			$(foreach name,ld-uClibc.so.* ld-linux.so.* ld-*.so ld-musl-*.so.*, \
+			  $(STAGING_DIR_ROOT)/lib/$(name) \
+			)))) \
+		--target $(REAL_GNU_TARGET_NAME) \
+		`cat $(TMP_DIR)/mklibs-progs $(TMP_DIR)/mklibs-libs` 2>&1
+	$(RSTRIP) $(TMP_DIR)/mklibs-out
+	for lib in `ls $(TMP_DIR)/mklibs-out/*.so.* 2>/dev/null`; do \
+		LIB="$${lib##*/}"; \
+		DEST="`ls "$(1)/lib/$$LIB" "$(1)/usr/lib/$$LIB" 2>/dev/null`"; \
+		[ -n "$$DEST" ] || continue; \
+		echo "Copying stripped library $$lib to $$DEST"; \
+		cp "$$lib" "$$DEST" || exit 1; \
+	done
+  endef
+endif
+
+# where to build (and put) .ipk packages
+opkg = \
+  IPKG_NO_SCRIPT=1 \
+  IPKG_INSTROOT=$(1) \
+  TMPDIR=$(1)/tmp \
+  $(STAGING_DIR_HOST)/bin/opkg \
+	--offline-root $(1) \
+	--force-postinstall \
+	--add-dest root:/ \
+	--add-arch all:100 \
+	--add-arch $(if $(ARCH_PACKAGES),$(ARCH_PACKAGES),$(BOARD)):200
+
+TARGET_DIR_ORIG := $(TARGET_ROOTFS_DIR)/root.orig-$(BOARD)
+
+ifdef CONFIG_CLEAN_IPKG
+  define clean_ipkg
+	-find $(1)/usr/lib/opkg/info -type f -and -not -name '*.control' | $(XARGS) rm -rf
+	-sed -i -ne '/^Require-User: /p' $(1)/usr/lib/opkg/info/*.control
+	awk ' \
+		BEGIN { conffiles = 0; print "Conffiles:" } \
+		/^Conffiles:/ { conffiles = 1; next } \
+		!/^ / { conffiles = 0; next } \
+		conffiles == 1 { print } \
+	' $(1)/usr/lib/opkg/status >$(1)/usr/lib/opkg/status.new
+	mv $(1)/usr/lib/opkg/status.new $(1)/usr/lib/opkg/status
+	-find $(1)/usr/lib/opkg -empty | $(XARGS) rm -rf
+  endef
+endif
+
+define prepare_rootfs
+	$(if $(2),@if [ -d '$(2)' ]; then \
+		$(call file_copy,$(2)/.,$(1)); \
+	fi)
+	@mkdir -p $(1)/etc/rc.d
+	@mkdir -p $(1)/var/lock
+	@( \
+		cd $(1); \
+		for script in ./usr/lib/opkg/info/*.postinst; do \
+			IPKG_INSTROOT=$(1) $$(which bash) $$script; \
+			ret=$$?; \
+			if [ $$ret -ne 0 ]; then \
+				echo "postinst script $$script has failed with exit code $$ret" >&2; \
+				exit 1; \
+			fi; \
+		done; \
+		for script in ./etc/init.d/*; do \
+			grep '#!/bin/sh /etc/rc.common' $$script >/dev/null || continue; \
+			IPKG_INSTROOT=$(1) $$(which bash) ./etc/rc.common $$script enable; \
+		done || true \
+	)
+	$(if $(SOURCE_DATE_EPOCH),sed -i "s/Installed-Time: .*/Installed-Time: $(SOURCE_DATE_EPOCH)/" $(1)/usr/lib/opkg/status)
+	@-find $(1) -name CVS   | $(XARGS) rm -rf
+	@-find $(1) -name .svn  | $(XARGS) rm -rf
+	@-find $(1) -name .git  | $(XARGS) rm -rf
+	@-find $(1) -name '.#*' | $(XARGS) rm -f
+	rm -rf $(1)/tmp/*
+	rm -f $(1)/usr/lib/opkg/lists/*
+	rm -f $(1)/usr/lib/opkg/info/*.postinst*
+	rm -f $(1)/var/lock/*.lock
+	rm -rf $(1)/boot
+	$(call clean_ipkg,$(1))
+	$(call mklibs,$(1))
+endef

+ 19 - 0
include/scan.awk

@@ -0,0 +1,19 @@
+BEGIN { FS="/" }
+$1 ~ /^feeds/ { FEEDS[$NF]=$0 }
+$1 !~ /^feeds/ { PKGS[$NF]=$0 }
+END {
+	# Filter-out libreCMC packages which have a feeds equivalent
+	for (pkg in PKGS)
+		if (pkg in FEEDS) {
+			print PKGS[pkg] > of
+			delete PKGS[pkg]
+		}
+	n = asort(PKGS)
+	for (i=1; i <= n; i++) {
+		print PKGS[i]
+	}
+	n = asort(FEEDS)
+	for (i=1; i <= n; i++){
+		print FEEDS[i]
+	}
+}

+ 110 - 0
include/scan.mk

@@ -0,0 +1,110 @@
+include $(TOPDIR)/include/verbose.mk
+TMP_DIR:=$(TOPDIR)/tmp
+
+all: $(TMP_DIR)/.$(SCAN_TARGET)
+
+SCAN_TARGET ?= packageinfo
+SCAN_NAME ?= package
+SCAN_DIR ?= package
+TARGET_STAMP:=$(TMP_DIR)/info/.files-$(SCAN_TARGET).stamp
+FILELIST:=$(TMP_DIR)/info/.files-$(SCAN_TARGET)-$(SCAN_COOKIE)
+OVERRIDELIST:=$(TMP_DIR)/info/.overrides-$(SCAN_TARGET)-$(SCAN_COOKIE)
+
+export PATH:=$(TOPDIR)/staging_dir/host/bin:$(PATH)
+
+ifeq ($(SCAN_NAME),target)
+  SCAN_DEPS=image/Makefile profiles/*.mk $(TOPDIR)/include/kernel*.mk $(TOPDIR)/include/target.mk image/*.mk
+else
+  SCAN_DEPS=$(TOPDIR)/include/package*.mk
+endif
+
+ifeq ($(IS_TTY),1)
+  define progress
+	printf "\033[M\r$(1)" >&2;
+  endef
+else
+  define progress
+	:;
+  endef
+endif
+
+define feedname
+$(if $(patsubst feeds/%,,$(1)),,$(word 2,$(subst /, ,$(1))))
+endef
+
+define PackageDir
+  $(TMP_DIR)/.$(SCAN_TARGET): $(TMP_DIR)/info/.$(SCAN_TARGET)-$(1)
+  $(TMP_DIR)/info/.$(SCAN_TARGET)-$(1): $(SCAN_DIR)/$(2)/Makefile $(foreach DEP,$(DEPS_$(SCAN_DIR)/$(2)/Makefile) $(SCAN_DEPS),$(wildcard $(if $(filter /%,$(DEP)),$(DEP),$(SCAN_DIR)/$(2)/$(DEP))))
+	{ \
+		$$(call progress,Collecting $(SCAN_NAME) info: $(SCAN_DIR)/$(2)) \
+		echo Source-Makefile: $(SCAN_DIR)/$(2)/Makefile; \
+		$(if $(3),echo Override: $(3),true); \
+		$(NO_TRACE_MAKE) --no-print-dir -r DUMP=1 FEED="$(call feedname,$(2))" -C $(SCAN_DIR)/$(2) $(SCAN_MAKEOPTS) 2>/dev/null || { \
+			mkdir -p "$(TOPDIR)/logs/$(SCAN_DIR)/$(2)"; \
+			$(NO_TRACE_MAKE) --no-print-dir -r DUMP=1 FEED="$(call feedname,$(2))" -C $(SCAN_DIR)/$(2) $(SCAN_MAKEOPTS) > $(TOPDIR)/logs/$(SCAN_DIR)/$(2)/dump.txt 2>&1; \
+			$$(call progress,ERROR: please fix $(SCAN_DIR)/$(2)/Makefile - see logs/$(SCAN_DIR)/$(2)/dump.txt for details\n) \
+			rm -f $$@; \
+		}; \
+		echo; \
+	} > $$@.tmp
+	mv $$@.tmp $$@
+endef
+
+$(OVERRIDELIST):
+	rm -f $(TMP_DIR)/info/.overrides-$(SCAN_TARGET)-*
+	touch $@
+
+ifeq ($(SCAN_NAME),target)
+  GREP_STRING=BuildTarget
+else
+  GREP_STRING=(Build/DefaultTargets|BuildPackage|KernelPackage)
+endif
+
+$(FILELIST): $(OVERRIDELIST)
+	rm -f $(TMP_DIR)/info/.files-$(SCAN_TARGET)-*
+	find -L $(SCAN_DIR) $(SCAN_EXTRA) -mindepth 1 $(if $(SCAN_DEPTH),-maxdepth $(SCAN_DEPTH)) -name Makefile | xargs grep -aHE 'call $(GREP_STRING)' | sed -e 's#^$(SCAN_DIR)/##' -e 's#/Makefile:.*##' | uniq | awk -v of=$(OVERRIDELIST) -f include/scan.awk > $@
+
+$(TMP_DIR)/info/.files-$(SCAN_TARGET).mk: $(FILELIST)
+	( \
+		cat $< | awk '{print "$(SCAN_DIR)/" $$0 "/Makefile" }' | xargs grep -HE '^ *SCAN_DEPS *= *' | awk -F: '{ gsub(/^.*DEPS *= */, "", $$2); print "DEPS_" $$1 "=" $$2 }'; \
+		awk -F/ -v deps="$$DEPS" -v of="$(OVERRIDELIST)" ' \
+		BEGIN { \
+			while (getline < (of)) \
+				override[$$NF]=$$0; \
+			close(of) \
+		} \
+		{ \
+			info=$$0; \
+			gsub(/\//, "_", info); \
+			dir=$$0; \
+			pkg=""; \
+			if($$NF in override) \
+				pkg=override[$$NF]; \
+			print "$$(eval $$(call PackageDir," info "," dir "," pkg "))"; \
+		} ' < $<; \
+		true; \
+	) > $@.tmp
+	mv $@.tmp $@
+
+-include $(TMP_DIR)/info/.files-$(SCAN_TARGET).mk
+
+$(TARGET_STAMP)::
+	+( \
+		$(NO_TRACE_MAKE) $(FILELIST); \
+		MD5SUM=$$(cat $(FILELIST) $(OVERRIDELIST) | mkhash md5 | awk '{print $$1}'); \
+		[ -f "$@.$$MD5SUM" ] || { \
+			rm -f $@.*; \
+			touch $@.$$MD5SUM; \
+			touch $@; \
+		} \
+	)
+
+$(TMP_DIR)/.$(SCAN_TARGET): $(TARGET_STAMP)
+	$(call progress,Collecting $(SCAN_NAME) info: merging...)
+	-cat $(FILELIST) | awk '{gsub(/\//, "_", $$0);print "$(TMP_DIR)/info/.$(SCAN_TARGET)-" $$0}' | xargs cat > $@ 2>/dev/null
+	$(call progress,Collecting $(SCAN_NAME) info: done)
+	echo
+
+FORCE:
+.PHONY: FORCE
+.NOTPARALLEL:

+ 23 - 0
include/scons.mk

@@ -0,0 +1,23 @@
+export PLATFORM=posix
+
+SCONS_VARS = \
+	CC="$(TARGET_CC_NOCACHE)" \
+	CXX="$(TARGET_CXX_NOCACHE)" \
+	CFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS)" \
+	CXXFLAGS="$(TARGET_CXXFLAGS) $(EXTRA_CXXFLAGS)" \
+	CPPFLAGS="$(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS)" \
+	LDFLAGS="$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS)" \
+	DESTDIR="$(PKG_INSTALL_DIR)"
+
+define Build/Configure/Default
+	(cd $(PKG_BUILD_DIR); \
+		$(SCONS_VARS) \
+		scons \
+			prefix=/usr \
+			$(SCONS_OPTIONS) \
+		install \
+	)
+endef
+
+define Build/Compile
+endef

+ 15 - 0
include/shell.sh

@@ -0,0 +1,15 @@
+getvar() {
+	eval "echo \"\${$1}\""
+}
+
+var2file() {
+	local var
+	eval "var=\"\${$1}\""
+	if [ -n "$var" ]; then echo "$var" > "$2"; fi
+}
+
+isset() {
+	local var
+	eval "var=\"\${$1}\""
+	[ -n "$var" ]
+}

+ 30 - 0
include/site/aarch64

@@ -0,0 +1,30 @@
+#!/bin/sh
+. $TOPDIR/include/site/linux
+ac_cv_c_littleendian=${ac_cv_c_littleendian=yes}
+ac_cv_c_bigendian=${ac_cv_c_bigendian=no}
+
+ac_cv_sizeof___int64=8
+ac_cv_sizeof_char=1
+ac_cv_sizeof_int=4
+ac_cv_sizeof_int16_t=2
+ac_cv_sizeof_int32_t=4
+ac_cv_sizeof_int64_t=8
+ac_cv_sizeof_long_int=8
+ac_cv_sizeof_long_long=8
+ac_cv_sizeof_long=8
+ac_cv_sizeof_off_t=8
+ac_cv_sizeof_short_int=2
+ac_cv_sizeof_short=2
+ac_cv_sizeof_size_t=8
+ac_cv_sizeof_ssize_t=8
+ac_cv_sizeof_u_int16_t=2
+ac_cv_sizeof_u_int32_t=4
+ac_cv_sizeof_u_int64_t=8
+ac_cv_sizeof_uint16_t=2
+ac_cv_sizeof_uint32_t=4
+ac_cv_sizeof_uint64_t=8
+ac_cv_sizeof_unsigned_int=4
+ac_cv_sizeof_unsigned_long=8
+ac_cv_sizeof_unsigned_long_long=8
+ac_cv_sizeof_unsigned_short=2
+ac_cv_sizeof_void_p=8

+ 30 - 0
include/site/aarch64_be

@@ -0,0 +1,30 @@
+#!/bin/sh
+. $TOPDIR/include/site/linux
+ac_cv_c_littleendian=${ac_cv_c_littleendian=no}
+ac_cv_c_bigendian=${ac_cv_c_bigendian=yes}
+
+ac_cv_sizeof___int64=8
+ac_cv_sizeof_char=1
+ac_cv_sizeof_int=4
+ac_cv_sizeof_int16_t=2
+ac_cv_sizeof_int32_t=4
+ac_cv_sizeof_int64_t=8
+ac_cv_sizeof_long_int=8
+ac_cv_sizeof_long_long=8
+ac_cv_sizeof_long=8
+ac_cv_sizeof_off_t=8
+ac_cv_sizeof_short_int=2
+ac_cv_sizeof_short=2
+ac_cv_sizeof_size_t=8
+ac_cv_sizeof_ssize_t=8
+ac_cv_sizeof_u_int16_t=2
+ac_cv_sizeof_u_int32_t=4
+ac_cv_sizeof_u_int64_t=8
+ac_cv_sizeof_uint16_t=2
+ac_cv_sizeof_uint32_t=4
+ac_cv_sizeof_uint64_t=8
+ac_cv_sizeof_unsigned_int=4
+ac_cv_sizeof_unsigned_long=8
+ac_cv_sizeof_unsigned_long_long=8
+ac_cv_sizeof_unsigned_short=2
+ac_cv_sizeof_void_p=8

+ 30 - 0
include/site/arc

@@ -0,0 +1,30 @@
+#!/bin/sh
+. $TOPDIR/include/site/linux
+ac_cv_c_littleendian=${ac_cv_c_littleendian=yes}
+ac_cv_c_bigendian=${ac_cv_c_bigendian=no}
+
+ac_cv_sizeof___int64=0
+ac_cv_sizeof_char=1
+ac_cv_sizeof_int=4
+ac_cv_sizeof_int16_t=2
+ac_cv_sizeof_int32_t=4
+ac_cv_sizeof_int64_t=8
+ac_cv_sizeof_long_int=4
+ac_cv_sizeof_long_long=8
+ac_cv_sizeof_long=4
+ac_cv_sizeof_off_t=8
+ac_cv_sizeof_short_int=2
+ac_cv_sizeof_short=2
+ac_cv_sizeof_size_t=4
+ac_cv_sizeof_ssize_t=4
+ac_cv_sizeof_u_int16_t=2
+ac_cv_sizeof_u_int32_t=4
+ac_cv_sizeof_u_int64_t=8
+ac_cv_sizeof_uint16_t=2
+ac_cv_sizeof_uint32_t=4
+ac_cv_sizeof_uint64_t=8
+ac_cv_sizeof_unsigned_int=4
+ac_cv_sizeof_unsigned_long=4
+ac_cv_sizeof_unsigned_long_long=8
+ac_cv_sizeof_unsigned_short=2
+ac_cv_sizeof_void_p=4

+ 30 - 0
include/site/arm

@@ -0,0 +1,30 @@
+#!/bin/sh
+. $TOPDIR/include/site/linux
+ac_cv_c_littleendian=${ac_cv_c_littleendian=yes}
+ac_cv_c_bigendian=${ac_cv_c_bigendian=no}
+
+ac_cv_sizeof___int64=0
+ac_cv_sizeof_char=1
+ac_cv_sizeof_int=4
+ac_cv_sizeof_int16_t=2
+ac_cv_sizeof_int32_t=4
+ac_cv_sizeof_int64_t=8
+ac_cv_sizeof_long_int=4
+ac_cv_sizeof_long_long=8
+ac_cv_sizeof_long=4
+ac_cv_sizeof_off_t=8
+ac_cv_sizeof_short_int=2
+ac_cv_sizeof_short=2
+ac_cv_sizeof_size_t=4
+ac_cv_sizeof_ssize_t=4
+ac_cv_sizeof_u_int16_t=2
+ac_cv_sizeof_u_int32_t=4
+ac_cv_sizeof_u_int64_t=8
+ac_cv_sizeof_uint16_t=2
+ac_cv_sizeof_uint32_t=4
+ac_cv_sizeof_uint64_t=8
+ac_cv_sizeof_unsigned_int=4
+ac_cv_sizeof_unsigned_long=4
+ac_cv_sizeof_unsigned_long_long=8
+ac_cv_sizeof_unsigned_short=2
+ac_cv_sizeof_void_p=4

+ 30 - 0
include/site/armeb

@@ -0,0 +1,30 @@
+#!/bin/sh
+. $TOPDIR/include/site/linux
+ac_cv_c_littleendian=${ac_cv_c_littleendian=no}
+ac_cv_c_bigendian=${ac_cv_c_bigendian=yes}
+
+ac_cv_sizeof___int64=0
+ac_cv_sizeof_char=1
+ac_cv_sizeof_int=4
+ac_cv_sizeof_int16_t=2
+ac_cv_sizeof_int32_t=4
+ac_cv_sizeof_int64_t=8
+ac_cv_sizeof_long_int=4
+ac_cv_sizeof_long_long=8
+ac_cv_sizeof_long=4
+ac_cv_sizeof_off_t=8
+ac_cv_sizeof_short_int=2
+ac_cv_sizeof_short=2
+ac_cv_sizeof_size_t=4
+ac_cv_sizeof_ssize_t=4
+ac_cv_sizeof_u_int16_t=2
+ac_cv_sizeof_u_int32_t=4
+ac_cv_sizeof_u_int64_t=8
+ac_cv_sizeof_uint16_t=2
+ac_cv_sizeof_uint32_t=4
+ac_cv_sizeof_uint64_t=8
+ac_cv_sizeof_unsigned_int=4
+ac_cv_sizeof_unsigned_long=4
+ac_cv_sizeof_unsigned_long_long=8
+ac_cv_sizeof_unsigned_short=2
+ac_cv_sizeof_void_p=4

+ 2 - 0
include/site/darwin

@@ -0,0 +1,2 @@
+ac_cv_func_futimens=no
+ac_cv_func_utimensat=no

+ 3 - 0
include/site/i386

@@ -0,0 +1,3 @@
+#!/bin/sh
+. $TOPDIR/include/site/i486
+

+ 30 - 0
include/site/i486

@@ -0,0 +1,30 @@
+#!/bin/sh
+. $TOPDIR/include/site/linux
+ac_cv_c_littleendian=${ac_cv_c_littleendian=yes}
+ac_cv_c_bigendian=${ac_cv_c_bigendian=no}
+
+ac_cv_sizeof___int64=0
+ac_cv_sizeof_char=1
+ac_cv_sizeof_int=4
+ac_cv_sizeof_int16_t=2
+ac_cv_sizeof_int32_t=4
+ac_cv_sizeof_int64_t=8
+ac_cv_sizeof_long_int=4
+ac_cv_sizeof_long_long=8
+ac_cv_sizeof_long=4
+ac_cv_sizeof_off_t=8
+ac_cv_sizeof_short_int=2
+ac_cv_sizeof_short=2
+ac_cv_sizeof_size_t=4
+ac_cv_sizeof_ssize_t=4
+ac_cv_sizeof_u_int16_t=2
+ac_cv_sizeof_u_int32_t=4
+ac_cv_sizeof_u_int64_t=8
+ac_cv_sizeof_uint16_t=2
+ac_cv_sizeof_uint32_t=4
+ac_cv_sizeof_uint64_t=8
+ac_cv_sizeof_unsigned_int=4
+ac_cv_sizeof_unsigned_long=4
+ac_cv_sizeof_unsigned_long_long=8
+ac_cv_sizeof_unsigned_short=2
+ac_cv_sizeof_void_p=4

Some files were not shown because too many files changed in this diff