Hello,
I downloaded SDK and build simple package (printing only hello world) for Chaos calmer, that is successfully run.
Now I need to include gpio.h and other header files into main program.
This is how Makefile looks like:
include $(TOPDIR)/rules.mk
# Name and release number of this package
PKG_NAME:=helloworld
PKG_RELEASE:=1
# This specifies the directory where we're going to build the program.
# The root build directory, $(BUILD_DIR), is by default the build_mipsel
# directory in your OpenWrt SDK directory
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
#include $(INCLUDE_DIR)/autotools.mk
#include $(INCLUDE_DIR)/cmake.mk
#include $(INCLUDE_DIR)/debug.mk
#include $(INCLUDE_DIR)/depends.mk
#include $(INCLUDE_DIR)/toolchain-build.mk
#include $(INCLUDE_DIR)/kernel-defaults.mk
#include $(INCLUDE_DIR)/autotools.mk
#include $(INCLUDE_DIR)/depends.mk
#include $(INCLUDE_DIR)/kernel-defaults.mk
#include $(INCLUDE_DIR)/download.mk
#include $(INCLUDE_DIR)/feeds.mk
#include $(INCLUDE_DIR)/host-build.mk
#include $(INCLUDE_DIR)/host.mk
#include $(INCLUDE_DIR)/image.mk
#include $(INCLUDE_DIR)/kernel-build.mk
#include $(INCLUDE_DIR)/package-bin.mk
#include $(INCLUDE_DIR)/package-defaults.mk
##include $(INCLUDE_DIR)/package-dumpinfo.mk
#include $(INCLUDE_DIR)/package.mk
#include $(INCLUDE_DIR)/package-seccomp.mk
#include $(INCLUDE_DIR)/prereq.mk
#include $(INCLUDE_DIR)/quilt.mk
include $(INCLUDE_DIR)/scan.mk
#include $(INCLUDE_DIR)/scons.mk
#include $(INCLUDE_DIR)/verbose.mk
#include $(INCLUDE_DIR)/subdir.mk
#include $(INCLUDE_DIR)/toplevel.mk
#include $(INCLUDE_DIR)/subdir.mk
# Specify package information for this program.
# The variables defined here should be self explanatory.
define Package/helloworld
SECTION:=utils
CATEGORY:=Utilities
TITLE:=Helloworld -- prints a snarky message
endef
# Specify what needs to be done to prepare for building the package.
# In our case, we need to copy the source files to the build directory.
# This is NOT the default. The default uses the PKG_SOURCE_URL and the
# PKG_SOURCE which is not defined here to download the source from the web.
# In order to just build a simple program that we have just written, it is
# much easier to do it this way.
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
endef
# We do not need to define Build/Configure or Build/Compile directives
# The defaults are appropriate for compiling a simple program such as this one
# Specify where and how to install the program. Since we only have one file,
# the helloworld executable, install it by copying it to the /bin directory on
# the router. The $(1) variable represents the root directory on the router running
# OpenWrt. The $(INSTALL_DIR) variable contains a command to prepare the install
# directory if it does not already exist. Likewise $(INSTALL_BIN) contains the
# command to copy the binary file from its current location (in our case the build
# directory) to the install directory.
define Package/helloworld/install
$(INSTALL_DIR) $(1)/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/helloworld $(1)/bin/
endef
# This line executes the necessary commands to compile our program.
# The above define directives specify all the information needed, but this
# line calls BuildPackage which in turn actually uses this information to
# build a package.
$(eval $(call BuildPackage,helloworld))Which .mk file should be included?
helloworld.c:
/****************
* Helloworld.c
* The most simplistic C program ever written.
* An epileptic monkey on crack could write this code.
*****************/
#include <stdio.h>
#include <linux/gpio.h>
int main(void)
{
printf("-----:D\n\n");
return 0;
}error after make:
helloworld.c:7:24: fatal error: linux/gpio.h: No such file or directory
#include <linux/gpio.h>
^
compilation terminated.
make[4]: *** [helloworld.o] Error 1
make[4]: Leaving directory `/home/karolina/Documents/CrossCompile/OpenWrt-SDK-15.05-ar71xx-generic_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64/build_dir/target-mips_34kc_uClibc-0.9.33.2/helloworld'
make[3]: *** [/home/karolina/Documents/CrossCompile/OpenWrt-SDK-15.05-ar71xx-generic_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64/build_dir/target-mips_34kc_uClibc-0.9.33.2/helloworld/.built] Error 2
make[3]: Leaving directory `/home/karolina/Documents/CrossCompile/OpenWrt-SDK-15.05-ar71xx-generic_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64/package/helloworld'
make[2]: *** [package/helloworld/compile] Error 2
make[2]: Leaving directory `/home/karolina/Documents/CrossCompile/OpenWrt-SDK-15.05-ar71xx-generic_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64'
make[1]: *** [/home/karolina/Documents/CrossCompile/OpenWrt-SDK-15.05-ar71xx-generic_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64/staging_dir/target-mips_34kc_uClibc-0.9.33.2/stamp/.package_compile] Error 2
make[1]: Leaving directory `/home/karolina/Documents/CrossCompile/OpenWrt-SDK-15.05-ar71xx-generic_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64'
make: *** [world] Error 2The purpose of helloworld.c is to one day turn on and off one GPIO pin...
