6

I've added my own .c file to Emacs /src directory as well as the following lines

emacs.o: ... file.c file.h
file.o: file.c

in deps.mk

I get file.o generated, but it is not linked when generating Emacs executable (at least that's what I see when I check presence of my function). Why?

In general, what actions should I undertake to add my .c file to Emacs executable?

Sergey
  • 211
  • 1
  • 6

2 Answers2

3

Quoting deps.mk:

## This file is included in src/Makefile if AUTO_DEPEND=no.\

So it's kind of a fallback file only used to give dependencies to make sure compilation ordering is right. You want to look in src/Makefile.in instead where you should have no difficulty finding the variable that contains all the .o files we need.

Stefan
  • 26,154
  • 3
  • 46
  • 84
2

The problem was not in a build system but in Emacs itself.
In order to have a function defined with DEFUN available for a user you must not only define it but also write in your file:

void
syms_of_filename (void)
{
  defsubr (&Sfunction_name);
  ...
}

and call this function from emacs.c

Sergey
  • 211
  • 1
  • 6