uPDFParser/Makefile

54 lines
954 B
Makefile
Raw Normal View History

2021-08-21 18:22:58 +02:00
AR ?= $(CROSS)ar
CXX ?= $(CROSS)g++
CXXFLAGS=-Wall -fPIC -I./include
LDFLAGS=
BUILD_STATIC ?= 0
BUILD_SHARED ?= 1
TARGETS =
ifneq ($(BUILD_STATIC), 0)
2021-08-21 18:22:58 +02:00
TARGETS += libupdfparser.a
endif
ifneq ($(BUILD_SHARED), 0)
2021-08-21 18:22:58 +02:00
TARGETS += libupdfparser.so
endif
ifneq ($(DEBUG),)
CXXFLAGS += -ggdb -O0
else
CXXFLAGS += -O2
endif
SRCDIR := src
INCDIR := inc
BUILDDIR := obj
TARGETDIR := bin
SRCEXT := cpp
OBJEXT := o
SOURCES = src/uPDFParser.cpp src/uPDFTypes.cpp
OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.$(OBJEXT)))
all: obj $(TARGETS)
obj:
mkdir obj
$(BUILDDIR)/%.$(OBJEXT): $(SRCDIR)/%.$(SRCEXT)
$(CXX) $(CXXFLAGS) -c $^ -o $@
libupdfparser.a: $(OBJECTS)
$(AR) crs $@ obj/*.o
libupdfparser.so: $(OBJECTS)
$(CXX) obj/*.o $(LDFLAGS) -o $@ -shared
2021-09-09 20:57:10 +02:00
test: tests/test.cpp libupdfparser.a
2021-08-21 18:22:58 +02:00
g++ -ggdb -O0 $^ -o $@ -Iinclude libupdfparser.a
clean:
2021-09-09 20:57:10 +02:00
rm -rf libupdfparser.so libupdfparser.a obj test