# SPDX-License-Identifier: GPL-2.0-only
#
# Copyright (C) 2023, guoct1@chinatelecom.cn.
#
MAKE = /usr/bin/env make
SHELL = /usr/bin/env bash
NPROC := $(shell nproc)
KDIR := ../..
ODIR := ./build
SUBARGS := $(wordlist 2, $(words $(MAKECMDGOALS)), $(MAKECMDGOALS))

.phony: all kctuts uctuts mf modules build collect clean

all: kctuts uctuts

kctuts:
	$(MAKE) -j $(NPROC) -C src/kernel $(SUBARGS) KDIR=$(shell realpath $(KDIR)) ODIR=$(shell realpath $(ODIR))/ko

uctuts:
	$(MAKE) -j $(NPROC) -C src/user $(SUBARGS) ODIR=$(shell realpath $(ODIR))/bin

kctuts_install:
	mkdir -p $(DESTDIR)/lib/modules/$(KVER)/kernel/lib/ctunit
	cp $(shell realpath $(ODIR))/ko/*.ko $(DESTDIR)/lib/modules/$(KVER)/kernel/lib/ctunit/
uctuts_install:
	@true
mf:
	@true
modules:
	@true
build:
	@true
collect:
	@true
clean:
	@true
%.all:
	@true
%.build:
	@true
%.collect:
	@true
%.clean:
	@true
