1 # Makefile for hdparm 2 3 # DESTDIR is for non root installs (eg packages, NFS) only! 4 DESTDIR = 5 6 binprefix = 7 manprefix = /usr 8 exec_prefix = $(binprefix)/ 9 sbindir = $(exec_prefix)sbin 10 mandir = $(manprefix)/share/man 11 oldmandir = $(manprefix)/man 12 13 CC ?= gcc 14 STRIP ?= strip 15 16 CFLAGS := -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 18 INSTALL = install 19 INSTALL_DATA = $(INSTALL) -m 644 20 INSTALL_DIR = $(INSTALL) -m 755 -d 21 INSTALL_PROGRAM = $(INSTALL) 22 23 OBJS = hdparm.o identify.o sgio.o sysfs.o geom.o fallocate.o fibmap.o fwdownload.o dvdspeed.o wdidle3.o apt.o 24 25 all: 26 $(MAKE) -j4 hdparm 27 28 static: 29 LDFLAGS=-static $(MAKE) 30 31 hdparm: Makefile hdparm.h sgio.h $(OBJS) 32 $(CC) $(LDFLAGS) -o hdparm $(OBJS) 33 $(STRIP) hdparm 34 35 hdparm.o: hdparm.h sgio.h 36 37 identify.o: hdparm.h 38 39 dvdspeed.o: dvdspeed.c 40 41 sgio.o: sgio.c sgio.h hdparm.h 42 43 fwdownload.o: fwdownload.c sgio.h hdparm.h 44 45 apt.o: apt.c 46 47 install: all hdparm.8 48 if [ ! -z $(DESTDIR) ]; then $(INSTALL_DIR) $(DESTDIR) ; fi 49 if [ ! -z $(DESTDIR)$(sbindir) ]; then $(INSTALL_DIR) $(DESTDIR)$(sbindir) ; fi 50 if [ ! -z $(DESTDIR)$(mandir) ]; then $(INSTALL_DIR) $(DESTDIR)$(mandir) ; fi 51 if [ ! -z $(DESTDIR)$(mandir)/man8/ ]; then $(INSTALL_DIR) $(DESTDIR)$(mandir)/man8/ ; fi 52 if [ -f $(DESTDIR)$(sbindir)/hdparm ]; then rm -f $(DESTDIR)$(sbindir)/hdparm ; fi 53 if [ -f $(DESTDIR)$(mandir)/man8/hdparm.8 ]; then rm -f $(DESTDIR)$(mandir)/man8/hdparm.8 ;\ 54 elif [ -f $(DESTDIR)$(oldmandir)/man8/hdparm.8 ]; then rm -f $(DESTDIR)$(oldmandir)/man8/hdparm.8 ; fi 55 $(INSTALL_PROGRAM) -D hdparm $(DESTDIR)$(sbindir)/hdparm 56 if [ -d $(DESTDIR)$(mandir) ]; then $(INSTALL_DATA) -D hdparm.8 $(DESTDIR)$(mandir)/man8/hdparm.8 ;\ 57 elif [ -d $(DESTDIR)$(oldmandir) ]; then $(INSTALL_DATA) -D hdparm.8 $(DESTDIR)$(oldmandir)/man8/hdparm.8 ; fi 58 59 clean: 60 -rm -f hdparm $(OBJS) core 2>/dev/null 61