forked from soutade/libgourou
Update Makefile to be more GNU/Linux style
This commit is contained in:
parent
3a0ab4b438
commit
8aec5be244
35
Makefile
35
Makefile
|
@ -1,21 +1,30 @@
|
||||||
AR ?= $(CROSS)ar
|
AR ?= $(CROSS)ar
|
||||||
CXX ?= $(CROSS)g++
|
CXX ?= $(CROSS)g++
|
||||||
|
|
||||||
|
ifeq ($(PREFIX),)
|
||||||
|
PREFIX := /usr/local
|
||||||
|
endif
|
||||||
|
|
||||||
UPDFPARSERLIB = ./lib/updfparser/libupdfparser.a
|
UPDFPARSERLIB = ./lib/updfparser/libupdfparser.a
|
||||||
|
|
||||||
CXXFLAGS=-Wall -fPIC -I./include -I./lib/pugixml/src/ -I./lib/updfparser/include
|
CXXFLAGS += -Wall -fPIC -I./include -I./lib/pugixml/src/ -I./lib/updfparser/include
|
||||||
LDFLAGS = $(UPDFPARSERLIB)
|
LDFLAGS = $(UPDFPARSERLIB)
|
||||||
|
|
||||||
|
VERSION := $(shell cat include/libgourou.h |grep LIBGOUROU_VERSION|cut -d '"' -f2)
|
||||||
|
|
||||||
BUILD_STATIC ?= 0
|
BUILD_STATIC ?= 0
|
||||||
BUILD_SHARED ?= 1
|
BUILD_SHARED ?= 1
|
||||||
BUILD_UTILS ?= 1
|
BUILD_UTILS ?= 1
|
||||||
|
|
||||||
TARGETS =
|
TARGETS =
|
||||||
|
TARGET_BINARIES =
|
||||||
ifneq ($(BUILD_STATIC), 0)
|
ifneq ($(BUILD_STATIC), 0)
|
||||||
TARGETS += libgourou.a
|
TARGETS += libgourou.a
|
||||||
|
TARGET_BINARIES += libgourou.a
|
||||||
endif
|
endif
|
||||||
ifneq ($(BUILD_SHARED), 0)
|
ifneq ($(BUILD_SHARED), 0)
|
||||||
TARGETS += libgourou.so
|
TARGETS += libgourou.so
|
||||||
|
TARGET_BINARIES += libgourou.so libgourou.so.$(VERSION)
|
||||||
endif
|
endif
|
||||||
ifneq ($(BUILD_UTILS), 0)
|
ifneq ($(BUILD_UTILS), 0)
|
||||||
TARGETS += build_utils
|
TARGETS += build_utils
|
||||||
|
@ -42,7 +51,10 @@ OBJEXT := o
|
||||||
SOURCES = src/libgourou.cpp src/user.cpp src/device.cpp src/fulfillment_item.cpp src/loan_token.cpp src/bytearray.cpp src/pugixml.cpp
|
SOURCES = src/libgourou.cpp src/user.cpp src/device.cpp src/fulfillment_item.cpp src/loan_token.cpp src/bytearray.cpp src/pugixml.cpp
|
||||||
OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.$(OBJEXT)))
|
OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.$(OBJEXT)))
|
||||||
|
|
||||||
all: lib obj $(TARGETS)
|
all: version lib obj $(TARGETS)
|
||||||
|
|
||||||
|
version:
|
||||||
|
@echo "Building libgourou $(VERSION)"
|
||||||
|
|
||||||
lib:
|
lib:
|
||||||
mkdir lib
|
mkdir lib
|
||||||
|
@ -63,13 +75,26 @@ libgourou.a: $(OBJECTS) $(UPDFPARSERLIB)
|
||||||
$(AR) crs $@ obj/*.o $(UPDFPARSERLIB)
|
$(AR) crs $@ obj/*.o $(UPDFPARSERLIB)
|
||||||
|
|
||||||
libgourou.so: $(OBJECTS) $(UPDFPARSERLIB)
|
libgourou.so: $(OBJECTS) $(UPDFPARSERLIB)
|
||||||
$(CXX) obj/*.o $(LDFLAGS) -o $@ -shared
|
$(CXX) obj/*.o -Wl,-soname,$@.$(VERSION) $(LDFLAGS) -o $@.$(VERSION) -shared
|
||||||
|
rm -f $@
|
||||||
|
ln -s $@.$(VERSION) $@
|
||||||
|
|
||||||
build_utils:
|
build_utils:
|
||||||
make -C utils ROOT=$(PWD) CXX=$(CXX) AR=$(AR) DEBUG=$(DEBUG) STATIC_UTILS=$(STATIC_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 -
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf libgourou.a libgourou.so obj
|
rm -rf libgourou.a libgourou.so libgourou.so.$(VERSION)* obj
|
||||||
make -C utils clean
|
make -C utils clean
|
||||||
|
|
||||||
ultraclean: clean
|
ultraclean: clean
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
|
|
||||||
TARGETS=acsmdownloader adept_activate adept_remove adept_loan_mgt launcher
|
TARGET_BINARIES=acsmdownloader adept_activate adept_remove adept_loan_mgt
|
||||||
|
TARGETS=$(TARGET_BINARIES) launcher
|
||||||
|
|
||||||
CXXFLAGS=-Wall -fPIC -I$(ROOT)/include -I$(ROOT)/lib/pugixml/src/
|
CXXFLAGS=-Wall -fPIC -I$(ROOT)/include -I$(ROOT)/lib/pugixml/src/
|
||||||
|
|
||||||
|
@ -32,6 +33,15 @@ ${COMMON_LIB}: ${COMMON_DEPS} ${STATIC_DEP}
|
||||||
%: %.cpp ${COMMON_LIB}
|
%: %.cpp ${COMMON_LIB}
|
||||||
$(CXX) $(CXXFLAGS) $^ $(LDFLAGS) -o $@
|
$(CXX) $(CXXFLAGS) $^ $(LDFLAGS) -o $@
|
||||||
|
|
||||||
|
install:
|
||||||
|
install -d $(DESTDIR)$(PREFIX)/bin/
|
||||||
|
install -m 644 $(TARGET_BINARIES) $(DESTDIR)$(PREFIX)/bin/
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
cd $(DESTDIR)$(PREFIX)/bin/
|
||||||
|
rm -f $(TARGET_BINARIES)
|
||||||
|
cd -
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(TARGETS) $(COMMON_LIB)
|
rm -f $(TARGETS) $(COMMON_LIB)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user