Skip to content

Instantly share code, notes, and snippets.

@smzn
Created June 11, 2019 01:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smzn/6a452143ccf3653f30ee04383128bfdb to your computer and use it in GitHub Desktop.
Save smzn/6a452143ccf3653f30ee04383128bfdb to your computer and use it in GitHub Desktop.
Makefile
# Comment/uncomment the following line to enable/disable debugging
#DEBUG = y
# Add your debugging flag (or not) to CFLAGS
ifeq ($(DEBUG),y)
DEBFLAGS = -O -g # "-O" is needed to expand inlines
else
DEBFLAGS = -O2
endif
EXTRA_CFLAGS += $(DEBFLAGS)
ifneq ($(KERNELRELEASE),)
# call from kernel build system
obj-m := chardev1.o
# chardev1-objs := chardev1.o
else
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
modules:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
endif
modules_install:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install
clean:
rm -rf *.o *~ core Module.* modules.* .depend .*.cmd *.ko *.mod.c .tmp_versions
.PHONY: modules modules_install clean
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment