wolfSSL: Use LIBWOLFSSL_VERSION_HEX to decide whether or not to use WOLFSSL_X509_V_OK
[privoxy.git] / windows / MYconfigure
1 #!/bin/sh
2 # run the configure script for a native Windows build
3
4 if [ -f ../configure.in ]; then
5    #  we're in the windows directory, so we need to go up a level
6    cd ..
7 fi
8
9 if [ ! -f configure ]; then
10    autoheader
11    #   creates config.h.in
12    autoconf
13    #   creates configure
14 fi
15
16 ####### configure options:
17 # --help                          Show configure options and a short description
18 #
19 # --host=i686-w64-mingw32         Use the mingw cross-compiler to build a 'native' windows binary
20 # --enable-mingw32                Use mingw32 for a Windows GUI
21 # --enable-static-linking         Use static linking instead of dynamic linking (and not have
22 #                                 to put all the .DLLs in the path or the same dir as Privoxy)
23 # --disable-pcre2                 Don't try to use the pcre2 library even if it's available
24 # --disable-pthread               Use native threads instead of POSIX pthreads library
25 # --disable-dynamic-pcre          Use the built-in, static pcre, even if libpcre is available
26 # --with-docbook=yes              Enable docbook documentation creation
27
28
29 export CFLAGS="-O2"
30 # note: configure.in line 155
31 #         if test "X$CFLAGS" = "X "; then # if CFLAGS were unset (see above)
32 #   In other words, if you set CFLAGS you need to include -O2 if you want optimization
33 #   assume I'll set cflags below, so set O2 now
34
35 export CPPFLAGS=""
36 # start with initially empty flags
37
38 export LDFLAGS=""
39 # start with initially empty flags
40
41
42 CFLAGS="${CFLAGS} -fdiagnostics-color=always"
43 # Have gcc diagnostics be in color even if stderr is not going to a terminal.
44 # It's nice having warnings in color even if I run a script that does
45 #   'make 2>&1 | tee log.make'
46
47 CFLAGS="${CFLAGS} -fstack-protector-strong -D_FORTIFY_SOURCE=2"
48 LDFLAGS="${LDFLAGS} -fstack-protector-strong"
49 # -fstack-protector-strong:  enable stack checking.
50 # NOTE: need to specify when compiling _and_ linking
51 # stack-protector-strong: better balance between security and performance.
52 #   This flag protects more kinds of vulnerable functions than -fstack-protector does,
53 #   but not every function, providing better performance than -fstack-protector-all.
54 # see : https://en.wikipedia.org/wiki/Buffer_overflow_protection
55 # NOTE: needs static linking or the following in the path:
56 #         /usr/i686-w64-mingw32/sys-root/mingw/bin/libssp-0.dll
57 #
58 # -D_FORTIFY_SOURCE:  detect some buffer overflow errors
59 #     ***>> requires compiler optimization level 1 or above <<***
60 # see : https://gcc.gnu.org/legacy-ml/gcc-patches/2004-09/msg02055.html
61 #   The difference between -D_FORTIFY_SOURCE=1 and -D_FORTIFY_SOURCE=2 is e.g. for
62 #     struct S { struct T { char buf[5]; int x; } t; char buf[20]; } var;
63 #   With -D_FORTIFY_SOURCE=1,
64 #     strcpy (&var.t.buf[1], "abcdefg");
65 #   is not considered an overflow (object is whole VAR), while with -D_FORTIFY_SOURCE=2
66 #     strcpy (&var.t.buf[1], "abcdefg");
67 #   will be considered a buffer overflow.
68
69 ### CFLAGS="${CFLAGS} -march=native"
70 # -march=cpu-type
71 #   Generate instructions for the machine type cpu-type.  In contrast to -mtune=cpu-type, which merely tunes the
72 #   generated code for the specified cpu-type, -march=cpu-type allows GCC to generate code that may not run at all on
73 #   processors other than the one indicated.
74 #   Specifying -march=cpu-type implies -mtune=cpu-type.
75 #
76 # -march=native
77 #   This selects the CPU to generate code for at compilation time by determining the processor type of the compiling
78 #   machine.  Using -march=native enables all instruction subsets supported by the local machine (hence the result
79 #   might not run on different machines).  Using -mtune=native produces code optimized for the local machine under
80 #   the constraints of the selected instruction set.
81
82 LDFLAGS="${LDFLAGS} -Wl,--nxcompat"
83 # https://en.wikipedia.org/wiki/Data_Execution_Prevention
84 #   Enable DEP with -Wl,--nxcompat
85 # also called NX or nxcompat for "no execute"  see: https://en.wikipedia.org/wiki/NX_bit
86 #   $ peflags -v privoxy.exe
87 #   privoxy.exe: coff(0x0106[+executable_image,+line_nums_stripped,+32bit_machine]) pe(0x0140[+dynamicbase,+nxcompat])
88
89 LDFLAGS="${LDFLAGS} -Wl,--dynamicbase,--export-all-symbols"
90 # https://en.wikipedia.org/wiki/Address_space_layout_randomization
91 # https://stackoverflow.com/questions/24283918/how-can-i-enable-aslr-dep-and-safeseh-on-an-exe-in-codeblocks-using-mingw
92 #   ASLR with gcc has a problem: -Wl,--dynamicbase doesn't emit the necessary relocation table.
93 #   As a workaround, you can pass -Wl,--dynamicbase,--export-all-symbols
94 #   NOTE: you can't have both this and profiling (cflags='-pg') enabled!
95
96 CFLAGS="${CFLAGS} -Wall"
97 # see: http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
98 # -Wall   doesn't actually turn on all warnings, so add  -Wextra
99 #    but then plenty too many complaints by
100 #      -Wmissing-field-initializers
101 #      -Wsign-compare
102 #      -Wtype-limits
103 #      -Wunused-but-set-parameter
104 #      -Wunused-but-set-variable
105 CFLAGS="${CFLAGS} -Wextra -Wno-missing-field-initializers -Wno-sign-compare -Wno-type-limits"
106 CFLAGS="${CFLAGS} -Wno-unused-parameter -Wno-unused-but-set-variable"
107
108 #-no-# CFLAGS="${CFLAGS} -Wconversion"
109 #   way too many warnings for things that don't look like a problem
110
111 CFLAGS="${CFLAGS} -Wno-deprecated-declarations"
112 #   way too many warnings in openssl.c about RSA deprecated-declarations
113
114 #-no-# CFLAGS="${CFLAGS} -Werror"
115 # Turn all warnings into errors.
116 #   Privoxy still has a few warnings that are not a problem
117
118 CFLAGS="${CFLAGS} -Wformat=2"
119 # -Wformat is enabled by -Wall.
120 # -Wformat=2 is equivalent to -Wformat -Wformat-nonliteral -Wformat-security -Wformat-y2k
121 #   -Wformat-security : also warn about uses of format functions that represent possible security problems.
122
123 CFLAGS="${CFLAGS} -Wlogical-op"
124 # Warn about suspicious uses of logical operators in expressions.
125
126 CFLAGS="${CFLAGS} -Wshadow"
127 # Warn whenever a local variable or type declaration shadows
128 # another variable or whenever a built-in function is shadowed.
129
130 #-no-# CFLAGS="${CFLAGS} -Wwrite-strings"
131 # These warnings help you find at compile time code that can try to write
132 # into a string constant, but only if you have been very careful about
133 # using const in declarations and prototypes.
134 # >>> Otherwise, it is just a nuisance. <<<  -- this, very much this
135
136 # why does the mingw library _not_ include .a files for libpcre?
137 # *sigh* build my own pcre so I can do static linking
138 # Get the 8.x PCRE library from
139 #   https://sourceforge.net/projects/pcre/files/pcre/
140 # Get the 10.x PCRE2 library from
141 #   https://github.com/PCRE2Project/pcre2/releases
142 #
143 #
144 usepcre2=yes
145 #
146 #
147 if [ "$usepcre2" = "yes" ]; then
148     PCREOPT=""
149     inc="/source/pcre2-10.42/src/"
150       # need pcre2.h
151     lib="/source/pcre2-10.42/.libs"
152       # need libpcre2-8.a & libpcre2-posix.a
153 else
154     PCREOPT="--disable-pcre2"
155     inc="/source/pcre-8.45/"
156     lib="/source/pcre-8.45/.libs"
157 fi
158 CPPFLAGS="${CPPFLAGS} -I${inc}"
159 LDFLAGS="${LDFLAGS} -L${lib}"
160
161 # mbedtls
162 ## https://github.com/Mbed-TLS/mbedtls/releases/tag/v2.16.12
163 ##   This is the last release of the 2.16 long-time support branch.
164 ##   Users who want a long-time branch should move to mbedtls-2.28,
165 ##   which is backward-compatible and will be supported for at least
166 ##   3 years.
167 # Get the 2.28.x mbedtls library from  https://github.com/Mbed-TLS/mbedtls/tags
168 # Release Notes: https://github.com/Mbed-TLS/mbedtls/releases/tag/v2.28.4
169
170 ##MITMOPT="--with-mbedtls"
171 ##inc="/source/mbedtls-2.28.4/include"
172 ##lib="/source/mbedtls-2.28.4/library"
173 ##CPPFLAGS="${CPPFLAGS} -I${inc}"
174 ##LDFLAGS="${LDFLAGS} -L${lib}"
175
176 MITMOPT="--with-openssl"
177
178 # brotli
179 # Get the brotli library from  https://github.com/google/brotli/releases
180 inc="/source/brotli-1.0.9/c/include"
181 lib="/source/brotli-1.0.9/.libs"
182 BROTLIOPT="--with-brotli"
183 CPPFLAGS="${CPPFLAGS} -I${inc}"
184 LDFLAGS="${LDFLAGS} -L${lib}"
185
186 ###
187 echo "CFLAGS=${CFLAGS}"
188 echo "CPPFLAGS=${CPPFLAGS}"
189 echo "LDFLAGS=${LDFLAGS}"
190
191 # ./configure cross-compilation options:
192 #    --build: the system on which the program will be built.
193 #    --host:  the system on which the generated program will run.
194 #    --target: only used to build a cross-compiling toolchain.
195
196 ./configure  --host=i686-w64-mingw32  --enable-mingw32  --enable-zlib \
197              --enable-extended-statistics \
198              ${PCREOPT} \
199              --enable-pcre-host-patterns \
200              --enable-static-linking \
201              --enable-strptime-sanity-checks \
202              --disable-pthread  \
203              --with-brotli  \
204              ${MITMOPT} \
205              --with-docbook=yes
206
207 #  -- done --