Makefile 3.47 KB
Newer Older
1
#  Makefile for hexer version 1.0.0
2

3
#  Copyright (c) 1995,1996 Sascha Demetrio
4
#  Copyright (c) 2009 - 2011, 2014, 2015 Peter Pentchev
5

6 7 8 9 10
#  It might be helpful to read the `README'-file first.

#  -- Where? --
#  The following lines determine where the binaries and manual pages for
#  hexer are gonna live.
11 12 13
PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin
MANDIR ?= $(PREFIX)/man/man1
14 15 16 17 18

#  -- Which terminal library? --
#  (It's probably save to leave the following lines unchanged.)
#
#  Use the following two lines, if you want to use the termcap-library.
19 20
#LTERMLIB ?=
#LTERMCAP ?= -ltermcap
21 22
#
#  Uncomment these if you want to use curses.
23 24
LTERMLIB ?=
LTERMCAP ?= -lcurses
25 26 27
#
#  Uncomment the following two lines if you want to use the termlib code
#  supplied with the package (not recommended).
28 29
#LTERMLIB = termlib.o
#LTERMCAP =
30

31 32
CPPFLAGS_STD ?= -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 \
		-D_FILE_OFFSET_BITS=64
33

34 35
#  If you want to add some system specific defines, it's probably more
#  appropriate to put them into `config.h'.
36
CPPFLAGS += $(CPPFLAGS_STD) -DHEXER_VERSION=\"1.0.0.dev1\"
37 38

#  -- Which compiler? --
39 40 41
CC ?= cc
CFLAGS ?= -O
LDFLAGS ?=
42
LDLIBS = $(LTERMCAP) -lm
43 44 45
#
#  Uncomment the following lines if you want to use the GNU compiler.
#CC = gcc
46
#CFLAGS = -O6
47
#LDFALGS =
48
#LDLIBS = $(LTERMCAP)
49 50

#  -- Which installer? --
51 52 53
INSTALL ?= install
INSTALLBIN ?= $(INSTALL) -s
INSTALLMAN ?= $(INSTALL) -m 644
54 55 56 57 58 59
#
#  Uncomment these if you don't have an installer.
#INSTALL = cp
#INSTALLBIN = $(INSTALL)
#INSTALLMAN = $(INSTALL)

60 61
MKDIR ?= mkdir -p

62 63 64 65 66 67 68 69 70
###  It shouldn't be necessary to change anything below this line.

HEXER = hexer
MYC = myc

CTAGS = ctags -tawf tags

OBJECTS = buffer.o tio.o edit.o main.o hexer.o readline.o regex.o port.o \
          exh.o set.o map.o signal.o util.o commands.o helptext.o calc.o \
71
	  $(LTERMLIB)
72 73 74 75 76 77 78 79 80 81 82 83 84 85

all: config.check $(HEXER)

config.check:
	@{  if [ ! -f config.h ]; then \
	      echo '***' Please read the file README on how to configure and; \
	      echo '***' compile hexer.\  Thank you.; \
	      exit 1; \
	    fi; }

$(HEXER): $(OBJECTS)
	$(CC) $(LDFLAGS) -o $@ $(OBJECTS) $(LDLIBS)

$(MYC): calc.c
86
	$(CC) $(LDFLAGS) $(CPPFLAGS) $(CFLAGS) -DMYCALC=1 -o $@ calc.c -lm
87 88

bin2c: bin2c.c
89
	$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ bin2c.c
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113

helptext.c: help.txt bin2c
	./bin2c -n helptext -o $@ help.txt

tags: *.c *.h
	-@{ \
	  echo Creating tags...; \
	  rm -f tags; \
	  for i in *.c *.h; do \
            echo $(CTAGS) $$i; \
	    $(CTAGS) $$i; \
	  done; \
	}

dep: depend

depend: *.c *.h
	-rm -f Makefile~
	sed '/\#\#\# DO NOT DELETE THIS LINE \#\#\#/q' \
	  < Makefile > Makefile~
	-echo >> Makefile~
	-echo '#' Dependencies: >> Makefile~
	-echo >> Makefile~
	@{ for i in *.c; do \
114
	      if [ "$$i" != 'termlib.c' ]; then \
115 116
	      echo $(CC) -MM $(CPPFLAGS) $$i '>>' Makefile~; \
	      $(CC) -MM $(CPPFLAGS) $$i >> Makefile~; \
117
	      fi \
118 119 120 121 122 123
	    done; }
	-echo >> Makefile~
	mv -f Makefile~ Makefile
	-touch depend

clean:
124 125 126
	rm -f $(HEXER) $(MYC) gen_testfile $(OBJECTS) bin2c
	rm -f helptext.c TESTFILE
	rm -f tags core *.bak
127 128

distclean: clean
129
	rm -f *~
130 131
	sed '/\#\#\# DO NOT DELETE THIS LINE \#\#\#/q' \
	  < Makefile > Makefile~
132
	echo >> Makefile~
133
	mv -f Makefile~ Makefile
134
	rm -f depend
135 136

install: all
137
	$(MKDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(MANDIR)
138 139 140 141
	$(INSTALLBIN) $(HEXER) $(DESTDIR)$(BINDIR)
	$(INSTALLMAN) $(HEXER).1 $(DESTDIR)$(MANDIR)
	[ ! -f $(MYC) ] || $(INSTALLBIN) $(MYC) $(DESTDIR)$(BINDIR)
	[ ! -f $(MYC) ] || $(INSTALLMAN) $(MYC).1 $(DESTDIR)$(MANDIR)
142 143 144

### DO NOT DELETE THIS LINE ###