I am in the process of converting old autotools setup with a handwritten Makefile.in (and of-course a configure.in) to the latest (Makefile.am and configure.ac). Up to now things were looking fine, but I ran into something I cannot find the answer for in other questions.
I added a define in Makefile.am that is included in the compile of all c-modules I indicated in _SOURCES but one. I see absolutely no difference between the c-sources, except that the one where the define is not included in the compile is the main of the program.
Below the code for Makefile.am (relevant part):
bin_PROGRAMS = wpe we
lib_LTLIBRARIES = libxwpe-x11.la libxwpe-term.la
libxwpe_x11_la_SOURCES = we_xterm.c WeXterm.c
libxwpe_x11_la_CPPFLAGS = -DLIBRARY_DIR=\"@libdir@/xwpe\"
libxwpe_term_la_SOURCES = we_term.c
libxwpe_term_la_CPPFLAGS = -DLIBRARY_DIR=\"@libdir@/xwpe\"
wpe_SOURCES = we_main.c we_block.c we_unix.c we_e_aus.c \
we_edit.c we_fl_fkt.c we_fl_unix.c we_hfkt.c \
we_menue.c we_mouse.c we_opt.c we_wind.c \
we_prog.c we_progn.c we_debug.c WeString.c \
WeSyntax.c WeExpArr.c WeLinux.c we_gpm.c
wpe_LDADD = libxwpe-x11.la libxwpe-term.la
wpe_CPPFLAGS = -DLIBRARY_DIR=\"@libdir@/xwpe\"
we_SOURCES = we_main.c we_block.c we_unix.c we_e_aus.c \
we_edit.c we_fl_fkt.c we_fl_unix.c we_hfkt.c \
we_menue.c we_mouse.c we_opt.c we_wind.c \
we_prog.c we_progn.c we_debug.c WeString.c \
WeSyntax.c WeExpArr.c WeLinux.c we_gpm.c
The result of the compile is that all c sources are compiled with the define of LIBRARY_DIR, except for we_main.c which is compiled without this define.
Does anyone have any idea what could cause this difference? What am I doing wrong? Should I not have defined wpe_CPPFLAGS but some other flag?
EDIT 1: Looking at the Makefile, I noticed that it compiles we_main multiple times! It create we-we_main.o, wpe-we_main.o and xwe-we_main.o. These files are all compiled correctly, but the only one I don't understand is the compilation of we_main.o which is compiled without the define. It looks like I am missing a flag that I should have defined. Probably I misunderstand the automake input in Makefile.am. Should I define an extra flag? If so, which one?
EDIT 2: Multiple compiles seems a bit wasteful. I am new to autotools, so there might be a better solution. If necessary I will pose a different query about this subject.