File: 02-Build-static-helper.patch

package info (click to toggle)
apq-postgresql 3.0-4
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 384 kB
  • ctags: 187
  • sloc: ada: 2,169; ansic: 2,003; makefile: 93; sql: 3; sh: 2
file content (121 lines) | stat: -rw-r--r-- 3,035 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
Author: Adrian-Ken Rueegsegger <ken@codelabs.ch>
Description: Build static helper and specify soname for dynamic lib.

--- apq-postgresql.orig/Makefile
+++ apq-postgresql/Makefile
@@ -2,6 +2,7 @@
 #
 # @author Marcelo Coraça de Freitas <marcelo.batera@gmail.com> 
 
+include Makefile.include
 
 # Set those variables when building for Windows or when you have
 # PostgreSQL installed in some hidden location.
@@ -18,33 +19,34 @@
 ifeq ($(OS), Windows_NT)
 	OUTPUT_NAME=apq-postgresqlhelp.dll
 else
-	OUTPUT_NAME=libapq-postgresqlhelp.so
+	OUTPUT_NAME=libapq-postgresqlhelp.so.${VERSION}
 endif
 
-
 PROJECT_FILES=apq-postgresql.gpr
 GPR_FILES=apq-postgresql.gpr
 
 
 INCLUDE_FILES=src*/*
 
-include Makefile.include
-
-
-
 pre_libs: c_libs
 
 pos_libs:
 
-
-c_libs: c_objs
-	cd lib && gcc -shared ../obj-c/numeric.o ../obj-c/notices.o -o $(OUTPUT_NAME) -L"${POSTGRESQL_LIB}" -lpq
-
+c_libs: c_objs static
+	cd lib && \
+		gcc -shared -Wl,-soname,$(OUTPUT_NAME) ../obj-c/numeric.o ../obj-c/notices.o -o $(OUTPUT_NAME) -lpq && \
+		ln -sf $(OUTPUT_NAME) libapq-postgresqlhelp.so
 c_objs:
-	cd obj-c && gcc -fPIC -I/usr/include/postgresql/ -I../src-c ../src-c/numeric.c -c -o numeric.o && gcc -fPIC -I"${POSTGRESQL_INCLUDE}" -I../src-c ../src-c/notices.c -c -o notices.o
-
-
+	cd obj-c && \
+		gcc -fPIC -g -I/usr/include/postgresql/	-I../src-c ../src-c/numeric.c -c -o numeric.o && \
+		gcc -fPIC -g -I/usr/include/postgresql/ -I../src-c ../src-c/notices.c -c -o notices.o
+
+static:
+	mkdir -p obj-c/static
+	cd obj-c/static && \
+		gcc -I/usr/include/postgresql/ -I../../src-c ../../src-c/numeric.c -c -o numeric.o && \
+		gcc -I/usr/include/postgresql/ -I../../src-c ../../src-c/notices.c -c -o notices.o
+	ar rcs lib/libapq-postgresqlhelp.a obj-c/static/*.o
 
 extra_clean:
-	@rm -f obj-c/* lib/*
-
+	@rm -rf obj-c/* lib/*
--- apq-postgresql.orig/Makefile.include
+++ apq-postgresql/Makefile.include
@@ -1,5 +1,7 @@
 
 VERSION=$(shell cat version)
+LIBTYPE=dynamic
+CURRENT_DIR=$(shell pwd)
 
 ifndef ($(PREFIX))
 	PREFIX=/usr/local
@@ -14,7 +16,7 @@
 endif
 
 ifndef ($(GPR_PATH))
-	GPR_PATH=$(LIB_PATH)/gnat 
+	GPR_PATH=$(LIB_PATH)/gnat
 endif
 
 
@@ -26,16 +28,14 @@
 	GPR_LIB_PATH=$(LIB_PATH)
 endif
 
-
 all: libs
 	@make pos_libs
 
-
 libs: pre_libs
 	@for project_file in $(PROJECT_FILES); do\
 		echo "Making $$project_file"; \
-		gnatprep "-Dversion=\"$(VERSION)\"" $$project_file{.in,}; \
-		gnatmake -P $$project_file; \
+		gnatprep "-Dversion=\"$(VERSION)\"" "-DLIBDIR=\"-L$(CURRENT_DIR)/lib\"" $$project_file.in $$project_file; \
+		gnatmake -P$$project_file -XLibtype="$(LIBTYPE)"; \
 	done
 
 clean: gprclean extra_clean
@@ -50,9 +50,6 @@
 docs:
 	@-sh ./gendoc.sh || echo There is no documentation available
 
-
-
-
 gprfile:
 	@echo "Preparing GPR file.."
 	@echo version:=\"$(VERSION)\" > gpr/gnatprep.def
@@ -67,8 +64,7 @@
 	@rm -f gpr/*gpr
 	@rm -f gpr/*.def
 
-
-install: includeinstall libinstall gprinstall 
+install: includeinstall libinstall gprinstall
 
 gprinstall: gprfile
 	@echo Installing GPR files..