#!/bin/bash read -r -d '' plugin_code <<'EOF' #include #include __attribute__((weak)) const gmk_floc* reading_file; int plugin_is_GPL_compatible; char* current_makefile(const char*nm,uint argc,char**argv) { unsigned int len = 1 + strlen( reading_file->filenm ); char* retval = gmk_alloc(len); strncpy( retval, reading_file->filenm, len ); return retval; } int test_gmk_setup() { gmk_add_function( "current_makefile", current_makefile, 0, 0, GMK_FUNC_NOEXPAND); return 1; } EOF echo "${plugin_code}" | clang -xc -fPIC -shared -o /tmp/test.so - read -r -d '' makefile <<'EOF' load /tmp/test.so $(info $(current_makefile)) $(info $(current_makefile )) $(info $(call current_makefile)) 'EOF' printf "${makefile}" | gmake -f - --warn-undefined-variables