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. 10# CC = gcc 11# CC = clang 12 13# LD = gcc 14# LD = clang 15 16EXECS = sg_sense_test sg_chk_asc sg_tst_nvme tst_sg_lib 17 18EXTRAS = 19 20MAN_PGS = 21MAN_PREF = man8 22 23OS_FLAGS = -DSG_LIB_FREEBSD -DHAVE_NVME 24EXTRA_FLAGS = $(OS_FLAGS) 25 26# For C++/clang testing 27## CC = gcc 28## CC = g++ 29## CC = clang 30## CC = clang++ 31 32# CFLAGS = -O2 -Wall -W $(EXTRA_FLAGS) -I ../include 33CFLAGS = -g -O2 -Wall -W $(EXTRA_FLAGS) -I ../include 34# CFLAGS = -g -O2 -Wall -W -pedantic -std=c99 $(EXTRA_FLAGS) -I ../include 35 36CFLAGS_PTHREADS = -D_REENTRANT 37 38# there is no rule to make the following in the parent directory, 39# it is assumed they are already built. 40D_FILES = ../lib/sg_lib.o ../lib/sg_lib_data.o ../lib/sg_cmds_basic.o ../lib/sg_pt_common.o ../lib/sg_pt_freebsd.o 41 42LDFLAGS = -lcam 43 44all: $(EXECS) 45 46extras: $(EXTRAS) 47 48 49depend dep: 50 for i in *.c; do $(CC) $(INCLUDES) $(CFLAGS) -M $$i; \ 51 done > .depend 52 53clean: 54 /bin/rm -f *.o $(EXECS) $(EXTRAS) core .depend 55 56sg_sense_test: sg_sense_test.o $(D_FILES) 57 $(CC) -o $@ $(LDFLAGS) $@.o $(D_FILES) 58 59# building sg_chk_asc depends on a prior successful make in ../lib 60sg_chk_asc: sg_chk_asc.o $(D_FILES) 61 $(CC) -o $@ $(LDFLAGS) $@.o $(D_FILES) 62 63sg_tst_nvme: sg_tst_nvme.o $(D_FILES) 64 $(CC) -o $@ $(LDFLAGS) $@.o $(D_FILES) 65 66tst_sg_lib: tst_sg_lib.o $(D_FILES) 67 $(CC) -o $@ $(LDFLAGS) $@.o $(D_FILES) 68 69install: $(EXECS) 70 install -d $(INSTDIR) 71 for name in $(EXECS) ; \ 72 do install -s -o root -g wheel -m 755 $$name $(INSTDIR); \ 73 done 74 install -d $(MANDIR)/$(MAN_PREF) 75 for mp in $(MAN_PGS); \ 76 do install -o root -g wheel -m 644 $$mp $(MANDIR)/$(MAN_PREF); \ 77 gzip -9f $(MANDIR)/$(MAN_PREF)/$$mp; \ 78 done 79 80uninstall: 81 dists="$(EXECS)"; \ 82 for name in $$dists; do \ 83 rm -f $(INSTDIR)/$$name; \ 84 done 85 for mp in $(MAN_PGS); do \ 86 rm -f $(MANDIR)/$(MAN_PREF)/$$mp.gz; \ 87 done 88 89# Linux uses GNU make and FreeBSD uses Berkely make. The following lines 90# only work in Linux. Possible solutions in FreeBSD: 91# a) use 'gmake'; b) comment out the next 3 lines, starting with 'ifeq' 92# c) build with 'make -f Makefile.freebsd' 93# In Linux one can install bmake (but that won't help here). 94# ifeq (.depend,$(wildcard .depend)) 95# include .depend 96# endif 97