56be179f629a907760d3c3802ab51a8e9940730d
[des2015.git] / mart / ex07 / Makefile
1 ###### CONFIGURATION ######
2
3 ### List of applications to be build
4 APPLICATIONS = ex07a ex07b ex07c
5
6 ### Note: to override the search path for the xeno-config script, use "make XENO=..."
7
8
9 ### List of modules to be build
10 MODULES =
11
12 ### Note: to override the kernel source path, use "make KSRC=..."
13
14
15
16 ###### USER SPACE BUILD (no change required normally) ######
17 ifeq ($(KERNELRELEASE),)
18 ifneq ($(APPLICATIONS),)
19
20 ### Default Xenomai installation path
21 XENO ?= /usr/xenomai
22
23 XENOCONFIG=$(shell PATH=$(XENO):$(XENO)/bin:$(PATH) which xeno-config 2>/dev/null)
24
25 ### Sanity check
26 ifeq ($(XENOCONFIG),)
27 all::
28 @echo ">>> Invoke make like this: \"make XENO=/path/to/xeno-config\" <<<"
29 @echo
30 endif
31
32
33 CC=$(shell $(XENOCONFIG) --cc)
34
35 CFLAGS=$(shell $(XENOCONFIG) --xeno-cflags) $(MY_CFLAGS)
36
37 LDFLAGS=$(shell $(XENOCONFIG) --xeno-ldflags) $(MY_LDFLAGS) -lnative
38
39 # This includes the library path of given Xenomai into the binary to make live
40 # easier for beginners if Xenomai's libs are not in any default search path.
41 LDFLAGS+=-Xlinker -rpath -Xlinker $(shell $(XENOCONFIG) --libdir)
42
43 LDFLAGS+= -lrtdk
44
45 all:: $(APPLICATIONS)
46
47 clean::
48 $(RM) $(APPLICATIONS) *.o
49
50 endif
51 endif
52
53
54
55 ###### SPECIAL TARGET RULES ######
56 rtprint: rtprint.c
57 $(CC) $(CFLAGS) $? $(LDFLAGS) -lrtdk -o $@
58
59
60
61 ###### KERNEL MODULE BUILD (no change required normally) ######
62 ifneq ($(MODULES),)
63
64 ### Default to sources of currently running kernel
65 KSRC ?= /lib/modules/$(shell uname -r)/build
66
67 OBJS := ${patsubst %, %.o, $(MODULES)}
68 CLEANMOD := ${patsubst %, .%*, $(MODULES)}
69 PWD := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
70
71 ### Kernel 2.6
72 ifeq ($(findstring 2.6,$(KSRC)),2.6)
73
74 obj-m := $(OBJS)
75 EXTRA_CFLAGS := -I$(KSRC)/include/xenomai -I$(KSRC)/include/xenomai/posix $(ADD_CFLAGS)
76
77 all::
78 $(MAKE) -C $(KSRC) SUBDIRS=$(PWD) modules
79
80 ### Kernel 2.4
81 else
82
83 ARCH ?= $(shell uname -i)
84 INCLUDE := -I$(KSRC)/include/xenomai -I$(KSRC)/include/xenomai/compat -I$(KSRC)/include/xenomai/posix
85 CFLAGS += $(shell $(MAKE) -s -C $(KSRC) CC=$(CC) ARCH=$(ARCH) SUBDIRS=$(PWD) modules) $(INCLUDE)
86
87 all:: $(OBJS)
88
89 endif
90
91 ## Target for capturing 2.4 module CFLAGS
92 modules:
93 @echo "$(CFLAGS)"
94
95 clean::
96 $(RM) $(CLEANMOD) *.o *.ko *.mod.c Module*.symvers
97 $(RM) -R .tmp*
98
99 endif