1 # SPDX-License-Identifier: GPL-2.0
2 include ..
/scripts
/Makefile.
include
7 srctree
:= $(patsubst %/,%,$(dir $(CURDIR
)))
8 srctree
:= $(patsubst %/,%,$(dir $(srctree
)))
11 # Do not use make's built-in rules
12 # (this improves performance and avoids hard-to-debug behaviour);
15 CC
= $(CROSS_COMPILE
)gcc
16 LD
= $(CROSS_COMPILE
)ld
17 CFLAGS
+= -O2
-Wall
-g
-D_GNU_SOURCE
-I
$(OUTPUT
)include
19 ALL_TARGETS
:= iio_event_monitor lsiio iio_generic_buffer
20 ALL_PROGRAMS
:= $(patsubst %,$(OUTPUT
)%,$(ALL_TARGETS
))
24 export srctree OUTPUT CC LD CFLAGS
25 include $(srctree
)/tools
/build
/Makefile.
include
28 # We need the following to be outside of kernel tree
30 $(OUTPUT
)include/linux
/iio
: ..
/..
/include/uapi
/linux
/iio
31 mkdir
-p
$(OUTPUT
)include/linux
/iio
2>&1 || true
32 ln
-sf
$(CURDIR
)/..
/..
/include/uapi
/linux
/iio
/events.h
$@
33 ln
-sf
$(CURDIR
)/..
/..
/include/uapi
/linux
/iio
/types.h
$@
35 prepare
: $(OUTPUT
)include/linux
/iio
37 LSIIO_IN
:= $(OUTPUT
)lsiio-in.o
38 $(LSIIO_IN
): prepare FORCE
39 $(Q
)$(MAKE
) $(build
)=lsiio
40 $(OUTPUT
)lsiio
: $(LSIIO_IN
)
41 $(QUIET_LINK
)$(CC
) $(CFLAGS
) $(LDFLAGS
) $< -o
$@
43 IIO_EVENT_MONITOR_IN
:= $(OUTPUT
)iio_event_monitor-in.o
44 $(IIO_EVENT_MONITOR_IN
): prepare FORCE
45 $(Q
)$(MAKE
) $(build
)=iio_event_monitor
46 $(OUTPUT
)iio_event_monitor
: $(IIO_EVENT_MONITOR_IN
)
47 $(QUIET_LINK
)$(CC
) $(CFLAGS
) $(LDFLAGS
) $< -o
$@
49 IIO_GENERIC_BUFFER_IN
:= $(OUTPUT
)iio_generic_buffer-in.o
50 $(IIO_GENERIC_BUFFER_IN
): prepare FORCE
51 $(Q
)$(MAKE
) $(build
)=iio_generic_buffer
52 $(OUTPUT
)iio_generic_buffer
: $(IIO_GENERIC_BUFFER_IN
)
53 $(QUIET_LINK
)$(CC
) $(CFLAGS
) $(LDFLAGS
) $< -o
$@
57 rm -rf
$(OUTPUT
)include/linux
/iio
58 find
$(if
$(OUTPUT
),$(OUTPUT
),.
) -name
'*.o' -delete
-o
-name
'\.*.d' -delete
60 install: $(ALL_PROGRAMS
)
61 install -d
-m
755 $(DESTDIR
)$(bindir); \
62 for program in
$(ALL_PROGRAMS
); do \
63 install $$program $(DESTDIR
)$(bindir); \
68 .PHONY
: all install clean FORCE prepare