Skip to content

Commit

Permalink
Applying 'GNU Make Manual' style to Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
ruck314 committed Feb 24, 2024
1 parent 8919ad0 commit d88cd67
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions data_gpu/driver/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# ----------------------------------------------------------------------------
# Title : Data GPU driver makefile
# Company : SLAC National Accelerator Laboratory
# ----------------------------------------------------------------------------
# File : Makefile
# Created : 2017-03-17
# Description :
# Builds the data_gpu kernel driver for aes_stream_drivers package
# ----------------------------------------------------------------------------
# This file is part of the aes_stream_drivers package. It is subject to
# the license terms in the LICENSE.txt file found in the top-level directory
Expand All @@ -13,39 +13,60 @@
# contained in the LICENSE.txt file.
# ----------------------------------------------------------------------------

# Optional path to NVIDIA drivers, if not specified, use empty string.
NVIDIA_DRIVERS ?= ""

# Define the module name.
NAME := datagpu

# Determine the directory of the current Makefile.
HOME := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))

# Kernel version and architecture for building the module.
KVER := $(shell uname -r)
ARCH := $(shell uname -m)

# Cross compilation settings (empty by default).
CROSS_COMPILE :=

# Enable warnings during module post-processing.
KBUILD_MODPOST_WARN := 1

# Kernel build directory.
KERNELDIR := /lib/modules/$(KVER)/build

# Source and object files.
SRCS := $(wildcard src/*.c)
OBJS := $(patsubst %.c,%.o,$(SRCS))

# NVIDIA extra symbols for module linking.
KBUILD_EXTRA_SYMBOLS := $(NVIDIA_DRIVERS)/Module.symvers

# Git versioning: Use tags with optional '-dirty' suffix for uncommitted changes.
ifndef GITV
GITT := $(shell cd $(HOME); git describe --tags)
GITD := $(shell cd $(HOME); git status --short -uno | wc -l)
GITV := $(if $(filter $(GITD),0),$(GITT),$(GITT)-dirty)
endif

# Compiler flags: Include paths and definitions.
ccflags-y += -I$(HOME)/src
ccflags-y += -DDMA_IN_KERNEL=1 -DGITV=\"$(GITV)\"
ccflags-y += -I$(NVIDIA_DRIVERS)/nvidia

# Object files for the module.
$(NAME)-objs := src/dma_buffer.o src/dma_common.o
$(NAME)-objs += src/axi_version.o src/axis_gen2.o src/gpu_async.o src/data_gpu_top.o
obj-m := $(NAME).o

# Module target.
obj-m := $(NAME).o

# Default target: Display git version and build the module.
all:
@echo $(GITV)
make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KERNELDIR) M=$(HOME) modules
$(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KERNELDIR) M=$(HOME) modules

# Clean target: Remove built module files and object files.
clean:
make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KERNELDIR) M=$(HOME) clean
$(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KERNELDIR) M=$(HOME) clean
rm -f $(OBJS)

0 comments on commit d88cd67

Please sign in to comment.