11module C = Configurator. V1
22
3+ let c_flags = ref []
4+
35let has_header_code f =
46 Format. sprintf {|
57#include < % s>
68int main() { return 0 ; } // Just so that dune- configurator linking works
79 | } f
810
911let has_header c f =
10- C. c_test c (has_header_code f)
12+ C. c_test c ~c_flags: ! c_flags (has_header_code f)
1113
1214let builtin_va_list_code = {|
1315int
@@ -59,7 +61,7 @@ int main() { return 0; } // Just so that dune-configurator linking works
5961exception FoundType of string
6062
6163let cil_check_integer_type_type c t1 t2 =
62- if C. c_test c (cil_check_integer_type_type_code t1 t2) then
64+ if C. c_test c ~c_flags: ! c_flags (cil_check_integer_type_type_code t1 t2) then
6365 raise (FoundType t2)
6466
6567let cil_check_integer_type_signs c t1 t2 =
@@ -78,13 +80,21 @@ let cil_check_integer_type c t1 =
7880 t2
7981
8082let () =
81- C. main ~name: " machdep" (fun c ->
82- let have_builtin_va_list = C. c_test c builtin_va_list_code in
83- let thread_is_keyword = not @@ C. c_test c thread_is_keyword_code in
84- let underscore_name = C. c_test c underscore_name_code in
85- let have_float16 = C. c_test c have_float16_code in
86-
87- C.C_define. gen_header_file c ~fname: " machdep-config.h" [
83+ let fname = ref " machdep-config.h" in
84+ let args = Arg. [
85+ (" -m" , String (fun s ->
86+ c_flags := (" -m" ^ s) :: ! c_flags;
87+ fname := " machdep" ^ s ^ " -config.h" ;
88+ ), " " );
89+ ]
90+ in
91+ C. main ~name: " machdep" ~args (fun c ->
92+ let have_builtin_va_list = C. c_test c ~c_flags: ! c_flags builtin_va_list_code in
93+ let thread_is_keyword = not @@ C. c_test c ~c_flags: ! c_flags thread_is_keyword_code in
94+ let underscore_name = C. c_test c ~c_flags: ! c_flags underscore_name_code in
95+ let have_float16 = C. c_test c ~c_flags: ! c_flags have_float16_code in
96+
97+ C.C_define. gen_header_file c ~fname: ! fname [
8898 (" HAVE_STDLIB_H" , Switch (has_header c " stdlib.h" ));
8999 (" HAVE_WCHAR_H" , Switch (has_header c " wchar.h" ));
90100 (" HAVE_STDBOOL_H" , Switch (has_header c " stdbool.h" ));
0 commit comments