From 3e228c1fb8c1f5999bbb062ec76b2d4dc77fc039 Mon Sep 17 00:00:00 2001 From: Maxim Devaev Date: Wed, 4 Sep 2024 15:49:55 +0300 Subject: [PATCH] refactoring --- Makefile | 6 ++---- janus/Makefile | 7 ++----- lib.mk | 3 +++ src/Makefile | 7 ++----- 4 files changed, 9 insertions(+), 14 deletions(-) create mode 100644 lib.mk diff --git a/Makefile b/Makefile index c83aec37..3af183a2 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +include lib.mk + -include config.mk DESTDIR ?= @@ -23,10 +25,6 @@ endif # ===== -define optbool -$(filter $(shell echo $(1) | tr A-Z a-z), yes on 1) -endef - ifeq ($(V),) ECHO = @ endif diff --git a/janus/Makefile b/janus/Makefile index 63d4a4a6..d20cd597 100644 --- a/janus/Makefile +++ b/janus/Makefile @@ -1,3 +1,5 @@ +include ../lib.mk + R_DESTDIR ?= PREFIX ?= /usr/local @@ -17,11 +19,6 @@ _SRCS = $(shell ls src/uslibs/*.c src/*.c) _BUILD = build -define optbool -$(filter $(shell echo $(1) | tr A-Z a-z), yes on 1) -endef - - WITH_PTHREAD_NP ?= 1 ifneq ($(call optbool,$(WITH_PTHREAD_NP)),) override _CFLAGS += -DWITH_PTHREAD_NP diff --git a/lib.mk b/lib.mk new file mode 100644 index 00000000..eb6cd86d --- /dev/null +++ b/lib.mk @@ -0,0 +1,3 @@ +define optbool +$(filter $(shell echo $(1) | tr A-Z a-z), yes on 1) +endef diff --git a/src/Makefile b/src/Makefile index 8a2ded0e..08024dca 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,3 +1,5 @@ +include ../lib.mk + R_DESTDIR ?= PREFIX ?= /usr/local @@ -45,11 +47,6 @@ _TARGETS = $(_USTR) $(_DUMP) _OBJS = $(_USTR_SRCS:%.c=$(_BUILD)/%.o) $(_DUMP_SRCS:%.c=$(_BUILD)/%.o) -define optbool -$(filter $(shell echo $(1) | tr A-Z a-z), yes on 1) -endef - - ifneq ($(call optbool,$(WITH_GPIO)),) override _CFLAGS += -DWITH_GPIO $(shell pkg-config --atleast-version=2 libgpiod 2> /dev/null && echo -DHAVE_GPIOD2) override _USTR_LDFLAGS += -lgpiod