File: Makefile

package info (click to toggle)
shhmsg 1.4.2-1
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 208 kB
  • ctags: 133
  • sloc: ansic: 319; makefile: 301; sh: 20
file content (107 lines) | stat: -rw-r--r-- 2,346 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
DIST		= shhmsg
VERMAJ		= 1
VERMIN		= 4
VERPAT		= 2
VERSION		= $(VERMAJ).$(VERMIN).$(VERPAT)

# Define SHARED as 1 for Linux shared ELF library
#SHARED		= 0

ifeq ($(SHARED),1)
LIBTARGET	= lib$(DIST).so.$(VERSION)
LIBTARGETSO	= lib$(DIST).so
LIBTARGETSOMAJ	= $(LIBTARGETSO).$(VERMAJ)
CCSHRD		= -fPIC
else
LIBTARGET	= lib$(DIST).a
endif

LIBHEAD		= $(DIST).h
TARGETS		= $(LIBTARGET)

INSTBASEDIR	= /usr/local
INSTLIBDIR	= $(INSTBASEDIR)/lib
INSTINCDIR	= $(INSTBASEDIR)/include
INSTALL		= install -m 644
INSTALLPROG	= install -m 755
MKDIRP		= install -d -m 755

CC		= gcc

INCDIR		= -I.

CCOPT		= -s -Wall -Werror=format-security $(CFLAGS) $(CPPFLAGS) $(INCDIR) -DHAVE_STRERROR -D_REENTRANT

# Object files to store in the library
LIBOBJS		= vars.o streams.o progname.o \
		  errno.o error.o fatal.o message.o verbose.o


all: $(TARGETS)

$(LIBTARGET): $(LIBOBJS)
ifeq ($(SHARED),1)
	$(CC) -shared -Wl,-soname,$(LIBTARGETSOMAJ) -o $(LIBTARGET) $(LIBOBJS) $(LDFLAGS)
else
	ar rcs $(LIBTARGET) $(LIBOBJS)
endif

.c.o:
	$(CC) $(CCSHRD) -o $@ -c $(CCOPT) $<

depend dep:
	$(CC) $(INCDIR) -MM *.c >depend

install: $(LIBTARGET)
	$(MKDIRP) $(INSTLIBDIR) $(INSTINCDIR)
	$(INSTALL) $(LIBTARGET) $(INSTLIBDIR)
	$(INSTALL) $(LIBHEAD) $(INSTINCDIR)
ifeq ($(SHARED),1)
	ln -sf $(LIBTARGET) $(INSTLIBDIR)/$(LIBTARGETSOMAJ)
	ln -sf $(LIBTARGETSOMAJ) $(INSTLIBDIR)/$(LIBTARGETSO)
	echo "Now run ldconfig if necessary."
endif

clean:
	rm -f *.o core *~ depend

chmod:
	chmod a+r *

# To let the author make a distribution. The rest of the Makefile
# should be used by the author only.
LSMFILE		= $(DIST)-$(VERSION).lsm
DISTDIR		= $(DIST)-$(VERSION)
DISTFILE	= $(DIST)-$(VERSION).tar.gz
DISTFILES	= README INSTALL shhmsg.txt CREDITS ChangeLog \
		  Makefile $(LSMFILE) \
		  $(LIBHEAD) \
		  internal.h \
		  errno.c \
		  error.c \
		  fatal.c \
		  message.c \
		  progname.c \
		  streams.c \
		  vars.c \
		  verbose.c

$(LSMFILE): $(DIST).lsm.in
	VER=$(VERSION); \
	DATE=`date "+%d%b%y"|tr '[a-z]' '[A-Z]'`; \
	sed -e "s/VER/$$VER/g;s/DATE/$$DATE/g" $(DIST).lsm.in > $(LSMFILE)

veryclean: clean
	rm -f $(TARGETS) $(DISTFILE) $(LSMFILE)

dist: $(LSMFILE) chmod
	mkdir $(DISTDIR)
	chmod a+rx $(DISTDIR)
	ln $(DISTFILES) $(DISTDIR)
	tar -cvzf $(DISTFILE) $(DISTDIR)
	chmod a+r $(DISTFILE)
	rm -rf $(DISTDIR)

ifeq (depend,$(wildcard depend))
include depend
endif