Reputation: 5317
I have a Makefile which is generated by a configure script with an option
In configure.ac:
AC_ARG_ENABLE([mmi],
AS_HELP_STRING([--enable-mmi], [Add the mmi function]),
[
AC_MSG_NOTICE([ * MMI: enabled])
AC_DEFINE([WITH_MMI], [1])
AC_SUBST(with_mmi, 1)
],
[
AC_MSG_NOTICE([ * MMI: disabled])
AC_SUBST(with_mmi, 0)
])
This option is also defined in a kconfig file (so we can change the config with a menuconfig type command instead of having to use the configure script directly)
The Makefile detect when the kconfig file is modified and in this case the configure script is run and the Makefile is modified.
The problem is that the Makefile is continuing and not using the parameter modified by the configure script.
If the make command is run a second time, it works correctly (the param is updated)
A workaround currently used is to force the exit of the Makefile directly after the configure script has been completed.
In Makefile.in:
%.o: %.c $(HEADERS) $(SELF_MAKEFILE) $(PTXDIST_PROJECT)/platform-myproject/state/myproject.prepare
gcc $(CFLAGS) -c -o $@ $<
$(PTXDIST_PROJECT)/platform-myproject/state/myproject.prepare: $(PTXCONFIG_FULL_PATH)
cd $(PTXDIST_PROJECT); ptxdist prepare myproject
@echo ============================================
@echo Makefile has been modified. Please run again
@echo ============================================
exit 1
Note: above the ptxdist prepare myproject
command is running the configure script and then is touching the $(PTXDIST_PROJECT)/platform-myproject/state/myproject.prepare
file
It would be much better if it was possible to ask the Makefile to read itself again if it was modified so that it could be run in one step without error.
Any idea on how I could accomplish this ?
Upvotes: 0
Views: 521
Reputation: 100866
Makefiles generated by automake know to re-run autoconf, and configure when the makefiles etc. change. It seems to me that if you move the invocation of the ptxdist prepare myproject
command into the autoconf file, not in the makefile, so that it's always done every time configure is invoked, then you won't have this problem.
If you don't want to do that then make will automatically re-invoke itself if any of its included makefiles changes. When you replied to Etan above you didn't say what the contents of myproject.prepare
are, but if it's just an empty file that is touched to tell make the preparation is up to date you can include that:
include $(PTXDIST_PROJECT)/platform-myproject/state/myproject.prepare
and it will happen. If this file is not empty and contains content you can't include as a makefile, then you can change things so that it DOES just touch an empty file:
PREPARE_SENTINEL = $(PTXDIST_PROJECT)/platform-myproject/state/prepare.sentinel
%.o: %.c $(HEADERS) $(SELF_MAKEFILE) $(PREPARE_SENTINEL)
gcc $(CFLAGS) -c -o $@ $<
$(PREPARE_SENTINEL): $(PTXCONFIG_FULL_PATH)
cd $(PTXDIST_PROJECT); ptxdist prepare myproject
@touch $@
include $(PREPARE_SENTINEL)
Upvotes: 3