1# Makefile for hdparm
2
3# DESTDIR is for non root installs (eg packages, NFS) only!
4DESTDIR = $(TARGETDIR)
5
6binprefix = 
7manprefix = /usr
8exec_prefix = $(binprefix)/
9sbindir = $(exec_prefix)sbin
10mandir = $(manprefix)/share/man
11oldmandir = $(manprefix)/man
12
13CC ?= gcc
14STRIP ?= strip
15
16CFLAGS := -O2 -W -Wall -Wbad-function-cast -Wcast-align -Wpointer-arith -Wcast-qual -Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -fkeep-inline-functions -Wwrite-strings -Waggregate-return -Wnested-externs -Wtrigraphs $(CFLAGS)
17
18LDFLAGS = -s
19#LDFLAGS = -s -static
20INSTALL = install
21INSTALL_DATA = $(INSTALL) -m 644
22INSTALL_DIR = $(INSTALL) -m 755 -d
23INSTALL_PROGRAM = $(INSTALL)
24
25OBJS = hdparm.o identify.o sgio.o sysfs.o geom.o fallocate.o fibmap.o fwdownload.o dvdspeed.o wdidle3.o
26
27all: hdparm
28
29hdparm: hdparm.h sgio.h $(OBJS)
30	$(CC) $(LDFLAGS) -o hdparm $(OBJS)
31	$(STRIP) hdparm
32
33hdparm.o:	hdparm.h sgio.h
34
35identify.o:	hdparm.h
36
37dvdspeed.o:     dvdspeed.c
38
39sgio.o: sgio.c sgio.h hdparm.h
40
41fwdownload.o: fwdownload.c sgio.h hdparm.h
42
43install: all hdparm.8
44	if [ ! -z $(DESTDIR) ]; then $(INSTALL_DIR) $(DESTDIR) ; fi
45	if [ ! -z $(DESTDIR)$(sbindir) ]; then $(INSTALL_DIR) $(DESTDIR)$(sbindir) ; fi
46#if [ ! -z $(DESTDIR)$(mandir) ]; then $(INSTALL_DIR) $(DESTDIR)$(mandir) ; fi
47#	if [ ! -z $(DESTDIR)$(mandir)/man8/ ]; then $(INSTALL_DIR) $(DESTDIR)$(mandir)/man8/ ; fi
48	if [ -f $(DESTDIR)$(sbindir)/hdparm ]; then rm -f $(DESTDIR)$(sbindir)/hdparm ; fi
49#	if [ -f $(DESTDIR)$(mandir)/man8/hdparm.8 ]; then rm -f $(DESTDIR)$(mandir)/man8/hdparm.8 ;\
50	elif [ -f $(DESTDIR)$(oldmandir)/man8/hdparm.8 ]; then rm -f $(DESTDIR)$(oldmandir)/man8/hdparm.8 ; fi
51	$(INSTALL_PROGRAM) -D hdparm $(DESTDIR)$(sbindir)/hdparm
52#	if [ -d $(DESTDIR)$(mandir) ]; then $(INSTALL_DATA) -D hdparm.8 $(DESTDIR)$(mandir)/man8/hdparm.8 ;\
53	elif [ -d $(DESTDIR)$(oldmandir) ]; then $(INSTALL_DATA) -D hdparm.8 $(DESTDIR)$(oldmandir)/man8/hdparm.8 ; fi
54
55clean:
56	-rm -f hdparm $(OBJS) core 2>/dev/null
57
58