-
Notifications
You must be signed in to change notification settings - Fork 126
Expand file tree
/
Copy pathMakefile.wng
More file actions
176 lines (146 loc) · 4.98 KB
/
Copy pathMakefile.wng
File metadata and controls
176 lines (146 loc) · 4.98 KB
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
166
167
168
169
170
171
172
173
174
175
176
# Makefile for less using mingw-w64 package:
# http://mingw-w64.org/doku.php
#
# Derived from Makefile.wnm
#
# Usage: mingw32-make -f Makefile.wng [REGEX_PACKAGE={posix|gnu|regcomp-local}]
#
# When cross compiling, add also: SHELL=sh CC=<mingw-cc>
#
# The optional command line parameter "REGEX_PACKAGE=..." is used to specify
# a regular expression package for compilation and linking. This parameter
# can assume one of four values:
#
# REGEX_PACKAGE == regcomp-local (default, always available)
# This choice selects the regular expression package written by Henry
# Spencer. It is implemented by the repository file "regexp.c", without
# any external dependencies.
#
# REGEX_PACKAGE == none (always available)
# This choice disables regex, and instead uses smart plain text search
#
# REGEX_PACKAGE == posix (might not be available)
# This choice selects the POSIX implementation, if provided by MingW.
#
# REGEX_PACKAGE == gnu (might not be available)
# This choice selects the GNU implementation, if provided by MingW.
#
# By default, the files help.c, funcs.h and lessmsg.inc are generated using few
# posix utilities (grep, sed, etc). On Windows, if the tools are missing, add:
# WINGEN=1
# to compile a native C program which will be used instead of the posix tools.
# NOTE: to cross compile with WINGEN=1, e.g. to arm, first run with native CC:
# make -f Makefile.wng CC=gcc buildgen.exe
# and then compile `less` with the arm CC:
# make -f Makefile.wng WINGEN=1 CC=armv7...
#### Start of system configuration section. ####
CC = gcc
# Definitions specific to mingw
#
MINGW_DEFINES = -DMINGW -DWIN32
# This specifies the "root" directory of the MingW installation.
# It is defined so that the compiler and linker can find the header files
# and library that provide regular expression support.
#
MINGW_ROOT_PATH = /mingw-w64/mingw64
# Determine the regular expression package to be used.
#
REGEX_PACKAGE ?= regcomp-local
ifeq (${REGEX_PACKAGE},regcomp-local)
MINGW_DEFINES += -DUSE_REGEXP_C
else ifeq (${REGEX_PACKAGE},posix)
MINGW_DEFINES += -DUSE_POSIX_REGCOMP
else ifeq (${REGEX_PACKAGE},gnu)
MINGW_DEFINES += -DUSE_GNU_REGEX
else ifeq (${REGEX_PACKAGE},none)
# without specific regex package, defines.wn sets NO_REGEX=1
else
$(error REGEX_PACKAGE must be posix, gnu, regcomp-local or none)
endif
MINGW_REGEX_IPATH = -I${MINGW_ROOT_PATH}/opt/include
MINGW_REGEX_LPATH = -L${MINGW_ROOT_PATH}/opt/lib
MINGW_REGEX_LIB = -lregex
CFLAGS_MINGW = ${MINGW_DEFINES}
ifneq (${REGEX_PACKAGE},regcomp-local)
CFLAGS_MINGW += ${MINGW_REGEX_IPATH}
endif
# MingW may use sh.exe instead of cmd.exe.
# Default to cmd.exe, but allow sh.exe too, e.g. for cross compile.
#
SHELL = cmd.exe
ifeq (${SHELL},cmd.exe)
CP = copy
MV = move
RM = del
DIFF = comp /M
else
CP = cp
MV = mv
RM = rm
DIFF = diff
endif
CFLAGS = -O2 ${CFLAGS_MINGW}
ifneq (${REGEX_PACKAGE},none)
ifneq (${REGEX_PACKAGE},regcomp-local)
LDFLAGS = ${MINGW_REGEX_LPATH}
LIBS = ${MINGW_REGEX_LIB}
endif
endif
LIBS += -lshell32
CFLAGS += ${XCFLAGS}
LDFLAGS += ${XLDFLAGS}
LIBS += ${XLDLIBS}
#### End of system configuration section. ####
# This rule allows us to supply the necessary -D options
# in addition to whatever the user asks for.
.c.o:
${CC} -c -I. ${CFLAGS} $<
LESS_SRC = brac.c ch.c charset.c cmdbuf.c command.c \
cvt.c decode.c edit.c evar.c filename.c forwback.c \
ifile.c input.c jump.c line.c linenum.c lmsg.c \
lsystem.c main.c mark.c optfunc.c option.c \
opttbl.c os.c output.c pattern.c position.c \
prompt.c screen.c search.c \
signal.c tags.c ttyin.c version.c xbuf.c
ifeq (${REGEX_PACKAGE},regcomp-local)
LESS_SRC += regexp.c
endif
ifneq (${SECURE_COMPILE},1)
LESS_SRC += lesskey_parse.c
else
MINGW_DEFINES += -DSECURE_COMPILE=1
endif
OBJ = ${patsubst %.c,%.o,$(LESS_SRC)} help.o
all: less.exe lessecho.exe
less.exe: ${OBJ}
${CC} ${LDFLAGS} -o $@ ${OBJ} ${LIBS}
lessecho.exe: lessecho.o version.o
${CC} ${LDFLAGS} -o $@ lessecho.o version.o
lessecho.o version.o: less.h defines.h funcs.h
defines.h: defines.wn
${CP} $< $@
ifeq (${WINGEN},1)
BUILDGEN = buildgen.exe
MKHELP = buildgen.exe help
MKFUNCS = type 2>NUL ${LESS_SRC} | buildgen.exe funcs
MKLESSMSG = type lessmsg lessmsg_int 2>NUL | buildgen.exe lessmsg
else
MKHELP = (perl mkhelp.pl || sh mkhelp.sh)
MKFUNCS = grep -h "^public [^;]*$$" ${LESS_SRC} | sed "s/$$/;/"
MKLESSMSG = sed -e "/^ *\#/d" -e "/^ *$$/d" -e "s/^ *\([^ ]*\) *\(.*\)/M(\1,\"\2\")/" lessmsg lessmsg_int
endif
funcs.h: ${LESS_SRC} ${BUILDGEN}
-${CP} funcs.h funcs.h.old
${MKFUNCS} >funcs.h.tmp
${DIFF} funcs.h.tmp funcs.h || ${MV} funcs.h.tmp funcs.h
help.c: less.hlp ${BUILDGEN}
${MKHELP} < less.hlp > $@
lessmsg.inc: lessmsg lessmsg_int ${BUILDGEN}
${MKLESSMSG} > $@
buildgen.exe: buildgen.c
${CC} $< -o $@
$(OBJ): less.h funcs.h defines.h lang.h lmsg.h lessmsg.inc pattern.h xbuf.h
TAGS:
etags *.c *.h
clean:
-${RM} *.o *.exe defines.h funcs.h help.c TAGS