Commit 8ade2de8 authored by Adam Wujek's avatar Adam Wujek 💬

Merge branch 'adam-coht'

Changes in the buildsystem.
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parents 9792fe68 4fe24d44
......@@ -7,3 +7,4 @@
modules.order
Module.symvers
Makefile.specific
*.tmp
FMC_BUS := $(shell scripts/check-submodule fmc-bus $(FMC_BUS))
ZIO := $(shell scripts/check-submodule zio $(ZIO))
ZIO_VERSION = $(shell cd $(ZIO); git describe --always --dirty --long --tags)
# include parent_common.mk for buildsystem's defines
# use absolute path for REPO_PARENT
REPO_PARENT=$(shell /bin/pwd)/..
-include $(REPO_PARENT)/parent_common.mk
all: kernel lib tools
# a hack, to prevent compiling wr-nic.ko, which won't work on older kernels
CONFIG_WR_NIC=n
export CONFIG_WR_NIC
# The user can override, using environment variables, all these three:
FMC_BUS ?= fmc-bus
ZIO ?= zio
SPEC_SW ?= spec-sw
# FMC_BUS_ABS, ZIO_ABS and SPEC_SW_ABS has to be absolut path, due to beeing
# passed to the Kbuild
FMC_BUS_ABS ?= $(abspath $(FMC_BUS) )
ZIO_ABS ?= $(abspath $(ZIO) )
SPEC_SW_ABS ?= $(abspath $(SPEC_SW) )
export FMC_BUS_ABS
export ZIO_ABS
export SPEC_SW_ABS
ZIO_VERSION = $(shell cd $(ZIO_ABS); git describe --always --dirty --long --tags)
export ZIO_VERSION
SPEC_SW := $(shell scripts/check-submodule spec-sw $(SPEC_SW))
DESTDIR ?= /usr/local
.PHONY: all clean modules install modules_install default
.PHONY: gitmodules prereq prereq_install prereq_install_warn prereq_clean
DIRS = $(FMC_BUS_ABS) $(ZIO_ABS) $(SPEC_SW_ABS) kernel lib tools
DIRS = kernel lib tools
$(SPEC_SW_ABS): $(FMC_BUS_ABS)
kernel: $(FMC_BUS_ABS) $(ZIO_ABS) $(SPEC_SW_ABS)
lib: $(ZIO_ABS)
tools: lib
all clean modules install modules_install: gitmodules
@if echo $@ | grep -q install; then $(MAKE) prereq_install_warn; fi
for d in $(DIRS); do $(MAKE) ZIO=$(ZIO) FMC_BUS=$(FMC_BUS) -C $$d $@ || exit 1; done
DESTDIR ?= /usr/local
all modules: prereq
.PHONY: all clean modules install modules_install $(DIRS)
.PHONY: gitmodules prereq_install prereq_install_warn
clean_all: clean prereq_clean
install modules_install: prereq_install_warn
# a hack, to prevent compiling wr-nic.ko, which won't work on older kernels
CONFIG_WR_NIC=n
export CONFIG_WR_NIC
all clean modules install modules_install: $(DIRS)
#### The following targets are used to manage prerequisite repositories
gitmodules:
@test -d fmc-bus/doc || echo "Checking out submodules"
@test -d fmc-bus/doc || git submodule update --init
@git submodule update
clean: TARGET = clean
modules: TARGET = modules
install: TARGET = install
modules_install: TARGET = modules_install
# The user can override, using environment variables, all these three:
SUBMOD = $(FMC_BUS) $(ZIO) $(SPEC_SW)
prereq:
for d in $(SUBMOD); do $(MAKE) -C $$d || exit 1; done
$(DIRS):
$(MAKE) -C $@ $(TARGET)
SUBMOD = $(FMC_BUS_ABS) $(ZIO_ABS) $(SPEC_SW_ABS)
prereq_install_warn:
@test -f .prereq_installed || \
......@@ -43,7 +64,21 @@ prereq_install:
for d in $(SUBMOD); do $(MAKE) -C $$d modules_install || exit 1; done
touch .prereq_installed
prereq_clean:
for d in $(SUBMOD); do $(MAKE) -C $$d clean || exit 1; done
$(FMC_BUS_ABS): fmc-bus-init_repo
$(ZIO_ABS): zio-init_repo
$(SPEC_SW_ABS): spec-sw-init_repo
# init submodule if missing
fmc-bus-init_repo:
@test -d $(FMC_BUS_ABS)/doc || ( echo "Checking out submodule $(FMC_BUS_ABS)"; git submodule update --init $(FMC_BUS_ABS) )
# init submodule if missing
zio-init_repo:
@test -d $(ZIO_ABS)/doc || ( echo "Checking out submodule $(ZIO_ABS)" && git submodule update --init $(ZIO_ABS) )
# init submodule if missing
spec-sw-init_repo:
@test -d $(SPEC_SW_ABS)/doc || ( echo "Checking out submodule $(SPEC_SW_ABS)" && git submodule update --init $(SPEC_SW_ABS) )
include scripts/gateware.mk
.tmp_versions
\ No newline at end of file
.tmp_versions
fmc-bus-link
.*.o.d
KBUILD_EXTRA_SYMBOLS := \
$(ZIO_ABS)/Module.symvers \
$(FMC_BUS_ABS)/kernel/Module.symvers
# add versions of supermodule. It is useful when fine-delay-sw is included as sub-module
# of a bigger project that we want to track
ifdef CONFIG_SUPER_REPO
ifdef CONFIG_SUPER_REPO_VERSION
SUBMODULE_VERSIONS += MODULE_INFO(version_$(CONFIG_SUPER_REPO),\"$(CONFIG_SUPER_REPO_VERSION)\");
endif
endif
# add versions of used submodules
SUBMODULE_VERSIONS += MODULE_INFO(version_fmc_bus,\"$(FMC_BUS_VERSION)\");
SUBMODULE_VERSIONS += MODULE_INFO(version_zio,\"$(ZIO_VERSION)\");
ccflags-y += -DADDITIONAL_VERSIONS="$(SUBMODULE_VERSIONS)"
# The library includes <sdb.h>, so point -I directtly there
# include our header before to avoid conflicts with the kernel
LINUXINCLUDE := -I$(FMC_BUS_ABS)/kernel/include -I$(FMC_BUS_ABS)/kernel/include/linux $(LINUXINCLUDE)
ccflags-y += \
-I$(ZIO_ABS)/include \
-I$(FMC_BUS_ABS) \
-I$(src)
ccflags-y += -DGIT_VERSION=\"$(GIT_VERSION)\"
#ccflags-y += -DDEBUG
# Extract ZIO minimum compatible version
ccflags-y += -D__ZIO_MIN_MAJOR_VERSION=$(shell echo $(ZIO_VERSION) | cut -d '-' -f 2 | cut -d '.' -f 1; )
ccflags-y += -D__ZIO_MIN_MINOR_VERSION=$(shell echo $(ZIO_VERSION) | cut -d '-' -f 2 | cut -d '.' -f 2; )
subdirs-ccflags-y = $(ccflags-y)
obj-m := fmc-fine-delay.o
fmc-fine-delay-objs = fd-zio.o fd-irq.o fd-core.o
fmc-fine-delay-objs += onewire.o spi.o i2c.o gpio.o
fmc-fine-delay-objs += acam.o calibrate.o pll.o time.o
fmc-fine-delay-objs += calibration.o fmc-util.o
fmc-fine-delay-objs += fmc-bus-link/sdb-lib/access.o
fmc-fine-delay-objs += fmc-bus-link/sdb-lib/glue.o
LINUX ?= /lib/modules/$(shell uname -r)/build
ZIO ?= $(src)/../zio
FMC_BUS ?= $(src)/../fmc-bus
KBUILD_EXTRA_SYMBOLS := \
$(ZIO)/Module.symvers \
$(FMC_BUS)/kernel/Module.symvers
GIT_VERSION = $(shell cd $(src); git describe --dirty --long --tags)
# include parent_common.mk for buildsystem's defines
# use absolute path for REPO_PARENT
REPO_PARENT=$(shell /bin/pwd)/../..
-include $(REPO_PARENT)/parent_common.mk
# For this CSM_VERSION, please see ohwr.org/csm documentation
ifdef CONFIG_CSM_VERSION
ccflags-y += -D"CERN_SUPER_MODULE=MODULE_VERSION(\"$(CONFIG_CSM_VERSION)\")"
else
ccflags-y += -DCERN_SUPER_MODULE=""
endif
# The library includes <sdb.h>, so point -I directtly there
# include our header before to avoid conflicts with the kernel
LINUXINCLUDE := -I$(FMC_BUS)/kernel/include -I$(FMC_BUS)/kernel/include/linux $(LINUXINCLUDE)
ccflags-y += \
-I$(ZIO)/include \
-I$(FMC_BUS) \
-I$(src)
ccflags-y += -DGIT_VERSION=\"$(GIT_VERSION)\"
#ccflags-y += -DDEBUG
LINUX ?= /lib/modules/$(shell uname -r)/build
# Extract ZIO minimum compatible version
ccflags-y += -D__ZIO_MIN_MAJOR_VERSION=$(shell echo $(ZIO_VERSION) | cut -d '-' -f 2 | cut -d '.' -f 1; )
ccflags-y += -D__ZIO_MIN_MINOR_VERSION=$(shell echo $(ZIO_VERSION) | cut -d '-' -f 2 | cut -d '.' -f 2; )
FMC_BUS ?= ../fmc-bus
ZIO ?= ../zio
subdirs-ccflags-y = $(ccflags-y)
# FMC_BUS_ABS, ZIO_ABS and SPEC_SW_ABS has to be absolut path, due to beeing
# passed to the Kbuild
FMC_BUS_ABS ?= $(abspath $(FMC_BUS) )
ZIO_ABS ?= $(abspath $(ZIO) )
obj-m := fmc-fine-delay.o
GIT_VERSION = $(shell git describe --dirty --long --tags)
export GIT_VERSION
fmc-fine-delay-objs = fd-zio.o fd-irq.o fd-core.o
fmc-fine-delay-objs += onewire.o spi.o i2c.o gpio.o
fmc-fine-delay-objs += acam.o calibrate.o pll.o time.o
fmc-fine-delay-objs += calibration.o fmc-util.o
fmc-fine-delay-objs += ../fmc-bus/sdb-lib/access.o
fmc-fine-delay-objs += ../fmc-bus/sdb-lib/glue.o
FMC_BUS_VERSION ?= $(shell cd $(FMC_BUS_ABS); git describe --always --dirty --long --tags)
ZIO_VERSION ?= $(shell cd $(ZIO_ABS); git describe --always --dirty --long --tags)
export FMC_BUS_VERSION
export ZIO_VERSION
all modules:
$(MAKE) -C $(LINUX) M=$(shell /bin/pwd) modules
rm -f fmc-bus-link
ln -s $(FMC_BUS_ABS) fmc-bus-link
$(MAKE) -C $(LINUX) M=$(shell /bin/pwd) FMC_BUS_ABS=$(FMC_BUS_ABS) ZIO_ABS=$(ZIO_ABS) modules
rm -f fmc-bus-link
install modules_install:
install modules_install: modules
$(MAKE) -C $(LINUX) M=$(shell /bin/pwd) modules_install
# be able to run the "clean" rule even if $(LINUX) is not valid
......
......@@ -369,4 +369,4 @@ module_exit(fd_exit);
MODULE_VERSION(GIT_VERSION);
MODULE_LICENSE("GPL and additional rights"); /* LGPL */
CERN_SUPER_MODULE;
ADDITIONAL_VERSIONS;
......@@ -5,7 +5,13 @@
# build a particular environment.
-include Makefile.specific
ZIO := $(shell cd ..; scripts/check-submodule zio $(ZIO))
# include parent_common.mk for buildsystem's defines
REPO_PARENT=../..
-include $(REPO_PARENT)/parent_common.mk
ZIO ?= ../zio
ZIO_ABS ?= $(abspath $(ZIO) )
LIB = libfdelay.a
LOBJ := fdelay-init.o
......@@ -13,7 +19,7 @@ LOBJ += fdelay-time.o
LOBJ += fdelay-tdc.o
LOBJ += fdelay-output.o
CFLAGS = -Wall -ggdb -O2 -I../kernel -I$(ZIO)/include $(EXTRACFLAGS)
CFLAGS = -Wall -ggdb -O2 -I../kernel -I$(ZIO_ABS)/include $(EXTRACFLAGS)
LDFLAGS = -L. -lfdelay
DESTDIR ?= /usr/local
......@@ -26,7 +32,7 @@ lib: $(LIB)
$(CC) $(CFLAGS) $*.c $(LDFLAGS) -o $@
$(LIB): $(LOBJ)
ar r $@ $^
$(AR) r $@ $^
clean:
rm -f $(LIB) .depend *.o *~
......
......@@ -5,11 +5,21 @@
# build a particular environment.
-include Makefile.specific
# include parent_common.mk for buildsystem's defines
REPO_PARENT=../..
-include $(REPO_PARENT)/fmc_common.mk
ZIO ?= ../zio
ZIO_ABS ?= $(abspath $(ZIO) )
M = $(shell /bin/pwd)/../kernel
DESTDIR ?= /usr/local
CFLAGS += -I$(M) -I../lib -I$(ZIO)/include -Wno-trigraphs -Wall -ggdb $(EXTRACFLAGS)
CFLAGS += -I$(M) -I../lib -I$(ZIO_ABS)/include -Wno-trigraphs -Wall -ggdb $(EXTRACFLAGS)
LDFLAGS = -L../lib
LDLIBS = -lfdelay
CC ?= $(CROSS_COMPILE)gcc
......@@ -26,7 +36,9 @@ all modules: $(progs)
clean:
rm -f $(progs) *.o *~
$(progs): tools-util.o tools-common.h $(wildcard ../lib/*.[ch])
COMMON_SRCS = tools-util.c
$(progs): $(COMMON_SRCS:.c=.o)
# make nothing for modules_install, but avoid errors
modules_install:
......@@ -35,9 +47,3 @@ install:
install -d $(DESTDIR)/bin
install -D $(progs) $(DESTDIR)/bin
# we need this as we are out of the kernel
%: %.c $(wildcard *.h)
$(CC) $(CFLAGS) -O2 $*.c tools-util.o \
-L../lib -lfdelay -o $@
%.o: %.c $(wildcard *.h)
$(CC) $(CFLAGS) -O2 -c $*.c -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