From 434f0b930e5e54ca9f483907b0b7c6d93462a5de Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Thu, 21 Mar 2019 10:40:00 +0100 Subject: [PATCH] Made Makefile concurrent so that it can be compiled with -jN --- CHANGELOG.md | 1 + Makefile.in | 2 +- apps/backend/Makefile.in | 12 ++++++++---- apps/cli/Makefile.in | 10 ++++++---- apps/netconf/Makefile.in | 6 +++++- apps/restconf/Makefile.in | 6 +++++- lib/src/Makefile.in | 18 +++++------------- util/Makefile.in | 21 +++++++++++++-------- 8 files changed, 44 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79830f07a..f9813c666 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ ``` ### Minor changes +* Made Makefile concurrent so that it can be compiled with -jN * Added flags to example backend to control its behaviour: * Start with `-- -r` to run the reset plugin * Start with `-- -s` to run the state callback diff --git a/Makefile.in b/Makefile.in index 8680fe3d1..b5f418bcb 100644 --- a/Makefile.in +++ b/Makefile.in @@ -58,7 +58,7 @@ SUBDIRS = lib apps include etc datastore yang all: $(SUBDIRS) -$(SUBDIRS): +$(SUBDIRS): include lib # Cannot build app before lib (for parallel make -j) (cd $@ && $(MAKE) $(MFLAGS) all) depend: diff --git a/apps/backend/Makefile.in b/apps/backend/Makefile.in index 5ddc0ce31..456778547 100644 --- a/apps/backend/Makefile.in +++ b/apps/backend/Makefile.in @@ -55,7 +55,7 @@ CLIXON_MAJOR = @CLIXON_VERSION_MAJOR@ CLIXON_MINOR = @CLIXON_VERSION_MINOR@ # Use this clixon lib for linking -CLIXON_LIB = libclixon.so.$(CLIXON_MAJOR).$(CLIXON_MINOR) +CLIXON_LIB = libclixon$(SH_SUFFIX).$(CLIXON_MAJOR).$(CLIXON_MINOR) # For dependency. A little strange that we rely on it being built in the src dir # even though it may exist in $(libdir). But the new version may not have been installed yet. @@ -89,13 +89,17 @@ MYLIBSO = $(MYLIBLINK).$(CLIXON_MAJOR) all: $(MYLIB) $(APPL) test +# Dependency of clixon library +$(top_srcdir)/lib/src/$(CLIXON_LIB): + (cd $(top_srcdir)/lib/src && $(MAKE) $(MFLAGS) $(CLIXON_LIB)) + clean: rm -f *.core $(APPL) $(APPOBJ) $(LIBOBJ) $(MYLIB) $(MYLIBSO) $(MYLIBLINK) distclean: clean rm -f Makefile *~ .depend test test.c -# Put demon in bin +# Put daemon in bin # Put other executables in libexec/ # Also create a libexec/ directory for writeable/temporary files. # Put config file in etc/ @@ -129,13 +133,13 @@ install-include: clixon_backend.h clixon_backend_handle.h clixon_backend_transac test.c : echo "int main(){}" > $@ -test: test.c $(LIBOBJ) +test: test.c $(LIBOBJ) $(MYLIB) $(CC) $(INCLUDES) $(LDFLAGS) $< $(LIBOBJ) -L. $(MYLIB) $(LIBS) -o $@ $(APPL) : $(APPOBJ) $(MYLIBLINK) $(LIBDEPS) $(CC) $(LDFLAGS) $(APPOBJ) -L. $(MYLIB) $(LIBS) -o $@ -$(MYLIB): $(LIBOBJ) +$(MYLIB): $(LIBOBJ) $(LIBDEPS) ifeq ($(HOST_VENDOR),apple) $(CC) $(LDFLAGS) -shared -undefined dynamic_lookup -o $@ -lc $(LIBOBJ) else diff --git a/apps/cli/Makefile.in b/apps/cli/Makefile.in index 2b75b479c..b69017ead 100644 --- a/apps/cli/Makefile.in +++ b/apps/cli/Makefile.in @@ -88,10 +88,12 @@ MYLIBLINK = lib$(MYNAME)$(SH_SUFFIX) MYLIB = $(MYLIBLINK).$(CLIXON_MAJOR).$(CLIXON_MINOR) MYLIBSO = $(MYLIBLINK).$(CLIXON_MAJOR) - - all: $(MYLIB) $(APPL) test +# Dependency of clixon library +$(top_srcdir)/lib/src/$(CLIXON_LIB): + (cd $(top_srcdir)/lib/src && $(MAKE) $(MFLAGS) $(CLIXON_LIB)) + clean: rm -f $(LIBOBJ) $(APPOBJ) *.core $(APPL) $(MYLIB) $(MYLIBSO) $(MYLIBLINK) @@ -132,13 +134,13 @@ uninstall: test.c : echo "int main(){}" > $@ -test: test.c $(LIBOBJ) +test: test.c $(LIBOBJ) $(MYLIB) $(CC) $(INCLUDES) $(LDFLAGS) $< $(LIBOBJ) -L. $(MYLIB) $(LIBS) -o $@ $(APPL): $(APPOBJ) $(MYLIBLINK) $(LIBDEPS) $(CC) $(LDFLAGS) $(APPOBJ) -L. $(MYLIB) $(LIBS) -o $@ -$(MYLIB) : $(LIBOBJ) +$(MYLIB) : $(LIBOBJ) $(LIBDEPS) ifeq ($(HOST_VENDOR),apple) $(CC) $(LDFLAGS) -shared -undefined dynamic_lookup -o $@ $(LIBOBJ) $(LIBS) else diff --git a/apps/netconf/Makefile.in b/apps/netconf/Makefile.in index 5349a0273..2184279d5 100644 --- a/apps/netconf/Makefile.in +++ b/apps/netconf/Makefile.in @@ -89,6 +89,10 @@ MYLIBSO = $(MYLIBLINK).$(CLIXON_MAJOR) all: $(MYLIB) $(APPL) +# Dependency of clixon library (LIBDEPS) +$(top_srcdir)/lib/src/$(CLIXON_LIB): + (cd $(top_srcdir)/lib/src && $(MAKE) $(MFLAGS) $(CLIXON_LIB)) + clean: rm -f $(APPL) $(APPOBJ) $(LIBOBJ) *.core $(MYLIB) $(MYLIBSO) $(MYLIBLINK) @@ -127,7 +131,7 @@ uninstall: $(APPL) : $(APPOBJ) $(MYLIBLINK) $(LIBDEPS) $(CC) $(LDFLAGS) $(APPOBJ) -L. $(MYLIB) $(LIBS) -o $@ -$(MYLIB) : $(LIBOBJ) +$(MYLIB) : $(LIBOBJ) $(LIBDEPS) ifeq ($(HOST_VENDOR),apple) $(CC) $(LDFLAGS) -shared -undefined dynamic_lookup -o $@ $(LIBOBJ) $(LIBS) else diff --git a/apps/restconf/Makefile.in b/apps/restconf/Makefile.in index 7c8f2d68d..9185c60cd 100644 --- a/apps/restconf/Makefile.in +++ b/apps/restconf/Makefile.in @@ -91,6 +91,10 @@ MYLIBSO = $(MYLIBLINK).$(CLIXON_MAJOR) all: $(MYLIB) $(APPL) +# Dependency of clixon library +$(top_srcdir)/lib/src/$(CLIXON_LIB): + (cd $(top_srcdir)/lib/src && $(MAKE) $(MFLAGS) $(CLIXON_LIB)) + clean: rm -f $(LIBOBJ) *.core $(APPL) $(APPOBJ) $(MYLIB) $(MYLIBSO) $(MYLIBLINK) @@ -133,7 +137,7 @@ uninstall: $(APPL) : $(APPOBJ) $(MYLIBLINK) $(LIBDEPS) $(CC) $(LDFLAGS) $(APPOBJ) -L. $(MYLIB) $(LIBS) -o $@ -$(MYLIB) : $(LIBOBJ) +$(MYLIB) : $(LIBOBJ) $(LIBDEPS) ifeq ($(HOST_VENDOR),apple) $(CC) $(LDFLAGS) -shared -undefined dynamic_lookup -o $@ $(LIBOBJ) $(LIBS) else diff --git a/lib/src/Makefile.in b/lib/src/Makefile.in index fc8fa3e44..d518c8262 100644 --- a/lib/src/Makefile.in +++ b/lib/src/Makefile.in @@ -74,7 +74,7 @@ SRC = clixon_sig.c clixon_log.c clixon_err.c clixon_event.c \ clixon_hash.c clixon_options.c clixon_plugin.c \ clixon_proto.c clixon_proto_client.c \ clixon_xpath.c clixon_xpath_ctx.c clixon_sha1.c \ - clixon_xml_db.c clixon_netconf_lib.c clixon_stream.c clixon_nacm.c + clixon_xml_db.c clixon_netconf_lib.c clixon_stream.c clixon_nacm.c YACCOBJS := lex.clixon_xml_parse.o clixon_xml_parse.tab.o \ lex.clixon_yang_parse.o clixon_yang_parse.tab.o \ @@ -124,9 +124,7 @@ lex.clixon_xml_parse.c : clixon_xml_parse.l clixon_xml_parse.tab.h $(LEX) -Pclixon_xml_parse clixon_xml_parse.l # -d is debug clixon_xml_parse.tab.c clixon_xml_parse.tab.h: clixon_xml_parse.y - $(YACC) -l -d -p clixon_xml_parse clixon_xml_parse.y # -t is debug - mv y.tab.c clixon_xml_parse.tab.c - mv y.tab.h clixon_xml_parse.tab.h + $(YACC) -l -d -b clixon_xml_parse -p clixon_xml_parse clixon_xml_parse.y # -t is debug lex.clixon_xml_parse.o : lex.clixon_xml_parse.c clixon_xml_parse.tab.h # special rule to for make clean to work $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -Wno-error -c $< @@ -136,9 +134,7 @@ lex.clixon_yang_parse.c : clixon_yang_parse.l clixon_yang_parse.tab.h $(LEX) -Pclixon_yang_parse clixon_yang_parse.l # -d is debug clixon_yang_parse.tab.c clixon_yang_parse.tab.h: clixon_yang_parse.y - $(YACC) -l -d -p clixon_yang_parse clixon_yang_parse.y # -t is debug - mv y.tab.c clixon_yang_parse.tab.c - mv y.tab.h clixon_yang_parse.tab.h + $(YACC) -l -d -b clixon_yang_parse -p clixon_yang_parse clixon_yang_parse.y # -t is debug lex.clixon_yang_parse.o : lex.clixon_yang_parse.c clixon_yang_parse.tab.h $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -Wno-error -c $< @@ -148,9 +144,7 @@ lex.clixon_json_parse.c : clixon_json_parse.l clixon_json_parse.tab.h $(LEX) -Pclixon_json_parse clixon_json_parse.l # -d is debug clixon_json_parse.tab.c clixon_json_parse.tab.h: clixon_json_parse.y - $(YACC) -l -d -p clixon_json_parse clixon_json_parse.y # -t is debug - mv y.tab.c clixon_json_parse.tab.c - mv y.tab.h clixon_json_parse.tab.h + $(YACC) -l -d -b clixon_json_parse -p clixon_json_parse clixon_json_parse.y # -t is debug lex.clixon_json_parse.o : lex.clixon_json_parse.c clixon_json_parse.tab.h $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -Wno-error -c $< @@ -160,9 +154,7 @@ lex.clixon_xpath_parse.c : clixon_xpath_parse.l clixon_xpath_parse.tab.h $(LEX) -Pclixon_xpath_parse clixon_xpath_parse.l # -d is debug clixon_xpath_parse.tab.c clixon_xpath_parse.tab.h: clixon_xpath_parse.y - $(YACC) -l -d -p clixon_xpath_parse clixon_xpath_parse.y # -t is debug - mv y.tab.c clixon_xpath_parse.tab.c - mv y.tab.h clixon_xpath_parse.tab.h + $(YACC) -l -d -b clixon_xpath_parse -p clixon_xpath_parse clixon_xpath_parse.y # -t is debug lex.clixon_xpath_parse.o : lex.clixon_xpath_parse.c clixon_xpath_parse.tab.h $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -Wno-error -c $< diff --git a/util/Makefile.in b/util/Makefile.in index b5abfd154..a4ef9f675 100644 --- a/util/Makefile.in +++ b/util/Makefile.in @@ -62,9 +62,10 @@ LIBS = @LIBS@ CPPFLAGS = @CPPFLAGS@ -INCLUDES = -I. @INCLUDES@ -I$(top_srcdir)/lib -I$(top_srcdir)/include +INCLUDES = -I. @INCLUDES@ -I$(top_srcdir)/lib -I$(top_srcdir)/include -MYLIB = ../lib/src/libclixon$(SH_SUFFIX).$(CLIXON_MAJOR).$(CLIXON_MINOR) +CLIXON_LIB = libclixon$(SH_SUFFIX).$(CLIXON_MAJOR).$(CLIXON_MINOR) +LIBDEPS = $(top_srcdir)/lib/src/$(CLIXON_LIB) # Utilities, unit testings. Not installed. APPSRC = clixon_util_xml.c @@ -80,26 +81,30 @@ APPS = $(APPSRC:.c=) all: $(APPS) +# Dependency of clixon library +$(top_srcdir)/lib/src/$(CLIXON_LIB): + (cd $(top_srcdir)/lib/src && $(MAKE) $(MFLAGS) $(CLIXON_LIB)) + clean: rm -f $(APPS) clixon_util_stream *.core # APPS -clixon_util_xml: clixon_util_xml.c $(MYLIB) +clixon_util_xml: clixon_util_xml.c $(LIBDEPS) $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) -o $@ -clixon_util_json: clixon_util_json.c $(MYLIB) +clixon_util_json: clixon_util_json.c $(LIBDEPS) $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) -o $@ -clixon_util_yang: clixon_util_yang.c $(MYLIB) +clixon_util_yang: clixon_util_yang.c $(LIBDEPS) $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) -o $@ -clixon_util_xpath: clixon_util_xpath.c $(MYLIB) +clixon_util_xpath: clixon_util_xpath.c $(LIBDEPS) $(CC) $(INCLUDES) $(CPPFLAGS) @CFLAGS@ $(LDFLAGS) $^ $(LIBS) -o $@ -clixon_util_stream: clixon_util_stream.c $(MYLIB) +clixon_util_stream: clixon_util_stream.c $(LIBDEPS) $(CC) $(INCLUDES) $(CPPFLAGS) @CFLAGS@ $(LDFLAGS) $^ $(LIBS) -lcurl -o $@ -clixon_util_datastore: clixon_util_datastore.c $(MYLIB) +clixon_util_datastore: clixon_util_datastore.c $(LIBDEPS) $(CC) $(INCLUDES) $(CPPFLAGS) @CFLAGS@ $(LDFLAGS) $^ $(LIBS) -o $@ distclean: clean