From 000c864f286f4e02a772c8c33f60997bd7e551bc Mon Sep 17 00:00:00 2001 From: Anjan Chanda <anjan.chanda@iopsys.eu> Date: Wed, 25 May 2022 19:45:54 +0200 Subject: [PATCH] Makefile: add install target --- Makefile | 4 ++-- Makefile.inc | 27 +++++++++++++++++++++++++++ libeasy/Makefile | 7 ++++++- libwifi/Makefile | 7 ++++++- 4 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 Makefile.inc diff --git a/Makefile b/Makefile index b0d5b051..da223de2 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ subdirs ?= $(dir $(wildcard */)) -.PHONY: all clean +.PHONY: all clean install -all clean: +all clean install: for i in $(subdirs) ; do [ -d $$i ] && $(MAKE) -C $$i $@ || exit; done diff --git a/Makefile.inc b/Makefile.inc new file mode 100644 index 00000000..48308a84 --- /dev/null +++ b/Makefile.inc @@ -0,0 +1,27 @@ +CP ?= cp -fpPR +INSTALL ?= install +INSTALL_DIR = $(INSTALL) -d -m 755 +INSTALL_PROGRAM = $(INSTALL) -m 755 +INSTALL_DATA = $(INSTALL) -m 644 +INSTALL_CONF = $(INSTALL) -m 600 +INSTALL_LIB = $(CP) + +INCDIR ?= /usr/include +LIBDIR ?= /usr/lib + + +header-files ?= $(wildcard *.h) +library-files ?= $(wildcard *.so*) + + +$(DESTDIR)/$(INCDIR)/%: % + $(INSTALL_DATA) -D $< $@ + +$(DESTDIR)/$(LIBDIR)/%: % + $(INSTALL_DIR) $(DESTDIR)/$(LIBDIR) + $(INSTALL_LIB) $< $@ + + +install-headers: $(addprefix $(DESTDIR)/$(INCDIR)/,$(header-files)) + +install-libs: $(addprefix $(DESTDIR)/$(LIBDIR)/,$(library-files)) diff --git a/libeasy/Makefile b/libeasy/Makefile index b8e68d09..c1c3531b 100644 --- a/libeasy/Makefile +++ b/libeasy/Makefile @@ -1,3 +1,5 @@ +-include ../Makefile.inc + CC = gcc #CFLAGS += -O2 -Wall -g -fvisibility=hidden @@ -11,7 +13,7 @@ objs_lib = event.o base64.o utils.o if_utils.o debug.o ver=$(shell cat ./VERSION) maj=$(shell cat ./VERSION | cut -f1 -d.) -.PHONY: all tests clean +.PHONY: all tests clean install all: libeasy.so.$(ver) @@ -28,5 +30,8 @@ tests: $(MAKE) -C tests all +install: install-headers install-libs + + clean: rm -f *.o *so* diff --git a/libwifi/Makefile b/libwifi/Makefile index 7a9661d7..fd221479 100644 --- a/libwifi/Makefile +++ b/libwifi/Makefile @@ -1,3 +1,4 @@ + CC = gcc CFLAGS = -O2 -Wall -g LIBWIFI_CFLAGS += -I. -I../libeasy @@ -62,6 +63,10 @@ libwifi-6.so.$(ver): $(objs_lib) -ln -sf $@ libwifi-6.so.$(maj) -ln -sf $@ libwifi-6.so +header-files=wifi.h +-include ../Makefile.inc + +install: install-headers install-libs docs: cd docs; doxygen ./Doxyfile @@ -71,4 +76,4 @@ docs: clean: rm -f *.o modules/$(objs_dir)/*.o *.so* -.PHONY: all docs clean +.PHONY: all docs clean install -- GitLab