(executable
 (name gen_stubs)
 (modules gen_stubs)
 (libraries posix-socket.stubs posix-base))

(executable
 (name gen_types_c)
 (modules gen_types_c)
 (libraries posix-socket.types posix-base))

(rule
 (targets gen_types.c)
 (action
  (run ./gen_types_c.exe %{targets})))

(rule
 (targets gen_types_c_target.exe)
 (deps
  (:c_code ./gen_types.c))
 (action
  (run
   %{ocaml-config:c_compiler}
   %{read-lines:../../../../base/c_flags}
   -I
   %{ocaml-config:standard_library}
   -o
   %{targets}
   %{c_code})))

(executable
 (name gen_constants_c)
 (modules gen_constants_c)
 (libraries posix-socket.constants posix-base eai_errno_defaults))

(rule
 (targets gen_constants.c)
 (action
  (run ./gen_constants_c.exe %{targets})))

(rule
 (targets gen_constants_c_target.exe)
 (deps
  (:c_code ./gen_constants.c))
 (action
  (run
   %{ocaml-config:c_compiler}
   %{read-lines:../../../../base/c_flags}
   -I
   %{ocaml-config:standard_library}
   -o
   %{targets}
   %{c_code})))

(library
 (name eai_errno_defaults)
 (libraries str posix_base)
 (modules eai_errno_defaults))

(executable
 (name gen_eai_errno_constants)
 (modules gen_eai_errno_constants)
 (libraries eai_errno_defaults))

(executable
 (name gen_eai_errno_type)
 (modules gen_eai_errno_type)
 (libraries eai_errno_defaults))

(executable
 (name gen_eai_errno_conversions)
 (modules gen_eai_errno_conversions)
 (libraries eai_errno_defaults))

(executable
 (name gen_is_native_detector)
 (modules gen_is_native_detector)
 (libraries eai_errno_defaults))

(rule
 (targets target_is_native_detector.c)
 (action
  (with-stdout-to
   %{targets}
   (run ./gen_is_native_detector.exe))))

(executable
 (name gen_get_value)
 (modules gen_get_value)
 (libraries eai_errno_defaults posix-socket))

(rule
 (targets target_is_native_detector.exe)
 (deps target_is_native_detector.c)
 (action
  (run %{ocaml-config:c_compiler} -o %{targets} target_is_native_detector.c)))
