Commit 1ff21c5c authored by Sergey Kosukhin's avatar Sergey Kosukhin
Browse files

init environment once in a separate makefile

parent 06f63918
......@@ -5,6 +5,7 @@
/Makefile
/config.log
/config.status
/main.mk
src/*.o
src/.dirstamp
......
CC= @CC@
CFLAGS= @CFLAGS@
CPPFLAGS= @CPPFLAGS@
LDFLAGS= @LDFLAGS@
LIBS= @LIBS@
SHELL= @SHELL@
BUILD_ENV= @BUILD_ENV_MAKE@
.SUFFIXES:
.PHONY: all install mostlyclean clean distclean
vpath %.c @srcdir@
prefix= @prefix@
exec_prefix= @exec_prefix@
INSTALL= @INSTALL@
src_files= \
src/foo.c \
src/main.c
obj_files= $(src_files:.c=.@OBJEXT@)
dir_files= $(addsuffix .dirstamp,$(dir $(obj_files)))
exec_files= \
src/main
DELEGATEE_FILE= main.mk
dir_files+= $(addsuffix .dirstamp,$(dir $(exec_files)))
# Eliminate duplicates:
dir_files:= $(sort $(dir_files))
all: $(exec_files)
mostlyclean:
rm -f $(exec_files) $(obj_files)
clean: mostlyclean
rm -f $(dir_files)
distclean: clean
rm -f config.log config.status Makefile
install: $(exec_files)
$(INSTALL) -d @bindir@ && $(INSTALL) $^ @bindir@
.SUFFIXES:
.NOTPARALLEL:
.PHONY: all distclean force-delegate
all:
$(BUILD_ENV) $(MAKE) -f $(DELEGATEE_FILE) $@
src/main: $(obj_files)
$(exec_files):| $(dir_files)
$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $+ $(LIBS)
%:: force-delegate
$(BUILD_ENV) $(MAKE) -f $(DELEGATEE_FILE) $@
%.@OBJEXT@: %.c | $(dir_files)
$(CC) -o $@ -c $(CFLAGS) $(CPPFLAGS) $<
Makefile:;
.PRECIOUS: $(dir_files)
%/.dirstamp:
@MKDIR_P@ $(@D) && touch $@
distclean:
@$(BUILD_ENV) $(MAKE) -f $(DELEGATEE_FILE) $@
rm -f Makefile
......@@ -12,6 +12,6 @@ AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_MKDIR_P
AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([Makefile main.mk])
AC_OUTPUT
CC= @CC@
CFLAGS= @CFLAGS@
CPPFLAGS= @CPPFLAGS@
LDFLAGS= @LDFLAGS@
LIBS= @LIBS@
.SUFFIXES:
.PHONY: all install mostlyclean clean distclean
vpath %.c @srcdir@
prefix= @prefix@
exec_prefix= @exec_prefix@
INSTALL= @INSTALL@
src_files= \
src/foo.c \
src/main.c
obj_files= $(src_files:.c=.@OBJEXT@)
dir_files= $(addsuffix .dirstamp,$(dir $(obj_files)))
exec_files= \
src/main
dir_files+= $(addsuffix .dirstamp,$(dir $(exec_files)))
# Eliminate duplicates:
dir_files:= $(sort $(dir_files))
all: $(exec_files)
mostlyclean:
rm -f $(exec_files) $(obj_files)
clean: mostlyclean
rm -f $(dir_files)
distclean: clean
rm -f config.log config.status main.mk
install: $(exec_files)
$(INSTALL) -d @bindir@ && $(INSTALL) $^ @bindir@
src/main: $(obj_files)
$(exec_files):| $(dir_files)
$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $+ $(LIBS)
%.@OBJEXT@: %.c | $(dir_files)
$(CC) -o $@ -c $(CFLAGS) $(CPPFLAGS) $<
.PRECIOUS: $(dir_files)
%/.dirstamp:
@MKDIR_P@ $(@D) && touch $@
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment