Commit fc9596c2 authored by Federico Vaga's avatar Federico Vaga

Adopt autotools

Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent e81ddf1f
aclocal.m4
autom4te.cache
autoscan.log
compile
config.h
config.h.in
config.log
config.status
configure
configure.ac
configure.scan
depcomp
install-sh
Makefile
Makefile.in
missing
stamp-h1
.deps
# SPDX-FileCopyrightText: 2020 CERN (home.cern)
#
# SPDX-License-Identifier: CC0-1.0
-include Makefile.specific
-include $(REPO_PARENT)/parent_common.mk
DIRS = kernel tools
.PHONY: all clean modules install modules_install coccicheck cppcheck $(DIRS)
all clean : $(DIRS)
install modules_install coccicheck modules: kernel
clean: TARGET = clean
modules: TARGET = modules
coccicheck: TARGET = coccicheck
install: TARGET = install
modules_install: TARGET = modules_install
cppcheck:
$(MAKE) -C tools $@
$(DIRS):
$(MAKE) -C $@ $(ENV_VAR) $(TARGET)
SUBDIRS = tools kernel
AC_INIT([spec], [1.0], [federico.vaga@cern.ch])
AC_LANG([C])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AC_PROG_CC
AC_ARG_WITH([kernel],
AS_HELP_STRING([--with-kernel],
[path to a Linux kernel]),
[with_kernel=$withval], [with_kernel=`uname -r`])
AC_ARG_WITH([repo-parent],
AS_HELP_STRING([--with-repo-parent],
[path to all dependencies]),
[with_repo_parent=$withval], [])
AC_ARG_WITH([general-cores],
AS_HELP_STRING([--with-general-cores],
[path to OHWR general-cores]),
[with_general_cores=$withval], [])
AC_ARG_WITH([fpgamgr],
AS_HELP_STRING([--with-fpgamgr],
[path to the FPGA manager backport for old kernels]),
[with_fpgamgr=$withval], [])
AC_ARG_ENABLE([fpgamgr],
AS_HELP_STRING([--enable-fpgamgr],
[activate the use of the FPGA manager backport for old kernels]),
[enable_fpgamgr_backport=y], [enable_fpgamgr_backport=n])
AC_ARG_WITH([fmc],
AS_HELP_STRING([--with-fmc],
[path to OHWR fmc-sw]),
[with_fmc=$withval], [])
AC_ARG_WITH([i2c-ocores],
AS_HELP_STRING([--with-i2c-ocores],
[path to i2c-ocores]),
[with_i2c_ocores=$withval], [])
AC_ARG_WITH([spi-ocores],
AS_HELP_STRING([--with-spi-ocores],
[path to spi-ocores]),
[with_spi_ocores=$withval], [])
AS_IF([test "x$with_repo_parent" != "x"],
[AC_SUBST([REPO_PARENT], [$with_repo_parent])
AC_SUBST([GENERAL_CORES], [$REPO_PARENT/general-cores])
AC_SUBST([FPGA_MGR], [$REPO_PARENT/fpga-mgr-backport])
AC_SUBST([FMC], [$REPO_PARENT/fmc-sw])
])
AS_IF([test "x$with_general_cores" != "x" ],
[AC_SUBST([GENERAL_CORES], [$with_general_cores])
AC_SUBST([I2C], [$GENERAL_CORES/software/i2c-ocores])
AC_SUBST([SPI], [$GENERAL_CORES/software/spi-ocores])
])
AS_IF([test "x$with_fpgamgr" != "x" ],
[AC_SUBST([FPGA_MGR], [$with_fpgamgr])])
AS_IF([test "x$with_fmc" != "x" ],
[AC_SUBST([FMC], [$with_fmc])])
AS_IF([test "x$with_i2c_ocores" != "x" ],
[AC_SUBST([I2C], [$with_i2c_ocores])])
AS_IF([test "x$with_spi_ocores" != "x" ],
[AC_SUBST([SPI], [$with_spi_ocores])])
AC_SUBST([CONFIG_FPGA_MGR_BACKPORT],[$enable_fpgamgr_backport])
AC_SUBST([with_kernel_mod], [/lib/modules/$with_kernel/extra/cern])
AC_SUBST([KERNEL_SRC], [/lib/modules/$with_kernel/build])
AC_SUBST([KERNEL_MOD], [$with_kernel_mod])
AC_CHECK_PROG([CHEBY], [cheby], [cheby])
AC_CHECK_PROG([CPPCHECK], [cppcheck], [cppcheck])
AC_CHECK_PROG([GIT], [git], [git])
AC_CHECK_HEADERS([fcntl.h, stdint.h, stdlib.h, string.h])
AC_CHECK_FUNCS([atexit], [AC_SUBST([NO_ATEXIT])], ["#"])
AC_CHECK_FUNCS([munmap], [AC_SUBST([NO_MUNMAP])], ["#"])
AC_CHECK_FUNCS([strerror], [AC_SUBST([NO_STRERROR])], ["#"])
AC_CHECK_FUNCS([strndup], [AC_SUBST([NO_STRNDUP])], ["#"])
AC_FUNC_MMAP
AC_TYPE_OFF_T
AM_PROG_CC_C_O
AC_SUBST([GIT_VERSION], [`$GIT describe --dirty --long --tags`])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([
Makefile
kernel/Makefile
tools/Makefile
])
AC_OUTPUT
......@@ -11,6 +11,11 @@ endif
endif
# add versions of used submodules
FPGA_MGR_ABS = $(abspath $(src)/$(FPGA_MGR))
FMC_ABS = $(abspath $(src)/$(FMC))
I2C_ABS = $(abspath $(src)/$(I2C))
SPI_ABS = $(abspath $(src)/$(SPI))
VER_MAJ := $(shell echo $(subst v,,$(VERSION)) | cut -d '.' -f 1)
VER_MIN := $(shell echo $(subst v,,$(VERSION)) | cut -d '.' -f 2)
SPEC_META_VERSION_COMPAT := $(shell printf "0x%02x%02x0000" $(VER_MAJ) $(VER_MIN))
......
# SPDX-FileCopyrightText: 2020 CERN (home.cern)
#
# SPDX-License-Identifier: CC0-1.0
-include Makefile.specific
-include $(REPO_PARENT)/parent_common.mk
KVERSION ?= $(shell uname -r)
LINUX ?= /lib/modules/$(KVERSION)/build
TOP_DIR ?= $(shell pwd)/../..
HDL_DIR ?= $(TOP_DIR)/hdl
DKMS ?= 0
ifndef (CONFIG_FPGA_MGR_BACKPORT)
ifeq ($(shell test $(shell uname -p) \> "4.4"), 0)
CONFIG_FPGA_MGR_BACKPORT := n
else
CONFIG_FPGA_MGR_BACKPORT := y
endif
endif
ifeq ($(DKMS), 1)
FPGA_MGR_VERSION ?= $(shell basename $(shell ls -d $(DKMSTREE)/fpga_mgr/* | grep -E "\/[0-9]+\.[0-9]+\.[0-9]+" | sort -V | tail -n 1))
FMC_VERSION ?= $(shell basename $(shell ls -d $(DKMSTREE)/fmc/* | grep -E "\/[0-9]+\.[0-9]+\.[0-9]+" | sort -V | tail -n 1))
I2C_VERSION ?= $(shell basename $(shell ls -d $(DKMSTREE)/i2c-ocores/* | grep -E "\/[0-9]+\.[0-9]+\.[0-9]+" | sort -V | tail -n 1))
SPI_VERSION ?= $(shell basename $(shell ls -d $(DKMSTREE)/spi-ocores/* | grep -E "\/[0-9]+\.[0-9]+\.[0-9]+" | sort -V | tail -n 1))
FPGA_MGR ?= $(DKMSTREE)/fpga_mgr/$(FPGA_MGR_VERSION)/source
FMC ?= $(DKMSTREE)/fmc/$(FMC_VERSION)/source
I2C ?= $(DKMSTREE)/i2c-ocores/$(I2C_VERSION)/source
SPI ?= $(DKMSTREE)/spi-ocores/$(SPI_VERSION)/source
endif
ifdef REPO_PARENT
FPGA_MGR ?= $(REPO_PARENT)/fpga-mgr-backport/
FMC ?= $(REPO_PARENT)/fmc-sw/
I2C ?= $(REPO_PARENT)/general-cores/software/i2c-ocores/
SPI ?= $(REPO_PARENT)/general-cores/software/spi-ocores/
endif
ifndef FPGA_MGR
$(error "Missing FPGA_MGR environment variable")
endif
ifndef FMC
$(error "Missing FMC environment variable")
endif
ifndef I2C
$(error "Missing I2C environment variable")
endif
ifndef SPI
$(error "Missing SPI environment variable")
endif
FPGA_MGR_ABS ?= $(abspath $(FPGA_MGR))
FMC_ABS ?= $(abspath $(FMC))
I2C_ABS ?= $(abspath $(I2C))
SPI_ABS ?= $(abspath $(SPI))
VERSION = $(shell git describe --dirty --long --tags)
CHEBY ?= cheby
CPPCHECK ?= cppcheck
all: modules
.PHONY: all modules clean help install modules_install coccicheck spec-core-fpga.h cppcheck
spec-core-fpga.h:
ifeq ($(DKMS), 0)
$(CHEBY) --gen-c -i $(HDL_DIR)/rtl/spec_base_regs.cheby > $@
endif
clean-spec-core-fpga.h:
ifeq ($(DKMS), 0)
rm -f spec-core-fpga.h
endif
install: modules_install
clean: clean-spec-core-fpga.h
modules help coccicheck modules_install clean: spec-core-fpga.h
$(MAKE) -C $(LINUX) M=$(shell pwd) \
VERSION=$(VERSION) \
FPGA_MGR_ABS=$(FPGA_MGR_ABS) \
CONFIG_FPGA_MGR_BACKPORT=$(CONFIG_FPGA_MGR_BACKPORT) \
FMC_ABS=$(FMC_ABS) \
I2C_ABS=$(I2C_ABS) \
SPI_ABS=$(SPI_ABS) \
$@
INCLUDE := -I./
cppcheck:
$(CPPCHECK) -q $(INCLUDE) --suppress=missingIncludeSystem --enable=all *.c *.h --error-exitcode=1
-include $(REPO_PARENT)/parent_common.mk
all-local: modules
modules:
$(CHEBY) --gen-c -i $(top_srcdir)/../hdl/rtl/spec_base_regs.cheby > spec-core-fpga.h
$(MAKE) -C $(KERNEL_SRC) M=$(abs_srcdir) \
VERSION=$(GIT_VERSION) \
FPGA_MGR_ABS=$(FPGA_MGR) \
CONFIG_FPGA_MGR_BACKPORT=$(CONFIG_FPGA_MGR_BACKPORT) \
FMC_ABS=$(FMC) \
I2C_ABS=$(I2C) \
SPI_ABS=$(SPI) \
$@
install-exec-hook: modules
$(MAKE) -C $(KERNEL_SRC) M=$(srcdir) modules_install
clean-local:
rm spec-core-fpga.h
$(MAKE) -C $(KERNEL_SRC) M=$(srcdir) clean
analyze: coccicheck
coccicheck:
$(MAKE) -C $(KERNEL_SRC) M=$(abs_srcdir) \
VERSION=$(GIT_VERSION) \
FPGA_MGR_ABS=$(FPGA_MGR) \
CONFIG_FPGA_MGR_BACKPORT=$(CONFIG_FPGA_MGR_BACKPORT) \
FMC_ABS=$(FMC) \
I2C_ABS=$(I2C) \
SPI_ABS=$(SPI) \
$@
.PHONY: analyze modules coccicheck
# SPDX-License-Identifier: LGPL-3.0-or-later
#
# Copyright (C) 2020 CERN
# If it exists includes Makefile.specific. In this Makefile, you should put
# specific Makefile code that you want to run before this. For example,
# build a particular environment.
-include Makefile.specific
DESTDIR ?= /usr/local/
TOOLS = spec-firmware-version
INCLUDE := -I. -I../kernel -I../include/uapi
CFLAGS = -ggdb $(INCLUDE) -Wall -Werror $(EXTRACFLAGS)
GIT_VERSION := $(shell git describe --dirty --long --tags)
CFLAGS += -DGIT_VERSION="\"$(GIT_VERSION)\""
CPPCHECK ?= cppcheck
all: $(TOOLS)
$(TOOLS):
clean:
rm -f $(TOOLS)
install:
install -d $(DESTDIR)/bin
install -D $(TOOLS) $(DESTDIR)/bin
cppcheck:
$(CPPCHECK) -q $(INCLUDE) --suppress=missingIncludeSystem --enable=all *.c *.h --error-exitcode=1
.PHONY: cppcheck
-include $(REPO_PARENT)/parent_common.mk
bin_PROGRAMS = spec-firmware-version
spec_firmware_versiondir = .
spec_firmware_version_SOURCES = spec-firmware-version.c
spec_firmware_version_HEADERS = $(top_srcdir)/include/uapi/linux/spec.h
spec_firmware_version_HEADERS += $(top_srcdir)/kernel/spec-core-fpga.h
spec_firmware_version_CFLAGS = -Wall -Werror
spec_firmware_version_CFLAGS += -I$(top_srcdir)/kernel -I$(top_srcdir)/include/uapi
spec_firmware_version_CFLAGS += -ggdb
spec_firmware_version_CFLAGS += -DGIT_VERSION="\"$(GIT_VERSION)\""
analyze: cppcheck
cppcheck:
$(CPPCHECK) -q $(srcdir) --suppress=missingIncludeSystem --enable=all *.c *.h --error-exitcode=1
.PHONY: analyze cppcheck
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