1#############################################################################
2# mined text editor compilation options (make include file for gcc options)
3# also gmake options (assuming gmake is used with gcc which isn't always true)
4
5
6#############################################################################
7# binary target directory
8
9SYS:=` uname | sed -e 's,_.*,,' `
10#ARCH=` uname -p 2> /dev/null | sed -e "s,unknown,," | grep . || uname -m | sed -e "s,/,_,g" `
11ARCH:=` uname -m | sed -e "s,/,_,g" `
12
13OBJDIR:=$(shell echo ../bin/$(SYS).$(ARCH) )
14
15
16#############################################################################
17# compilation source options
18
19# Define if pedantic analysis wanted:
20#GFLAGS= -ansi -pedantic -Wall -Wtraditional -Wpointer-arith -Wconversion -Waggregate-return -Winline
21# For regular compilation:
22# Leave in extra flags that produce no warnings (covered by -Wall):
23#	-Wimplicit[-int] -Wreturn-type -Wunused -Wswitch -Wchar-subscripts -Wparentheses
24# Leave out extra flags that produce some warnings:
25#	-Wtraditional
26#	-W (covered by -Wall)
27# Including again:
28#	-Wuninitialized (covered by -Wall)
29# Perhaps also leave out flag that produces extra warnings (Linux, ...?):
30#	-Wconversion
31# (rotten C crap: value does match prototype, so why this silly
32#  warning "passing arg ... with different width due to prototype" ???
33# Perhaps also leave out flag that produces extra warnings (Linux, ...?):
34#	-pedantic
35# (rotten C crap: prototype matches exactly, so why this silly
36#  warning "promoted argument `c' doesn't match prototype" ???
37GFLAGS= -ansi -Waggregate-return -Winline \
38	-Wimplicit -Wunused -Wswitch -Wchar-subscripts \
39	-Wformat -Wparentheses -Wmissing-braces \
40	-Wuninitialized \
41	${WFLAGS} $(W) $(WC)
42# The following warnings are left out deliberately:
43#	-Wreturn-type	# causes obscure "error 1" on my Linux
44#	-pedantic	# causes junk messages about "braced groups"
45#	-Wpointer-arith	# causes junk messages from library include files
46#	-Wconversion	# causes junk messages from library include files
47#	-Wall -W / -Wextra
48
49GCC3FLAGS=-Wdeclaration-after-statement -Wno-pragmas
50# -Wunreachable-code deprecated
51GCC4FLAGS=$(GCC3FLAGS) -Wno-pointer-sign
52
53# Warning options for newer gcc versions:
54# (additional grep for the sake of MSys sed failing on CRLF from MinGW gcc)
55W= $(shell $(CC) -v 2>&1 | grep "gcc version" | sed -e "s,gcc version [4-9].*,$(GCC4FLAGS)," -e t -e d )
56# Tune further -W options with the environment variable $WFLAGS
57
58# Suppress overzealous warnings for clang:
59#? WDEF=-Wno-everything	# before -W options
60CLANGFLAGS=-Wno-pointer-sign -Wno-invalid-source-encoding -Wno-knr-promoted-parameter
61# -Wimplicit-fallthrough has no effect...
62#? -Wno-incompatible-pointer-types	# disabled by pragma in textfile.c
63WC= $(shell $(CC) -v 2>&1 | sed -e "s,.*clang.*,$(CLANGFLAGS)," -e t -e d )
64
65# code checking
66# checking for function signatures:
67PROTOFLAGS=	-Wmissing-prototypes -Wreturn-type
68
69
70#############################################################################
71# compilation mode options (optimisation and debug)
72
73# Optimization flag/level:
74#OPT= -O2
75
76# Debugging option
77DEBUG= # -ggdb -gstabs
78
79
80#############################################################################
81# compilation setup
82
83# Collection of compilation parameters:
84CFLAGS= $(SYSFLAGS) $(GFLAGS) $(OPT) $(DEBUG) ${CCFLAGS}
85
86
87#############################################################################
88# link options
89
90LINKOPTS=$(GLDOPTS) # --warn-common?
91# for newer ncursesw?
92#LDL=-ldl	# if libdl library exists:
93ldl_libs=$(shell echo "/usr/lib ${LDFLAGS} " | sed -e "s, -L, ,g" -e "s, ,/libdl.* ,g" )
94LDL=$(shell ls $(ldl_libs) | sed -e "s,.*/libdl\..*,-ldl," -e 1q )
95
96
97#############################################################################
98# dynamic make targets
99# this version for GNU make
100# (if gcc is used, GNU make is also assumed)
101
102# derive list of character set mappings from source files:
103CHARTABS=$(shell echo charmaps/*.map | sed -e "s,\.map,.c,g" )
104CJKfilter=$(shell if echo "$(OPT)" | egrep "(-DNOCJK|-DnoCJKcharmaps)" > /dev/null; then echo '-e s,charmaps/cjk-[a-z]*.map,,g'; fi )
105CHAROBJS=$(shell echo charmaps/*.map | sed $(CJKfilter) -e 's,\([^ ]*\)\.map,$(OBJDIR)/\1.o,g' )
106CHARDEPS=$(CHAROBJS)
107
108# extract list of configured keyboard mappings from keymaps.cfg:
109KEYMAPS=$(shell sh ./mkkmlist )
110
111# disable the explicit make targets for dynamically
112# generating and invoking makefiles
113MAKEMAPS=
114
115
116#############################################################################
117# end
118