I've time and again used the standard Makefile
for building out of tree modules. It is reproduced below:
# Comment/uncomment the following line to disable/enable debugging
DEBUG = y
# Add your debugging flag (or not) to CFLAGS
ifeq ($(DEBUG),y)
DEBFLAGS = -O0 -g3 -DSCULL_DEBUG # "-O" is needed to expand inlines
else
DEBFLAGS = -O2
endif
LDDINC=$(PWD)/../include
EXTRA_CFLAGS += $(DEBFLAGS)
EXTRA_CFLAGS += -I$(LDDINC)
ifneq ($(KERNELRELEASE),)
# call from kernel build system
@echo 'called from kernel build system' #<-- FAILS HERE
scull-objs := main.o pipe.o access.o
obj-m := scull.o
else
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
modules:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
endif
install:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install
cd /lib/modules/$(shell uname -r) && depmod -a
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions
depend .depend dep:
$(CC) $(EXTRA_CFLAGS) -M *.c > .depend
ifeq (.depend,$(wildcard .depend))
include .depend
endif
I would like make
to print custom string messages as it processes this Makefile so I tried adding @echo
messages (see FAILS HERE
in the code). But doing so fails with the following error:
Makefile:25: *** recipe commences before first target. Stop.
the offending line is marked above. Is there anyway I can do what I intend to do?