Call subdir make only for one level #331.
authorDaniel Carl <danielcarl@gmx.de>
Thu, 23 Mar 2017 12:28:00 +0000 (13:28 +0100)
committerDaniel Carl <danielcarl@gmx.de>
Thu, 23 Mar 2017 12:58:25 +0000 (13:58 +0100)
We can't control dependencies in case all the subdirs are processed from
the upper most Makefile. So now the subdir make used to create the
webextension and the script is called from the src/Makefile which knows
somethings more about dependencies.

Makefile
config.mk
src/Makefile

index a554a39..e2af9b9 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 include config.mk
 
-all: vimb
+all: $(SRCDIR)/vimb
 
 options:
        @echo "vimb build options:"
@@ -10,15 +10,10 @@ options:
        @echo "EXTCFLAGS = $(EXTCFLAGS)"
        @echo "CC        = $(CC)"
 
-vimb: $(SUBDIRS:%=%.subdir-all)
+$(SRCDIR)/vimb:
+       @$(MAKE) $(MFLAGS) -C $(SRCDIR)
 
-%.subdir-all:
-       @$(MAKE) $(MFLAGS) -C $*
-
-%.subdir-clean:
-       @$(MAKE) $(MFLAGS) -C $* clean
-
-install: vimb
+install: $(SRCDIR)/vimb
        @# binary
        install -d $(BINPREFIX)
        install -m 755 $(SRCDIR)/vimb $(BINPREFIX)/vimb
@@ -37,7 +32,8 @@ install: vimb
 uninstall:
        $(RM) $(BINPREFIX)/vimb $(DESTDIR)$(MANDIR)/man1/vimb.1 $(EXTPREFIX)/$(EXTTARGET)
 
-clean: $(SUBDIRS:%=%.subdir-clean)
+clean:
+       @$(MAKE) $(MFLAGS) -C $(SRCDIR) clean
 
 sandbox:
        @make $(MFLAGS) RUNPREFIX=$(CURDIR)/sandbox/usr PREFIX=/usr DESTDIR=./sandbox install
@@ -45,4 +41,4 @@ sandbox:
 runsandbox: sandbox
        sandbox/usr/bin/vimb
 
-.PHONY: all options clean install uninstall sandbox sandbox-clean
+.PHONY: all vimb options clean install uninstall sandbox
index c445f5a..93cd476 100644 (file)
--- a/config.mk
+++ b/config.mk
@@ -11,7 +11,6 @@ EXTPREFIX        := $(RUNPREFIX)/lib/vimb
 # define some directories
 SRCDIR  = src
 DOCDIR  = doc
-SUBDIRS = $(SRCDIR)/scripts $(SRCDIR)/webextension $(SRCDIR)
 
 # used libs
 LIBS = gtk+-3.0 'webkit2gtk-4.0 >= 2.3.5'
index b1bd8be..d85bd26 100644 (file)
@@ -1,17 +1,18 @@
 BASEDIR=..
 include $(BASEDIR)/config.mk
 
-OBJ = $(patsubst %.c, %.o, $(wildcard *.c))
+SUBDIRS = scripts webextension
+OBJ     = $(patsubst %.c, %.o, $(wildcard *.c))
 
 all: vimb
 
-clean:
+clean: $(SUBDIRS:%=%.subdir-clean)
        $(RM) vimb *.o
 
-vimb: $(OBJ)
-       $(CC) $(LDFLAGS) $^ -o $@
+vimb: $(OBJ) webextension.subdir-all
+       $(CC) $(LDFLAGS) $(OBJ) -o $@
 
-$(OBJ): config.h $(BASEDIR)/config.mk
+$(OBJ): scripts.subdir-all config.h $(BASEDIR)/config.mk
 
 -include $(OBJ:.o=.d)
 
@@ -23,4 +24,10 @@ config.h:
        @echo "${CC} $@"
        @$(CC) $(CFLAGS) -c -o $@ $<
 
+%.subdir-all: config.h
+       @$(MAKE) $(MFLAGS) -C $*
+
+%.subdir-clean:
+       @$(MAKE) $(MFLAGS) -C $* clean
+
 .PHONY: all clean