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