OpenWrt Forum Archive

Topic: Makefiles

The content of this topic has been archived on 23 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Is there any information in regards to Makefile conventions in the inner .src/ directory? I've seen a few decent examples of the root package Makefile. But I haven't been able to successfully include gpio_dev.h and some other things and I think it's because of the Makefile.

Is there an easy way to see full packages for openWRT? I appears as if most are just Makefiles and patches.\

EDIT: more details

I'm trying to work with GPIOs (normally) and also using GPIOs as an i2c bus. So I'm getting errors when I try to include <linux/gpio_dev.h> etc

killerwhale:/datastore/openwrt-pidproject/backfire# make package/PIDd/compile V=99
make[1]: Entering directory `/datastore/openwrt-pidproject/backfire'
make[2]: Entering directory `/datastore/openwrt-pidproject/backfire/package/PIDd'
mkdir -p /datastore/openwrt-pidproject/backfire/build_dir/target-mips_uClibc-0.9.30.1/PIDd-0.1
cp -fpR ./src/* /datastore/openwrt-pidproject/backfire/build_dir/target-mips_uClibc-0.9.30.1/PIDd-0.1/
touch /datastore/openwrt-pidproject/backfire/build_dir/target-mips_uClibc-0.9.30.1/PIDd-0.1/.prepared_1a372c82749f4838841c30c704442757
(cd /datastore/openwrt-pidproject/backfire/build_dir/target-mips_uClibc-0.9.30.1/PIDd-0.1/./; if [ -x ./configure ]; then /usr/bin/find /datastore/openwrt-pidproject/backfire/build_dir/target-mips_uClibc-0.9.30.1/PIDd-0.1/ -name config.guess | xargs -r chmod u+w; /usr/bin/find /datastore/openwrt-pidproject/backfire/build_dir/target-mips_uClibc-0.9.30.1/PIDd-0.1/ -name config.guess | xargs -r -n1 cp /datastore/openwrt-pidproject/backfire/scripts/config.guess; /usr/bin/find /datastore/openwrt-pidproject/backfire/build_dir/target-mips_uClibc-0.9.30.1/PIDd-0.1/ -name config.sub | xargs -r chmod u+w; /usr/bin/find /datastore/openwrt-pidproject/backfire/build_dir/target-mips_uClibc-0.9.30.1/PIDd-0.1/ -name config.sub | xargs -r -n1 cp /datastore/openwrt-pidproject/backfire/scripts/config.sub; AR=mips-openwrt-linux-uclibc-ar AS="mips-openwrt-linux-uclibc-gcc -c -Os -pipe -mips32 -mtune=mips32 -funit-at-a-time -fhonour-copts -msoft-float" LD=mips-openwrt-linux-uclibc-ld NM=mips-openwrt-linux-uclibc-nm CC="mips-openwrt-linux-uclibc-gcc" GCC="mips-openwrt-linux-uclibc-gcc" CXX="mips-openwrt-linux-uclibc-g++" RANLIB=mips-openwrt-linux-uclibc-ranlib STRIP=mips-openwrt-linux-uclibc-strip OBJCOPY=mips-openwrt-linux-uclibc-objcopy OBJDUMP=mips-openwrt-linux-uclibc-objdump SIZE=mips-openwrt-linux-uclibc-size CFLAGS="-Os -pipe -mips32 -mtune=mips32 -funit-at-a-time -fhonour-copts -msoft-float " CXXFLAGS="-Os -pipe -mips32 -mtune=mips32 -funit-at-a-time -fhonour-copts -msoft-float " CPPFLAGS="-I/datastore/openwrt-pidproject/backfire/staging_dir/target-mips_uClibc-0.9.30.1/usr/include -I/datastore/openwrt-pidproject/backfire/staging_dir/target-mips_uClibc-0.9.30.1/include -I/datastore/openwrt-pidproject/backfire/staging_dir/toolchain-mips_gcc-4.3.3+cs_uClibc-0.9.30.1/usr/include -I/datastore/openwrt-pidproject/backfire/staging_dir/toolchain-mips_gcc-4.3.3+cs_uClibc-0.9.30.1/include " LDFLAGS="-L/datastore/openwrt-pidproject/backfire/staging_dir/target-mips_uClibc-0.9.30.1/usr/lib -L/datastore/openwrt-pidproject/backfire/staging_dir/target-mips_uClibc-0.9.30.1/lib -L/datastore/openwrt-pidproject/backfire/staging_dir/toolchain-mips_gcc-4.3.3+cs_uClibc-0.9.30.1/usr/lib -L/datastore/openwrt-pidproject/backfire/staging_dir/toolchain-mips_gcc-4.3.3+cs_uClibc-0.9.30.1/lib "   ./configure --target=mips-openwrt-linux --host=mips-openwrt-linux --build=i486-linux-gnu --program-prefix="" --program-suffix="" --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --libexecdir=/usr/lib --sysconfdir=/etc --datadir=/usr/share --localstatedir=/var --mandir=/usr/man --infodir=/usr/info --disable-nls   --with-linux-headers=""  ; fi; )
touch /datastore/openwrt-pidproject/backfire/build_dir/target-mips_uClibc-0.9.30.1/PIDd-0.1/.configured_
make -C /datastore/openwrt-pidproject/backfire/build_dir/target-mips_uClibc-0.9.30.1/PIDd-0.1 AR=mips-openwrt-linux-uclibc-ar AS="mips-openwrt-linux-uclibc-gcc -c -Os -pipe -mips32 -mtune=mips32 -funit-at-a-time -fhonour-copts -msoft-float" LD=mips-openwrt-linux-uclibc-ld NM=mips-openwrt-linux-uclibc-nm CC="mips-openwrt-linux-uclibc-gcc" GCC="mips-openwrt-linux-uclibc-gcc" CXX="mips-openwrt-linux-uclibc-g++" RANLIB=mips-openwrt-linux-uclibc-ranlib STRIP=mips-openwrt-linux-uclibc-strip OBJCOPY=mips-openwrt-linux-uclibc-objcopy OBJDUMP=mips-openwrt-linux-uclibc-objdump SIZE=mips-openwrt-linux-uclibc-size CFLAGS="-Os -pipe -mips32 -mtune=mips32 -funit-at-a-time -fhonour-copts -msoft-float -I/arch/mips/ar531x"
make[3]: Entering directory `/datastore/openwrt-pidproject/backfire/build_dir/target-mips_uClibc-0.9.30.1/PIDd-0.1'
mips-openwrt-linux-uclibc-g++    -c -o Heater.o Heater.cpp
In file included from Heater.cpp:1:
Heater.h:15:24: error: linux/gpio.h: No such file or directory
Heater.cpp: In member function 'void Heater::setup(unsigned int, long int)':
Heater.cpp:12: error: 'GPIO_CLEAR' was not declared in this scope
Heater.cpp:22: error: 'GPIO_DIR_OUT' was not declared in this scope
Heater.cpp:22: error: 'ioctl' was not declared in this scope
Heater.cpp: In member function 'void Heater::update(long int)':
Heater.cpp:37: error: 'GPIO_SET' was not declared in this scope
Heater.cpp:42: error: 'GPIO_CLEAR' was not declared in this scope
Heater.cpp: In static member function 'static void Heater::elementPower(int)':
Heater.cpp:61: error: 'ioctl' was not declared in this scope

(Last edited by napierzaza on 18 Feb 2011, 19:46)

I've read the doc on Makefiles in the documentation. But now I have no idea how to make it work. I've pretty much dead copied the gpioctl makefiles and even with a stub app it doesn't work.

That's not a make problem, it's not finding the headers, and those should be defined in the C files - ie the code itself. Check the source tarball for references to linux/gpio.h and create a patch if necessary. Googling tells me it should be in your distro's kernel headers package (and there seem to be lots of gpio.h files in the kernel headers).

(Last edited by Borromini on 19 Feb 2011, 11:43)

Where can I find the tarball? I have the downloaded src and can build images fine. But I've had trouble trying to even find any headers for gpio_dev.h or i2c_dev.h

The source gets downloaded as a tarball or a zip file, then extracted. You probably already have it on your system. The OpenWrt buildroot should have the kernel headers installed, check it.

The discussion might have continued from here.