(library
 (name avcodec)
 (public_name ffmpeg-avcodec)
 (synopsis "Bindings to ffmpeg's avcodec library")
 (foreign_stubs
  (language c)
  (names avcodec_stubs)
  (flags
   (:include c_flags.sexp)))
 (c_library_flags
  (:include c_library_flags.sexp))
 (install_c_headers avcodec_stubs)
 (libraries ffmpeg-avutil))

(rule
 (targets c_flags c_flags.sexp c_library_flags.sexp)
 (action
  (run ./config/discover.exe)))

(rule
 (targets avcodec_stubs.c)
 (mode fallback)
 (deps
  hw_config_method_stubs.h
  codec_capabilities_stubs.h
  codec_properties_stubs.h
  codec_id_stubs.h)
 (action
  (echo "this should not happen")))

(rule
 (targets hw_config_method_stubs.h)
 (deps c_flags)
 (action
  (run
   ../gen_code/gen_code.exe
   "%{cc}"
   hw_config_method
   h
   %{read-lines:c_flags})))

(rule
 (targets hw_config_method.ml)
 (deps hw_config_method_stubs.h c_flags)
 (action
  (run
   ../gen_code/gen_code.exe
   "%{cc}"
   hw_config_method
   ml
   %{read-lines:c_flags})))

(rule
 (targets codec_capabilities_stubs.h)
 (deps c_flags)
 (action
  (run
   ../gen_code/gen_code.exe
   "%{cc}"
   codec_capabilities
   h
   %{read-lines:c_flags})))

(rule
 (targets codec_capabilities.ml)
 (deps codec_capabilities_stubs.h c_flags)
 (action
  (run
   ../gen_code/gen_code.exe
   "%{cc}"
   codec_capabilities
   ml
   %{read-lines:c_flags})))

(rule
 (targets codec_properties_stubs.h)
 (deps c_flags)
 (action
  (run
   ../gen_code/gen_code.exe
   "%{cc}"
   codec_properties
   h
   %{read-lines:c_flags})))

(rule
 (targets codec_properties.ml)
 (deps codec_properties_stubs.h c_flags)
 (action
  (run
   ../gen_code/gen_code.exe
   "%{cc}"
   codec_properties
   ml
   %{read-lines:c_flags})))

(rule
 (targets codec_id_stubs.h)
 (deps c_flags)
 (action
  (run ../gen_code/gen_code.exe "%{cc}" codec_id h %{read-lines:c_flags})))

(rule
 (targets codec_id.ml)
 (deps codec_id_stubs.h c_flags)
 (action
  (run ../gen_code/gen_code.exe "%{cc}" codec_id ml %{read-lines:c_flags})))
