1SHELL = /bin/sh 2 3PREFIX=/usr/local 4INSTDIR=$(DESTDIR)/$(PREFIX)/bin 5MANDIR=$(DESTDIR)/$(PREFIX)/man 6 7# In Linux the default C compiler is GCC while in FreeBSD (since release 10 ?) 8# the default C compiler is clang. Swap the comment marks (lines starting 9# with '#') on the next 4 (non-blank) lines. 10CC = gcc 11# CC = clang 12 13LD = gcc 14# LD = clang 15 16 17EXECS = sg_simple1 sg_simple2 sg_simple3 sg_simple4 sg_simple16 \ 18 scsi_inquiry sg_excl sg_simple5 sg__sat_identify \ 19 sg__sat_phy_event sg__sat_set_features sg_sat_chk_power \ 20 sg_sat_smart_rd_data 21 22EXTRAS = sgq_dd 23 24BSG_EXTRAS = 25 26 27MAN_PGS = 28MAN_PREF = man8 29 30LARGE_FILE_FLAGS = -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 31 32CPPFLAGS = -iquote ../include -D_REENTRANT $(LARGE_FILE_FLAGS) 33# CPPFLAGS = -iquote ../include -D_REENTRANT $(LARGE_FILE_FLAGS) -DDEBUG 34 35CFLAGS = -g -O2 -W -Wall 36# CFLAGS = -g -O2 -Wall -DSG_KERNEL_INCLUDES 37# CFLAGS = -g -O2 -Wall -pedantic 38 39LDFLAGS = 40 41LIBFILESOLD = ../lib/sg_lib.o ../lib/sg_lib_data.o ../lib/sg_io_linux.o 42LIBFILESNEW = ../lib/sg_lib.o ../lib/sg_lib_data.o ../lib/sg_pt_common.o ../lib/sg_pt_linux.o ../lib/sg_pt_linux_nvme.o 43 44all: $(EXECS) 45 46extras: $(EXTRAS) 47 48bsg: $(BSG_EXTRAS) 49 50 51depend dep: 52 for i in *.c; do $(CC) $(INCLUDES) $(CFLAGS) -M $$i; \ 53 done > .depend 54 55clean: 56 /bin/rm -f *.o $(EXECS) $(EXTRAS) $(BSG_EXTRAS) core .depend 57 58sg_simple1: sg_simple1.o $(LIBFILESOLD) 59 $(LD) -o $@ $(LDFLAGS) $^ 60 61sg_simple2: sg_simple2.o 62 $(LD) -o $@ $(LDFLAGS) $^ 63 64sg_simple3: sg_simple3.o $(LIBFILESOLD) 65 $(LD) -o $@ $(LDFLAGS) $^ 66 67sg_simple4: sg_simple4.o $(LIBFILESOLD) 68 $(LD) -o $@ $(LDFLAGS) $^ 69 70sg_simple16: sg_simple16.o $(LIBFILESOLD) 71 $(LD) -o $@ $(LDFLAGS) $^ 72 73scsi_inquiry: scsi_inquiry.o 74 $(LD) -o $@ $(LDFLAGS) $^ 75 76sg_excl: sg_excl.o $(LIBFILESOLD) 77 $(LD) -o $@ $(LDFLAGS) $^ 78 79sg_simple5: sg_simple5.o $(LIBFILESNEW) 80 $(LD) -o $@ $(LDFLAGS) $^ 81 82sg__sat_identify: sg__sat_identify.o $(LIBFILESOLD) 83 $(LD) -o $@ $(LDFLAGS) $^ 84 85sg__sat_phy_event: sg__sat_phy_event.o $(LIBFILESOLD) 86 $(LD) -o $@ $(LDFLAGS) $^ 87 88sg__sat_set_features: sg__sat_set_features.o $(LIBFILESOLD) 89 $(LD) -o $@ $(LDFLAGS) $^ 90 91sg_sat_chk_power: sg_sat_chk_power.o $(LIBFILESOLD) 92 $(LD) -o $@ $(LDFLAGS) $^ 93 94sg_sat_smart_rd_data: sg_sat_smart_rd_data.o $(LIBFILESOLD) 95 $(LD) -o $@ $(LDFLAGS) $^ 96 97sgq_dd: sgq_dd.o $(LIBFILESOLD) 98 $(LD) -o $@ $(LDFLAGS) $^ 99 100install: $(EXECS) 101 install -d $(INSTDIR) 102 for name in $^; \ 103 do install -s -o root -g root -m 755 $$name $(INSTDIR); \ 104 done 105 install -d $(MANDIR)/$(MAN_PREF) 106 for mp in $(MAN_PGS); \ 107 do install -o root -g root -m 644 $$mp $(MANDIR)/$(MAN_PREF); \ 108 gzip -9f $(MANDIR)/$(MAN_PREF)/$$mp; \ 109 done 110 111uninstall: 112 dists="$(EXECS)"; \ 113 for name in $$dists; do \ 114 rm -f $(INSTDIR)/$$name; \ 115 done 116 for mp in $(MAN_PGS); do \ 117 rm -f $(MANDIR)/$(MAN_PREF)/$$mp.gz; \ 118 done 119 120# Linux uses GNU make and FreeBSD uses Berkely make. The following lines 121# only work in Linux. Possible solutions in FreeBSD: 122# a) use 'gmake'; b) comment out the next 3 lines, starting with 'ifeq' 123# c) build with 'make -f Makefile.freebsd' 124# In Linux one can install bmake (but that won't help here). 125ifeq (.depend,$(wildcard .depend)) 126include .depend 127endif 128