2023-08-08 20:11:33 +02:00
|
|
|
PREFIX ?= /usr/local
|
|
|
|
LIBDIR ?= /lib
|
|
|
|
INCDIR ?= /include
|
2023-01-10 21:03:45 +01:00
|
|
|
|
2021-07-03 21:57:53 +02:00
|
|
|
AR ?= $(CROSS)ar
|
|
|
|
CXX ?= $(CROSS)g++
|
|
|
|
|
2021-08-21 20:57:31 +02:00
|
|
|
UPDFPARSERLIB = ./lib/updfparser/libupdfparser.a
|
|
|
|
|
2023-01-08 21:12:38 +01:00
|
|
|
CXXFLAGS += -Wall -fPIC -I./include -I./usr/include/pugixml -I./lib/updfparser/include
|
2023-01-14 12:56:06 +01:00
|
|
|
LDFLAGS = -lpugixml
|
2021-08-21 20:57:31 +02:00
|
|
|
|
2023-01-08 21:05:04 +01:00
|
|
|
VERSION := $(shell cat include/libgourou.h |grep LIBGOUROU_VERSION|cut -d '"' -f2)
|
|
|
|
|
2021-08-21 20:57:31 +02:00
|
|
|
BUILD_STATIC ?= 0
|
|
|
|
BUILD_SHARED ?= 1
|
2021-08-25 21:54:52 +02:00
|
|
|
BUILD_UTILS ?= 1
|
2021-08-21 20:57:31 +02:00
|
|
|
|
|
|
|
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)
|
2021-08-21 20:57:31 +02:00
|
|
|
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
|
2021-08-21 20:57:31 +02:00
|
|
|
endif
|
2021-08-25 21:54:52 +02:00
|
|
|
ifneq ($(BUILD_SHARED), 0)
|
2021-08-21 20:57:31 +02:00
|
|
|
TARGETS += libgourou.so
|
2023-01-10 21:03:45 +01:00
|
|
|
TARGET_LIBRARIES += libgourou.so libgourou.so.$(VERSION)
|
2021-08-21 20:57:31 +02:00
|
|
|
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
|
|
|
|
|
2022-08-07 16:45:59 +02:00
|
|
|
ifneq ($(STATIC_NONCE),)
|
|
|
|
CXXFLAGS += -DSTATIC_NONCE=1
|
|
|
|
endif
|
|
|
|
|
2021-07-03 21:57:53 +02:00
|
|
|
SRCDIR := src
|
|
|
|
BUILDDIR := obj
|
|
|
|
SRCEXT := cpp
|
|
|
|
OBJEXT := o
|
|
|
|
|
2023-01-08 21:12:38 +01:00
|
|
|
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)))
|
|
|
|
|
2023-01-08 21:05:04 +01:00
|
|
|
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
|
|
|
|
2022-03-12 22:59:27 +01: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-08-08 20:11:33 +02:00
|
|
|
$(MAKE) -C utils ROOT=$(PWD) CXX=$(CXX) AR=$(AR) DEBUG=$(DEBUG) STATIC_UTILS=$(STATIC_UTILS) DESTDIR=$(DESTDIR) PREFIX=$(PREFIX)
|
2023-01-08 21:05:04 +01:00
|
|
|
|
2023-01-10 21:03:45 +01:00
|
|
|
install: $(TARGET_LIBRARIES)
|
|
|
|
install -d $(DESTDIR)$(PREFIX)$(LIBDIR)
|
2023-01-08 21:05:04 +01:00
|
|
|
# Use cp to preserver symlinks
|
2023-01-10 21:03:45 +01:00
|
|
|
cp --no-dereference $(TARGET_LIBRARIES) $(DESTDIR)$(PREFIX)$(LIBDIR)
|
2023-08-08 20:11:33 +02:00
|
|
|
$(MAKE) -C utils ROOT=$(PWD) CXX=$(CXX) AR=$(AR) DEBUG=$(DEBUG) STATIC_UTILS=$(STATIC_UTILS) DESTDIR=$(DESTDIR) PREFIX=$(PREFIX) install
|
2023-01-08 21:05:04 +01:00
|
|
|
|
|
|
|
uninstall:
|
2023-01-10 21:03:45 +01:00
|
|
|
cd $(DESTDIR)$(PREFIX)/$(LIBDIR)
|
|
|
|
rm -f $(TARGET_LIBRARIES) libgourou.so.$(VERSION)
|
2023-01-08 21:05:04 +01:00
|
|
|
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:
|
2023-01-08 21:05:04 +01:00
|
|
|
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
|