Commit 121a2c1f authored by Alessandro Rubini's avatar Alessandro Rubini

Makefiles: some contortions to be friends of submodules

This patch adds a script "check-fmc-bus" that returns the pathname of
the fmc-bus kernel driver, either under this directory or under
../fmc-bus .  The former applies when fmc-bus is a submodule of this
package, the latter applies when we both are submodules of another
package.

The final aim is helping the naive user, who just wants to build it
all in a single step -- both if building this package or another
package that depends on both fmc-bus and this one.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 37dff380
DIRS = fmc-bus/kernel kernel tools doc # We have a problem here: this package may be a submodule of something
# else (for example: fine-delay). If this is the case, fmc-bus is on ../
# This external script returns the pathname of the "kernel" subdir of fmc-bus
FMC_DRV = $(./check-fmc-bus)
DIRS = $(FMC_DRV) kernel tools
all clean modules install modules_install: all clean modules install modules_install:
for d in $(DIRS); do $(MAKE) -C $$d $@ || exit 1; done for d in $(DIRS); do $(MAKE) -C $$d $@ || exit 1; done
#!/bin/sh
cd $(dirname $0)
# If this project _and_ fmc-bus are submodules of ../, pick ../fmc-bus
FMC_SUBDIR=$(/bin/pwd)/fmc-bus/kernel
FMC_DOTDOT=$(/bin/pwd)/../fmc-bus/kernel
THIS=$(basename $(/bin/pwd))
if ! test -f ../.gitmodules; then
echo $FMC_SUBDIR
exit 0
fi
if ! grep "submodule \"$THIS\"" ../.gitmodules > /dev/null; then
echo $FMC_SUBDIR
exit 0
fi
if ! grep "submodule \"fmc-bus\"" ../.gitmodules > /dev/null; then
echo $FMC_SUBDIR
exit 0
fi
echo $FMC_DOTDOT
\ No newline at end of file
LINUX ?= /lib/modules/$(shell uname -r)/build LINUX ?= /lib/modules/$(shell uname -r)/build
KBUILD_EXTRA_SYMBOLS := $M/../fmc-bus/kernel/Module.symvers FMC_DRV ?= $(shell $M/../check-fmc-bus)
ccflags-y += -I$M/include -I$M/../fmc-bus/kernel/include KBUILD_EXTRA_SYMBOLS := $(FMC_DRV)/Module.symvers
ccflags-y += -I$M/include -I$(FMC_DRV)/include
ccflags-y += $(WR_NIC_CFLAGS) ccflags-y += $(WR_NIC_CFLAGS)
obj-m += spec.o obj-m += spec.o
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment