gnumake.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* External interfaces usable by dynamic objects loaded into GNU Make.
  2. --THIS API IS A "TECHNOLOGY PREVIEW" ONLY. IT IS NOT A STABLE INTERFACE--
  3. Copyright (C) 2013-2016 Free Software Foundation, Inc.
  4. This file is part of GNU Make.
  5. GNU Make is free software; you can redistribute it and/or modify it under the
  6. terms of the GNU General Public License as published by the Free Software
  7. Foundation; either version 3 of the License, or (at your option) any later
  8. version.
  9. GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License along with
  13. this program. If not, see <http://www.gnu.org/licenses/>. */
  14. #ifndef _GNUMAKE_H_
  15. #define _GNUMAKE_H_
  16. /* Specify the location of elements read from makefiles. */
  17. typedef struct
  18. {
  19. const char *filenm;
  20. unsigned long lineno;
  21. } gmk_floc;
  22. typedef char *(*gmk_func_ptr)(const char *nm, unsigned int argc, char **argv);
  23. #ifdef _WIN32
  24. # ifdef GMK_BUILDING_MAKE
  25. # define GMK_EXPORT __declspec(dllexport)
  26. # else
  27. # define GMK_EXPORT __declspec(dllimport)
  28. # endif
  29. #else
  30. # define GMK_EXPORT
  31. #endif
  32. /* Free memory returned by the gmk_expand() function. */
  33. GMK_EXPORT void gmk_free (char *str);
  34. /* Allocate memory in GNU make's context. */
  35. GMK_EXPORT char *gmk_alloc (unsigned int len);
  36. /* Run $(eval ...) on the provided string BUFFER. */
  37. GMK_EXPORT void gmk_eval (const char *buffer, const gmk_floc *floc);
  38. /* Run GNU make expansion on the provided string STR.
  39. Returns an allocated buffer that the caller must free with gmk_free(). */
  40. GMK_EXPORT char *gmk_expand (const char *str);
  41. /* Register a new GNU make function NAME (maximum of 255 chars long).
  42. When the function is expanded in the makefile, FUNC will be invoked with
  43. the appropriate arguments.
  44. The return value of FUNC must be either NULL, in which case it expands to
  45. the empty string, or a pointer to the result of the expansion in a string
  46. created by gmk_alloc(). GNU make will free the memory when it's done.
  47. MIN_ARGS is the minimum number of arguments the function requires.
  48. MAX_ARGS is the maximum number of arguments (or 0 if there's no maximum).
  49. MIN_ARGS and MAX_ARGS may not exceed 255.
  50. The FLAGS value may be GMK_FUNC_DEFAULT, or one or more of the following
  51. flags OR'd together:
  52. GMK_FUNC_NOEXPAND: the arguments to the function will be not be expanded
  53. before FUNC is called.
  54. */
  55. GMK_EXPORT void gmk_add_function (const char *name, gmk_func_ptr func,
  56. unsigned int min_args, unsigned int max_args,
  57. unsigned int flags);
  58. #define GMK_FUNC_DEFAULT 0x00
  59. #define GMK_FUNC_NOEXPAND 0x01
  60. #endif /* _GNUMAKE_H_ */