blob: 12f4a5c84566a48164130cb28e2129c75891b8d2 [file] [log] [blame]
Stefan Reinauer6559f432010-12-17 00:13:54 +00001##
2## Makefile for nvram utility
3##
4## (C) 2005-2008 coresystems GmbH
5## written by Stefan Reinauer <stepan@coresystems.de>
6##
7## This program is free software; you can redistribute it and/or modify
8## it under the terms of the GNU General Public License as published by
9## the Free Software Foundation; version 2 of the License.
10##
11## This program is distributed in the hope that it will be useful,
12## but WITHOUT ANY WARRANTY; without even the implied warranty of
13## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14## GNU General Public License for more details.
15##
16## You should have received a copy of the GNU General Public License
17## along with this program; if not, write to the Free Software
Paul Menzela46a7122013-02-23 18:37:27 +010018## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Stefan Reinauer6559f432010-12-17 00:13:54 +000019##
Stefan Reinauer6540ae52007-07-12 16:35:42 +000020
Stefan Reinauera67aab72008-09-27 10:08:28 +000021PROGRAM = nvramtool
Stefan Reinauer6540ae52007-07-12 16:35:42 +000022
Stefan Reinauera67aab72008-09-27 10:08:28 +000023CC = gcc
24STRIP = strip
25INSTALL = /usr/bin/install
26PREFIX = /usr/local
Patrick Georgi44a89b32012-05-01 12:10:45 +020027CFLAGS = -O2 -g -Wall -W -I. -DCMOS_HAL=1
Stefan Reinauera67aab72008-09-27 10:08:28 +000028#CFLAGS = -Os -Wall
Stefan Reinauer6540ae52007-07-12 16:35:42 +000029
Patrick Georgic6d2b092011-01-28 07:47:10 +000030CLI_OBJS = cli/nvramtool.o cli/opts.o
31
Stefan Reinauera67aab72008-09-27 10:08:28 +000032OBJS = cmos_lowlevel.o cmos_ops.o common.o compute_ip_checksum.o \
Vikram Narayanana8111cf2012-04-14 15:25:13 +053033 hexdump.o input_file.o layout.o accessors/layout-common.o accessors/layout-text.o accessors/layout-bin.o lbtable.o \
Patrick Georgi1e916e02011-01-28 07:54:11 +000034 reg_expr.o cbfs.o accessors/cmos-hw-unix.o accessors/cmos-mem.o
Patrick Georgic6d2b092011-01-28 07:47:10 +000035
36OBJS += $(CLI_OBJS)
Stefan Reinauer6540ae52007-07-12 16:35:42 +000037
Stefan Reinauer4db6cbd2009-09-01 09:54:21 +000038OS_ARCH = $(shell uname)
39ifeq ($(OS_ARCH), Darwin)
Stefan Reinauercff573d2011-03-18 22:08:39 +000040LDFLAGS = -framework DirectHW
Stefan Reinauer4db6cbd2009-09-01 09:54:21 +000041endif
jakllschb0c94a12011-02-08 16:07:49 +000042ifeq ($(OS_ARCH), NetBSD)
43LDFLAGS = -l$(shell uname -p)
44endif
Zheng Baob13e94c2012-09-28 16:02:35 +080045ifeq ($(shell uname -o 2>/dev/null), Cygwin)
Raymond Danksa2937142012-04-27 08:46:55 -060046LDFLAGS = -lioperm
47CFLAGS += -D__GLIBC__
48endif
Stefan Reinauer4db6cbd2009-09-01 09:54:21 +000049
Stefan Reinauera67aab72008-09-27 10:08:28 +000050all: dep $(PROGRAM)
Stefan Reinauer6540ae52007-07-12 16:35:42 +000051
Stefan Reinauera67aab72008-09-27 10:08:28 +000052$(PROGRAM): $(OBJS)
Rudolf Marek6e296652011-01-24 21:05:53 +000053 $(CC) -o $(PROGRAM) $(OBJS) $(LDFLAGS) $(CFLAGS)
Stefan Reinauera67aab72008-09-27 10:08:28 +000054 $(STRIP) $(STRIP_ARGS) $(PROGRAM)
Stefan Reinauer6540ae52007-07-12 16:35:42 +000055
56clean:
Patrick Georgic6d2b092011-01-28 07:47:10 +000057 rm -f $(PROGRAM) $(OBJS)
Stefan Reinauer6540ae52007-07-12 16:35:42 +000058
Stefan Reinauera67aab72008-09-27 10:08:28 +000059distclean: clean
60 rm -f .dependencies
61
62dep:
Yunlian Jiang063c7c52013-08-09 11:24:00 -070063 @$(CC) -MM -MG *.c > .dependencies
Stefan Reinauera67aab72008-09-27 10:08:28 +000064
65install: $(PROGRAM)
Stefan Reinauer4db6cbd2009-09-01 09:54:21 +000066 mkdir -p $(DESTDIR)$(PREFIX)/sbin
67 $(INSTALL) $(PROGRAM) $(DESTDIR)$(PREFIX)/sbin
68 mkdir -p $(DESTDIR)$(PREFIX)/share/man/man8
Lubomir Rintelba1f9aa2014-01-28 16:52:48 +000069 $(INSTALL) -p -m644 cli/$(PROGRAM).8 $(DESTDIR)$(PREFIX)/share/man/man8
Stefan Reinauera67aab72008-09-27 10:08:28 +000070
71.PHONY: all clean distclean dep
72
73-include .dependencies