Debian Codegraph @

Makefile

raw
1 # Makefile for hexer version 1.0.7
2
3 # SPDX-FileCopyrightText: 1995,1996 Sascha Demetrio
4 # SPDX-FileCopyrightText: 2009 - 2011, 2014 - 2016, 2018, 2020 Peter Pentchev
5 # SPDX-License-Identifier: BSD-3-Clause
6
7 # It might be helpful to read the `README'-file first.
8
9 # -- Where? --
10 # The following lines determine where the binaries and manual pages for
11 # hexer are going to live.
12 PREFIX ?= /usr/local
13 BINDIR ?= $(PREFIX)/bin
14 MANDIR ?= $(PREFIX)/man/man1
15 DOCSDIR ?= $(PREFIX)/share/doc/hexer
16
17 # -- Which terminal library? --
18 # (It's probably save to leave the following lines unchanged.)
19 #
20 # Use the following line if you want to use the termcap library.
21 #LTERMCAP ?= -ltermcap
22 #
23 # ...or this one if you want to use curses.
24 LTERMCAP ?= -lcurses
25
26 CPPFLAGS_STD ?= -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 \
27 -D_FILE_OFFSET_BITS=64
28
29 # Tell the compiler that hexer uses C99 language features.
30 # This is a GCC-specific option; adjust it for the compiler used if needed.
31 CFLAGS_STD ?= -std=c99
32
33 # If you want to add some system specific defines, it's probably more
34 # appropriate to put them into `config.h'.
35 CPPFLAGS += $(CPPFLAGS_STD) -DHEXER_VERSION=\"1.0.7\"
36
37 # -- Which compiler? --
38 CC ?= cc
39 CC_FOR_BUILD ?= $(CC)
40 CFLAGS ?= -O
41 CFLAGS += ${CFLAGS_STD}
42 LDFLAGS ?=
43 LDLIBS = $(LTERMCAP) -lm
44 #
45 # Uncomment the following lines if you want to use the GNU compiler.
46 #CC = gcc
47 #CFLAGS = -O6
48 #LDFALGS =
49 #LDLIBS = $(LTERMCAP)
50
51 # -- Which installer? --
52 INSTALL ?= install
53 INSTALLBIN ?= $(INSTALL) -s
54 INSTALLMAN ?= $(INSTALL) -m 644
55 #
56 # Uncomment these if you don't have an installer.
57 #INSTALL = cp
58 #INSTALLBIN = $(INSTALL)
59 #INSTALLMAN = $(INSTALL)
60
61 MKDIR ?= mkdir -p
62
63 ### It shouldn't be necessary to change anything below this line.
64
65 HEXER = hexer
66 MYC = myc
67
68 CTAGS = ctags -tawf tags
69
70 OBJECTS = buffer.o tio.o edit.o main.o hexer.o readline.o regex.o \
71 exh.o set.o map.o signal.o util.o commands.o helptext.o calc.o
72
73 all: $(HEXER)
74
75 $(HEXER): $(OBJECTS)
76 $(CC) $(LDFLAGS) -o $@ $(OBJECTS) $(LDLIBS)
77
78 $(MYC): calc.c config.h
79 $(CC) $(LDFLAGS) $(CPPFLAGS) $(CFLAGS) -DMYCALC=1 -o $@ calc.c -lm
80
81 bin2c: bin2c.c
82 $(CC_FOR_BUILD) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ bin2c.c
83
84 helptext.c: help.txt bin2c
85 ./bin2c -n helptext -o $@ help.txt
86
87 .c.o: config.h
88 $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
89
90 %.o: %.c config.h
91 $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
92
93 config.h:
94 [ ! -e config.h.auto ] || rm config.h.auto
95 echo "/* Autogenerated by Makefile and config-test.c */" > config.h.auto
96 for item in \
97 SIGTYPE_INT \
98 ALLOCA_H \
99 VASPRINTF \
100 ; do \
101 echo "Testing for $$item"; \
102 if $(CC) $(CPPFLAGS) $(CFLAGS) -D"TEST_$$item" -c -o config-test.o -Werror config-test.c; then \
103 value=1; \
104 else \
105 value=0; \
106 fi; \
107 echo "- result: $$value"; \
108 printf "\\n#define HAVE_%s\\t%d\\n" "$$item" "$$value" >> config.h.auto; \
109 done
110
111 [ ! -e config.h ] || rm config.h
112 mv config.h.auto config.h
113
114 tags: *.c *.h
115 -@{ \
116 echo Creating tags...; \
117 rm -f tags; \
118 for i in *.c *.h; do \
119 echo $(CTAGS) $$i; \
120 $(CTAGS) $$i; \
121 done; \
122 }
123
124 dep: depend
125
126 depend: *.c *.h config.h
127 -rm -f Makefile~
128 sed '/\#\#\# DO NOT DELETE THIS LINE \#\#\#/q' \
129 < Makefile > Makefile~
130 -echo >> Makefile~
131 -echo '#' Dependencies: >> Makefile~
132 -echo >> Makefile~
133 @{ for i in *.c; do \
134 echo $(CC) -MM $(CPPFLAGS) $$i '>>' Makefile~; \
135 $(CC) -MM $(CPPFLAGS) $$i >> Makefile~; \
136 done; }
137 -echo >> Makefile~
138 mv -f Makefile~ Makefile
139 -touch depend
140
141 clean:
142 rm -f $(HEXER) $(MYC) gen_testfile $(OBJECTS) bin2c
143 rm -f config-test.o
144 rm -f config.h
145 rm -f helptext.c TESTFILE
146 rm -f tags core *.bak
147
148 distclean: clean
149 rm -f *~
150 sed '/\#\#\# DO NOT DELETE THIS LINE \#\#\#/q' \
151 < Makefile > Makefile~
152 echo >> Makefile~
153 mv -f Makefile~ Makefile
154 rm -f depend
155
156 install: all
157 $(MKDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(MANDIR) $(DESTDIR)$(DOCSDIR)/md
158 $(INSTALLBIN) $(HEXER) $(DESTDIR)$(BINDIR)
159 $(INSTALLMAN) $(HEXER).1 $(DESTDIR)$(MANDIR)
160 $(INSTALLMAN) docs/*.md $(DESTDIR)$(DOCSDIR)/md
161 [ ! -f $(MYC) ] || $(INSTALLBIN) $(MYC) $(DESTDIR)$(BINDIR)
162 [ ! -f $(MYC) ] || $(INSTALLMAN) $(MYC).1 $(DESTDIR)$(MANDIR)
163
164 ### DO NOT DELETE THIS LINE ###
165