Cleaned up Makefiles, especially LINKAGE=static vs dynamic
Added LIBSTATIC_SUFFIX instead of hardcoded .a Changed building of build.c not to be triggered by install
This commit is contained in:
parent
3ec0c42959
commit
d175720b7e
7 changed files with 169 additions and 129 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue