remake  4.3+dbg-1.5
gnuremake.h
Go to the documentation of this file.
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 #ifndef _REMAKE_GNUMAKE_H_
20 #define _REMAKE_GNUMAKE_H_
21 
22 /* Specify the location of elements read from makefiles. */
23 typedef struct
24  {
25  const char *filenm;
26  unsigned long lineno;
27  unsigned long offset;
28  } gmk_floc;
29 
30 typedef char *(*gmk_func_ptr)(const char *nm, unsigned int argc, char **argv);
31 
32 #ifdef _WIN32
33 # ifdef GMK_BUILDING_MAKE
34 # define GMK_EXPORT __declspec(dllexport)
35 # else
36 # define GMK_EXPORT __declspec(dllimport)
37 # endif
38 #else
39 # define GMK_EXPORT
40 #endif
41 
42 /* Free memory returned by the gmk_expand() function. */
43 GMK_EXPORT void gmk_free (char *str);
44 
45 /* Allocate memory in GNU make's context. */
46 GMK_EXPORT char *gmk_alloc (unsigned int len);
47 
48 /* Run $(eval ...) on the provided string BUFFER. */
49 GMK_EXPORT void gmk_eval (const char *buffer, const gmk_floc *floc);
50 
51 /* Run GNU make expansion on the provided string STR.
52  Returns an allocated buffer that the caller must free with gmk_free(). */
53 GMK_EXPORT char *gmk_expand (const char *str);
54 
55 /* Register a new GNU make function NAME (maximum of 255 chars long).
56  When the function is expanded in the makefile, FUNC will be invoked with
57  the appropriate arguments.
58 
59  The return value of FUNC must be either NULL, in which case it expands to
60  the empty string, or a pointer to the result of the expansion in a string
61  created by gmk_alloc(). GNU make will free the memory when it's done.
62 
63  MIN_ARGS is the minimum number of arguments the function requires.
64  MAX_ARGS is the maximum number of arguments (or 0 if there's no maximum).
65  MIN_ARGS and MAX_ARGS may not exceed 255.
66 
67  The FLAGS value may be GMK_FUNC_DEFAULT, or one or more of the following
68  flags OR'd together:
69 
70  GMK_FUNC_NOEXPAND: the arguments to the function will be not be expanded
71  before FUNC is called.
72 */
73 GMK_EXPORT void gmk_add_function (const char *name, gmk_func_ptr func,
74  unsigned int min_args, unsigned int max_args,
75  unsigned int flags);
76 
77 #define GMK_FUNC_DEFAULT 0x00
78 #define GMK_FUNC_NOEXPAND 0x01
79 
80 #endif /* _REMAKE_GNUMAKE_H_ */
GMK_EXPORT char * gmk_expand(const char *str)
char *(* gmk_func_ptr)(const char *nm, unsigned int argc, char **argv)
Definition: gnuremake.h:30
GMK_EXPORT char * gmk_alloc(unsigned int len)
unsigned long offset
Definition: gnuremake.h:27
unsigned long lineno
Definition: gnuremake.h:26
GMK_EXPORT void gmk_add_function(const char *name, gmk_func_ptr func, unsigned int min_args, unsigned int max_args, unsigned int flags)
Definition: gnuremake.h:23
GMK_EXPORT void gmk_free(char *str)
#define GMK_EXPORT
Definition: gnuremake.h:39
const char * filenm
Definition: gnuremake.h:25
GMK_EXPORT void gmk_eval(const char *buffer, const gmk_floc *floc)
char * name
Definition: variable.h:58