2021-07-03 21:57:53 +02:00
|
|
|
AR ?= $(CROSS)ar
|
|
|
|
CXX ?= $(CROSS)g++
|
|
|
|
|
2023-01-08 21:05:04 +01:00
|
|
|
ifeq ($(PREFIX),)
|
|
|
|
PREFIX := /usr/local
|
|
|
|
endif
|
|
|
|
|
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
|
|
|
|
LDFLAGS = $(UPDFPARSERLIB) -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-08 21:05:04 +01:00
|
|
|
TARGET_BINARIES =
|
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-08 21:05:04 +01:00
|
|
|
TARGET_BINARIES += libgourou.a
|
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-08 21:05:04 +01:00
|
|
|
TARGET_BINARIES += 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
|
|
|
|
INCDIR := inc
|
|
|
|
BUILDDIR := obj
|
|
|
|
TARGETDIR := bin
|
|
|
|
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 $@
|
|
|
|
|
|
|
|
libgourou: libgourou.a libgourou.so
|
|
|
|
|
2022-03-12 22:59:27 +01:00
|
|
|
libgourou.a: $(OBJECTS) $(UPDFPARSERLIB)
|
|
|
|
$(AR) crs $@ obj/*.o $(UPDFPARSERLIB)
|
2021-07-03 21:57:53 +02:00
|
|
|
|
2021-08-21 20:57:31 +02:00
|
|
|
libgourou.so: $(OBJECTS) $(UPDFPARSERLIB)
|
2023-01-08 21:05:04 +01:00
|
|
|
$(CXX) obj/*.o -Wl,-soname,$@.$(VERSION) $(LDFLAGS) -o $@.$(VERSION) -shared
|
|
|
|
rm -f $@
|
|
|
|
ln -s $@.$(VERSION) $@
|
2021-07-03 21:57:53 +02:00
|
|
|
|
2021-08-25 21:54:52 +02:00
|
|
|
build_utils:
|
2023-01-08 21:05:04 +01:00
|
|
|
make -C utils ROOT=$(PWD) CXX=$(CXX) AR=$(AR) DEBUG=$(DEBUG) STATIC_UTILS=$(STATIC_UTILS) DEST_DIR=$(DEST_DIR) PREFIX=$(PREFIX)
|
|
|
|
|
|
|
|
install:
|
|
|
|
install -d $(DESTDIR)$(PREFIX)/lib/
|
|
|
|
# Use cp to preserver symlinks
|
|
|
|
cp --no-dereference $(TARGET_BINARIES) $(DESTDIR)$(PREFIX)/lib/
|
|
|
|
make -C utils ROOT=$(PWD) CXX=$(CXX) AR=$(AR) DEBUG=$(DEBUG) STATIC_UTILS=$(STATIC_UTILS) DEST_DIR=$(DEST_DIR) PREFIX=$(PREFIX) install
|
|
|
|
|
|
|
|
uninstall:
|
|
|
|
cd $(DESTDIR)$(PREFIX)/lib/
|
|
|
|
rm -f $(TARGET_BINARIES) libgourou.so.$(VERSION)
|
|
|
|
cd -
|
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
|
2021-07-03 21:57:53 +02:00
|
|
|
make -C utils clean
|
|
|
|
|
|
|
|
ultraclean: clean
|
|
|
|
rm -rf lib
|
|
|
|
make -C utils ultraclean
|