libgourou/Makefile

116 lines
2.6 KiB
Makefile
Raw Normal View History

2023-01-10 21:03:45 +01:00
LIBDIR ?= /usr/lib
INCDIR ?= /usr/include
2021-07-03 21:57:53 +02:00
AR ?= $(CROSS)ar
CXX ?= $(CROSS)g++
ifeq ($(PREFIX),)
PREFIX := /usr/local
endif
UPDFPARSERLIB = ./lib/updfparser/libupdfparser.a
CXXFLAGS += -Wall -fPIC -I./include -I./usr/include/pugixml -I./lib/updfparser/include
2023-01-14 12:56:06 +01:00
LDFLAGS = -lpugixml
VERSION := $(shell cat include/libgourou.h |grep LIBGOUROU_VERSION|cut -d '"' -f2)
BUILD_STATIC ?= 0
BUILD_SHARED ?= 1
2021-08-25 21:54:52 +02:00
BUILD_UTILS ?= 1
TARGETS =
2023-01-10 21:03:45 +01:00
TARGET_LIBRARIES =
2023-01-14 12:56:06 +01:00
ifneq ($(STATIC_UTILS),)
BUILD_STATIC=1
endif
2021-08-25 21:54:52 +02:00
ifneq ($(BUILD_STATIC), 0)
TARGETS += libgourou.a
2023-01-10 21:03:45 +01:00
TARGET_LIBRARIES += libgourou.a
2023-01-14 12:56:06 +01:00
STATIC_UTILS=1
endif
2021-08-25 21:54:52 +02:00
ifneq ($(BUILD_SHARED), 0)
TARGETS += libgourou.so
2023-01-10 21:03:45 +01:00
TARGET_LIBRARIES += libgourou.so libgourou.so.$(VERSION)
endif
2021-08-25 21:54:52 +02:00
ifneq ($(BUILD_UTILS), 0)
TARGETS += build_utils
endif
2021-07-03 21:57:53 +02:00
ifneq ($(DEBUG),)
2022-08-07 16:45:12 +02:00
CXXFLAGS += -ggdb -O0 -DDEBUG
2021-07-03 21:57:53 +02:00
else
CXXFLAGS += -O2
endif
ifneq ($(STATIC_NONCE),)
CXXFLAGS += -DSTATIC_NONCE=1
endif
2021-07-03 21:57:53 +02:00
SRCDIR := src
BUILDDIR := obj
SRCEXT := cpp
OBJEXT := o
SOURCES = src/libgourou.cpp src/user.cpp src/device.cpp src/fulfillment_item.cpp src/loan_token.cpp src/bytearray.cpp
2021-07-03 21:57:53 +02:00
OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.$(OBJEXT)))
all: version lib obj $(TARGETS)
version:
@echo "Building libgourou $(VERSION)"
2021-07-03 21:57:53 +02:00
lib:
mkdir lib
./scripts/setup.sh
2022-06-12 15:00:38 +02:00
update_lib:
./scripts/update_lib.sh
2021-07-03 21:57:53 +02:00
obj:
mkdir obj
$(BUILDDIR)/%.$(OBJEXT): $(SRCDIR)/%.$(SRCEXT)
$(CXX) $(CXXFLAGS) -c $^ -o $@
2023-01-14 12:56:06 +01:00
libgourou: $(TARGET_LIBRARIES)
2021-07-03 21:57:53 +02:00
libgourou.a: $(OBJECTS) $(UPDFPARSERLIB)
2023-01-14 12:56:06 +01:00
$(AR) rcs --thin $@ $^
2021-07-03 21:57:53 +02:00
2023-01-10 21:03:45 +01:00
libgourou.so.$(VERSION): $(OBJECTS) $(UPDFPARSERLIB)
2023-01-14 12:56:06 +01:00
$(CXX) $^ -Wl,-soname,$@ $(LDFLAGS) -o $@ -shared
2023-01-10 21:03:45 +01:00
libgourou.so: libgourou.so.$(VERSION)
ln -f -s $^ $@
2021-07-03 21:57:53 +02:00
2023-01-10 21:03:45 +01:00
build_utils: $(TARGET_LIBRARIES)
2023-01-14 12:56:06 +01:00
$(MAKE) -C utils ROOT=$(PWD) CXX=$(CXX) AR=$(AR) DEBUG=$(DEBUG) STATIC_UTILS=$(STATIC_UTILS) DEST_DIR=$(DEST_DIR) PREFIX=$(PREFIX)
2023-01-10 21:03:45 +01:00
install: $(TARGET_LIBRARIES)
install -d $(DESTDIR)$(PREFIX)$(LIBDIR)
# Use cp to preserver symlinks
2023-01-10 21:03:45 +01:00
cp --no-dereference $(TARGET_LIBRARIES) $(DESTDIR)$(PREFIX)$(LIBDIR)
2023-01-14 12:56:06 +01:00
$(MAKE) -C utils ROOT=$(PWD) CXX=$(CXX) AR=$(AR) DEBUG=$(DEBUG) STATIC_UTILS=$(STATIC_UTILS) DEST_DIR=$(DEST_DIR) PREFIX=$(PREFIX) install
uninstall:
2023-01-10 21:03:45 +01:00
cd $(DESTDIR)$(PREFIX)/$(LIBDIR)
rm -f $(TARGET_LIBRARIES) libgourou.so.$(VERSION)
cd -
2021-07-03 21:57:53 +02:00
2023-01-10 21:03:45 +01:00
install_headers:
install -d $(DESTDIR)$(PREFIX)/$(INCDIR)/libgourou
cp --no-dereference include/*.h $(DESTDIR)$(PREFIX)/$(INCDIR)/libgourou
uninstall_headers:
rm -rf $(DESTDIR)$(PREFIX)/$(INCDIR)/libgourou
2021-07-03 21:57:53 +02:00
clean:
rm -rf libgourou.a libgourou.so libgourou.so.$(VERSION)* obj
2023-01-14 12:56:06 +01:00
$(MAKE) -C utils clean
2021-07-03 21:57:53 +02:00
ultraclean: clean
rm -rf lib
2023-01-14 12:56:06 +01:00
$(MAKE) -C utils ultraclean