Debian Codegraph @

GNUmakefile

raw
1 # Makefile for mg
2
3 # This Makefile has been written by Han Boetes
4 # <[email protected]> and is released in Public Domain.
5
6 # *sigh* Those debian folks are really tidy on their licenses.
7
8 name= mg
9
10 prefix= /usr/local
11 bindir= $(prefix)/bin
12 libdir= $(prefix)/lib
13 includedir= $(prefix)/include
14 mandir= $(prefix)/man
15
16 PKG_CONFIG= /usr/bin/pkg-config --silence-errors
17 INSTALL= /usr/bin/install
18 STRIP= /usr/bin/strip
19
20 UNAME:= $(shell uname)
21 ifeq ($(UNAME),FreeBSD)
22 BSD_CPPFLAGS:= -DHAVE_UTIL_H
23 BSD_LIBS:= -lutil
24 else
25 BSD_CPPFLAGS:= $(shell $(PKG_CONFIG) --cflags libbsd-overlay) -DHAVE_PTY_H
26 BSD_LIBS:= $(shell $(PKG_CONFIG) --libs libbsd-overlay) -lutil
27 endif
28
29 # Test if required libraries are installed. Rather bummer that they
30 # are also required to run make clean or uninstall. Oh well... Who
31 # does that?
32 ifeq ($(BSD_LIBS),)
33 $(error You probably need to install "libbsd-dev" or "libbsd-devel" or something like that.)
34 endif
35
36 CURSES_LIBS:= $(shell $(PKG_CONFIG) --libs ncurses)
37 ifeq ($(CURSES_LIBS),)
38 $(error You probably need to install "libncurses5-dev" or "libncurses6-devel" or something like that.)
39 endif
40
41 ifdef STATIC
42 LDFLAGS=-static -static-libgcc
43 endif
44
45 CC?= gcc
46 CFLAGS?= -O2 -pipe
47 CFLAGS+= -g -Wall
48 CPPFLAGS= -DREGEX
49 CPPFLAGS+= -D_GNU_SOURCE
50 CPPFLAGS+= $(BSD_CPPFLAGS)
51 LIBS= $(CURSES_LIBS) $(BSD_LIBS)
52
53
54 OBJS= autoexec.o basic.o bell.o buffer.o cinfo.o dir.o display.o \
55 echo.o extend.o file.o fileio.o funmap.o interpreter.o help.o \
56 kbd.o keymap.o line.o macro.o main.o match.o modes.o paragraph.o \
57 re_search.o region.o search.o spawn.o tty.o ttyio.o ttykbd.o \
58 undo.o util.o version.o window.o word.o yank.o
59 OBJS+= cmode.o cscope.o dired.o grep.o tags.o
60
61
62 # Portability stuff.
63 CFLAGS+= -Wno-strict-aliasing -Wno-deprecated-declarations
64 EXE_EXT=
65
66 .c.o:
67 $(CC) $(CFLAGS) $(CPPFLAGS) -c $<
68
69 all: $(name)
70
71 $(name): $(OBJS)
72 $(CC) $(LDFLAGS) $(OBJS) -o $(name) $(LIBS)
73
74 distclean: clean
75 -rm -f *.core core.* .#*
76
77 clean:
78 -rm -f *.o $(name)$(EXE_EXT)
79
80
81 install: $(name) $(name).1
82 $(INSTALL) -d $(DESTDIR)$(bindir)
83 $(INSTALL) -d $(DESTDIR)$(mandir)/man1
84 $(INSTALL) -m 755 $(name) $(DESTDIR)$(bindir)/$(name)
85 $(INSTALL) -m 444 $(name).1 $(DESTDIR)$(mandir)/man1/$(name).1
86
87 install-strip: install
88 $(STRIP) $(DESTDIR)$(bindir)/$(name)
89
90 uninstall:
91 rm -f \
92 $(DESTDIR)$(bindir)/$(name)$(EXE_EXT) \
93 $(DESTDIR)$(mandir)/man1/$(name).1
94
95 rebuild:
96 make clean all