1# Makefile for less using mingw-w64 package: 2# http://mingw-w64.org/doku.php 3# 4# Derived from Makefile.wnm 5# 6# Usage: mingw32-make -f Makefile.wng [REGEX_PACKAGE={posix|gnu|regcomp-local}] 7# 8# The optional command line parameter "REGEX_PACKAGE" is used to specify 9# a regular expression package for compilation and linking. This parameter 10# can assume one of three values. 11# 12# REGEX_PACKAGE == regcomp-local 13# This choice selects the regular expression package written by Henry 14# Spencer. It is implemented by the repository file "regexp.c". 15# 16# REGEX_PACKAGE == posix 17# This choice selects the POSIX implementation and is provided by MingW. 18# This is the default choice. 19# 20# REGEX_PACKAGE == gnu 21# This choice selects the GNU implementation and is provided by MingW. 22# 23 24#### Start of system configuration section. #### 25 26CC = gcc 27 28# Definitions specific to mingw 29# 30MINGW_DEFINES = -DMINGW -DWIN32 31 32# This specifies the "root" directory of the MingW installation. 33# It is defined so that the compiler and linker can find the header files 34# and library that provide regular expression support. 35# 36MINGW_ROOT_PATH = /mingw-w64/mingw64 37 38# Determine the regular expression package to be used. 39# 40REGEX_PACKAGE ?= posix 41ifeq (${REGEX_PACKAGE},regcomp-local) 42 MINGW_DEFINES += -DUSE_REGEXP_C 43else ifeq (${REGEX_PACKAGE},posix) 44 MINGW_DEFINES += -DUSE_POSIX_REGCOMP 45else ifeq (${REGEX_PACKAGE},gnu) 46 MINGW_DEFINES += -DUSE_GNU_REGEX 47else 48 $(error REGEX_PACKAGE must be posix, gnu or regcomp-local) 49endif 50 51MINGW_REGEX_IPATH = -I${MINGW_ROOT_PATH}/opt/include 52MINGW_REGEX_LPATH = -L${MINGW_ROOT_PATH}/opt/lib 53MINGW_REGEX_LIB = -lregex 54 55CFLAGS_MINGW = ${MINGW_DEFINES} 56ifneq (${REGEX_PACKAGE},regcomp-local) 57CFLAGS_MINGW += ${MINGW_REGEX_IPATH} 58endif 59 60# MingW may use sh.exe instead of cmd.exe. 61# Make sure it does not. 62# 63SHELL = cmd.exe 64 65CFLAGS = -O2 ${CFLAGS_MINGW} 66ifneq (${REGEX_PACKAGE},regcomp-local) 67LDFLAGS = ${MINGW_REGEX_LPATH} 68LIBS = ${MINGW_REGEX_LIB} 69endif 70 71#### End of system configuration section. #### 72 73# This rule allows us to supply the necessary -D options 74# in addition to whatever the user asks for. 75.c.o: 76 ${CC} -c -I. ${CFLAGS} $< 77 78LESS_SRC = brac.c ch.c charset.c cmdbuf.c command.c \ 79 cvt.c decode.c edit.c filename.c forwback.c \ 80 ifile.c input.c jump.c line.c linenum.c \ 81 lsystem.c main.c mark.c optfunc.c option.c \ 82 opttbl.c os.c output.c pattern.c position.c \ 83 prompt.c screen.c scrsize.c search.c \ 84 signal.c tags.c ttyin.c version.c xbuf.c 85ifeq (${REGEX_PACKAGE},regcomp-local) 86LESS_SRC += regexp.c 87endif 88 89OBJ = \ 90 main.o screen.o brac.o ch.o charset.o cmdbuf.o \ 91 command.o cvt.o decode.o edit.o filename.o forwback.o \ 92 help.o ifile.o input.o jump.o lesskey_parse.o line.o linenum.o \ 93 lsystem.o mark.o optfunc.o option.o opttbl.o os.o \ 94 output.o pattern.o position.o prompt.o search.o signal.o \ 95 tags.o ttyin.o version.o xbuf.o 96ifeq (${REGEX_PACKAGE},regcomp-local) 97OBJ += regexp.o 98endif 99 100 101all: clean less lesskey lessecho 102 103less: ${OBJ} 104 ${CC} ${LDFLAGS} -o $@ ${OBJ} ${LIBS} 105 106lesskey: lesskey.o lesskey_parse.o version.o xbuf.o 107 ${CC} ${LDFLAGS} -o $@ lesskey.o lesskey_parse.o version.o xbuf.o 108 109lessecho: lessecho.o version.o 110 ${CC} ${LDFLAGS} -o $@ lessecho.o version.o 111 112defines.h: defines.wn 113 copy $< $@ 114 115funcs.h: ${LESS_SRC} 116 -move funcs.h funcs.h.old 117 grep -h "^public [^;]*$$" ${LESS_SRC} | sed "s/$$/;/" >funcs.h 118 119help.c: less.hlp 120 perl mkhelp.pl < $< > $@ 121 122${OBJ}: less.h defines.h funcs.h 123 124TAGS: 125 etags *.c *.h 126 127clean: 128 -del *.o 129 -del *.exe 130 -del defines.h 131 -del funcs.h 132 -del help.c 133 -if exist TAGS del TAGS 134