summaryrefslogtreecommitdiff
path: root/make
diff options
context:
space:
mode:
Diffstat (limited to 'make')
-rw-r--r--make/gcc-linux.mk87
-rw-r--r--make/installwin.mk21
-rw-r--r--make/libtool.mk133
-rw-r--r--make/mingw.mk83
-rw-r--r--make/msvc.mk107
-rw-r--r--make/proxy.mk10
-rw-r--r--make/rules.mk49
7 files changed, 490 insertions, 0 deletions
diff --git a/make/gcc-linux.mk b/make/gcc-linux.mk
new file mode 100644
index 0000000..d34ecf0
--- /dev/null
+++ b/make/gcc-linux.mk
@@ -0,0 +1,87 @@
+#
+# This file primarily exists for making it possible to test the build
+# system and external library support from Linux. However, its use is
+# strongly discouraged; use the (default) libtool rules for building
+# on Linux.
+#
+
+# --- Required interface definitions ---
+
+OBJ=o
+LOBJ=o
+
+# Usage: $(call libname,base)
+define libname
+lib$(1).so
+endef
+
+# Usage: $(call binname,base)
+define binname
+$(1)
+endef
+
+# --- Required rule definitions ---
+
+# 1 2
+# Usage: $(call compile,src,includes)
+define compile
+ $(CXX) $(CPPFLAGS) $(CXXFLAGS) \
+ $(call depflags,$(basename $(call src_to_obj,$(1)))) \
+ $(foreach I,$(2),-I$(I)) \
+ -c $(1) -o $(call src_to_obj,$(1))
+endef
+
+# 1 2
+# Usage: $(call c_compile,src,includes)
+define c_compile
+ $(CC) $(CPPFLAGS) $(CFLAGS) \
+ $(call depflags,$(basename $(call c_src_to_obj,$(1)))) \
+ $(foreach I,$(2),-I$(I)) \
+ -c $(1) -o $(call c_src_to_obj,$(1))
+endef
+
+define libcompile
+ $(CXX) $(CPPFLAGS) $(CXXFLAGS) -fpic \
+ $(call depflags,$(basename $(call src_to_lobj,$(1)))) \
+ $(foreach I,$(2),-I$(I)) \
+ -c $(1) -o $(call src_to_lobj,$(1))
+endef
+define c_libcompile
+ $(CC) $(CPPFLAGS) $(CXXFLAGS) -fpic \
+ $(call depflags,$(basename $(call c_src_to_lobj,$(1)))) \
+ $(foreach I,$(2),-I$(I)) \
+ -c $(1) -o $(call c_src_to_lobj,$(1))
+endef
+
+
+# 1 2
+# Usage: $(call makeslib,objs,library)
+define makeslib
+ $(RM) $2
+ $(AR) cru $(2) $(1)
+ $(RANLIB) $(2)
+endef
+
+# 1 2 3 4 5 6 7
+# Usage: $(call makelib,objs,library,ldflags,libs,current,revision,age)
+define makelib
+ $(RM) $(2) $(2).*
+ major=$$(( $(5) - $(7) )); \
+ versuffix=$$major.$(7).$(6); \
+ $(CXX) $(CXXFLAGS) -shared -o $(2).$$versuffix $(1) \
+ -Wl,--soname -Wl,`basename $(2)`.$$major \
+ $(3) $(4) && \
+ ln -s `basename $(2)`.$$versuffix $(2) && \
+ ln -s `basename $(2)`.$$versuffix $(2).$$major
+endef
+
+# 1 2 3 4
+# Usage: $(call makebin,objs,binary,ldflags,libs)
+define makebin
+ $(CXX) $(CXXFLAGS) $(1) -o $(2) $(LDFLAGS) $(3) $(4)
+endef
+
+# Install target
+
+install: all
+ @echo Automated installation is not supported for buildrules=$(BUILDRULES)
diff --git a/make/installwin.mk b/make/installwin.mk
new file mode 100644
index 0000000..e3401d8
--- /dev/null
+++ b/make/installwin.mk
@@ -0,0 +1,21 @@
+DEST=$(INSTALL_DIR)/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION)
+installwin: all
+ $(RM) -r $(INSTALL_DIR)
+ mkdir $(INSTALL_DIR)
+ mkdir $(DEST)
+ mkdir $(DEST)/bin
+ mkdir $(DEST)/lib
+ mkdir $(DEST)/include
+ mkdir $(DEST)/include/qpdf
+ mkdir $(DEST)/doc
+ cp libqpdf/$(OUTPUT_DIR)/$(STATIC_LIB_NAME) $(DEST)/lib
+ cp libqpdf/$(OUTPUT_DIR)/qpdf*.dll $(DEST)/bin
+ perl copy_dlls libqpdf/$(OUTPUT_DIR)/qpdf*.dll $(DEST)/bin $(OBJDUMP)
+ cp qpdf/$(OUTPUT_DIR)/qpdf.exe $(DEST)/bin
+ cp zlib-flate/$(OUTPUT_DIR)/zlib-flate.exe $(DEST)/bin
+ cp qpdf/fix-qdf $(DEST)/bin
+ cp include/qpdf/*.h $(DEST)/include/qpdf
+ cp include/qpdf/*.hh $(DEST)/include/qpdf
+ cp doc/stylesheet.css $(DEST)/doc
+ cp doc/qpdf-manual.html $(DEST)/doc
+ cp doc/qpdf-manual.pdf $(DEST)/doc
diff --git a/make/libtool.mk b/make/libtool.mk
new file mode 100644
index 0000000..8112c2c
--- /dev/null
+++ b/make/libtool.mk
@@ -0,0 +1,133 @@
+# --- Required interface definitions ---
+
+# LIBTOOL needs bash
+SHELL=/bin/bash
+
+OBJ=o
+LOBJ=lo
+
+# Usage: $(call libname,base)
+define libname
+lib$(1).la
+endef
+
+# Usage: $(call binname,base)
+define binname
+$(1)
+endef
+
+# --- Private definitions ---
+
+ifeq ($(HAVE_LD_VERSION_SCRIPT), 1)
+LD_VERSION_FLAGS=-Wl,--version-script=libqpdf.map
+else
+LD_VERSION_FLAGS=
+endif
+
+# Usage: $(call libdepflags,$(basename obj))
+# Usage: $(call fixdeps,$(basename obj))
+ifeq ($(GENDEPS),1)
+libdepflags=-MD -MF $(1).tdep -MP
+fixdeps=sed -e 's/\.o:/.lo:/' < $(1).tdep > $(1).dep
+
+else
+libdepflags=
+fixdeps=
+endif
+
+# --- Required rule definitions ---
+
+# 1 2
+# Usage: $(call compile,src,includes)
+define compile
+ $(CXX) $(CXXFLAGS) \
+ $(call depflags,$(basename $(call src_to_obj,$(1)))) \
+ $(foreach I,$(2),-I$(I)) \
+ $(CPPFLAGS) \
+ -c $(1) -o $(call src_to_obj,$(1))
+endef
+
+# 1 2
+# Usage: $(call c_compile,src,includes)
+define c_compile
+ $(CC) $(CFLAGS) \
+ $(call depflags,$(basename $(call c_src_to_obj,$(1)))) \
+ $(foreach I,$(2),-I$(I)) \
+ $(CPPFLAGS) \
+ -c $(1) -o $(call c_src_to_obj,$(1))
+endef
+
+# 1 2
+# Usage: $(call libcompile,src,includes)
+define libcompile
+ $(LIBTOOL) --quiet --mode=compile \
+ $(CXX) $(CXXFLAGS) \
+ $(call libdepflags,$(basename $(call src_to_obj,$(1)))) \
+ $(foreach I,$(2),-I$(I)) \
+ $(CPPFLAGS) \
+ -c $(1) -o $(call src_to_obj,$(1)); \
+ $(call fixdeps,$(basename $(call src_to_obj,$(1))))
+endef
+
+# 1 2
+# Usage: $(call libcompile,src,includes)
+define c_libcompile
+ $(LIBTOOL) --quiet --mode=compile \
+ $(CC) $(CXXFLAGS) \
+ $(call libdepflags,$(basename $(call c_src_to_obj,$(1)))) \
+ $(foreach I,$(2),-I$(I)) \
+ $(CPPFLAGS) \
+ -c $(1) -o $(call c_src_to_obj,$(1)); \
+ $(call fixdeps,$(basename $(call src_to_obj,$(1))))
+endef
+
+# 1 2
+# Usage: $(call makeslib,objs,library)
+define makeslib
+ $(RM) $2
+ $(AR) cru $(2) $(1)
+ $(RANLIB) $(2)
+endef
+
+# 1 2 3 4 5 6 7
+# Usage: $(call makelib,objs,library,ldflags,libs,current,revision,age)
+define makelib
+ $(LIBTOOL) --mode=link \
+ $(CXX) $(CXXFLAGS) $(LD_VERSION_FLAGS) \
+ -o $(2) $(1) $(4) $(3) \
+ -rpath $(libdir) -version-info $(5):$(6):$(7)
+endef
+
+# 1 2 3 4
+# Usage: $(call makebin,objs,binary,ldflags,libs)
+define makebin
+ $(LIBTOOL) --mode=link $(CXX) $(CXXFLAGS) $(1) -o $(2) $(4) $(3)
+endef
+
+# Install target
+
+install: all
+ ./mkinstalldirs $(DESTDIR)$(libdir)/pkgconfig
+ ./mkinstalldirs $(DESTDIR)$(bindir)
+ ./mkinstalldirs $(DESTDIR)$(includedir)/qpdf
+ ./mkinstalldirs $(DESTDIR)$(docdir)
+ ./mkinstalldirs $(DESTDIR)$(mandir)/man1
+ $(LIBTOOL) --mode=install install -c \
+ libqpdf/$(OUTPUT_DIR)/libqpdf.la \
+ $(DESTDIR)$(libdir)/libqpdf.la
+ $(LIBTOOL) --finish $(DESTDIR)$(libdir)
+ $(RM) $(DESTDIR)$(libdir)/libqpdf.la
+ $(LIBTOOL) --mode=install install -c \
+ qpdf/$(OUTPUT_DIR)/qpdf \
+ $(DESTDIR)$(bindir)/qpdf
+ $(LIBTOOL) --mode=install install -c \
+ zlib-flate/$(OUTPUT_DIR)/zlib-flate \
+ $(DESTDIR)$(bindir)/zlib-flate
+ cp qpdf/fix-qdf $(DESTDIR)$(bindir)
+ cp include/qpdf/*.h $(DESTDIR)$(includedir)/qpdf
+ cp include/qpdf/*.hh $(DESTDIR)$(includedir)/qpdf
+ cp doc/stylesheet.css $(DESTDIR)$(docdir)
+# cp doc/qpdf-manual.html $(DESTDIR)$(docdir)
+# cp doc/qpdf-manual.pdf $(DESTDIR)$(docdir)
+ cp doc/*.1 $(DESTDIR)$(mandir)/man1
+ cp libqpdf.pc $(DESTDIR)$(libdir)/pkgconfig
diff --git a/make/mingw.mk b/make/mingw.mk
new file mode 100644
index 0000000..00119d1
--- /dev/null
+++ b/make/mingw.mk
@@ -0,0 +1,83 @@
+# --- Required interface definitions ---
+
+OBJ=o
+LOBJ=o
+
+# Usage: $(call libname,base)
+define libname
+lib$(1).a
+endef
+
+# Usage: $(call binname,base)
+define binname
+$(1).exe
+endef
+
+# --- Required rule definitions ---
+
+# 1 2
+# Usage: $(call compile,src,includes)
+define compile
+ $(CXX) $(CPPFLAGS) $(CXXFLAGS) \
+ $(call depflags,$(basename $(call src_to_obj,$(1)))) \
+ $(foreach I,$(2),-I$(I)) \
+ -c $(1) -o $(call src_to_obj,$(1))
+endef
+
+# 1 2
+# Usage: $(call c_compile,src,includes)
+define c_compile
+ $(CC) $(CPPFLAGS) $(CFLAGS) \
+ $(call depflags,$(basename $(call src_to_obj,$(1)))) \
+ $(foreach I,$(2),-I$(I)) \
+ -c $(1) -o $(call c_src_to_obj,$(1))
+endef
+
+# 1 2
+# Usage: $(call libcompile,src,includes)
+define libcompile
+ $(CXX) $(CPPFLAGS) $(CXXFLAGS) -DDLL_EXPORT \
+ $(call depflags,$(basename $(call src_to_obj,$(1)))) \
+ $(foreach I,$(2),-I$(I)) \
+ -c $(1) -o $(call src_to_obj,$(1))
+endef
+
+# 1 2
+# Usage: $(call c_libcompile,src,includes)
+define c_libcompile
+ $(CC) $(CPPFLAGS) $(CFLAGS) -DDLL_EXPORT \
+ $(call depflags,$(basename $(call src_to_obj,$(1)))) \
+ $(foreach I,$(2),-I$(I)) \
+ -c $(1) -o $(call c_src_to_obj,$(1))
+endef
+
+# 1 2
+# Usage: $(call makeslib,objs,library)
+define makeslib
+ $(RM) $2
+ $(AR) cru $(2) $(1)
+ $(RANLIB) $(2)
+endef
+
+# 1 2 3 4 5 6 7
+# Usage: $(call makelib,objs,library,ldflags,libs,current,revision,age)
+define makelib
+ $(DLLTOOL) -l $(2) -D $$(basename `echo $(2) | sed -e 's,/lib\(.*\).a,/\1,'`$(shell expr $(5) - $(7)).dll) $(1); \
+ $(CXX) -shared -o `echo $(2) | sed -e 's,/lib\(.*\).a,/\1,'`$(shell expr $(5) - $(7)).dll \
+ $(1) $(3) $(4)
+endef
+
+# 1 2 3 4
+# Usage: $(call makebin,objs,binary,ldflags,libs)
+define makebin
+ $(CXX) $(CXXFLAGS) $(1) -o $(2) $(3) $(4)
+endef
+
+# Install target
+
+INSTALL_DIR = install-mingw$(WINDOWS_WORDSIZE)
+STATIC_LIB_NAME = libqpdf.a
+include make/installwin.mk
+install: installwin
+ $(STRIP) $(DEST)/bin/*.exe
+ $(STRIP) $(DEST)/bin/*.dll
diff --git a/make/msvc.mk b/make/msvc.mk
new file mode 100644
index 0000000..5f3f69a
--- /dev/null
+++ b/make/msvc.mk
@@ -0,0 +1,107 @@
+# --- Required interface definitions ---
+
+OBJ=obj
+LOBJ=obj
+
+# Usage: $(call libname,base)
+define libname
+$(1).lib
+endef
+
+# Usage: $(call binname,base)
+define binname
+$(1).exe
+endef
+
+# --- Local Changes ---
+
+# Filter out -g
+CFLAGS := $(filter-out -g,$(CFLAGS))
+CXXFLAGS := $(filter-out -g,$(CXXFLAGS))
+
+# /WX makes all warnings errors.
+CFLAGS += /WX
+CXXFLAGS += /WX
+
+# /w14267 makes warning 4267 a level 1 warning. This warning reports
+# potential issues between size_t, off_t, and non-compatible integer
+# types.
+CFLAGS += /w14267
+CXXFLAGS += /w14267
+
+clean::
+ $(RM) *.pdb
+
+# --- Required rule definitions ---
+
+# 1 2
+# Usage: $(call compile,src,includes)
+define compile
+ cl /nologo /Zi /Gy /EHsc /MD /TP /GR $(CPPFLAGS) $(CXXFLAGS) \
+ $(foreach I,$(2),-I$(I)) \
+ /c $(1) /Fo$(call src_to_obj,$(1))
+endef
+
+# 1 2
+# Usage: $(call c_compile,src,includes)
+define c_compile
+ cl /nologo /O2 /Zi /Gy /EHsc /MD $(CPPFLAGS) $(CFLAGS) \
+ $(foreach I,$(2),-I$(I)) \
+ /c $(1) /Fo$(call c_src_to_obj,$(1))
+endef
+
+# 1 2
+# Usage: $(call libcompile,src,includes)
+define libcompile
+ cl /nologo /O2 /Zi /Gy /EHsc /MD /TP /GR $(CPPFLAGS) $(CXXFLAGS) \
+ -DDLL_EXPORT $(foreach I,$(2),-I$(I)) \
+ /c $(1) /Fo$(call src_to_obj,$(1))
+endef
+
+# 1 2
+# Usage: $(call c_libcompile,src,includes)
+define c_libcompile
+ cl /nologo /O2 /Zi /Gy /EHsc /MD $(CPPFLAGS) $(CXXFLAGS) \
+ -DDLL_EXPORT $(foreach I,$(2),-I$(I)) \
+ /c $(1) /Fo$(call c_src_to_obj,$(1))
+endef
+
+# 1 2
+# Usage: $(call makeslib,objs,library)
+define makeslib
+ lib /nologo /OUT:$(2) $(1)
+endef
+
+# 1 2 3 4 5 6 7
+# Usage: $(call makelib,objs,library,ldflags,libs,current,revision,age)
+define makelib
+ cl /nologo /O2 /Zi /Gy /EHsc /MD /LD /Fe$(basename $(2))$(shell expr $(5) - $(7)).dll $(1) \
+ /link /incremental:no \
+ $(foreach L,$(subst -L,,$(3)),/LIBPATH:$(L)) \
+ $(foreach L,$(subst -l,,$(4)),$(L).lib)
+ if [ -f $(basename $(2))$(shell expr $(5) - $(7)).dll.manifest ]; then \
+ mt.exe -nologo -manifest $(basename $(2))$(shell expr $(5) - $(7)).dll.manifest \
+ -outputresource:$(basename $(2))$(shell expr $(5) - $(7)).dll\;2; \
+ fi
+ mv $(basename $(2))$(shell expr $(5) - $(7)).lib $(2)
+endef
+
+# 1 2 3 4
+# Usage: $(call makebin,objs,binary,ldflags,libs)
+define makebin
+ cl /nologo /O2 /Zi /Gy /EHsc /MD $(1) \
+ /link /incremental:no /OUT:$(2) \
+ $(foreach L,$(subst -L,,$(3)),/LIBPATH:$(L)) \
+ $(foreach L,$(subst -l,,$(4)),$(L).lib)
+ if [ -f $(2).manifest ]; then \
+ mt.exe -nologo -manifest $(2).manifest \
+ -outputresource:$(2)\;2; \
+ fi
+endef
+
+# Install target
+
+INSTALL_DIR = install-msvc$(WINDOWS_WORDSIZE)
+STATIC_LIB_NAME = qpdf.lib
+include make/installwin.mk
+install: installwin
diff --git a/make/proxy.mk b/make/proxy.mk
new file mode 100644
index 0000000..1683186
--- /dev/null
+++ b/make/proxy.mk
@@ -0,0 +1,10 @@
+THIS=$(notdir $(abspath .))
+
+all:
+ $(MAKE) -C .. build_$(THIS)
+
+check:
+ $(MAKE) -C .. check_$(THIS)
+
+clean:
+ $(MAKE) -C .. clean_$(THIS)
diff --git a/make/rules.mk b/make/rules.mk
new file mode 100644
index 0000000..efeb9a7
--- /dev/null
+++ b/make/rules.mk
@@ -0,0 +1,49 @@
+include make/$(BUILDRULES).mk
+
+define firstelem
+$(word 1,$(subst /, ,$(1)))
+endef
+SPC := $(subst /, ,/)
+define lastelem
+$(subst $(SPC),/,$(word $(words $(subst /, ,$(1))),$(subst /, ,$(1))))
+endef
+define objbase
+$(patsubst %.$(2),%.$(3),$(firstelem)/$(OUTPUT_DIR)/$(lastelem))
+endef
+
+# Usage: $(call src_to_obj,srcs)
+define src_to_obj
+$(foreach F,$(1),$(call objbase,$(F),cc,$(OBJ)))
+endef
+
+# Usage: $(call c_src_to_obj,srcs)
+define c_src_to_obj
+$(foreach F,$(1),$(call objbase,$(F),c,$(OBJ)))
+endef
+
+# Usage: $(call src_to_lobj,srcs)
+define src_to_lobj
+$(foreach F,$(1),$(call objbase,$(F),cc,$(LOBJ)))
+endef
+
+# Usage: $(call c_src_to_lobj,srcs)
+define c_src_to_lobj
+$(foreach F,$(1),$(call objbase,$(F),c,$(LOBJ)))
+endef
+
+# Usage: $(call obj_to_dep,objs)
+define obj_to_dep
+$(patsubst %.$(OBJ),%.dep,$(1))
+endef
+
+# Usage: $(call lobj_to_dep,objs)
+define lobj_to_dep
+$(patsubst %.$(LOBJ),%.dep,$(1))
+endef
+
+# Usage: $(call depflags,$(basename obj))
+ifeq ($(GENDEPS),1)
+depflags=-MD -MF $(1).dep -MP
+else
+depflags=
+endif