X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=mart%2Fex06%2FMakefile;h=42b17b31c5940f473ebf1d546a285879e939742f;hb=b0bd8f724348ba4ec1adb341bc37ab556d7abb10;hp=6eaf4672a3231a92f709ce06867249c3aca29689;hpb=cb6632a064a7688274a0a89def28dbe5bcce5693;p=des2015.git diff --git a/mart/ex06/Makefile b/mart/ex06/Makefile index 6eaf467..42b17b3 100644 --- a/mart/ex06/Makefile +++ b/mart/ex06/Makefile @@ -1,9 +1,99 @@ -CFLAGS=$(shell xeno-config --xeno-cflags) -lnative -lrtdk -LDFLAGS=$(shell xeno-config --xeno-ldflags) +###### CONFIGURATION ###### -BINARIES=$(addprefix ex06,a b c d) +### List of applications to be build +APPLICATIONS = ex06a ex06b ex06c ex06d -all: $(BINARIES) +### Note: to override the search path for the xeno-config script, use "make XENO=..." -clean: - $(RM) -v $(BINARIES) *.o + +### List of modules to be build +MODULES = + +### Note: to override the kernel source path, use "make KSRC=..." + + + +###### USER SPACE BUILD (no change required normally) ###### +ifeq ($(KERNELRELEASE),) +ifneq ($(APPLICATIONS),) + +### Default Xenomai installation path +XENO ?= /usr/xenomai + +XENOCONFIG=$(shell PATH=$(XENO):$(XENO)/bin:$(PATH) which xeno-config 2>/dev/null) + +### Sanity check +ifeq ($(XENOCONFIG),) +all:: + @echo ">>> Invoke make like this: \"make XENO=/path/to/xeno-config\" <<<" + @echo +endif + + +CC=$(shell $(XENOCONFIG) --cc) + +CFLAGS=$(shell $(XENOCONFIG) --xeno-cflags) $(MY_CFLAGS) + +LDFLAGS=$(shell $(XENOCONFIG) --xeno-ldflags) $(MY_LDFLAGS) -lnative + +# This includes the library path of given Xenomai into the binary to make live +# easier for beginners if Xenomai's libs are not in any default search path. +LDFLAGS+=-Xlinker -rpath -Xlinker $(shell $(XENOCONFIG) --libdir) + +LDFLAGS+= -lrtdk + +all:: $(APPLICATIONS) + +clean:: + $(RM) $(APPLICATIONS) *.o + +endif +endif + + + +###### SPECIAL TARGET RULES ###### +rtprint: rtprint.c + $(CC) $(CFLAGS) $? $(LDFLAGS) -lrtdk -o $@ + + + +###### KERNEL MODULE BUILD (no change required normally) ###### +ifneq ($(MODULES),) + +### Default to sources of currently running kernel +KSRC ?= /lib/modules/$(shell uname -r)/build + +OBJS := ${patsubst %, %.o, $(MODULES)} +CLEANMOD := ${patsubst %, .%*, $(MODULES)} +PWD := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi) + +### Kernel 2.6 +ifeq ($(findstring 2.6,$(KSRC)),2.6) + +obj-m := $(OBJS) +EXTRA_CFLAGS := -I$(KSRC)/include/xenomai -I$(KSRC)/include/xenomai/posix $(ADD_CFLAGS) + +all:: + $(MAKE) -C $(KSRC) SUBDIRS=$(PWD) modules + +### Kernel 2.4 +else + +ARCH ?= $(shell uname -i) +INCLUDE := -I$(KSRC)/include/xenomai -I$(KSRC)/include/xenomai/compat -I$(KSRC)/include/xenomai/posix +CFLAGS += $(shell $(MAKE) -s -C $(KSRC) CC=$(CC) ARCH=$(ARCH) SUBDIRS=$(PWD) modules) $(INCLUDE) + +all:: $(OBJS) + +endif + +## Target for capturing 2.4 module CFLAGS +modules: + @echo "$(CFLAGS)" + +clean:: + $(RM) $(CLEANMOD) *.o *.ko *.mod.c Module*.symvers + $(RM) -R .tmp* + +endif \ No newline at end of file