blob: 75120528ef5482c6f3dab5a073c63e5c8aa65142 [file] [log] [blame] [raw]
# Makefile for portable mfiutil
# Copyright 2015-2024 Rivoreo
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
# IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
CC := gcc
#CC := gcc-4.3.2-gld
INSTALL ?= install
CFLAGS += -std=gnu99 -Wall -Wno-unused-value -Os
CFLAGS += -I include
#CFLAGS += -D DEBUG=1
# For Solaris only
#CFLAGS += -D HAVE_LIBDEVINFO=1
#LIBS += -l devinfo
# Required for BSD make
CFLAGS += $(CPPFLAGS)
PREFIX ?= /usr/local
SBINDIR ?= $(PREFIX)/sbin
DATADIR ?= $(PREFIX)/share
MANDIR ?= $(DATADIR)/man
PROG := mfiutil
MANPAGE := mfiutil.8
SRCS:= mfiutil.c mfi_bbu.c mfi_cmd.c mfi_config.c mfi_drive.c mfi_evt.c \
mfi_flash.c mfi_patrol.c mfi_show.c mfi_volume.c mfi_foreign.c \
mfi_properties.c human_readable.c
OBJECTS = $(addsuffix .o,$(basename $(SRCS))) ${SRCS:R:S/$/.o/g}
default: $(PROG)
$(PROG): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) -o $@ $(LIBS)
clean:
rm -f $(OBJECTS) $(PROG)
install: $(PROG) $(MANPAGE)
[ -d "$(DESTDIR)$(SBINDIR)" ] || mkdir -p "$(DESTDIR)$(SBINDIR)"
[ -d "$(DESTDIR)$(MANDIR)/man8" ] || mkdir -p "$(DESTDIR)$(MANDIR)/man8"
$(INSTALL) -m 755 $(PROG) "$(DESTDIR)$(SBINDIR)/"
$(INSTALL) -m 644 $(MANPAGE) "$(DESTDIR)$(MANDIR)/man8/"
.PHONY: default clean install