diff --git a/apps/backend/Makefile.in b/apps/backend/Makefile.in index 0860f384..97833b42 100644 --- a/apps/backend/Makefile.in +++ b/apps/backend/Makefile.in @@ -43,8 +43,8 @@ CPPFLAGS = @CPPFLAGS@ ifeq ($(LINKAGE),dynamic) CPPFLAGS += -fPIC endif - SH_SUFFIX = @SH_SUFFIX@ +LIBSTATIC_SUFFIX = @LIBSTATIC_SUFFIX@ INSTALLFLAGS = @INSTALLFLAGS@ LDFLAGS = @LDFLAGS@ ifneq ($(LINKAGE),dynamic) @@ -68,7 +68,7 @@ CLIXON_MINOR = @CLIXON_VERSION_MINOR@ ifeq ($(LINKAGE),dynamic) CLIXON_LIB = libclixon$(SH_SUFFIX).$(CLIXON_MAJOR).$(CLIXON_MINOR) else - CLIXON_LIB = libclixon.a + CLIXON_LIB = libclixon$(LIBSTATIC_SUFFIX) endif # For dependency. A little strange that we rely on it being built in the src dir @@ -102,22 +102,21 @@ MYNAME = clixon_backend MYLIBDYNAMIC = lib$(MYNAME)$(SH_SUFFIX).$(CLIXON_MAJOR).$(CLIXON_MINOR) MYLIBSO = lib$(MYNAME)$(SH_SUFFIX).$(CLIXON_MAJOR) MYLIBLINK = lib$(MYNAME)$(SH_SUFFIX) -MYLIBSTATIC = lib$(MYNAME).a +MYLIBSTATIC = lib$(MYNAME)$(LIBSTATIC_SUFFIX) +all: $(APPL) test ifeq ($(LINKAGE),dynamic) - MYLIB = $(MYLIBDYNAMIC) +all: $(MYLIBDYNAMIC) else - MYLIB = $(MYLIBSTATIC) +all: $(MYSTATIC) endif -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) test test.c + rm -f *.core $(APPL) $(APPOBJ) $(LIBOBJ) $(MYLIBDYNAMIC) $(MYLIBSTATIC) $(MYLIBSO) $(MYLIBLINK) test test.c rm -f *.gcda *.gcno *.gcov # coverage distclean: clean @@ -131,18 +130,25 @@ install: install-lib $(APPL) install -d -m 0755 $(DESTDIR)$(sbindir) install -m 0755 $(INSTALLFLAGS) $(APPL) $(DESTDIR)$(sbindir) -install-lib: $(MYLIB) - install -d -m 0755 $(DESTDIR)$(libdir) - install -m 0644 $(INSTALLFLAGS) $(MYLIB) $(DESTDIR)$(libdir) - install -d -m 0755 $(DESTDIR)$(libdir)/clixon/plugins/backend ifeq ($(LINKAGE),dynamic) - ln -sf $(MYLIB) $(DESTDIR)$(libdir)/$(MYLIBSO) # -l:libclixon_backend.so.2 +install-lib: $(MYLIBDYNAMIC) + install -d -m 0755 $(DESTDIR)$(libdir) + install -m 0644 $(INSTALLFLAGS) $< $(DESTDIR)$(libdir) + install -d -m 0755 $(DESTDIR)$(libdir)/clixon/plugins/backend + ln -sf $< $(DESTDIR)$(libdir)/$(MYLIBSO) # -l:libclixon_backend.so.2 ln -sf $(MYLIBSO) $(DESTDIR)$(libdir)/$(MYLIBLINK) # -l:libclixon_backend.so +else +install-lib: $(MYLIBSTATIC) + install -d -m 0755 $(DESTDIR)$(libdir) + install -m 0644 $(INSTALLFLAGS) $< $(DESTDIR)$(libdir) + install -d -m 0755 $(DESTDIR)$(libdir)/clixon/plugins/backend endif uninstall: rm -f $(DESTDIR)$(sbindir)/$(APPL) rm -f $(DESTDIR)$(libdir)/$(MYLIBLINK)* + rm -f $(DESTDIR)$(libdir)/$(MYLIBSTATIC) + rm -f $(DESTDIR)$(libdir)/$(MYLIBDYNAMIC) rm -f $(DESTDIR)$(includedir)/clixon/* install-include: clixon_backend.h clixon_backend_handle.h clixon_backend_transaction.h clixon_backend_plugin.h clixon_backend_commit.h @@ -153,25 +159,28 @@ install-include: clixon_backend.h clixon_backend_handle.h clixon_backend_transac .SUFFIXES: .c .o .c.o: - # Note: CLIXON_CONFIG_SBINDIR is where clixon_restconf is believed to be installed, unless - # overruled by CLICON_RESTCONF_INSTALLDIR option $(CC) $(INCLUDES) $(CPPFLAGS) -D__PROGRAM__=\"$(APPL)\" -DCLIXON_CONFIG_SBINDIR=\"$(sbindir)\" $(CFLAGS) -c $< # Just link test programs test.c : echo "int main(){}" > $@ -test: test.c $(LIBOBJ) $(MYLIB) - $(CC) $(INCLUDES) $(LDFLAGS) $< $(LIBOBJ) -L. $(MYLIB) $(LIBS) -o $@ +test: test.c $(LIBOBJ) -# Note LIBDEPS is in lib/src and will always be remade du to a date dependency ifeq ($(LINKAGE),dynamic) -$(APPL) : $(APPOBJ) $(MYLIB) $(LIBDEPS) - $(CC) $(LDFLAGS) $(APPOBJ) -L. $(MYLIB) $(LIBS) -o $@ +test: $(MYLIBDYNAMIC) else -$(APPL) : $(APPOBJ) $(LIBOBJ) $(LIBDEPS) - $(CC) $(LDFLAGS) $(APPOBJ) -L. $(LIBOBJ) $(LIBS) -o $@ +test: $(MYLIBSTATIC) endif + $(CC) $(INCLUDES) $(LDFLAGS) -L . $^ $(LIBS) -o $@ + +ifeq ($(LINKAGE),dynamic) +$(APPL): $(MYLIBDYNAMIC) +else +$(APPL): $(MYLIBSTATIC) +endif +$(APPL) : $(APPOBJ) $(LIBDEPS) + $(CC) $(LDFLAGS) -L. $^ $(LIBS) -o $@ $(MYLIBDYNAMIC): $(LIBOBJ) $(LIBDEPS) ifeq ($(HOST_VENDOR),apple) @@ -181,9 +190,7 @@ else endif # link-name is needed for application linking, eg for clixon_cli and clixon_backend -$(MYLIBLINK) : $(MYLIB) -# ln -sf $(MYLIB) $(MYLIBSO) -# ln -sf $(MYLIB) $@ +$(MYLIBLINK) : $(MYLIBDYNAMIC) $(MYLIBSTATIC) : $(LIBOBJ) $(LIBDEPS) ar -crs $@ $(LIBOBJ) $(LIBDEPS) diff --git a/apps/cli/Makefile.in b/apps/cli/Makefile.in index 1bc4b106..5529d429 100644 --- a/apps/cli/Makefile.in +++ b/apps/cli/Makefile.in @@ -32,6 +32,10 @@ # # ***** END LICENSE BLOCK ***** # +# Define CLIGEN_LIB for static CLIgen linking +# +# For remote case of loading cli plugins statically: +# Define EXTRAS for statically load plugins, together with enabling CLIXON_STATIC_PLUGINS VPATH = @srcdir@ srcdir = @srcdir@ @@ -43,10 +47,11 @@ CPPFLAGS = @CPPFLAGS@ ifeq ($(LINKAGE),dynamic) CPPFLAGS += -fPIC endif -SH_SUFFIX = .so +SH_SUFFIX = @SH_SUFFIX@ +LIBSTATIC_SUFFIX = @LIBSTATIC_SUFFIX@ INSTALLFLAGS = @INSTALLFLAGS@ LDFLAGS = @LDFLAGS@ -ifneq ($(LINKAGE),dynamic) +ifeq ($(LINKAGE),dynamic) LDFLAGS += -rdynamic -L. # -rdynamic for using -ldl endif @@ -69,16 +74,7 @@ CLIXON_MINOR = @CLIXON_VERSION_MINOR@ ifeq ($(LINKAGE),dynamic) CLIXON_LIB = libclixon$(SH_SUFFIX).$(CLIXON_MAJOR).$(CLIXON_MINOR) else - CLIXON_LIB = libclixon.a - -# Somewhat ad-hoc mechanism to find libcligen: -# First find in DESTDIR, if not, try root -ifneq ("$(wildcard $(DESTDIR)$(libdir)/libcligen.a)","") -CLIGEN_LIB = $(DESTDIR)$(libdir)/libcligen.a -else -CLIGEN_LIB = $(libdir)/libcligen.a -endif - + CLIXON_LIB = libclixon$(LIBSTATIC_SUFFIX) endif # LINKAGE # For dependency. A little strange that we rely on it being built in the src dir @@ -110,22 +106,22 @@ MYNAME = clixon_cli MYLIBDYNAMIC = lib$(MYNAME)$(SH_SUFFIX).$(CLIXON_MAJOR).$(CLIXON_MINOR) MYLIBSO = lib$(MYNAME)$(SH_SUFFIX).$(CLIXON_MAJOR) MYLIBLINK = lib$(MYNAME)$(SH_SUFFIX) -MYLIBSTATIC = lib$(MYNAME).a +MYLIBSTATIC = lib$(MYNAME)$(LIBSTATIC_SUFFIX) + +all: $(APPL) test ifeq ($(LINKAGE),dynamic) - MYLIB = $(MYLIBDYNAMIC) +all: $(MYLIBDYNAMIC) else - MYLIB = $(MYLIBSTATIC) +all: $(MYSTATIC) endif -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) test test.c + rm -f $(LIBOBJ) $(APPOBJ) *.core $(APPL) $(MYLIBDYNAMIC) $(MYLIBSTATIC) $(MYLIBSO) $(MYLIBLINK) test test.c rm -f *.gcda *.gcno *.gcov # coverage distclean: clean @@ -139,13 +135,18 @@ install: install-lib $(APPL) install -d -m 0755 $(DESTDIR)$(bindir) install -m 0755 $(INSTALLFLAGS) $(APPL) $(DESTDIR)$(bindir) -install-lib: $(MYLIB) - install -d -m 0755 $(DESTDIR)$(libdir) - install -m 0644 $(INSTALLFLAGS) $(MYLIB) $(DESTDIR)$(libdir) - install -d -m 0755 $(DESTDIR)$(libdir)/clixon/plugins/cli ifeq ($(LINKAGE),dynamic) - ln -sf $(MYLIB) $(DESTDIR)$(libdir)/$(MYLIBSO) # -l:libclixon_cli.so.2 +install-lib: $(MYLIBDYNAMIC) + install -d -m 0755 $(DESTDIR)$(libdir) + install -m 0644 $(INSTALLFLAGS) $< $(DESTDIR)$(libdir) + install -d -m 0755 $(DESTDIR)$(libdir)/clixon/plugins/cli + ln -sf $< $(DESTDIR)$(libdir)/$(MYLIBSO) # -l:libclixon_cli.so.2 ln -sf $(MYLIBSO) $(DESTDIR)$(libdir)/$(MYLIBLINK) # -l:libclixon_cli.so +else +install-lib: $(MYLIBSTATIC) + install -d -m 0755 $(DESTDIR)$(libdir) + install -m 0644 $(INSTALLFLAGS) $< $(DESTDIR)$(libdir) + install -d -m 0755 $(DESTDIR)$(libdir)/clixon/plugins/cli endif install-include: clixon_cli.h clixon_cli_api.h cli_generate.h @@ -155,7 +156,8 @@ install-include: clixon_cli.h clixon_cli_api.h cli_generate.h uninstall: rm -f $(DESTDIR)$(bindir)/$(APPL) rm -f $(DESTDIR)$(libdir)/$(MYLIBLINK)* - rm -f $(DESTDIR)$(libdir)/$(MYLIB) + rm -f $(DESTDIR)$(libdir)/$(MYLIBSTATIC) + rm -f $(DESTDIR)$(libdir)/$(MYLIBDYNAMIC) rm -f $(DESTDIR)$(includedir)/clixon/* .SUFFIXES: @@ -168,18 +170,22 @@ uninstall: test.c : echo "int main(){}" > $@ -test: test.c $(LIBOBJ) $(MYLIB) - $(CC) $(INCLUDES) $(LDFLAGS) $< $(LIBOBJ) -L. $(MYLIB) $(LIBS) -o $@ +test: test.c $(LIBOBJ) - -# Note LIBDEPS is in lib/src and will always be remade du to a date dependency -$(APPL): $(APPOBJ) $(MYLIB) $(LIBDEPS) ifeq ($(LINKAGE),dynamic) - $(CC) $(LDFLAGS) $(APPOBJ) -L. $(MYLIB) $(LIBS) -o $@ +test: $(MYLIBDYNAMIC) else - # Force static libcligen.a linking - $(CC) $(LDFLAGS) $(APPOBJ) $(EXTRAS) -L. $(LIBOBJ) $(CLIGEN_LIB) $(LIBS) -o $@ +test: $(MYLIBSTATIC) endif + $(CC) $(INCLUDES) $(LDFLAGS) -L . $^ $(LIBS) -o $@ + +ifeq ($(LINKAGE),dynamic) +$(APPL): $(MYLIBDYNAMIC) +else +$(APPL): $(MYLIBSTATIC) +endif +$(APPL): $(APPOBJ) $(LIBDEPS) + $(CC) $(LDFLAGS) $(EXTRAS) -L. $^ $(CLIGEN_LIB) $(LIBS) -o $@ $(MYLIBDYNAMIC) : $(LIBOBJ) $(LIBDEPS) ifeq ($(HOST_VENDOR),apple) @@ -189,9 +195,7 @@ else endif # link-name is needed for application linking, eg for clixon_cli and clixon_config -$(MYLIBLINK) : $(MYLIB) -# ln -sf $(MYLIB) $(MYLIBSO) -# ln -sf $(MYLIB) $@ +$(MYLIBLINK) : $(MYLIBDYNAMIC) $(MYLIBSTATIC) : $(LIBOBJ) $(LIBDEPS) ar -crs $@ $(LIBOBJ) $(LIBDEPS) diff --git a/apps/netconf/Makefile.in b/apps/netconf/Makefile.in index b2f77a0e..cac53f79 100644 --- a/apps/netconf/Makefile.in +++ b/apps/netconf/Makefile.in @@ -54,6 +54,8 @@ includedir = @includedir@ HOST_VENDOR = @host_vendor@ SH_SUFFIX = @SH_SUFFIX@ +LIBSTATIC_SUFFIX = @LIBSTATIC_SUFFIX@ + CLIXON_MAJOR = @CLIXON_VERSION_MAJOR@ CLIXON_MINOR = @CLIXON_VERSION_MINOR@ @@ -61,7 +63,7 @@ CLIXON_MINOR = @CLIXON_VERSION_MINOR@ ifeq ($(LINKAGE),dynamic) CLIXON_LIB = libclixon$(SH_SUFFIX).$(CLIXON_MAJOR).$(CLIXON_MINOR) else - CLIXON_LIB = libclixon.a + CLIXON_LIB = libclixon$(LIBSTATIC_SUFFIX) endif # For dependency @@ -96,21 +98,21 @@ MYNAME = clixon_netconf MYLIBDYNAMIC = lib$(MYNAME)$(SH_SUFFIX).$(CLIXON_MAJOR).$(CLIXON_MINOR) MYLIBSO = lib$(MYNAME)$(SH_SUFFIX).$(CLIXON_MAJOR) MYLIBLINK = lib$(MYNAME)$(SH_SUFFIX) -MYLIBSTATIC = lib$(MYNAME).a -ifeq ($(LINKAGE),dynamic) - MYLIB = $(MYLIBDYNAMIC) -else - MYLIB = $(MYLIBSTATIC) -endif +MYLIBSTATIC = lib$(MYNAME)$(LIBSTATIC_SUFFIX) -all: $(MYLIB) $(APPL) +all: $(APPL) +ifeq ($(LINKAGE),dynamic) +all: $(MYLIBDYNAMIC) +else +all: $(MYSTATIC) +endif # 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) + rm -f $(APPL) $(APPOBJ) $(LIBOBJ) *.core $(MYLIBDYNAMIC) $(MYLIBSTATIC) $(MYLIBSO) $(MYLIBLINK) rm -f *.gcda *.gcno *.gcov # coverage distclean: clean @@ -124,12 +126,20 @@ install: install-lib $(APPL) install -d -m 0755 $(DESTDIR)$(bindir) install -m 0755 $(INSTALLFLAGS) $(APPL) $(DESTDIR)$(bindir) -install-lib: $(MYLIB) - install -d -m 0755 $(DESTDIR)$(libdir) - install -m 0644 $(INSTALLFLAGS) $(MYLIB) $(DESTDIR)$(libdir) ifeq ($(LINKAGE),dynamic) - ln -sf $(MYLIB) $(DESTDIR)$(libdir)/$(MYLIBSO) # -l:libclixon_netconf.so.2 +install-lib: $(MYLIBDYNAMIC) + install -d -m 0755 $(DESTDIR)$(libdir) + install -m 0644 $(INSTALLFLAGS) $< $(DESTDIR)$(libdir) +# install -d -m 0755 $(DESTDIR)$(libdir)/clixon/plugins/netconf + ln -sf $< $(DESTDIR)$(libdir)/$(MYLIBSO) # -l:libclixon_netconf.so.2 ln -sf $(MYLIBSO) $(DESTDIR)$(libdir)/$(MYLIBLINK) # -l:libclixon_netconf.so + + ln -sf $< $(DESTDIR)$(libdir)/$(MYLIBSO) # -l:libclixon_cli.so.2 + ln -sf $(MYLIBSO) $(DESTDIR)$(libdir)/$(MYLIBLINK) # -l:libclixon_cli.so +else +install-lib: $(MYLIBSTATIC) + install -d -m 0755 $(DESTDIR)$(libdir) + install -m 0644 $(INSTALLFLAGS) $< $(DESTDIR)$(libdir) endif install-include: clixon_netconf.h @@ -139,7 +149,8 @@ install-include: clixon_netconf.h uninstall: rm -f $(DESTDIR)$(bindir)/$(APPL) rm -f $(DESTDIR)$(libdir)/$(MYLIBLINK)* - rm -f $(DESTDIR)$(libdir)/$(MYLIB) + rm -f $(DESTDIR)$(libdir)/$(MYLIBSTATIC) + rm -f $(DESTDIR)$(libdir)/$(MYLIBDYNAMIC) rm -f $(DESTDIR)$(includedir)/clixon/* .SUFFIXES: @@ -148,9 +159,13 @@ uninstall: .c.o: $(CC) $(INCLUDES) $(CPPFLAGS) -D__PROGRAM__=\"$(APPL)\" $(CFLAGS) -c $< -# Note LIBDEPS is in lib/src and will always be remade du to a date dependency -$(APPL) : $(APPOBJ) $(MYLIB) $(LIBDEPS) - $(CC) $(LDFLAGS) $(APPOBJ) -L. $(MYLIB) $(LIBS) -o $@ +ifeq ($(LINKAGE),dynamic) +$(APPL): $(MYLIBDYNAMIC) +else +$(APPL): $(MYLIBSTATIC) +endif +$(APPL) : $(APPOBJ) $(LIBDEPS) + $(CC) $(LDFLAGS) -L. $^ $(LIBS) -o $@ $(MYLIBDYNAMIC) : $(LIBOBJ) $(LIBDEPS) ifeq ($(HOST_VENDOR),apple) @@ -160,9 +175,7 @@ else endif # link-name is needed for application linking, eg for clixon_cli and clixon_config -$(MYLIBLINK) : $(MYLIB) -# ln -sf $(MYLIB) $(MYLIBSO) -# ln -sf $(MYLIB) $@ +$(MYLIBLINK) : $(MYLIBDYNAMIC) $(MYLIBSTATIC) : $(LIBOBJ) $(LIBDEPS) ar -crs $@ $(LIBOBJ) $(LIBDEPS) diff --git a/apps/restconf/Makefile.in b/apps/restconf/Makefile.in index db67ad22..a263d6d1 100644 --- a/apps/restconf/Makefile.in +++ b/apps/restconf/Makefile.in @@ -62,7 +62,8 @@ wwwdir = @wwwdir@ # one of fcgi or native: with_restconf = @with_restconf@ -SH_SUFFIX = .so +SH_SUFFIX = @SH_SUFFIX@ +LIBSTATIC_SUFFIX = @LIBSTATIC_SUFFIX@ CLIXON_MAJOR = @CLIXON_VERSION_MAJOR@ CLIXON_MINOR = @CLIXON_VERSION_MINOR@ @@ -70,7 +71,7 @@ CLIXON_MINOR = @CLIXON_VERSION_MINOR@ ifeq ($(LINKAGE),dynamic) CLIXON_LIB = libclixon$(SH_SUFFIX).$(CLIXON_MAJOR).$(CLIXON_MINOR) else - CLIXON_LIB = libclixon.a + CLIXON_LIB = libclixon$(LIBSTATIC_SUFFIX) endif # For dependency @@ -130,22 +131,21 @@ MYNAME = clixon_restconf MYLIBDYNAMIC = lib$(MYNAME)$(SH_SUFFIX).$(CLIXON_MAJOR).$(CLIXON_MINOR) MYLIBSO = lib$(MYNAME)$(SH_SUFFIX).$(CLIXON_MAJOR) MYLIBLINK = lib$(MYNAME)$(SH_SUFFIX) -MYLIBSTATIC = lib$(MYNAME).a +MYLIBSTATIC = lib$(MYNAME)$(LIBSTATIC_SUFFIX) +all: $(APPL) ifeq ($(LINKAGE),dynamic) - MYLIB = $(MYLIBDYNAMIC) +all: $(MYLIBDYNAMIC) else - MYLIB = $(MYLIBSTATIC) +all: $(MYSTATIC) endif -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) *.o $(MYLIB) $(MYLIBSO) $(MYLIBLINK) # extra .o to clean residue if with_restconf changes + rm -f $(LIBOBJ) *.core $(APPL) $(APPOBJ) *.o $(MYLIBDYNAMIC) $(MYLIBSTATIC) $(MYLIBSO) $(MYLIBLINK) # extra .o to clean residue if with_restconf changes rm -f *.gcda *.gcno *.gcov # coverage distclean: clean @@ -163,12 +163,16 @@ ifeq ($(with_restconf),fcgi) install -d -m 0755 $(DESTDIR)$(wwwdir) endif -install-lib: $(MYLIB) - install -d -m 0755 $(DESTDIR)$(libdir) - install -m 0644 $(INSTALLFLAGS) $(MYLIB) $(DESTDIR)$(libdir) ifeq ($(LINKAGE),dynamic) - ln -sf $(MYLIB) $(DESTDIR)$(libdir)/$(MYLIBSO) # -l:libclixon_restconf.so.2 +install-lib: $(MYLIBDYNAMIC) + install -d -m 0755 $(DESTDIR)$(libdir) + install -m 0644 $(INSTALLFLAGS) $< $(DESTDIR)$(libdir) + ln -sf $< $(DESTDIR)$(libdir)/$(MYLIBSO) # -l:libclixon_restconf.so.2 ln -sf $(MYLIBSO) $(DESTDIR)$(libdir)/$(MYLIBLINK) # -l:libclixon_restconf.so +else +install-lib: $(MYLIBSTATIC) + install -d -m 0755 $(DESTDIR)$(libdir) + install -m 0644 $(INSTALLFLAGS) $< $(DESTDIR)$(libdir) endif install-include: clixon_restconf.h @@ -178,7 +182,8 @@ install-include: clixon_restconf.h uninstall: rm -f $(DESTDIR)$(sbindir)/$(APPL) rm -f $(DESTDIR)$(libdir)/$(MYLIBLINK)* - rm -f $(DESTDIR)$(libdir)/$(MYLIB) + rm -f $(DESTDIR)$(libdir)/$(MYLIBSTATIC) + rm -f $(DESTDIR)$(libdir)/$(MYLIBDYNAMIC) .SUFFIXES: .SUFFIXES: .c .o @@ -186,9 +191,13 @@ uninstall: .c.o: $(CC) $(INCLUDES) -D__PROGRAM__=\"clixon_restconf\" $(CPPFLAGS) $(CFLAGS) -c $< -# Note LIBDEPS is in lib/src and will always be remade du to a date dependency -$(APPL) : $(APPOBJ) $(MYLIB) $(LIBDEPS) - $(CC) $(LDFLAGS) $(APPOBJ) -L. $(MYLIB) $(LIBS) -o $@ +ifeq ($(LINKAGE),dynamic) +$(APPL): $(MYLIBDYNAMIC) +else +$(APPL): $(MYLIBSTATIC) +endif +$(APPL) : $(APPOBJ) $(LIBDEPS) + $(CC) $(LDFLAGS) -L. $^ $(LIBS) -o $@ ifeq ($(HOST_VENDOR),apple) $(MYLIBDYNAMIC) : $(LIBOBJ) $(LIBDEPS) @@ -199,7 +208,7 @@ $(MYLIBDYNAMIC) : $(LIBOBJ) $(LIBDEPS) endif # link-name is needed for application linking, eg for clixon_cli and clixon_config -$(MYLIBLINK) : $(MYLIB) +$(MYLIBLINK) : $(MYLIBDYNAMIC) $(MYLIBSTATIC) : $(LIBOBJ) $(LIBDEPS) ar -crs $@ $(LIBOBJ) $(LIBDEPS) diff --git a/configure b/configure index b9a7a52a..1a980958 100755 --- a/configure +++ b/configure @@ -641,6 +641,7 @@ HAVE_LIBNGHTTP2 HAVE_LIBEVHTP with_restconf LINKAGE +LIBSTATIC_SUFFIX SH_SUFFIX CLIXON_DEFAULT_CONFIG INSTALLFLAGS @@ -3359,6 +3360,7 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + # Set to native or fcgi -> compile apps/restconf HAVE_LIBEVHTP=false # consider using neutral constant such as with-http1 @@ -4557,13 +4559,10 @@ if test "$prefix" = "NONE"; then prefix=${ac_default_prefix} fi -if test "$LINKAGE" = "dynamic" ; then - SH_SUFFIX=".so" -elif test "$LINKAGE" = "static" ; then - SH_SUFFIX=".a" -else - as_fn_error $? "No such linkage: ${LINKAGE}" "$LINENO" 5 -fi +# Postfix for shared libs +SH_SUFFIX=".so" +# Postfix for static libs +LIBSTATIC_SUFFIX=".a" # This is for cligen diff --git a/configure.ac b/configure.ac index ad292ef8..3bd702f6 100644 --- a/configure.ac +++ b/configure.ac @@ -94,6 +94,7 @@ AC_SUBST(INSTALLFLAGS) AC_SUBST(CLIXON_DEFAULT_CONFIG) AC_SUBST(LIBS) AC_SUBST(SH_SUFFIX) +AC_SUBST(LIBSTATIC_SUFFIX) AC_SUBST(LINKAGE) AC_SUBST(with_restconf) # Set to native or fcgi -> compile apps/restconf AC_SUBST(HAVE_LIBEVHTP,false) # consider using neutral constant such as with-http1 @@ -149,13 +150,10 @@ if test "$prefix" = "NONE"; then prefix=${ac_default_prefix} fi -if test "$LINKAGE" = "dynamic" ; then - SH_SUFFIX=".so" -elif test "$LINKAGE" = "static" ; then - SH_SUFFIX=".a" -else - AC_MSG_ERROR([No such linkage: ${LINKAGE}]) -fi +# Postfix for shared libs +SH_SUFFIX=".so" +# Postfix for static libs +LIBSTATIC_SUFFIX=".a" # This is for cligen AC_ARG_WITH([cligen], AS_HELP_STRING([--with-cligen=dir],[Use CLIGEN installation in this dir])) diff --git a/lib/src/Makefile.in b/lib/src/Makefile.in index eea467fd..444120a7 100644 --- a/lib/src/Makefile.in +++ b/lib/src/Makefile.in @@ -57,7 +57,8 @@ CFLAGS = @CFLAGS@ ifeq ($(LINKAGE),dynamic) CFLAGS += -fPIC endif -SH_SUFFIX = .so +SH_SUFFIX = @SH_SUFFIX@ +LIBSTATIC_SUFFIX = @LIBSTATIC_SUFFIX@ INSTALL = @INSTALL@ INSTALL_LIB = @INSTALL@ INSTALLFLAGS = @INSTALLFLAGS@ @@ -105,18 +106,16 @@ MYNAME = clixon MYLIBDYNAMIC = lib$(MYNAME)$(SH_SUFFIX).$(CLIXON_MAJOR).$(CLIXON_MINOR) MYLIBSO = lib$(MYNAME)$(SH_SUFFIX).$(CLIXON_MAJOR) MYLIBLINK = lib$(MYNAME)$(SH_SUFFIX) -MYLIBSTATIC = lib$(MYNAME).a +MYLIBSTATIC = lib$(MYNAME)$(LIBSTATIC_SUFFIX) ifeq ($(LINKAGE),dynamic) - MYLIB = $(MYLIBDYNAMIC) +all: $(MYLIBLINK) $(MYLIBDYNAMIC) else - MYLIB = $(MYLIBSTATIC) +all: $(MYLIBSTATIC) endif -all: $(MYLIB) $(MYLIBLINK) - clean: - rm -f $(OBJS) $(MYLIB) $(MYLIBLINK) $(GENOBJS) $(GENSRC) *.core + rm -f $(OBJS) $(MYLIBLINK) $(MYLIBSTATIC) $(MYLIBDYNAMIC) $(GENOBJS) $(GENSRC) *.core rm -f clixon_xml_parse.tab.[ch] clixon_xml_parse.yy.[co] rm -f clixon_yang_parse.tab.[ch] clixon_yang_parse.[co] rm -f clixon_json_parse.tab.[ch] clixon_json_parse.[co] @@ -224,20 +223,26 @@ lex.clixon_instance_id_parse.o : lex.clixon_instance_id_parse.c clixon_instance_ distclean: clean rm -f Makefile *~ .depend +# This is a way to not declare GENSRC as .PHONY. Instead rebuild +# as a side-effect of building library, but not when doing make install + +prelib: + rm -f $(GENSRC) + .SUFFIXES: .SUFFIXES: .c .o .c.o: - rm -f $@ && $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -c $< + $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -c $< +# Prefix befor $(CC): rm -f $@ && , but unsure of why # Compute the length of the date command (and add some extra with XXX) DATELEN = $(shell date +"%Y.%m.%d %H:%M by `whoami` on `hostname`XXXX"|wc -c) -.PHONY: build.c build.c: - echo "/* This file is generated from the Clixon Makefile */" > build.c; - date +"const char CLIXON_BUILDSTR[$(DATELEN)]=\"%Y.%m.%d %H:%M by `whoami` on `hostname`"\"\; >> build.c; - echo "const char CLIXON_VERSION[64]=\"$(CLIXON_VERSION)\""\; >> build.c; + echo "/* This file is generated from the Clixon Makefile */" > $@; + date +"const char CLIXON_BUILDSTR[$(DATELEN)]=\"%Y.%m.%d %H:%M by `whoami` on `hostname`"\"\; >> $@; + echo "const char CLIXON_VERSION[64]=\"$(CLIXON_VERSION)\""\; >> $@; # Note: will always be remade since GENOBS is date dependent $(MYLIBDYNAMIC) : $(GENOBJS) $(OBJS) @@ -248,7 +253,7 @@ else endif # link-name is needed for application linking, eg for clixon_backend/clixon_cli -$(MYLIBLINK) : $(MYLIB) +$(MYLIBLINK) : $(MYLIBDYNAMIC) $(MYLIBSTATIC) : $(GENOBJS) $(OBJS) ar -crs $@ $(GENOBJS) $(OBJS) @@ -257,17 +262,22 @@ install: install-lib install-include: -install-lib: $(MYLIB) - $(INSTALL) -m 0755 -d $(DESTDIR)$(libdir) - $(INSTALL_LIB) -m 0644 $(INSTALLFLAGS) $(MYLIB) $(DESTDIR)$(libdir) ifeq ($(LINKAGE),dynamic) - ln -sf $(MYLIB) $(DESTDIR)$(libdir)/$(MYLIBSO) # -l:libclixon.so.3 +install-lib: $(MYLIBDYNAMIC) + $(INSTALL) -m 0755 -d $(DESTDIR)$(libdir) + $(INSTALL_LIB) -m 0644 $(INSTALLFLAGS) $(MYLIBDYNAMIC) $(DESTDIR)$(libdir) + ln -sf $(MYLIBDYNAMIC) $(DESTDIR)$(libdir)/$(MYLIBSO) # -l:libclixon.so.3 ln -sf $(MYLIBSO) $(DESTDIR)$(libdir)/$(MYLIBLINK) # -l:libclixon.so +else +install-lib: $(MYLIBSTATIC) + $(INSTALL) -m 0755 -d $(DESTDIR)$(libdir) + $(INSTALL_LIB) -m 0644 $(INSTALLFLAGS) $(MYLIBSTATIC) $(DESTDIR)$(libdir) endif uninstall: rm -f $(DESTDIR)$(libdir)/$(MYLIBLINK)* - rm -f $(DESTDIR)$(libdir)/$(MYLIB) + rm -f $(DESTDIR)$(libdir)/$(MYLIBDYNAMIC) + rm -f $(DESTDIR)$(libdir)/$(MYLIBSTATIC) TAGS: find . -name '*.[chyl]' -print | etags -