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
|
# 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 three values.
#
# REGEX_PACKAGE == regcomp-local
# This choice selects the regular expression package written by Henry
# Spencer. It is implemented by the repository file "regexp.c".
#
# REGEX_PACKAGE == posix
# This choice selects the POSIX implementation and is provided by MingW.
# This is the default choice.
#
# REGEX_PACKAGE == gnu
# This choice selects the GNU implementation and is provided by MingW.
#
# REGEX_PACKAGE == none
# This choice disables regex, and instead uses smart plain text search.
#
# By default, the files help.c and funcs.h 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
#### 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 \
lsystem.c main.c mark.c optfunc.c option.c \
opttbl.c os.c output.c pattern.c position.c \
prompt.c screen.c scrsize.c search.c \
signal.c tags.c ttyin.c version.c xbuf.c
ifeq (${REGEX_PACKAGE},regcomp-local)
LESS_SRC += regexp.c
endif
OBJ = \
main.o screen.o brac.o ch.o charset.o cmdbuf.o \
command.o cvt.o decode.o edit.o evar.o filename.o forwback.o \
help.o ifile.o input.o jump.o lesskey_parse.o line.o linenum.o \
lsystem.o mark.o optfunc.o option.o opttbl.o os.o \
output.o pattern.o position.o prompt.o search.o signal.o \
tags.o ttyin.o version.o xbuf.o
ifeq (${REGEX_PACKAGE},regcomp-local)
OBJ += regexp.o
endif
all: less.exe lesskey.exe lessecho.exe
less.exe: ${OBJ}
${CC} ${LDFLAGS} -o $@ ${OBJ} ${LIBS}
lesskey.exe: lesskey.o lesskey_parse.o version.o xbuf.o
${CC} ${LDFLAGS} -o $@ lesskey.o lesskey_parse.o version.o xbuf.o
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
else
MKHELP = (perl mkhelp.pl || sh mkhelp.sh)
MKFUNCS = grep -h "^public [^;]*$$" ${LESS_SRC} | sed "s/$$/;/"
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 > $@
buildgen.exe: buildgen.c
${CC} $< -o $@
${OBJ}: less.h defines.h funcs.h
TAGS:
etags *.c *.h
clean:
-${RM} *.o *.exe defines.h funcs.h help.c TAGS
|