File: 0002-build-shared-library.patch

package info (click to toggle)
cliquer 1.21-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 492 kB
  • sloc: ansic: 5,394; makefile: 186
file content (266 lines) | stat: -rw-r--r-- 9,246 bytes parent folder | download | duplicates (2)
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
From: "Bernhard R. Link" <brlink@debian.org>
Date: Sat, 12 Mar 2011 16:06:39 +0100
Subject: build shared library

---
 Makefile       | 24 ++++++++++++++++++++----
 cliquer.h      | 18 +++++++++---------
 graph.h        | 30 +++++++++++++++---------------
 libcliquer.map | 43 +++++++++++++++++++++++++++++++++++++++++++
 misc.h         |  7 +++++++
 reorder.h      | 28 ++++++++++++++--------------
 6 files changed, 108 insertions(+), 42 deletions(-)
 create mode 100644 libcliquer.map

diff --git a/Makefile b/Makefile
index 6c5de54..da7fb79 100644
--- a/Makefile
+++ b/Makefile
@@ -19,6 +19,14 @@ CFLAGS=-Wall -O3 -fomit-frame-pointer -funroll-loops
 # SunOS:
 #CFLAGS=-fast
 
+# GCC:
+SHLDFLAGS = --shared -Wl,--soname=libcliquer.so.1 -Wl,--version-script=libcliquer.map
+SHCFLAGS  = -fPIC -fvisibility=hidden
+
+# SunOS:
+#SHLDFLAGS = --shared -Wl,--soname=libcliquer.so.1 -Wl,--version-script=libcliquer.map
+#SHCFLAGS  = -fPIC
+
 ## Program options:
 
 # Enable long options for cl (eg. "cl --help"), comment out to disable.
@@ -29,14 +37,19 @@ LONGOPTS = -DENABLE_LONG_OPTIONS
 ##### End of configurable options
 
 
-all: cl
+all: cl libcliquer.so
+
+libcliquer_OBJECTS = cliquer.o graph.o reorder.o
 
 
 testcases: testcases.o cliquer.o graph.o reorder.o
 	$(CC) $(LDFLAGS) -o $@ testcases.o cliquer.o graph.o reorder.o
 
-cl: cl.o cliquer.o graph.o reorder.o
-	$(CC) $(LDFLAGS) -o $@ cl.o cliquer.o graph.o reorder.o
+libcliquer.so: $(libcliquer_OBJECTS) libcliquer.map
+	$(CC) $(LDFLAGS) $(SHCFLAGS) $(SHLDFLAGS) -o $@ $(libcliquer_OBJECTS)
+
+cl: cl.o libcliquer.so
+	$(CC) $(LDFLAGS) -o $@ cl.o -L. -lcliquer
 
 
 cl.o testcases.o cliquer.o graph.o reorder.o: cliquer.h set.h graph.h misc.h reorder.h Makefile cliquerconf.h
@@ -44,8 +57,11 @@ cl.o testcases.o cliquer.o graph.o reorder.o: cliquer.h set.h graph.h misc.h reo
 cl.o: cl.c
 	$(CC) $(CFLAGS) $(LONGOPTS) -o $@ -c $<
 
+$(libcliquer_OBJECTS): %.o: %.c
+	$(CC) $(CFLAGS) $(SHCFLAGS) $(LONGOPTS) -o $@ -c $<
+
 clean:
-	rm -f *.o *~ cl testcases
+	rm -f *.o *~ cl testcases *.so*
 
 backup:
 	mkdir "`date "+backup-%Y-%m-%d-%H-%M"`" 2>/dev/null || true
diff --git a/cliquer.h b/cliquer.h
index d9993be..aa7fafb 100644
--- a/cliquer.h
+++ b/cliquer.h
@@ -24,29 +24,29 @@ struct _clique_options {
 	int clique_list_length;
 };
 
-extern clique_options *clique_default_options;
+PUBLIC clique_options *clique_default_options;
 
 /* Weighted clique functions */
