Skip to content

Commit

Permalink
Made Makefile concurrent so that it can be compiled with -jN
Browse files Browse the repository at this point in the history
  • Loading branch information
olofhagsand committed Mar 21, 2019
1 parent 0bf838e commit 434f0b9
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 32 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 8 additions & 4 deletions apps/backend/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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/
Expand Down Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions apps/cli/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion apps/netconf/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion apps/restconf/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down
18 changes: 5 additions & 13 deletions lib/src/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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 $<
Expand All @@ -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 $<
Expand All @@ -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 $<
Expand All @@ -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 $<
Expand Down
21 changes: 13 additions & 8 deletions util/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 434f0b9

Please sign in to comment.