fix packaging
[adaptation/panda/wpa_supplicant.git] / packaging / 0001-eap_peer-create-a-libeap-library-with-header-files-a.patch
1 From 3de5e59b291b6f58317bb16736f8c0271754378e Mon Sep 17 00:00:00 2001
2 From: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
3 Date: Sat, 2 Oct 2010 00:11:51 -0700
4 Subject: [PATCH] eap_peer: create a libeap library, with header files and pkg-config [v2]
5
6 This adds infrastructe in src/eap_peer to make libeap.so and install
7 the needed header files and pkg-config files.
8
9 Now, this is quite dirty and probably not what we want in the long
10 term, but serves as an starting point:
11
12  - we don't build from the wpa_supplicant directory because the
13    objects the .so have to be built with -fPIC. So if you need to
14    build both the binary and the library:
15
16    make -C wpa_supplicant
17    make -C src/eap_peer clean
18    make -C src/eap_peer
19
20    As I said, it's dirty -- we'd need either wpa_supplicant linking
21    against the library properly (but that seems not to be desirable)
22    or a multiple object build approach ala automake.
23
24  - need to use 'override CFLAGS' in src/eap_peer/Makefile, otherwise
25    any CFLAGS setting will kill the build infrastructure. I miss
26    AM_CFLAGS.
27
28  - adds 'eap_register_methods()' that will register every compiled in
29    method.
30
31 Signed-off-by: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
32 ---
33  build_release              |   12 +++
34  src/eap_peer/Makefile      |  191 ++++++++++++++++++++++++++++++++++++++++++--
35  src/eap_peer/eap_methods.c |  114 ++++++++++++++++++++++++++
36  src/eap_peer/eap_methods.h |    1 +
37  src/eap_peer/libeap0.pc    |   10 +++
38  5 files changed, 320 insertions(+), 8 deletions(-)
39  create mode 100644 src/eap_peer/libeap0.pc
40
41 diff --git a/src/eap_peer/Makefile b/src/eap_peer/Makefile
42 index 3651056..58c067a 100644
43 --- a/src/eap_peer/Makefile
44 +++ b/src/eap_peer/Makefile
45 @@ -1,11 +1,186 @@
46 -all:
47 -       @echo Nothing to be made.
48 +LIBEAP_NAME = libeap
49 +LIBEAP_CURRENT = 0
50 +LIBEAP_REVISION = 0
51 +LIBEAP_AGE = 0
52 +
53 +LIBEAP = $(LIBEAP_NAME).so.$(LIBEAP_CURRENT).$(LIBEAP_REVISION).$(LIBEAP_AGE)
54 +LIBEAP_SO = $(LIBEAP_NAME).so.$(LIBEAP_CURRENT)
55 +
56 +.PHONY: all clean install uninstall
57 +
58 +all: $(LIBEAP)
59 +
60 +ifndef CC
61 +CC=gcc
62 +endif
63 +
64 +ifndef CFLAGS
65 +CFLAGS = -MMD -O0 -Wall -g
66 +endif
67 +
68 +CONFIG_TLS=openssl
69 +
70 +INCLUDE_INSTALL_DIR=/usr/include/eap_peer
71 +
72 +# Got to use override all across the board, otherwise a 'make
73 +# CFLAGS=XX' will kill us because the command line's CFLAGS will
74 +# overwrite Make's and we'll loose all the infrastructure it sets.
75 +override CFLAGS += -I. -I.. -I../crypto -I../utils -I../common
76 +
77 +# at least for now, need to include config_ssid.h and config_blob.h from
78 +# wpa_supplicant directory
79 +override CFLAGS += -I ../../wpa_supplicant
80 +
81 +OBJS_both += ../utils/common.o
82 +OBJS_both += ../utils/os_unix.o
83 +OBJS_both += ../utils/wpa_debug.o
84 +OBJS_both += ../utils/base64.o
85 +OBJS_both += ../utils/wpabuf.o
86 +OBJS_both += ../crypto/md5.o
87 +OBJS_both += ../crypto/sha1.o
88 +OBJS_both += ../crypto/sha1-tlsprf.o
89 +OBJS_both += ../crypto/aes-encblock.o
90 +OBJS_both += ../crypto/aes-wrap.o
91 +OBJS_both += ../crypto/aes-ctr.o
92 +OBJS_both += ../crypto/aes-eax.o
93 +OBJS_both += ../crypto/aes-omac1.o
94 +OBJS_both += ../crypto/ms_funcs.o
95 +OBJS_both += ../crypto/sha256.o
96 +
97 +
98 +OBJS_both += ../eap_common/eap_peap_common.o
99 +OBJS_both += ../eap_common/eap_psk_common.o
100 +OBJS_both += ../eap_common/eap_pax_common.o
101 +OBJS_both += ../eap_common/eap_sake_common.o
102 +OBJS_both += ../eap_common/eap_gpsk_common.o
103 +OBJS_both += ../eap_common/chap.o
104 +
105 +OBJS_peer += ../eap_peer/eap_tls.o
106 +OBJS_peer += ../eap_peer/eap_peap.o
107 +OBJS_peer += ../eap_peer/eap_ttls.o
108 +OBJS_peer += ../eap_peer/eap_md5.o
109 +OBJS_peer += ../eap_peer/eap_mschapv2.o
110 +OBJS_peer += ../eap_peer/mschapv2.o
111 +OBJS_peer += ../eap_peer/eap_otp.o
112 +OBJS_peer += ../eap_peer/eap_gtc.o
113 +OBJS_peer += ../eap_peer/eap_leap.o
114 +OBJS_peer += ../eap_peer/eap_psk.o
115 +OBJS_peer += ../eap_peer/eap_pax.o
116 +OBJS_peer += ../eap_peer/eap_sake.o
117 +OBJS_peer += ../eap_peer/eap_gpsk.o
118 +OBJS_peer += ../eap_peer/eap.o
119 +OBJS_peer += ../eap_common/eap_common.o
120 +OBJS_peer += ../eap_peer/eap_methods.o
121 +OBJS_peer += ../eap_peer/eap_tls_common.o
122 +
123 +override CFLAGS += -DEAP_TLS
124 +override CFLAGS += -DEAP_PEAP
125 +override CFLAGS += -DEAP_TTLS
126 +override CFLAGS += -DEAP_MD5
127 +override CFLAGS += -DEAP_MSCHAPv2
128 +override CFLAGS += -DEAP_GTC
129 +override CFLAGS += -DEAP_OTP
130 +override CFLAGS += -DEAP_LEAP
131 +override CFLAGS += -DEAP_PSK
132 +override CFLAGS += -DEAP_PAX
133 +override CFLAGS += -DEAP_SAKE
134 +override CFLAGS += -DEAP_GPSK -DEAP_GPSK_SHA256
135 +override CFLAGS += -DEAP_TLS_FUNCS
136 +
137 +override CFLAGS += -DIEEE8021X_EAPOL
138 +
139 +ifeq ($(CONFIG_TLS), openssl)
140 +override CFLAGS += -DEAP_TLS_OPENSSL
141 +OBJS_both += ../crypto/tls_openssl.o
142 +OBJS_both += ../crypto/crypto_openssl.o
143 +LIBS += -lssl -lcrypto
144 +override CFLAGS += -DINTERNAL_SHA256
145 +endif
146 +
147 +ifeq ($(CONFIG_TLS), internal)
148 +OBJS_both += ../crypto/tls_internal.o
149 +OBJS_both += ../tls/tlsv1_common.o ../../tls/tlsv1_record.o
150 +OBJS_both += ../tls/tlsv1_cred.o
151 +OBJS_both += ../tls/asn1.o ../../tls/x509v3.o
152 +OBJS_both += ../crypto/crypto_internal.o ../../tls/rsa.o ../../tls/bignum.o
153 +
154 +OBJS_peer += ../tls/tlsv1_client.o
155 +OBJS_peer += ../tls/tlsv1_client_write.o ../../tls/tlsv1_client_read.o
156 +override CFLAGS += -DCONFIG_TLS_INTERNAL_CLIENT
157 +
158 +OBJS_server += ../tls/tlsv1_server.o
159 +OBJS_server += ../tls/tlsv1_server_write.o ../../tls/tlsv1_server_read.o
160 +override CFLAGS += -DCONFIG_TLS_INTERNAL_SERVER
161 +
162 +override CFLAGS += -DCONFIG_TLS_INTERNAL
163 +override CFLAGS += -DCONFIG_CRYPTO_INTERNAL
164 +override CFLAGS += -DCONFIG_INTERNAL_X509
165 +override CFLAGS += -DINTERNAL_AES
166 +override CFLAGS += -DINTERNAL_SHA1
167 +override CFLAGS += -DINTERNAL_SHA256
168 +override CFLAGS += -DINTERNAL_MD5
169 +override CFLAGS += -DINTERNAL_MD4
170 +override CFLAGS += -DINTERNAL_DES
171 +ifdef CONFIG_INTERNAL_LIBTOMMATH
172 +override CFLAGS += -DCONFIG_INTERNAL_LIBTOMMATH
173 +else
174 +LIBS += -ltommath
175 +endif
176 +endif
177 +
178 +ifndef LDO
179 +LDO=$(CC)
180 +endif
181 +
182 +
183 +OBJS_lib=$(OBJS_both) $(OBJS_peer)
184 +
185 + #$(OBJS_server)
186 +
187 +override CFLAGS  += -fPIC -DPIC
188 +LDFLAGS += -shared
189 +
190 +$(LIBEAP): $(OBJS_lib)
191 +       $(LDO) $(LDFLAGS) $(OBJS_lib) -Wl,-soname -Wl,$(LIBEAP_SO) -o $(LIBEAP) $(LIBS)
192 +
193 +
194 +UTIL_HEADERS = ../utils/includes.h ../utils/common.h \
195 +       ../utils/wpabuf.h ../utils/build_config.h \
196 +       ../utils/os.h ../utils/wpa_debug.h
197 +COMMON_HEADERS = ../common/defs.h 
198 +EAP_COMMON_HEADERS = ../eap_common/eap_defs.h 
199 +MAIN_HEADERS = eap.h eap_methods.h eap_config.h
200 +CRYPTO_HEADERS =  ../crypto/tls.h  
201 +
202 +install: 
203 +
204 +       mkdir -p $(DESTDIR)/usr/lib
205 +#      copy the lib file to std lib location
206 +       cp $(LIBEAP) $(DESTDIR)/usr/lib
207 +       ln -fs $(LIBEAP_SO) $(DESTDIR)/usr/lib/$(LIBEAP_NAME).so
208 +
209 +#      copy the headers reqd by apps using eap peer library in its own subfolder under /usr/include
210 +       mkdir -p \
211 +               $(DESTDIR)/$(INCLUDE_INSTALL_DIR)/eap_common \
212 +               $(DESTDIR)/$(INCLUDE_INSTALL_DIR)/common \
213 +               $(DESTDIR)/$(INCLUDE_INSTALL_DIR)/util \
214 +               $(DESTDIR)/$(INCLUDE_INSTALL_DIR)/crypto
215 +       install -m 0644 $(EAP_COMMON_HEADERS) $(DESTDIR)/$(INCLUDE_INSTALL_DIR)/eap_common
216 +       install -m 0644 $(COMMON_HEADERS) $(DESTDIR)/$(INCLUDE_INSTALL_DIR)/common
217 +       install -m 0644 $(CRYPTO_HEADERS) $(DESTDIR)/$(INCLUDE_INSTALL_DIR)/crypto
218 +       install -m 0644 $(UTIL_HEADERS) $(DESTDIR)/$(INCLUDE_INSTALL_DIR)/util
219 +       install -m 0644 $(MAIN_HEADERS) $(DESTDIR)/$(INCLUDE_INSTALL_DIR)/
220 +
221 +       mkdir -p $(DESTDIR)/usr/lib/pkgconfig
222 +       cp libeap0.pc $(DESTDIR)/usr/lib/pkgconfig
223 +
224 +uninstall: 
225 +
226 +       rm $(DESTDIR)/usr/lib/$(LIBEAP)
227 +       rm -fr $(DESTDIR)/$(INCLUDE_INSTALL_DIR)
228 +       rm -f $(DESTDIR)/usr/lib/pkgconfig/libeap0.pc
229  
230  clean:
231 -       rm -f *~ *.o *.so *.d
232 +       rm -f *~ *.o *.so *.d libeap.a $(LIBEAP) $(OBJS_lib)
233  
234 -install:
235 -       if ls *.so >/dev/null 2>&1; then \
236 -               install -d $(DESTDIR)$(LIBDIR)/wpa_supplicant && \
237 -               cp *.so $(DESTDIR)$(LIBDIR)/wpa_supplicant \
238 -       ; fi
239 +-include $(OBJS:%.o=%.d)
240 diff --git a/src/eap_peer/eap_methods.c b/src/eap_peer/eap_methods.c
241 index 3b0af05..092f266 100644
242 --- a/src/eap_peer/eap_methods.c
243 +++ b/src/eap_peer/eap_methods.c
244 @@ -340,6 +340,120 @@ int eap_peer_method_register(struct eap_method *method)
245  
246  
247  /**
248 + * eap_peer_register_methods - Register all known EAP peer methods
249 + *
250 + * This function is called at program start to register all compiled
251 + * in EAP peer methods.
252 + */
253 +int eap_peer_register_methods(void)
254 +{
255 +       int ret = 0;
256 +
257 +#ifdef EAP_MD5
258 +       if (ret == 0)
259 +               ret = eap_peer_md5_register();
260 +#endif /* EAP_MD5 */
261 +
262 +#ifdef EAP_TLS
263 +       if (ret == 0)
264 +               ret = eap_peer_tls_register();
265 +#endif /* EAP_TLS */
266 +
267 +#ifdef EAP_MSCHAPv2
268 +       if (ret == 0)
269 +               ret = eap_peer_mschapv2_register();
270 +#endif /* EAP_MSCHAPv2 */
271 +
272 +#ifdef EAP_PEAP
273 +       if (ret == 0)
274 +               ret = eap_peer_peap_register();
275 +#endif /* EAP_PEAP */
276 +
277 +#ifdef EAP_TTLS
278 +       if (ret == 0)
279 +               ret = eap_peer_ttls_register();
280 +#endif /* EAP_TTLS */
281 +
282 +#ifdef EAP_GTC
283 +       if (ret == 0)
284 +               ret = eap_peer_gtc_register();
285 +#endif /* EAP_GTC */
286 +
287 +#ifdef EAP_OTP
288 +       if (ret == 0)
289 +               ret = eap_peer_otp_register();
290 +#endif /* EAP_OTP */
291 +
292 +#ifdef EAP_SIM
293 +       if (ret == 0)
294 +               ret = eap_peer_sim_register();
295 +#endif /* EAP_SIM */
296 +
297 +#ifdef EAP_LEAP
298 +       if (ret == 0)
299 +               ret = eap_peer_leap_register();
300 +#endif /* EAP_LEAP */
301 +
302 +#ifdef EAP_PSK
303 +       if (ret == 0)
304 +               ret = eap_peer_psk_register();
305 +#endif /* EAP_PSK */
306 +
307 +#ifdef EAP_AKA
308 +       if (ret == 0)
309 +               ret = eap_peer_aka_register();
310 +#endif /* EAP_AKA */
311 +
312 +#ifdef EAP_AKA_PRIME
313 +       if (ret == 0)
314 +               ret = eap_peer_aka_prime_register();
315 +#endif /* EAP_AKA_PRIME */
316 +
317 +#ifdef EAP_FAST
318 +       if (ret == 0)
319 +               ret = eap_peer_fast_register();
320 +#endif /* EAP_FAST */
321 +
322 +#ifdef EAP_PAX
323 +       if (ret == 0)
324 +               ret = eap_peer_pax_register();
325 +#endif /* EAP_PAX */
326 +
327 +#ifdef EAP_SAKE
328 +       if (ret == 0)
329 +               ret = eap_peer_sake_register();
330 +#endif /* EAP_SAKE */
331 +
332 +#ifdef EAP_GPSK
333 +       if (ret == 0)
334 +               ret = eap_peer_gpsk_register();
335 +#endif /* EAP_GPSK */
336 +
337 +#ifdef EAP_WSC
338 +       if (ret == 0)
339 +               ret = eap_peer_wsc_register();
340 +#endif /* EAP_WSC */
341 +
342 +#ifdef EAP_IKEV2
343 +       if (ret == 0)
344 +               ret = eap_peer_ikev2_register();
345 +#endif /* EAP_IKEV2 */
346 +
347 +#ifdef EAP_VENDOR_TEST
348 +       if (ret == 0)
349 +               ret = eap_peer_vendor_test_register();
350 +#endif /* EAP_VENDOR_TEST */
351 +
352 +#ifdef EAP_TNC
353 +       if (ret == 0)
354 +               ret = eap_peer_tnc_register();
355 +#endif /* EAP_TNC */
356 +
357 +       return ret;
358 +}
359 +
360 +
361 +/**
362   * eap_peer_unregister_methods - Unregister EAP peer methods
363   *
364   * This function is called at program termination to unregister all EAP peer
365 diff --git a/src/eap_peer/eap_methods.h b/src/eap_peer/eap_methods.h
366 index 384c61b..b83a46f 100644
367 --- a/src/eap_peer/eap_methods.h
368 +++ b/src/eap_peer/eap_methods.h
369 @@ -32,6 +32,7 @@ EapType eap_peer_get_type(const char *name, int *vendor);
370  const char * eap_get_name(int vendor, EapType type);
371  size_t eap_get_names(char *buf, size_t buflen);
372  char ** eap_get_names_as_string_array(size_t *num);
373 +int eap_peer_register_methods(void);
374  void eap_peer_unregister_methods(void);
375  
376  #else /* IEEE8021X_EAPOL */
377 diff --git a/src/eap_peer/libeap0.pc b/src/eap_peer/libeap0.pc
378 new file mode 100644
379 index 0000000..2f8463a
380 --- /dev/null
381 +++ b/src/eap_peer/libeap0.pc
382 @@ -0,0 +1,10 @@
383 +prefix=/usr
384 +exec_prefix=/usr
385 +libdir=${exec_prefix}/lib
386 +includedir=${prefix}/include
387 +
388 +Name: libeap0
389 +Description: EAP Peer Library API
390 +Version: 0.7.2
391 +Libs: -L${libdir} -leap
392 +Cflags: -I${includedir}
393 -- 
394 1.6.6.1
395