Allow top-level Makefile to use arm-none-eabi toolchain
[osmocom-bb.git] / src / Makefile
1
2 # this is not really used as we don't do 'make install'. You can still specify
3 # it in case you _want_ to manually 'make install' the target libosmocore.
4 CROSS_INST_PREFIX ?= /usr/local/stow/osmocom-bb/arm-2010.09
5
6 # this is the host tuple of your cross-toolchain
7 CROSS_HOST ?= $(shell which arm-elf-gcc >/dev/null 2>&1 && echo arm-elf || echo arm-none-eabi)
8
9 # this is the prefix of your cross-toolchain programs
10 CROSS_TOOL_PREFIX=$(CROSS_HOST)-
11
12 TOPDIR=$(shell pwd)
13 OSMOCORE_CONFIGURE_ENV= LIBOSMOCORE_LIBS=$(TOPDIR)/shared/libosmocore/build-host/src/.libs/libosmocore.a \
14                         LIBOSMOVTY_LIBS=$(TOPDIR)/shared/libosmocore/build-host/src/vty/.libs/libosmovty.a \
15                         LIBOSMOCORE_CFLAGS=-I$(TOPDIR)/shared/libosmocore/include \
16                         LIBOSMOVTY_CFLAGS=-I$(TOPDIR)/shared/libosmocore/include
17
18 all: libosmocore-target nofirmware firmware
19 nofirmware: libosmocore-host layer23 osmocon gsmmap
20
21 libosmocore-host: shared/libosmocore/build-host/src/.libs/libosmocore.la
22
23 shared/libosmocore/build-host:
24         mkdir $@
25
26 shared/libosmocore/configure: shared/libosmocore/configure.in
27         cd shared/libosmocore && autoreconf -i
28
29 shared/libosmocore/build-host/Makefile: shared/libosmocore/configure shared/libosmocore/build-host
30         cd shared/libosmocore/build-host && ../configure $(HOST_CONFARGS)
31
32 shared/libosmocore/build-host/src/.libs/libosmocore.la: shared/libosmocore/build-host/Makefile
33         cd shared/libosmocore/build-host && make
34
35
36 libosmocore-target: shared/libosmocore/build-target/src/.libs/libosmocore.a
37
38 shared/libosmocore/build-target:
39         mkdir $@
40
41 shared/libosmocore/build-target/Makefile: shared/libosmocore/configure shared/libosmocore/build-target
42         cd shared/libosmocore/build-target && ../configure \
43                         --host=$(CROSS_HOST) --disable-vty --enable-panic-infloop \
44                         --disable-shared --disable-talloc --disable-tests \
45                 CFLAGS="-Os -ffunction-sections -I$(TOPDIR)/target/firmware/include -nostartfiles -nodefaultlibs"
46
47 shared/libosmocore/build-target/src/.libs/libosmocore.a: shared/libosmocore/build-target/Makefile
48         cd shared/libosmocore/build-target && make
49
50
51 .PHONY: osmocon
52 osmocon: host/osmocon/osmocon
53
54 host/osmocon/configure: host/osmocon/configure.ac
55         cd host/osmocon && autoreconf -i
56
57 host/osmocon/Makefile: host/osmocon/configure
58         cd host/osmocon && $(OSMOCORE_CONFIGURE_ENV) ./configure $(HOST_CONFARGS)
59
60 host/osmocon/osmocon: host/osmocon/Makefile libosmocore-host
61         make -C host/osmocon
62
63
64 .PHONY: gsmmap
65 gsmmap: host/gsmmap/gsmmap
66
67 host/gsmmap/configure: host/gsmmap/configure.ac
68         cd host/gsmmap && autoreconf -i
69
70 host/gsmmap/Makefile: host/gsmmap/configure
71         cd host/gsmmap && $(OSMOCORE_CONFIGURE_ENV) ./configure $(HOST_CONFARGS)
72
73 host/gsmmap/gsmmap: host/gsmmap/Makefile libosmocore-host
74         make -C host/gsmmap
75
76
77 .PHONY: layer23
78 layer23: host/layer23/layer23
79
80 host/layer23/configure: host/layer23/configure.ac
81         cd host/layer23 && autoreconf -i
82
83 host/layer23/Makefile: host/layer23/configure
84         cd host/layer23 && $(OSMOCORE_CONFIGURE_ENV) ./configure $(HOST_CONFARGS)
85
86 host/layer23/layer23: host/layer23/Makefile libosmocore-host
87         make -C host/layer23
88
89
90 .PHONY: firmware
91 firmware: libosmocore-target
92         make -C target/firmware CROSS_COMPILE=$(CROSS_TOOL_PREFIX)
93
94
95 clean:
96         make -C shared/libosmocore/build-host $@
97         make -C shared/libosmocore/build-target $@
98         make -C host/layer23 $@
99         make -C host/osmocon $@
100         make -C target/firmware $@
101
102 distclean:
103         rm -rf shared/libosmocore/build-host
104         rm -rf shared/libosmocore/build-target
105         make -C host/layer23 $@
106         make -C host/osmocon $@
107         make -C target/firmware $@