File: Makefile

package info (click to toggle)
hexer 1.0.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 864 kB
  • sloc: ansic: 11,408; python: 290; makefile: 120; sh: 8
file content (165 lines) | stat: -rw-r--r-- 4,190 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#  Makefile for hexer version 1.0.7

#  SPDX-FileCopyrightText: 1995,1996 Sascha Demetrio
#  SPDX-FileCopyrightText: 2009 - 2011, 2014 - 2016, 2018, 2020 Peter Pentchev
#  SPDX-License-Identifier: BSD-3-Clause

#  It might be helpful to read the `README'-file first.

#  -- Where? --
#  The following lines determine where the binaries and manual pages for
#  hexer are going to live.
PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin
MANDIR ?= $(PREFIX)/man/man1
DOCSDIR ?= $(PREFIX)/share/doc/hexer

#  -- Which terminal library? --
#  (It's probably save to leave the following lines unchanged.)
#
#  Use the following line if you want to use the termcap library.
#LTERMCAP ?= -ltermcap
#
#  ...or this one if you want to use curses.
LTERMCAP ?= -lcurses

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

# Tell the compiler that hexer uses C99 language features.
# This is a GCC-specific option; adjust it for the compiler used if needed.
CFLAGS_STD ?=	-std=c99

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

#  -- Which compiler? --
CC ?= cc
CC_FOR_BUILD ?= $(CC)
CFLAGS ?= -O
CFLAGS += ${CFLAGS_STD}
LDFLAGS ?=
LDLIBS = $(LTERMCAP) -lm
#
#  Uncomment the following lines if you want to use the GNU compiler.
#CC = gcc
#CFLAGS = -O6
#LDFALGS =
#LDLIBS = $(LTERMCAP)

#  -- Which installer? --
INSTALL ?= install
INSTALLBIN ?= $(INSTALL) -s
INSTALLMAN ?= $(INSTALL) -m 644
#
#  Uncomment these if you don't have an installer.
#INSTALL = cp
#INSTALLBIN = $(INSTALL)
#INSTALLMAN = $(INSTALL)

MKDIR ?= mkdir -p

###  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 \
          exh.o set.o map.o signal.o util.o commands.o helptext.o calc.o

all: $(HEXER)

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

$(MYC): calc.c config.h
	$(CC) $(LDFLAGS) $(CPPFLAGS) $(CFLAGS) -DMYCALC=1 -o $@ calc.c -lm

bin2c: bin2c.c
	$(CC_FOR_BUILD) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ bin2c.c

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

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

%.o:	%.c config.h
	$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<

config.h:
	[ ! -e config.h.auto ] || rm config.h.auto
	echo "/* Autogenerated by Makefile and config-test.c */" > config.h.auto
	for item in \
		SIGTYPE_INT	\
		ALLOCA_H	\
		VASPRINTF	\
	    ; do \
		echo "Testing for $$item"; \
		if $(CC) $(CPPFLAGS) $(CFLAGS) -D"TEST_$$item" -c -o config-test.o -Werror config-test.c; then \
			value=1; \
		else \
			value=0; \
		fi; \
		echo "- result: $$value"; \
		printf "\\n#define HAVE_%s\\t%d\\n" "$$item" "$$value" >> config.h.auto; \
	done
	
	[ ! -e config.h ] || rm config.h
	mv config.h.auto config.h

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 config.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 \
	      echo $(CC) -MM $(CPPFLAGS) $$i '>>' Makefile~; \
	      $(CC) -MM $(CPPFLAGS) $$i >> Makefile~; \
	    done; }
	-echo >> Makefile~
	mv -f Makefile~ Makefile
	-touch depend

clean:
	rm -f $(HEXER) $(MYC) gen_testfile $(OBJECTS) bin2c
	rm -f config-test.o
	rm -f config.h
	rm -f helptext.c TESTFILE
	rm -f tags core *.bak

distclean: clean
	rm -f *~
	sed '/\#\#\# DO NOT DELETE THIS LINE \#\#\#/q' \
	  < Makefile > Makefile~
	echo >> Makefile~
	mv -f Makefile~ Makefile
	rm -f depend

install: all
	$(MKDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(MANDIR) $(DESTDIR)$(DOCSDIR)/md
	$(INSTALLBIN) $(HEXER) $(DESTDIR)$(BINDIR)
	$(INSTALLMAN) $(HEXER).1 $(DESTDIR)$(MANDIR)
	$(INSTALLMAN) docs/*.md $(DESTDIR)$(DOCSDIR)/md
	[ ! -f $(MYC) ] || $(INSTALLBIN) $(MYC) $(DESTDIR)$(BINDIR)
	[ ! -f $(MYC) ] || $(INSTALLMAN) $(MYC).1 $(DESTDIR)$(MANDIR)

### DO NOT DELETE THIS LINE ###