aboutsummaryrefslogtreecommitdiffstats
path: root/make
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2009-10-10 16:15:09 +0200
committerJay Berkenbilt <ejb@ql.org>2009-10-10 16:15:09 +0200
commitcaa397ed157ada95129dbe784c01c6a1f95b226f (patch)
tree0afc674c2395f25143392a34b1454d42a064d2cb /make
parent25e9bdc75ba314333aaa4ab38358719abbedd102 (diff)
downloadqpdf-caa397ed157ada95129dbe784c01c6a1f95b226f.tar.zst
generalize build rules, add experimental support for manual compilation without libtool
git-svn-id: svn+q:///qpdf/trunk@753 71b93d88-0707-0410-a8cf-f5a4172ac649
Diffstat (limited to 'make')
-rw-r--r--make/gcc-linux.mk67
-rw-r--r--make/libtool.mk74
-rw-r--r--make/rules.mk68
3 files changed, 147 insertions, 62 deletions
diff --git a/make/gcc-linux.mk b/make/gcc-linux.mk
new file mode 100644
index 00000000..41978402
--- /dev/null
+++ b/make/gcc-linux.mk
@@ -0,0 +1,67 @@
+# --- Required interface definitions ---
+
+OBJ=o
+LOBJ=o
+
+# Usage: $(call libname,base)
+define libname
+lib$(1).a 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 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_obj,$(1)))) \
+ $(foreach I,$(2),-I$(I)) \
+ -c $(1) -o $(call src_to_obj,$(1))
+endef
+
+
+# 1 2 3 4 5
+# Usage: $(call makelib,objs,library,current,revision,age)
+define makelib
+ $(RM) $2
+ if [ "$(findstring .a,$(2))" = ".a" ]; then \
+ ar cru $(2) $(1); \
+ ranlib $(2); \
+ else \
+ major=$$(( $(3) - $(5))); \
+ versuffix=$$major.$5.$4; \
+ $(CXX) $(CXXFLAGS) -shared -o $(2).$$versuffix $(1) \
+ -Wl,--soname -Wl,`basename $(2)`.$$major \
+ $(LDFLAGS) $(LIBS); \
+ ln -s `basename $(2)`.$$versuffix $(2); \
+ ln -s `basename $(2)`.$$versuffix $(2).$$major; \
+ fi
+endef
+
+# 1 2
+# Usage: $(call makebin,objs,binary)
+define makebin
+ $(CXX) $(CXXFLAGS) $(1) -o $(2) $(LDFLAGS) \
+ -Llibqpdf/$(OUTPUT_DIR) -lqpdf $(LIBS)
+endef
diff --git a/make/libtool.mk b/make/libtool.mk
new file mode 100644
index 00000000..3287d5aa
--- /dev/null
+++ b/make/libtool.mk
@@ -0,0 +1,74 @@
+# --- Required interface definitions ---
+
+OBJ=o
+LOBJ=lo
+
+# Usage: $(call libname,base)
+define libname
+lib$(1).la
+endef
+
+# Usage: $(call binname,base)
+define binname
+$(1)
+endef
+
+# --- Private definitions ---
+
+# 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) $(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
+ $(LIBTOOL) --quiet --mode=compile \
+ $(CXX) $(CPPFLAGS) $(CXXFLAGS) \
+ $(call libdepflags,$(basename $(call src_to_obj,$(1)))) \
+ $(foreach I,$(2),-I$(I)) \
+ -c $(1) -o $(call src_to_obj,$(1)); \
+ $(call fixdeps,$(basename $(call src_to_obj,$(1))))
+endef
+
+# 1 2 3 4 5
+# Usage: $(call makelib,objs,library,current,revision,age)
+define makelib
+ $(LIBTOOL) --mode=link \
+ $(CXX) $(CXXFLAGS) -o $(2) $(1) $(LDFLAGS) $(LIBS) \
+ -rpath $(libdir) -version-info $(3):$(4):$(5)
+endef
+
+# 1 2
+# Usage: $(call makebin,objs,binary)
+define makebin
+ $(LIBTOOL) --mode=link \
+ $(CXX) $(CXXFLAGS) $(1) -o $(2) $(LDFLAGS) \
+ -Llibqpdf/$(OUTPUT_DIR) -lqpdf $(LIBS)
+endef
diff --git a/make/rules.mk b/make/rules.mk
index 01b6f2f2..a55087b5 100644
--- a/make/rules.mk
+++ b/make/rules.mk
@@ -1,27 +1,28 @@
+include make/$(BUILDRULES).mk
# Usage: $(call src_to_obj,srcs)
define src_to_obj
-$(foreach F,$(1),$(dir $(F))$(OUTPUT_DIR)/$(patsubst %.cc,%.o,$(notdir $(F))))
+$(foreach F,$(1),$(dir $(F))$(OUTPUT_DIR)/$(patsubst %.cc,%.$(OBJ),$(notdir $(F))))
endef
# Usage: $(call c_src_to_obj,srcs)
define c_src_to_obj
-$(foreach F,$(1),$(dir $(F))$(OUTPUT_DIR)/$(patsubst %.c,%.o,$(notdir $(F))))
+$(foreach F,$(1),$(dir $(F))$(OUTPUT_DIR)/$(patsubst %.c,%.$(OBJ),$(notdir $(F))))
endef
# Usage: $(call src_to_lobj,srcs)
define src_to_lobj
-$(foreach F,$(1),$(dir $(F))$(OUTPUT_DIR)/$(patsubst %.cc,%.lo,$(notdir $(F))))
+$(foreach F,$(1),$(dir $(F))$(OUTPUT_DIR)/$(patsubst %.cc,%.$(LOBJ),$(notdir $(F))))
endef
# Usage: $(call obj_to_dep,objs)
define obj_to_dep
-$(patsubst %.o,%.dep,$(1))
+$(patsubst %.$(OBJ),%.dep,$(1))
endef
# Usage: $(call lobj_to_dep,objs)
define lobj_to_dep
-$(patsubst %.lo,%.dep,$(1))
+$(patsubst %.$(LOBJ),%.dep,$(1))
endef
# Usage: $(call depflags,$(basename obj))
@@ -30,60 +31,3 @@ depflags=-MD -MF $(1).dep -MP
else
depflags=
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
-
-# 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
- $(LIBTOOL) --quiet --mode=compile \
- $(CXX) $(CPPFLAGS) $(CXXFLAGS) \
- $(call libdepflags,$(basename $(call src_to_obj,$(1)))) \
- $(foreach I,$(2),-I$(I)) \
- -c $(1) -o $(call src_to_obj,$(1)); \
- $(call fixdeps,$(basename $(call src_to_obj,$(1))))
-endef
-
-# 1 2 3 4 5
-# Usage: $(call makelib,objs,library,current,revision,age)
-define makelib
- $(LIBTOOL) --mode=link \
- $(CXX) $(CXXFLAGS) -o $(2) $(1) $(LDFLAGS) $(LIBS) \
- -rpath $(libdir) -version-info $(3):$(4):$(5)
-endef
-
-# 1 2
-# Usage: $(call makebin,objs,binary)
-define makebin
- $(LIBTOOL) --mode=link \
- $(CXX) $(CXXFLAGS) $(1) -o $(2) $(LDFLAGS) \
- -Llibqpdf/$(OUTPUT_DIR) -lqpdf $(LIBS)
-endef
-