1 #Copyright (c) Brian B.
3 #Permission to use, copy, modify, and/or distribute this software for any purpose
4 #with or without fee is hereby granted.
6 #THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
7 #REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
8 #FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
9 #INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
10 #OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
11 #TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
12 rule -configure-options-help- {
13 Echo "jam configure supports" ;
14 Echo " --prefix=dir [/usr/local]" ;
15 Echo " --debug build with debug symbols" ;
16 Echo " --tests build tests" ;
17 Echo " --multiarch multiarch support" ;
18 Echo " --shared build with shared library" ;
22 rule -configure-options-debug- {
26 rule -configure-options-tests- {
30 rule -configure-options-multiarch- {
34 rule -configure-options-shared- {
38 # $(1) -- program, string list
39 # $(2) -- additional compiler flags (optional)
40 # $(3) -- additional linker flags (optional)
41 rule -configure-try-exec-cc- {
45 local tfn = [ RandName ] ;
47 if [ ListWrite $(tfn) : $(1) ] {
48 rc = [ Command $(CC) -c $(tfn:Q) -o $(tfn:S=.o:Q) $(2) '2>/dev/null' : exit-code no-output ] ;
50 rc = [ Command $(LINK) $(tfn:S=.o:Q) -o $(tfn:S=.elf:Q) $(3) '2>/dev/null' : exit-code no-output ] ;
52 res = [ Command $(tfn:S=.elf:Q) : parse-output no-space-break no-tab-break no-cr-break ] ;
55 Command rm $(tfn:Q) $(tfn:S=.o:Q) $(tfn:S=.elf:Q) '2>/dev/null' ;
62 # $(2) -- program, string list
63 # $(3) -- additional compiler flags (optional)
64 # $(4) -- additional linker flags (optional)
65 rule -configure-test-exec-cc- {
67 Echo 'generate code for' $(1) '... ' : -n ;
68 r = [ -configure-try-exec-cc- $(2) : $(3) : $(4) ] ;
70 if ( $(r) = "-D__m32__" ) {
72 } else if ( $(r) = "-D__m64__" ) {
82 rule -configure-test-arch- {
84 -configure-test-exec-cc- "" :
87 "switch (sizeof(void*)) {"
88 "case 4: printf(\"-D__m32__\"); break;"
89 "case 8: printf(\"-D__m64__\"); break;"
99 Echo 'checking for' $(1) '... ' : -n ;
100 if [ Command pkg-config --exists $(1) : exit-code no-output ] == 0 {
110 PREFIX = /usr/local ;
112 local arch = [ -configure-test-arch- ] ;
113 -configure-add-line- "CFLAGS.all += $(arch) ;" ;
116 if ( $(arch) = '-D__m32__' ) {
117 ARCH_LIB = "/i386-linux-gnu" ;
119 ARCH_LIB = "/x86_64-linux-gnu" ;
122 if ( $(arch) = '-D__m32__' ) {
123 ARCH_LIB = "/powerpc-aix-ibm" ;
125 ARCH_LIB = "/powerpc64-aix-ibm" ;
132 Exit "Architecture not supported" ;
135 local pl = [ Command "echo $(ARCH_LIB) | sed \"s/\\//\\\\\\\\\\\//g\"" : dummy ] ;
136 local pp = [ Command "echo $(PREFIX) | sed \"s/\\//\\\\\\\\\\\//g\"" : dummy ] ;
138 local sslflags = "" ;
141 local ispthread = 1 ;
142 -configure-add-line- "ARCH_LIB = $(ARCH_LIB) ;" ;
143 if ( 'gcc' in $(CC) ) && $(OS) != 'AIX' {
144 estack = "-Wl,-z,execstack" ;
146 if [ -pkg-find- libcrypto ] && [ -pkg-find- libssl ] == 1 {
147 sslflags = [ Command pkg-config --cflags libssl : parse-output no-space-break no-tab-break no-cr-break ] ;
148 sslflags = "-DUSE_SSL $(sslflags) $(crpflags)" ;
150 sslibs = [ Command pkg-config --libs libssl : parse-output no-space-break no-tab-break no-cr-break ] ;
152 sslibs = [ Command pkg-config --libs --static libssl : parse-output no-space-break no-tab-break no-cr-break ] ;
154 -configure-add-line- "CFLAGS.all += $(sslflags) ;" ;
155 -configure-add-line- "LINKLIBS.all += $(sslibs) ;" ;
161 -configure-add-line- "LINKLIBS.all += -lm -lrt ;" ;
163 -configure-add-line- "LINKLIBS.all += -ldl ;" ;
165 if $(ispthread) == 1 {
166 -configure-add-line- "LINKLIBS.all += -pthread ;" ;
169 Command "sed -e \"s/@prefix/\\$(pp)/\" -e \"s/@arch_lib/\\$(pl)/g\" -e \"s/@ext_libs/-pthread/\" -e \"s/@cflags/$(arch)/\" -e \"s/@estack/$(estack)/\" -e \"s/@sslflags/$(sslflags)/\" -e \"s/@sslibs/$(sslibs)/\" ./libex.pc.in > ./libex.pc" ;
171 Command "sed -e \"s/@prefix/\\$(pp)/\" -e \"s/@arch_lib//g\" -e \"s/@ext_libs/-pthread/\" -e \"s/@cflags/$(arch)/\" -e \"s/@estack/$(estack)/\" -e \"s/@sslflags/$(sslflags)/\" -e \"s/@sslibs/$(sslibs)/\" ./libex.pc.in > ./libex.pc" ;
174 -configure-add-line- "LINKLIBS.all += -blibpath\\:/usr/lib\\:/usr/local/lib\\:/lib -lbsd -lm -lrt ;" ;
176 -configure-add-line- "LINKLIBS.all += -ldl ;" ;
178 if $(ispthread) == 1 {
179 -configure-add-line- "LINKLIBS.all += -pthread ;" ;
182 Command "sed -e \"s/@prefix/\\$(pp)/\" -e \"s/@arch_lib/\\$(pl)/g\" -e \"s/@ext_libs/-lpthread -lbsd/\" -e \"s/@cflags/$(arch)/\" -e \"s/@estack/$(estack)/\" -e \"s/@sslflags/$(sslflags)/\" -e \"s/@sslibs/$(sslibs)/\" ./libex.pc.in > ./libex.pc" ;
184 Command "sed -e \"s/@prefix/\\$(pp)/\" -e \"s/@arch_lib//g\" -e \"s/@ext_libs/-lpthread -lbsd/\" -e \"s/@cflags/$(arch)/\" -e \"s/@estack/$(estack)/\" -e \"s/@sslflags/$(sslflags)/\" -e \"s/@sslibs/$(sslibs)/\" ./libex.pc.in > ./libex.pc" ;
188 -configure-add-line- "CFLAGS.all += -D__WINDOWS__ ;" ;
192 -configure-add-line- "CFLAGS.all += -O0 -g3 -DDEBUG ;" ;
194 -configure-add-line- "CFLAGS.all += -O0 -g -DDEBUG ;" ;
197 -configure-add-line- "set-profile ;" ;
199 -configure-add-line- "BUILDDEBUG =" "$(BUILDDEBUG)" ";" ;
200 -configure-add-line- "BUILDTESTS =" "$(BUILDTESTS)" ";" ;
201 -configure-add-line- "MULTIARCH =" "$(MULTIARCH)" ";" ;
202 -configure-add-line- "BUILDSO =" "$(BUILDSO)" ";" ;
205 rule -configure-preinit- {