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