Commit 2289721d authored by Federico Vaga's avatar Federico Vaga

bld: install properly the libraries and tools

Add the install target to lib/Makefile and tools/Makefile. The target
puts binaries in /usr/local/lib, and /usr/local/bin
Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent 50845869
......@@ -12,6 +12,9 @@ IGNORE_CPU_SUFFIX := y
REPO_PARENT ?=
-include $(REPO_PARENT)/parent_common.mk
DESTDIR ?= /usr/local
ZIO ?= $(HOME)/git/zio
ZIO_ABS ?= $(abspath $(ZIO) )
......@@ -19,7 +22,12 @@ GIT_VERSION := $(shell git describe --dirty --long --tags)
ZIO_GIT_VERSION := $(shell cd $(ZIO_ABS); git describe --dirty --long --tags)
FMCADC_100MS_4CH_14BIT_GIT_VERSION := $(shell cd $(FMCADC100M); git describe --dirty --long --tags)
SO_VERSION_XYZ := $(shell echo $(GIT_VERSION) | grep -o -E "[0-9]+\.[0-9]+\.[0-9]")
SO_VERSION_X := $(shell echo $(SO_VERSION_XYZ) | cut -d "." -f 1)
LIBS = libadc.so
LIBS_XYZ = $(LIBS).$(SO_VERSION_XYZ)
LIB = libadc.a
LOBJ := route.o
LOBJ += init.o
......@@ -45,7 +53,7 @@ CC ?= $(CROSS_COMPILE)gcc
CPPCHECK ?= cppcheck
FLAWFINDER ?= flawfinder
all: $(LIB) $(LIBS)
all: $(LIB) $(LIBS_XYZ)
%: %.c $(LIB)
......@@ -54,7 +62,7 @@ all: $(LIB) $(LIBS)
$(LIB): $(LOBJ)
$(AR) r $@ $^
$(LIBS): $(LIB)
$(LIBS_XYZ): $(LIB)
$(CC) -shared -o $@ -Wl,--whole-archive,-soname,$@ $^ -Wl,--no-whole-archive
cppcheck:
......@@ -64,11 +72,17 @@ flawfinder:
$(FLAWFINDER) -SQDC --error-level=4 .
clean:
rm -f $(LIB) $(LIBS) .depend *.o *~
rm -f $(LIB) $(LIBS_XYZ) .depend *.o *~
.depend: Makefile $(wildcard *.c *.h ../*.h)
$(CC) $(CFLAGS) -M $(LOBJ:.o=.c) -o $@
install:
install: $(LIBS_XYZ) $(LIB)
install -d $(DESTDIR)/lib
install -m 644 $(LIB) $(DESTDIR)/lib
install -m 755 $(LIBS_XYZ) $(DESTDIR)/lib
ln -sf $(LIBS_XYZ) $(DESTDIR)/lib/$(LIBS).$(SO_VERSION_X)
ln -sf $(LIBS).$(SO_VERSION_X) $(DESTDIR)/lib/$(LIBS)
-include .depend
......@@ -24,19 +24,21 @@ LDFLAGS = -L$(LIBADC)
LDLIBS += -Wl,-Bstatic -ladc
LDLIBS += -Wl,-Bdynamic -lrt
DEMOS := adc-acq
DEMOS += example
PROGS := adc-acq
DEMOS := example
CPPCHECK ?= cppcheck
FLAWFINDER ?= flawfinder
all: demo
all: demo progs
demo: $(DEMOS)
install:
progs: $(PROGS)
install: progs
install -d $(DESTDIR)/bin
install -D $(DEMOS) $(DESTDIR)/bin
install -m 755 $(PROGS) $(DESTDIR)/bin
%: %.c $(LIBADC)/libadc.a
$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) $(LDLIBS)
......@@ -48,6 +50,6 @@ flawfinder:
$(FLAWFINDER) -SQDC --error-level=4 .
clean:
rm -f $(DEMOS) *.o *~
rm -f $(DEMOS) $(PROGS) *.o *~
.PHONY: all, clean
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment