blob: b92addab891cd6211eaf047272dd16fb9b767b15 [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##
Stefan Reinauer6540ae52007-07-12 16:35:42 +000016
Stefan Reinauera67aab72008-09-27 10:08:28 +000017PROGRAM = nvramtool
Stefan Reinauer6540ae52007-07-12 16:35:42 +000018
Stefan Reinauera67aab72008-09-27 10:08:28 +000019CC = gcc
20STRIP = strip
21INSTALL = /usr/bin/install
22PREFIX = /usr/local
Patrick Georgi44a89b32012-05-01 12:10:45 +020023CFLAGS = -O2 -g -Wall -W -I. -DCMOS_HAL=1
Stefan Reinauera67aab72008-09-27 10:08:28 +000024#CFLAGS = -Os -Wall
Stefan Reinauer6540ae52007-07-12 16:35:42 +000025
Patrick Georgic6d2b092011-01-28 07:47:10 +000026CLI_OBJS = cli/nvramtool.o cli/opts.o
27
Stefan Reinauera67aab72008-09-27 10:08:28 +000028OBJS = cmos_lowlevel.o cmos_ops.o common.o compute_ip_checksum.o \
Vikram Narayanana8111cf2012-04-14 15:25:13 +053029 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 +000030 reg_expr.o cbfs.o accessors/cmos-hw-unix.o accessors/cmos-mem.o
Patrick Georgic6d2b092011-01-28 07:47:10 +000031
32OBJS += $(CLI_OBJS)
Stefan Reinauer6540ae52007-07-12 16:35:42 +000033
Stefan Reinauer4db6cbd2009-09-01 09:54:21 +000034OS_ARCH = $(shell uname)
35ifeq ($(OS_ARCH), Darwin)
Stefan Reinauercff573d2011-03-18 22:08:39 +000036LDFLAGS = -framework DirectHW
Stefan Reinauer4db6cbd2009-09-01 09:54:21 +000037endif
jakllschb0c94a12011-02-08 16:07:49 +000038ifeq ($(OS_ARCH), NetBSD)
39LDFLAGS = -l$(shell uname -p)
40endif
Zheng Baob13e94c2012-09-28 16:02:35 +080041ifeq ($(shell uname -o 2>/dev/null), Cygwin)
Raymond Danksa2937142012-04-27 08:46:55 -060042LDFLAGS = -lioperm
43CFLAGS += -D__GLIBC__
44endif
Stefan Reinauer4db6cbd2009-09-01 09:54:21 +000045
Stefan Reinauera67aab72008-09-27 10:08:28 +000046all: dep $(PROGRAM)
Stefan Reinauer6540ae52007-07-12 16:35:42 +000047
Stefan Reinauera67aab72008-09-27 10:08:28 +000048$(PROGRAM): $(OBJS)
Rudolf Marek6e296652011-01-24 21:05:53 +000049 $(CC) -o $(PROGRAM) $(OBJS) $(LDFLAGS) $(CFLAGS)
Stefan Reinauera67aab72008-09-27 10:08:28 +000050 $(STRIP) $(STRIP_ARGS) $(PROGRAM)
Stefan Reinauer6540ae52007-07-12 16:35:42 +000051
52clean:
Martin Roth0be83c02015-10-21 14:50:00 -060053 rm -f $(PROGRAM) $(OBJS) junit.xml
Stefan Reinauer6540ae52007-07-12 16:35:42 +000054
Stefan Reinauera67aab72008-09-27 10:08:28 +000055distclean: clean
56 rm -f .dependencies
57
58dep:
Yunlian Jiang063c7c52013-08-09 11:24:00 -070059 @$(CC) -MM -MG *.c > .dependencies
Stefan Reinauera67aab72008-09-27 10:08:28 +000060
61install: $(PROGRAM)
Stefan Reinauer4db6cbd2009-09-01 09:54:21 +000062 mkdir -p $(DESTDIR)$(PREFIX)/sbin
63 $(INSTALL) $(PROGRAM) $(DESTDIR)$(PREFIX)/sbin
64 mkdir -p $(DESTDIR)$(PREFIX)/share/man/man8
Lubomir Rintelba1f9aa2014-01-28 16:52:48 +000065 $(INSTALL) -p -m644 cli/$(PROGRAM).8 $(DESTDIR)$(PREFIX)/share/man/man8
Stefan Reinauera67aab72008-09-27 10:08:28 +000066
67.PHONY: all clean distclean dep
68
69-include .dependencies