xref: /aosp_15_r20/external/sg3_utils/testing/Makefile.cyg (revision 44704f698541f6367e81f991ef8bb54ccbf3fc18)
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
16EXECS = sg_sense_test sg_chk_asc sg_tst_nvme tst_sg_lib
17
18EXTRAS =
19
20BSG_EXTRAS =
21
22
23MAN_PGS =
24MAN_PREF = man8
25
26LARGE_FILE_FLAGS = -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
27
28# For C++/clang testing
29## CC = gcc
30## CC = g++
31## CC = clang
32## CC = clang++
33
34CPPFLAGS = -iquote ../include -iquote .. -D_REENTRANT $(LARGE_FILE_FLAGS) -DHAVE_CONFIG_H -DHAVE_NVME
35CFLAGS = -g -O2 -W -Wall
36# CFLAGS = -g -O2 -Wall -DSG_KERNEL_INCLUDES
37# CFLAGS = -g -O2 -Wall -pedantic
38# CFLAGS = -Wall -W -pedantic -std=c11 --analyze
39# CFLAGS = -Wall -W -pedantic -std=c++14 -fPIC
40
41LDFLAGS =
42
43LIBFILESOLD = ../lib/sg_lib.o ../lib/sg_lib_data.o
44LIBFILESNEW = ../lib/sg_lib.o ../lib/sg_lib_data.o \
45		../lib/sg_pt_win32.o ../lib/sg_pt_common.o  ../lib/sg_cmds_basic.o
46
47all: $(EXECS)
48
49extras: $(EXTRAS)
50
51bsg: $(BSG_EXTRAS)
52
53
54depend dep:
55	for i in *.c; do $(CC) $(INCLUDES) $(CFLAGS) -M $$i; \
56	done > .depend
57
58clean:
59	/bin/rm -f *.o $(EXECS) $(EXTRAS) $(BSG_EXTRAS) core .depend
60
61sg_iovec_tst: sg_iovec_tst.o $(LIBFILESOLD)
62	$(LD) -o $@ $(LDFLAGS) $^
63
64sg_sense_test: sg_sense_test.o $(LIBFILESOLD)
65	$(LD) -o $@ $(LDFLAGS) $^
66
67sg_queue_tst: sg_queue_tst.o $(LIBFILESOLD)
68	$(LD) -o $@ $(LDFLAGS) $^
69
70bsg_queue_tst: bsg_queue_tst.o $(LIBFILESOLD)
71	$(LD) -o $@ $(LDFLAGS) $^
72
73# building sg_chk_asc depends on a prior successful make in ../lib
74sg_chk_asc: sg_chk_asc.o ../lib/sg_lib.o ../lib/sg_lib_data.o
75	$(LD) -o $@ $(LDFLAGS) $^
76
77sg_tst_nvme: sg_tst_nvme.o $(LIBFILESNEW)
78	$(LD) -o $@ $(LDFLAGS) $^
79
80tst_sg_lib: tst_sg_lib.o ../lib/sg_lib.o ../lib/sg_lib_data.o
81	$(LD) -o $@ $(LDFLAGS) $^
82
83install: $(EXECS)
84	install -d $(INSTDIR)
85	for name in $^; \
86	 do install -s -o root -g root -m 755 $$name $(INSTDIR); \
87	done
88	install -d $(MANDIR)/$(MAN_PREF)
89	for mp in $(MAN_PGS); \
90	 do install -o root -g root -m 644 $$mp $(MANDIR)/$(MAN_PREF); \
91	 gzip -9f $(MANDIR)/$(MAN_PREF)/$$mp; \
92	done
93
94uninstall:
95	dists="$(EXECS)"; \
96	for name in $$dists; do \
97	 rm -f $(INSTDIR)/$$name; \
98	done
99	for mp in $(MAN_PGS); do \
100	 rm -f $(MANDIR)/$(MAN_PREF)/$$mp.gz; \
101	done
102
103# Linux uses GNU make and FreeBSD uses Berkely make. The following lines
104# only work in Linux. Possible solutions in FreeBSD:
105#    a) use 'gmake'; b) comment out the next 3 lines, starting with 'ifeq'
106#        c) build with 'make -f Makefile.freebsd'
107# In Linux one can install bmake (but that won't help here).
108ifeq (.depend,$(wildcard .depend))
109include .depend
110endif
111