Add nvramtool to coreboot build system
[coreboot.git] / util / nvramtool / Makefile.inc
1 ##
2 ## Integration of nvramtool into the coreboot build system
3 ##
4 ## (C) 2005-2008 coresystems GmbH
5 ## written by Stefan Reinauer <stepan@coresystems.de>
6 ## (C) 2012 secunet Security Networks AG
7 ##
8 ## This program is free software; you can redistribute it and/or modify
9 ## it under the terms of the GNU General Public License as published by
10 ## the Free Software Foundation; version 2 of the License.
11 ##
12 ## This program is distributed in the hope that it will be useful,
13 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 ## GNU General Public License for more details.
16 ##
17 ## You should have received a copy of the GNU General Public License
18 ## along with this program; if not, write to the Free Software
19 ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
20 ##
21
22 OS_ARCH        = $(shell uname)
23 NVRAMTOOLFLAGS := -I$(top)/util/nvramtool
24 ifeq ($(OS_ARCH), Darwin)
25 NVRAMTOOLFLAGS += -framework DirectHW
26 endif
27 ifeq ($(OS_ARCH), NetBSD)
28 NVRAMTOOLFLAGS += -l$(shell uname -p)
29 endif
30
31 nvramtoolobj :=
32 nvramtoolobj += cli/nvramtool.o cli/opts.o
33 nvramtoolobj += cmos_lowlevel.o cmos_ops.o common.o compute_ip_checksum.o
34 nvramtoolobj += hexdump.o input_file.o layout.o accessors/layout-text.o accessors/layout-bin.o lbtable.o
35 nvramtoolobj += reg_expr.o cbfs.o accessors/cmos-hw-unix.o accessors/cmos-mem.o
36
37 $(objutil)/nvramtool $(objutil)/nvramtool/accessors $(objutil)/nvramtool/cli:
38         mkdir -p $@
39
40 $(objutil)/nvramtool/%.o: $(top)/util/nvramtool/%.c
41         printf "    HOSTCC     $(subst $(objutil)/,,$(@))\n"
42         $(HOSTCC) $(NVRAMTOOLFLAGS) $(HOSTCFLAGS) -c -o $@ $<
43
44 $(objutil)/nvramtool/nvramtool: $(objutil)/nvramtool $(objutil)/nvramtool/accessors $(objutil)/nvramtool/cli $(addprefix $(objutil)/nvramtool/,$(nvramtoolobj))
45         printf "    HOSTCC     $(subst $(objutil)/,,$(@)) (link)\n"
46         $(HOSTCC) $(NVRAMTOOLFLAGS) -o $@ $(addprefix $(objutil)/nvramtool/,$(nvramtoolobj))
47
48