diff --git a/software/Makefile b/software/Makefile index 21482cb2ec6d9814e771191b2c13dd3f024ea5ab..52354ab54ccf20d897f692dd5802838b73f64691 100644 --- a/software/Makefile +++ b/software/Makefile @@ -1,3 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Copyright (C) 2019 CERN + +TOP_DIR ?= $(shell pwd)/.. + -include Makefile.specific # include parent_common.mk for buildsystem's defines @@ -5,11 +11,36 @@ REPO_PARENT ?= $(shell /bin/pwd)/.. -include $(REPO_PARENT)/parent_common.mk +GCORES ?= $(TOP_DIR) +include $(GCORES)/common.mk +DIR_NAME := general-cores-$(VERSION) +DST := $(PREFIX)/usr/src/$(DIR_NAME)/ + DIRS := i2c-ocores DIRS += spi-ocores DIRS += htvic -.PHONY: all clean modules install modules_install +GIT ?= git +ifeq (,$(shell which $(GIT))) +$(error "Missing git") +endif + +.PHONY: all clean modules install modules_install dkms_install all clean modules install modules_install: for D in $(DIRS); do $(MAKE) -C $$D $@; done + +dkms_install: + $(eval $@_dst := $(shell mktemp -d)) + @mkdir -p $($@_dst) + @mkdir -p $(DST) + @$(GIT) archive --format=tar -o $($@_dst)/$(DIR_NAME).tar --prefix=$(DIR_NAME)/ HEAD + @cd $($@_dst) && tar -xf $(DIR_NAME).tar + @mv $($@_dst)/$(DIR_NAME)/* $(DST) && rm -rf $($@_dst) + @cp $(GCORES)/common.mk $(DST) + @sed -e '2,$$d' -i $(DST)/common.mk + @sed -r -i -e "s/@PKGVER@/$(VERSION)/" $(DST)/dkms.conf + @sed -e "15d" -e "6,13d" -e "23,26d" -e '33,$$d' \ + -i $(DST)/Makefile + @find $(DST) -name Makefile -exec \ + sed -r -e "s,^(TOP_DIR.*)[.]{2}/?$$,\1," -i {} \;