libgourou/Makefile

103 lines
2.3 KiB
Makefile
Raw Normal View History

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./lib/pugixml/src/ -I./lib/updfparser/include
LDFLAGS = $(UPDFPARSERLIB)
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 =
TARGET_BINARIES =
2021-08-25 21:54:52 +02:00
ifneq ($(BUILD_STATIC), 0)
TARGETS += libgourou.a
TARGET_BINARIES += libgourou.a
endif
2021-08-25 21:54:52 +02:00
ifneq ($(BUILD_SHARED), 0)
TARGETS += libgourou.so
TARGET_BINARIES += 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
INCDIR := inc
BUILDDIR := obj
TARGETDIR := bin
SRCEXT := cpp
OBJEXT := o
2022-04-03 09:32:06 +02:00
SOURCES = src/libgourou.cpp src/user.cpp src/device.cpp src/fulfillment_item.cpp src/loan_token.cpp src/bytearray.cpp src/pugixml.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 $@
libgourou: libgourou.a libgourou.so
libgourou.a: $(OBJECTS) $(UPDFPARSERLIB)
$(AR) crs $@ obj/*.o $(UPDFPARSERLIB)
2021-07-03 21:57:53 +02:00
libgourou.so: $(OBJECTS) $(UPDFPARSERLIB)
$(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:
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:
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