File: GNUmakefile

package info (click to toggle)
mg 20161005-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 700 kB
  • ctags: 973
  • sloc: ansic: 14,256; makefile: 24; sh: 7
file content (93 lines) | stat: -rw-r--r-- 2,316 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
# Makefile for mg

# This Makefile has been written by Han Boetes
# <hboetes@gmail.com> and is released in Public Domain.

# *sigh* Those debian folks are really tidy on their licenses.

name=		mg

prefix=		/usr/local
bindir=		$(prefix)/bin
libdir=		$(prefix)/lib
includedir=	$(prefix)/include
mandir=		$(prefix)/man

PKG_CONFIG=	/usr/bin/pkg-config --silence-errors
INSTALL=	/usr/bin/install
STRIP=		/usr/bin/strip

UNAME:=		$(shell uname)
ifeq ($(UNAME),FreeBSD)
  BSD_CPPFLAGS:=
  BSD_LIBS:=	-lutil
else
  BSD_CPPFLAGS:= $(shell $(PKG_CONFIG) --cflags libbsd-overlay)
  BSD_LIBS:=	 $(shell $(PKG_CONFIG) --libs libbsd-overlay)
endif

# Test is some required libraries are installed. Rather bummer that
# they are also required to run make clean or uninstall. Oh well... Who
# does that?
ifeq ($(BSD_LIBS),)
  $(error You probably need to install "libbsd-dev" or "libbsd-devel" or something like that.)
endif

CURSES_LIBS:= $(shell $(PKG_CONFIG) --libs ncurses)
ifeq ($(CURSES_LIBS),)
  $(error You probably need to install "libncurses5-dev" or "libnnurses6-devel" or something like that.)
endif

CC?=		gcc
CFLAGS?=	-O2 -pipe
CFLAGS+=	-g -Wall
CPPFLAGS+=	-DREGEX
CPPFLAGS+=	-D_GNU_SOURCE
CPPFLAGS+=	$(BSD_CPPFLAGS) -D__dead=__dead2
LIBS=		$(CURSES_LIBS) $(BSD_LIBS)


OBJS=	autoexec.o basic.o bell.o buffer.o cinfo.o dir.o display.o \
	echo.o extend.o file.o fileio.o funmap.o help.o kbd.o keymap.o \
	line.o macro.o main.o match.o modes.o paragraph.o \
	re_search.o region.o search.o spawn.o tty.o ttyio.o ttykbd.o \
	undo.o util.o version.o window.o word.o yank.o
OBJS+=	cmode.o cscope.o dired.o grep.o tags.o


# Portability stuff.
CFLAGS+= 	 -Wno-strict-aliasing -Wno-deprecated-declarations
EXE_EXT=

.c.o:
	$(CC) $(CFLAGS) $(CPPFLAGS) -c $<

all: $(name)


$(name): $(OBJS)
	$(CC) $(LDFLAGS) $(OBJS) -o $(name) $(LIBS)

distclean: clean
	-rm -f *.core core.*

clean:
	-rm -f *.o $(name)$(EXE_EXT)


install: $(name) $(name).1
	$(INSTALL) -d $(DESTDIR)$(bindir)
	$(INSTALL) -d $(DESTDIR)$(mandir)/man1
	$(INSTALL) -m 755 $(name)		$(DESTDIR)$(bindir)/$(name)
	$(INSTALL) -m 444 $(name).1		$(DESTDIR)$(mandir)/man1/$(name).1

install-strip: install
	$(STRIP) $(DESTDIR)$(bindir)/$(name)

uninstall:
	rm -f \
	$(DESTDIR)$(bindir)/$(name)$(EXE_EXT) \
	$(DESTDIR)$(mandir)/man1/$(name).1

rebuild:
	make clean all