2 # run the configure script for a native Windows build
4 if [ -f ../configure.in ]; then
5 # we're in the windows directory, so we need to go up a level
9 if [ ! -f configure ]; then
16 ####### configure options:
17 # --help Show configure options and a short description
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-pthread Use native threads instead of POSIX pthreads library
24 # --disable-dynamic-pcre Use the built-in, static pcre, even if libpcre is available
25 # --with-docbook=yes Enable docbook documentation creation
29 # note: configure.in line 155
30 # if test "X$CFLAGS" = "X "; then # if CFLAGS were unset (see above)
31 # In other words, if you set CFLAGS you need to include -O2 if you want optimization
32 # assume I'll set cflags below, so set O2 now
35 # start with initially empty flags
38 ### CFLAGS="${CFLAGS} -fstack-protector-strong"
39 ### LDFLAGS="${LDFLAGS} -fstack-protector-strong"
40 # enable stack checking. NOTE: need to specify when compiling _and_ linking
41 # stack-protector-strong: better balance between security and performance.
42 # This flag protects more kinds of vulnerable functions than -fstack-protector does,
43 # but not every function, providing better performance than -fstack-protector-all.
44 # see : https://en.wikipedia.org/wiki/Buffer_overflow_protection
45 # NOTE: needs static linking or the following in the path:
46 # /usr/i686-w64-mingw32/sys-root/mingw/bin/libssp-0.dll
48 ### CFLAGS="${CFLAGS} -march=native"
50 # Generate instructions for the machine type cpu-type. In contrast to -mtune=cpu-type, which merely tunes the
51 # generated code for the specified cpu-type, -march=cpu-type allows GCC to generate code that may not run at all on
52 # processors other than the one indicated.
53 # Specifying -march=cpu-type implies -mtune=cpu-type.
56 # This selects the CPU to generate code for at compilation time by determining the processor type of the compiling
57 # machine. Using -march=native enables all instruction subsets supported by the local machine (hence the result
58 # might not run on different machines). Using -mtune=native produces code optimized for the local machine under
59 # the constraints of the selected instruction set.
61 LDFLAGS="${LDFLAGS} -Wl,--nxcompat"
62 # https://en.wikipedia.org/wiki/Data_Execution_Prevention
63 # Enable DEP with -Wl,--nxcompat
65 LDFLAGS="${LDFLAGS} -Wl,--dynamicbase,--export-all-symbols"
66 # https://en.wikipedia.org/wiki/Address_space_layout_randomization
67 # https://stackoverflow.com/questions/24283918/how-can-i-enable-aslr-dep-and-safeseh-on-an-exe-in-codeblocks-using-mingw
68 # ASLR with gcc has a problem: -Wl,--dynamicbase doesn't emit the necessary relocation table.
69 # As a workaround, you can pass -Wl,--dynamicbase,--export-all-symbols
70 # NOTE: you can't have both this and profiling (cflags='-pg') enabled!
72 #CFLAGS="${CFLAGS} -pg"
73 #LDFLAGS="${LDFLAGS} -pg"
74 # Generate extra code to write profile information suitable for the analysis program gprof.
75 # Use this option when compiling the source files you want data about, and you must also use it when linking.
76 # -- creates a "gmon.out" profile file when the program exits
77 # -- then do 'gprof -b privoxy.exe gmon.out'
78 # ??? WHY ??? profiling doesn't work if ASLR is enabled
81 ### CFLAGS="${CFLAGS} -Wall"
82 # see: http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
83 # -Wall doesn't actually turn on all warnings, so add -Wextra
84 # but then plenty too many complaints by
85 # -Wmissing-field-initializers
88 ### CFLAGS="${CFLAGS} -Wextra -Wno-missing-field-initializers -Wno-sign-compare -Wno-type-limits"
90 # CFLAGS="${CFLAGS} -Wconversion"
91 # way too many warnings for things that don't look like a problem
93 ### CFLAGS="${CFLAGS} -Wformat-security"
94 # If -Wformat is specified, also warn about uses of format functions that represent possible security problems.
96 ### CFLAGS="${CFLAGS} -Wlogical-op"
97 # Warn about suspicious uses of logical operators in expressions.
99 CFLAGS="${CFLAGS} -Wshadow"
100 # Warn whenever a local variable or type declaration shadows
101 # another variable or whenever a built-in function is shadowed.
103 # CFLAGS="${CFLAGS} -Wwrite-strings"
104 # These warnings help you find at compile time code that can try to write
105 # into a string constant, but only if you have been very careful about
106 # using const in declarations and prototypes.
107 # >>> Otherwise, it is just a nuisance. <<< -- this, very much this
109 echo "CFLAGS=${CFLAGS}"
110 echo "LDFLAGS=${LDFLAGS}"
112 # ./configure cross-compilation options:
113 # --build: the system on which the program will be built.
114 # --host: the system on which the generated program will run.
115 # --target: only used to build a cross-compiling toolchain.
117 ./configure --host=i686-w64-mingw32 --enable-mingw32 --enable-zlib \
118 --enable-static-linking \
119 --enable-strptime-sanity-checks \
120 --disable-pthread --disable-dynamic-pcre \