Alexei Starovoitov | 3c731eb | 2014-09-26 00:17:07 -0700 | [diff] [blame] | 1 | # kbuild trick to avoid linker error. Can be omitted if a module is built. |
| 2 | obj- := dummy.o |
| 3 | |
| 4 | # List of programs to build |
Alexei Starovoitov | ffb65f2 | 2014-11-13 17:36:48 -0800 | [diff] [blame] | 5 | hostprogs-y := test_verifier test_maps |
Alexei Starovoitov | 03f4723 | 2014-12-01 15:06:36 -0800 | [diff] [blame] | 6 | hostprogs-y += sock_example |
Alexei Starovoitov | a808578 | 2014-12-01 15:06:38 -0800 | [diff] [blame] | 7 | hostprogs-y += sockex1 |
Alexei Starovoitov | fbe3310 | 2014-12-01 15:06:39 -0800 | [diff] [blame] | 8 | hostprogs-y += sockex2 |
Alexei Starovoitov | b896c4f | 2015-03-25 12:49:23 -0700 | [diff] [blame] | 9 | hostprogs-y += tracex1 |
Alexei Starovoitov | d822a19 | 2015-03-25 12:49:24 -0700 | [diff] [blame^] | 10 | hostprogs-y += tracex2 |
Alexei Starovoitov | 3c731eb | 2014-09-26 00:17:07 -0700 | [diff] [blame] | 11 | |
| 12 | test_verifier-objs := test_verifier.o libbpf.o |
Alexei Starovoitov | ffb65f2 | 2014-11-13 17:36:48 -0800 | [diff] [blame] | 13 | test_maps-objs := test_maps.o libbpf.o |
Alexei Starovoitov | 03f4723 | 2014-12-01 15:06:36 -0800 | [diff] [blame] | 14 | sock_example-objs := sock_example.o libbpf.o |
Alexei Starovoitov | a808578 | 2014-12-01 15:06:38 -0800 | [diff] [blame] | 15 | sockex1-objs := bpf_load.o libbpf.o sockex1_user.o |
Alexei Starovoitov | fbe3310 | 2014-12-01 15:06:39 -0800 | [diff] [blame] | 16 | sockex2-objs := bpf_load.o libbpf.o sockex2_user.o |
Alexei Starovoitov | b896c4f | 2015-03-25 12:49:23 -0700 | [diff] [blame] | 17 | tracex1-objs := bpf_load.o libbpf.o tracex1_user.o |
Alexei Starovoitov | d822a19 | 2015-03-25 12:49:24 -0700 | [diff] [blame^] | 18 | tracex2-objs := bpf_load.o libbpf.o tracex2_user.o |
Alexei Starovoitov | 3c731eb | 2014-09-26 00:17:07 -0700 | [diff] [blame] | 19 | |
| 20 | # Tell kbuild to always build the programs |
| 21 | always := $(hostprogs-y) |
Alexei Starovoitov | a808578 | 2014-12-01 15:06:38 -0800 | [diff] [blame] | 22 | always += sockex1_kern.o |
Alexei Starovoitov | fbe3310 | 2014-12-01 15:06:39 -0800 | [diff] [blame] | 23 | always += sockex2_kern.o |
Alexei Starovoitov | b896c4f | 2015-03-25 12:49:23 -0700 | [diff] [blame] | 24 | always += tracex1_kern.o |
Alexei Starovoitov | d822a19 | 2015-03-25 12:49:24 -0700 | [diff] [blame^] | 25 | always += tracex2_kern.o |
Alexei Starovoitov | 3c731eb | 2014-09-26 00:17:07 -0700 | [diff] [blame] | 26 | |
| 27 | HOSTCFLAGS += -I$(objtree)/usr/include |
Alexei Starovoitov | a808578 | 2014-12-01 15:06:38 -0800 | [diff] [blame] | 28 | |
| 29 | HOSTCFLAGS_bpf_load.o += -I$(objtree)/usr/include -Wno-unused-variable |
| 30 | HOSTLOADLIBES_sockex1 += -lelf |
Alexei Starovoitov | fbe3310 | 2014-12-01 15:06:39 -0800 | [diff] [blame] | 31 | HOSTLOADLIBES_sockex2 += -lelf |
Alexei Starovoitov | b896c4f | 2015-03-25 12:49:23 -0700 | [diff] [blame] | 32 | HOSTLOADLIBES_tracex1 += -lelf |
Alexei Starovoitov | d822a19 | 2015-03-25 12:49:24 -0700 | [diff] [blame^] | 33 | HOSTLOADLIBES_tracex2 += -lelf |
Alexei Starovoitov | a808578 | 2014-12-01 15:06:38 -0800 | [diff] [blame] | 34 | |
| 35 | # point this to your LLVM backend with bpf support |
| 36 | LLC=$(srctree)/tools/bpf/llvm/bld/Debug+Asserts/bin/llc |
| 37 | |
| 38 | %.o: %.c |
| 39 | clang $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) \ |
| 40 | -D__KERNEL__ -Wno-unused-value -Wno-pointer-sign \ |
| 41 | -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf -filetype=obj -o $@ |