###
#
# PastixCTags: ??
#
###
FILE(WRITE ${CMAKE_BINARY_DIR}/unprotect.cmake "
    FILE(WRITE \${DST} \"#ifdef MURGE_PASTIX_H\")
    FILE(APPEND \${DST} \"#  define MURGE_PASTIX_WAS_INCLUDED\")
    FILE(APPEND \${DST} \"#  undef  MURGE_PASTIX_H\")
    FILE(APPEND \${DST} \"#endif /* MURGE_PASTIX_H */\")
    FILE(APPEND \${DST} \"\")
    FILE(READ _src \${SRC})
    FILE(APPEND \${DST} \${_src})
    FILE(APPEND \${DST} \"\")
    FILE(APPEND \${DST} \"#undef MURGE_PASTIX_H\")
    FILE(APPEND \${DST} \"#ifdef MURGE_PASTIX_WAS_INCLUDED\")
    FILE(APPEND \${DST} \"#  define MURGE_PASTIX_H\")
    FILE(APPEND \${DST} \"#  undef MURGE_PASTIX_WAS_INCLUDED\")
    FILE(APPEND \${DST} \"#endif /* MURGE_PASTIX_WAS_INCLUDED */\")")

FILE(WRITE ${CMAKE_BINARY_DIR}/generate_zmurge.cmake "
    EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E echo \"#ifndef ZMURGE_PASTIX_H\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#define ZMURGE_PASTIX_H\"
      COMMAND ${CMAKE_COMMAND} -E echo \"\"
      COMMAND ${CMAKE_COMMAND} -E ${CTAGS} -x --c-kinds=fp \${SRC} |awk '{printf \"#define %-30s\t Z%-30s\n\"
      COMMAND ${CMAKE_COMMAND} -E echo \"\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#define MURGE_UserData_ ZMURGE_UserData_\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#define MURGE_UserData_t ZMURGE_UserData_t\"
      COMMAND ${CMAKE_COMMAND} -E echo \"\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#ifndef PREC_DOUBLE\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#  define PREC_DOUBLE\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#endif /* PREC_DOUBLE */\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#ifndef TYPE_COMPLEX\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#  define TYPE_COMPLEX\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#endif /* TYPE_COMPLEX */\"
      COMMAND ${CMAKE_COMMAND} -E echo \"\"
      COMMAND ${CMAKE_COMMAND} -E cat \${SRC}
      COMMAND ${CMAKE_COMMAND} -E echo \"\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#ifndef OVERWRITE_MURGE_CALLS\"
      COMMAND ${CMAKE_COMMAND} -E ${CTAGS} -x --c-kinds=fp \${SRC} |awk '{printf \"#  undef %-30s\n\"
      COMMAND ${CMAKE_COMMAND} -E echo \"\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#  undef MURGE_UserData_\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#  undef MURGE_UserData_t\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#endif /* OVERWRITE_MURGE_CALLS */\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#endif /* ZMURGE_PASTIX_H */\"
      OUTPUT_FILE \${DST})")

FILE(WRITE ${CMAKE_BINARY_DIR}/generate_dmurge.cmake "
    EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E echo \"#ifndef DMURGE_PASTIX_H\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#define DMURGE_PASTIX_H\"
      COMMAND ${CMAKE_COMMAND} -E echo \"\"
      COMMAND ${CMAKE_COMMAND} -E ${CTAGS} -x --c-kinds=fp \${SRC} |awk '{printf \"#define %-30s\t D%-30s\n\"
      COMMAND ${CMAKE_COMMAND} -E echo \"\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#define MURGE_UserData_ DMURGE_UserData_\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#define MURGE_UserData_t DMURGE_UserData_t\"
      COMMAND ${CMAKE_COMMAND} -E echo \"\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#ifndef PREC_DOUBLE\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#  define PREC_DOUBLE\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#endif /* PREC_DOUBLE */\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#ifdef TYPE_COMPLEX\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#  undef TYPE_COMPLEX\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#endif /* TYPE_COMPLEX */\"
      COMMAND ${CMAKE_COMMAND} -E echo \"\"
      COMMAND ${CMAKE_COMMAND} -E cat \${SRC}
      COMMAND ${CMAKE_COMMAND} -E echo \"\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#ifndef OVERWRITE_MURGE_CALLS\"
      COMMAND ${CMAKE_COMMAND} -E ${CTAGS} -x --c-kinds=fp \${SRC} |awk '{printf \"#  undef %-30s\n\"
      COMMAND ${CMAKE_COMMAND} -E echo \"\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#  undef MURGE_UserData_\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#  undef MURGE_UserData_t\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#endif /* OVERWRITE_MURGE_CALLS */\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#endif /* DMURGE_PASTIX_H */\"
      OUTPUT_FILE \${DST})")

FILE(WRITE ${CMAKE_BINARY_DIR}/generate_cmurge.cmake "
    EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E echo \"#ifndef CMURGE_PASTIX_H\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#define CMURGE_PASTIX_H\"
      COMMAND ${CMAKE_COMMAND} -E echo \"\"
      COMMAND ${CMAKE_COMMAND} -E ${CTAGS} -x --c-kinds=fp \${SRC} |awk '{printf \"#define %-30s\t C%-30s\n\"
      COMMAND ${CMAKE_COMMAND} -E echo \"\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#define MURGE_UserData_ CMURGE_UserData_\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#define MURGE_UserData_t CMURGE_UserData_t\"
      COMMAND ${CMAKE_COMMAND} -E echo \"\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#ifdef PREC_DOUBLE\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#  undef PREC_DOUBLE\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#endif /* PREC_DOUBLE */\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#ifndef TYPE_COMPLEX\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#  define TYPE_COMPLEX\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#endif /* TYPE_COMPLEX */\"
      COMMAND ${CMAKE_COMMAND} -E echo \"\"
      COMMAND ${CMAKE_COMMAND} -E cat \${SRC}
      COMMAND ${CMAKE_COMMAND} -E echo \"\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#ifndef OVERWRITE_MURGE_CALLS\"
      COMMAND ${CMAKE_COMMAND} -E ${CTAGS} -x --c-kinds=fp \${SRC} |awk '{printf \"#  undef %-30s\n\"
      COMMAND ${CMAKE_COMMAND} -E echo \"\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#  undef MURGE_UserData_\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#  undef MURGE_UserData_t\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#endif /* OVERWRITE_MURGE_CALLS */\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#endif /* CMURGE_PASTIX_H */\"
      OUTPUT_FILE \${DST})")


FILE(WRITE ${CMAKE_BINARY_DIR}/generate_smurge.cmake "
    EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E echo \"#ifndef SMURGE_PASTIX_H\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#define SMURGE_PASTIX_H\"
      COMMAND ${CMAKE_COMMAND} -E echo \"\"
      COMMAND ${CMAKE_COMMAND} -E ${CTAGS} -x --c-kinds=fp \${SRC} |awk '{printf \"#define %-30s\t S%-30s\n\"
      COMMAND ${CMAKE_COMMAND} -E echo \"\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#define MURGE_UserData_ SMURGE_UserData_\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#define MURGE_UserData_t SMURGE_UserData_t\"
      COMMAND ${CMAKE_COMMAND} -E echo \"\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#ifdef PREC_DOUBLE\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#  undef PREC_DOUBLE\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#endif /* PREC_DOUBLE */\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#ifdef TYPE_COMPLEX\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#  undef TYPE_COMPLEX\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#endif /* TYPE_COMPLEX */\"
      COMMAND ${CMAKE_COMMAND} -E echo \"\"
      COMMAND ${CMAKE_COMMAND} -E cat \${SRC}
      COMMAND ${CMAKE_COMMAND} -E echo \"\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#ifndef OVERWRITE_MURGE_CALLS\"
      COMMAND ${CMAKE_COMMAND} -E ${CTAGS} -x --c-kinds=fp \${SRC} |awk '{printf \"#  undef %-30s\n\"
      COMMAND ${CMAKE_COMMAND} -E echo \"\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#  undef MURGE_UserData_\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#  undef MURGE_UserData_t\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#endif /* OVERWRITE_MURGE_CALLS */\"
      COMMAND ${CMAKE_COMMAND} -E echo \"#endif /* SMURGE_PASTIX_H */\"
      OUTPUT_FILE \${DST})")

add_custom_command(OUTPUT ${CMAKE_SOURCE_DIR}/sopalin/src/murge_pastix_unprotected.h
  COMMAND ${CMAKE_COMMAND}
  -DSRC=sopalin/src/murge_pastix.h
  -DDST=${CMAKE_SOURCE_DIR}/sopalin/src/murge_pastix_unprotected.h
  -P ${CMAKE_BINARY_DIR}/unprotect.cmake
  DEPENDS sopalin/src/murge_pastix.h ${CMAKE_BINARY_DIR}/unprotect.cmake)

foreach(p "s" "d" "c" "z")
  add_custom_command(OUTPUT ${CMAKE_SOURCE_DIR}/sopalin/src/${p}murge_pastix.h
    COMMAND ${CMAKE_COMMAND}
    -DSRC=sopalin/src/murge_pastix.h
    -DDST=${CMAKE_BINARY_DIR}/sopalin/src/${p}murge_pastix.h
    -P ${CMAKE_BINARY_DIR}/generate_${p}murge.cmake
    DEPENDS sopalin/src/murge_pastix.h ${CMAKE_BINARY_DIR}/generate_${p}murge.cmake)
  add_custom_target(${p}murge_pastix_h ALL DEPENDS ${CMAKE_SOURCE_DIR}/sopalin/src/${p}murge_pastix.h)
endforeach()