-extern int clique_max_weight(graph_t *g,clique_options *opts);
-extern set_t clique_find_single(graph_t *g,int min_weight,int max_weight,
+PUBLIC int clique_max_weight(graph_t *g,clique_options *opts);
+PUBLIC set_t clique_find_single(graph_t *g,int min_weight,int max_weight,
 				boolean maximal, clique_options *opts);
-extern int clique_find_all(graph_t *g, int req_weight, boolean exact,
+PUBLIC int clique_find_all(graph_t *g, int req_weight, boolean exact,
 			   boolean maximal, clique_options *opts);
 
 /* Unweighted clique functions */
 #define clique_unweighted_max_size clique_unweighted_max_weight
-extern int clique_unweighted_max_weight(graph_t *g, clique_options *opts);
-extern set_t clique_unweighted_find_single(graph_t *g,int min_size,
+PUBLIC int clique_unweighted_max_weight(graph_t *g, clique_options *opts);
+PUBLIC set_t clique_unweighted_find_single(graph_t *g,int min_size,
 					   int max_size,boolean maximal,
 					   clique_options *opts);
-extern int clique_unweighted_find_all(graph_t *g, int min_size, int max_size,
+PUBLIC int clique_unweighted_find_all(graph_t *g, int min_size, int max_size,
 				      boolean maximal, clique_options *opts);
 
 /* Time printing functions */
-extern boolean clique_print_time(int level, int i, int n, int max,
+PUBLIC boolean clique_print_time(int level, int i, int n, int max,
 				 double cputime, double realtime,
 				 clique_options *opts);
-extern boolean clique_print_time_always(int level, int i, int n, int max,
+PUBLIC boolean clique_print_time_always(int level, int i, int n, int max,
 					double cputime, double realtime,
 					clique_options *opts);
 
diff --git a/graph.h b/graph.h
index 9c94f17..8701b28 100644
--- a/graph.h
+++ b/graph.h
@@ -25,26 +25,26 @@ struct _graph_t {
 } while (FALSE)
 
 
-extern graph_t *graph_new(int n);
-extern void graph_free(graph_t *g);
-extern void graph_resize(graph_t *g, int size);
-extern void graph_crop(graph_t *g);
+PUBLIC graph_t *graph_new(int n);
+PUBLIC void graph_free(graph_t *g);
+PUBLIC void graph_resize(graph_t *g, int size);
+PUBLIC void graph_crop(graph_t *g);
 
-extern boolean graph_weighted(graph_t *g);
-extern int graph_edge_count(graph_t *g);
+PUBLIC boolean graph_weighted(graph_t *g);
+PUBLIC int graph_edge_count(graph_t *g);
 
-extern graph_t *graph_read_dimacs(FILE *fp);
-extern graph_t *graph_read_dimacs_file(char *file);
-extern boolean graph_write_dimacs_ascii(graph_t *g, char *comment,FILE *fp);
-extern boolean graph_write_dimacs_ascii_file(graph_t *g,char *comment,
+PUBLIC graph_t *graph_read_dimacs(FILE *fp);
+PUBLIC graph_t *graph_read_dimacs_file(char *file);
+PUBLIC boolean graph_write_dimacs_ascii(graph_t *g, char *comment,FILE *fp);
+PUBLIC boolean graph_write_dimacs_ascii_file(graph_t *g,char *comment,
 					     char *file);
-extern boolean graph_write_dimacs_binary(graph_t *g, char *comment,FILE *fp);
-extern boolean graph_write_dimacs_binary_file(graph_t *g, char *comment,
+PUBLIC boolean graph_write_dimacs_binary(graph_t *g, char *comment,FILE *fp);
+PUBLIC boolean graph_write_dimacs_binary_file(graph_t *g, char *comment,
 					      char *file);
 
-extern void graph_print(graph_t *g);
-extern boolean graph_test(graph_t *g, FILE *output);
-extern int graph_test_regular(graph_t *g);
+PUBLIC void graph_print(graph_t *g);
+PUBLIC boolean graph_test(graph_t *g, FILE *output);
+PUBLIC int graph_test_regular(graph_t *g);
 
 UNUSED_FUNCTION INLINE
 static int graph_subgraph_weight(graph_t *g,set_t s) {
diff --git a/libcliquer.map b/libcliquer.map
new file mode 100644
index 0000000..5650839
--- /dev/null
+++ b/libcliquer.map
@@ -0,0 +1,43 @@
+CLIQUER_1 {
+	global:
+		clique_default_options;
+		clique_max_weight;
+		clique_find_single;
+		clique_find_all;
+		clique_unweighted_max_weight;
+		clique_unweighted_find_single;
+		clique_unweighted_find_all;
+		clique_print_time;
+		clique_print_time_always;
+		graph_new;
+		graph_free;
+		graph_resize;
+		graph_crop;
+		graph_weighted;
+		graph_edge_count;
+		graph_read_dimacs;
+		graph_read_dimacs_file;
+		graph_write_dimacs_ascii;
+		graph_write_dimacs_ascii_file;
+		graph_write_dimacs_binary;
+		graph_write_dimacs_binary_file;
+		graph_print;
+		graph_test;
+		graph_test_regular;
+		reorder_set;
+		reorder_graph;
+		reorder_duplicate;
+		reorder_invert;
+		reorder_reverse;
+		reorder_ident;
+		reorder_is_bijection;
+		reorder_by_greedy_coloring;
+		reorder_by_weighted_greedy_coloring;
+		reorder_by_unweighted_greedy_coloring;
+		reorder_by_degree;
+		reorder_by_random;
+		reorder_by_ident;
+		reorder_by_reverse;
+	local:
+		*;
+};
diff --git a/misc.h b/misc.h
index 9cad635..60f8349 100644
--- a/misc.h
+++ b/misc.h
@@ -26,6 +26,13 @@
 # endif
 #endif  /* !UNUSED_FUNCTION */
 
+#ifndef PUBLIC
+#  if __GNUC__ >= 4
+#    define PUBLIC extern __attribute__ ((visibility("default")))
+#  else
+#    define PUBLIC extern
+#  endif
+#endif
 
 /*
  * Default inlining directive:  "inline"
diff --git a/reorder.h b/reorder.h
index 5c06d31..1d3b4e1 100644
--- a/reorder.h
+++ b/reorder.h
@@ -5,22 +5,22 @@
 #include "set.h"
 #include "graph.h"
 
-extern void reorder_set(set_t s,int *order);
-extern void reorder_graph(graph_t *g, int *order);
-extern int *reorder_duplicate(int *order,int n);
-extern void reorder_invert(int *order,int n);
-extern void reorder_reverse(int *order,int n);
-extern int *reorder_ident(int n);
-extern boolean reorder_is_bijection(int *order,int n);
+PUBLIC void reorder_set(set_t s,int *order);
+PUBLIC void reorder_graph(graph_t *g, int *order);
+PUBLIC int *reorder_duplicate(int *order,int n);
+PUBLIC void reorder_invert(int *order,int n);
+PUBLIC void reorder_reverse(int *order,int n);
+PUBLIC int *reorder_ident(int n);
+PUBLIC boolean reorder_is_bijection(int *order,int n);
 
 
 #define reorder_by_default reorder_by_greedy_coloring
-extern int *reorder_by_greedy_coloring(graph_t *g, boolean weighted);
-extern int *reorder_by_weighted_greedy_coloring(graph_t *g, boolean weighted);
-extern int *reorder_by_unweighted_greedy_coloring(graph_t *g,boolean weighted);
-extern int *reorder_by_degree(graph_t *g, boolean weighted);
-extern int *reorder_by_random(graph_t *g, boolean weighted);
-extern int *reorder_by_ident(graph_t *g, boolean weighted);
-extern int *reorder_by_reverse(graph_t *g, boolean weighted);
+PUBLIC int *reorder_by_greedy_coloring(graph_t *g, boolean weighted);
+PUBLIC int *reorder_by_weighted_greedy_coloring(graph_t *g, boolean weighted);
+PUBLIC int *reorder_by_unweighted_greedy_coloring(graph_t *g,boolean weighted);
+PUBLIC int *reorder_by_degree(graph_t *g, boolean weighted);
+PUBLIC int *reorder_by_random(graph_t *g, boolean weighted);
+PUBLIC int *reorder_by_ident(graph_t *g, boolean weighted);
+PUBLIC int *reorder_by_reverse(graph_t *g, boolean weighted);
 
 #endif /* !CLIQUER_REORDER_H */