let ipkg fail when a package file to be installed is not found
[openwrt.git] / openwrt / package / gsm / patches / 01-debian-libsgm-1.0.10-13.patch
1 diff -ruN gsm-1.0.10-orig/Makefile gsm-1.0.10-1/Makefile
2 --- gsm-1.0.10-orig/Makefile    1996-07-02 16:36:06.000000000 +0200
3 +++ gsm-1.0.10-1/Makefile       2005-04-08 18:47:52.000000000 +0200
4 @@ -7,11 +7,13 @@
5  SASR   = -DSASR
6  ######### Define SASR if >> is a signed arithmetic shift (-1 >> 1 == -1)
7  
8 -MULHACK = -DUSE_FLOAT_MUL
9 +#MULHACK = -DUSE_FLOAT_MUL
10 +MULHACK =
11  ######### Define this if your host multiplies floats faster than integers,
12  ######### e.g. on a SPARCstation.
13  
14 -FAST   = -DFAST
15 +#FAST  = -DFAST
16 +FAST   =
17  ######### Define together with USE_FLOAT_MUL to enable the GSM library's
18  ######### approximation option for incorrect, but good-enough results.
19  
20 @@ -44,7 +46,8 @@
21  # CCFLAGS      = -c -O
22  
23  CC             = gcc -ansi -pedantic
24 -CCFLAGS        = -c -O2 -DNeedFunctionPrototypes=1
25 +COPTS          = -O2
26 +CCFLAGS        = -c $(COPTS) -DNeedFunctionPrototypes=1
27  
28  LD             = $(CC)
29  
30 @@ -78,10 +81,10 @@
31  # Leave GSM_INSTALL_ROOT empty to not install the GSM library outside of
32  # this directory.
33  
34 -GSM_INSTALL_ROOT = $(INSTALL_ROOT)
35 +GSM_INSTALL_ROOT = $(INSTALL_ROOT)/usr
36  GSM_INSTALL_LIB = $(GSM_INSTALL_ROOT)/lib
37 -GSM_INSTALL_INC = $(GSM_INSTALL_ROOT)/inc
38 -GSM_INSTALL_MAN = $(GSM_INSTALL_ROOT)/man/man3
39 +GSM_INSTALL_INC = $(GSM_INSTALL_ROOT)/include
40 +GSM_INSTALL_MAN = $(GSM_INSTALL_ROOT)/share/man/man3
41  
42  
43  # Where do you want to install the toast binaries and their manpage?
44 @@ -89,14 +92,14 @@
45  # Leave TOAST_INSTALL_ROOT empty to not install the toast binaries outside
46  # of this directory.
47  
48 -TOAST_INSTALL_ROOT       = $(INSTALL_ROOT)
49 +TOAST_INSTALL_ROOT       = $(INSTALL_ROOT)/usr
50  TOAST_INSTALL_BIN = $(TOAST_INSTALL_ROOT)/bin
51 -TOAST_INSTALL_MAN = $(TOAST_INSTALL_ROOT)/man/man1
52 +TOAST_INSTALL_MAN = $(TOAST_INSTALL_ROOT)/share/man/man1
53  
54  #  Other tools
55  
56  SHELL          = /bin/sh
57 -LN             = ln
58 +LN             = ln -s
59  BASENAME       = basename
60  AR             = ar
61  ARFLAGS                = cr
62 @@ -126,7 +129,7 @@
63  
64  # Flags
65  
66 -# DEBUG        = -DNDEBUG
67 +DEBUG  = -DNDEBUG
68  ######### Remove -DNDEBUG to enable assertions.
69  
70  CFLAGS = $(CCFLAGS) $(SASR) $(DEBUG) $(MULHACK) $(FAST) $(LTP_CUT) \
71 @@ -140,6 +143,7 @@
72  # Targets
73  
74  LIBGSM = $(LIB)/libgsm.a
75 +LIBGSMSO= $(LIB)/libgsm.so
76  
77  TOAST  = $(BIN)/toast
78  UNTOAST        = $(BIN)/untoast
79 @@ -258,6 +262,9 @@
80  
81  GSM_INSTALL_TARGETS =  \
82                 $(GSM_INSTALL_LIB)/libgsm.a             \
83 +               $(GSM_INSTALL_LIB)/libgsm.so            \
84 +               $(GSM_INSTALL_LIB)/libgsm.so.1          \
85 +               $(GSM_INSTALL_LIB)/libgsm.so.1.0.10     \
86                 $(GSM_INSTALL_INC)/gsm.h                \
87                 $(GSM_INSTALL_MAN)/gsm.3                \
88                 $(GSM_INSTALL_MAN)/gsm_explode.3        \
89 @@ -279,7 +286,7 @@
90  
91  # Target rules
92  
93 -all:           $(LIBGSM) $(TOAST) $(TCAT) $(UNTOAST)
94 +all:           $(LIBGSM) $(LIBGSMSO) $(TOAST) $(TCAT) $(UNTOAST)
95                 @-echo $(ROOT): Done.
96  
97  tst:           $(TST)/lin2cod $(TST)/cod2lin $(TOAST) $(TST)/test-result
98 @@ -299,6 +306,11 @@
99  
100  # The basic API: libgsm
101  
102 +$(LIBGSMSO):   $(LIB) $(GSM_OBJECTS)
103 +               $(LD) -o $@.1.0.10 -shared -Xlinker -soname -Xlinker libgsm.so.1 $(GSM_OBJECTS) -lc
104 +               ln -fs libgsm.so.1.0.10 lib/libgsm.so.1
105 +               ln -fs libgsm.so.1.0.10 lib/libgsm.so
106 +
107  $(LIBGSM):     $(LIB) $(GSM_OBJECTS)
108                 -rm $(RMFLAGS) $(LIBGSM)
109                 $(AR) $(ARFLAGS) $(LIBGSM) $(GSM_OBJECTS)
110 @@ -308,15 +320,15 @@
111  # Toast, Untoast and Tcat -- the compress-like frontends to gsm.
112  
113  $(TOAST):      $(BIN) $(TOAST_OBJECTS) $(LIBGSM)
114 -               $(LD) $(LFLAGS) -o $(TOAST) $(TOAST_OBJECTS) $(LIBGSM) $(LDLIB)
115 +               $(LD) $(LFLAGS) -o $(TOAST) $(TOAST_OBJECTS) $(LIBGSMSO) $(LDLIB)
116  
117  $(UNTOAST):    $(BIN) $(TOAST)
118                 -rm $(RMFLAGS) $(UNTOAST)
119 -               $(LN) $(TOAST) $(UNTOAST)
120 +               $(LN) toast $(UNTOAST)
121  
122  $(TCAT):       $(BIN) $(TOAST)
123                 -rm $(RMFLAGS) $(TCAT)
124 -               $(LN) $(TOAST) $(TCAT)
125 +               $(LN) toast $(TCAT)
126  
127  
128  # The local bin and lib directories
129 @@ -351,53 +363,66 @@
130                 fi
131  
132  $(TOAST_INSTALL_BIN)/toast:    $(TOAST)
133 -               -rm $@
134 -               cp $(TOAST) $@
135 +               mkdir -p $(TOAST_INSTALL_BIN)
136 +               cp -f $(TOAST) $@
137                 chmod 755 $@
138  
139  $(TOAST_INSTALL_BIN)/untoast:  $(TOAST_INSTALL_BIN)/toast
140 -               -rm $@
141 -               ln $? $@
142 +               mkdir -p $(TOAST_INSTALL_BIN)
143 +               ln -sf $? $@
144  
145  $(TOAST_INSTALL_BIN)/tcat:     $(TOAST_INSTALL_BIN)/toast
146 -               -rm $@
147 -               ln $? $@
148 +               mkdir -p $(TOAST_INSTALL_BIN)
149 +               ln -sf $? $@
150  
151  $(TOAST_INSTALL_MAN)/toast.1:  $(MAN)/toast.1
152 -               -rm $@
153 -               cp $? $@
154 +               mkdir -p $(TOAST_INSTALL_MAN)
155 +               cp -f $? $@
156                 chmod 444 $@
157  
158  $(GSM_INSTALL_MAN)/gsm.3:      $(MAN)/gsm.3
159 -               -rm $@
160 -               cp $? $@
161 +               mkdir -p $(GSM_INSTALL_MAN)
162 +               cp -f $? $@
163                 chmod 444 $@
164  
165  $(GSM_INSTALL_MAN)/gsm_option.3:       $(MAN)/gsm_option.3
166 -               -rm $@
167 -               cp $? $@
168 +               mkdir -p $(GSM_INSTALL_MAN)
169 +               cp -f $? $@
170                 chmod 444 $@
171  
172  $(GSM_INSTALL_MAN)/gsm_explode.3:      $(MAN)/gsm_explode.3
173 -               -rm $@
174 -               cp $? $@
175 +               mkdir -p $(GSM_INSTALL_MAN)
176 +               cp -f $? $@
177                 chmod 444 $@
178  
179  $(GSM_INSTALL_MAN)/gsm_print.3:        $(MAN)/gsm_print.3
180 -               -rm $@
181 -               cp $? $@
182 +               mkdir -p $(GSM_INSTALL_MAN)
183 +               cp -f $? $@
184                 chmod 444 $@
185  
186  $(GSM_INSTALL_INC)/gsm.h:      $(INC)/gsm.h
187 -               -rm $@
188 -               cp $? $@
189 +               mkdir -p $(GSM_INSTALL_INC)
190 +               cp -f $? $@
191                 chmod 444 $@
192  
193  $(GSM_INSTALL_LIB)/libgsm.a:   $(LIBGSM)
194 -               -rm $@
195 -               cp $? $@
196 +               mkdir -p $(GSM_INSTALL_LIB)
197 +               cp -f $? $@
198                 chmod 444 $@
199  
200 +$(GSM_INSTALL_LIB)/libgsm.so:  $(LIBGSMSO)
201 +               mkdir -p $(GSM_INSTALL_LIB)
202 +               cp -f $? $@
203 +
204 +$(GSM_INSTALL_LIB)/libgsm.so.1:        $(LIBGSMSO)
205 +               mkdir -p $(GSM_INSTALL_LIB)
206 +               cp -f $? $@
207 +
208 +$(GSM_INSTALL_LIB)/libgsm.so.1.0.10:   $(LIBGSMSO)
209 +               mkdir -p $(GSM_INSTALL_LIB)
210 +               cp -f $? $@
211 +               chmod 755 $@
212 +
213  
214  # Distribution
215  
216 @@ -426,7 +451,9 @@
217  
218  clean: semi-clean
219                 -rm $(RMFLAGS) $(LIBGSM) $(ADDTST)/add          \
220 -                       $(TOAST) $(TCAT) $(UNTOAST)     \
221 +                       $(LIBGSMSO) $(LIB)/libgsm.so.1.0.10     \
222 +                       $(LIB)libgsm.so.1                       \
223 +                       $(TOAST) $(TCAT) $(UNTOAST)             \
224                         $(ROOT)/gsm-1.0.tar.Z
225  
226  
227 diff -ruN gsm-1.0.10-orig/inc/config.h gsm-1.0.10-1/inc/config.h
228 --- gsm-1.0.10-orig/inc/config.h        1996-07-02 16:32:27.000000000 +0200
229 +++ gsm-1.0.10-1/inc/config.h   2005-04-08 18:24:31.000000000 +0200
230 @@ -9,29 +9,29 @@
231  #ifndef        CONFIG_H
232  #define        CONFIG_H
233  
234 -/*efine        SIGHANDLER_T    int             /* signal handlers are void     */
235 -/*efine HAS_SYSV_SIGNAL        1               /* sigs not blocked/reset?      */
236 +/*efine        SIGHANDLER_T    int             -* signal handlers are void     */
237 +/*efine HAS_SYSV_SIGNAL        1               -* sigs not blocked/reset?      */
238  
239  #define        HAS_STDLIB_H    1               /* /usr/include/stdlib.h        */
240 -/*efine        HAS_LIMITS_H    1               /* /usr/include/limits.h        */
241 +#define        HAS_STDIO_H     1               /* /usr/include/stdio.h         */
242 +/*efine        HAS_LIMITS_H    1               -* /usr/include/limits.h        */
243  #define        HAS_FCNTL_H     1               /* /usr/include/fcntl.h         */
244 -/*efine        HAS_ERRNO_DECL  1               /* errno.h declares errno       */
245  
246  #define        HAS_FSTAT       1               /* fstat syscall                */
247  #define        HAS_FCHMOD      1               /* fchmod syscall               */
248  #define        HAS_CHMOD       1               /* chmod syscall                */
249  #define        HAS_FCHOWN      1               /* fchown syscall               */
250  #define        HAS_CHOWN       1               /* chown syscall                */
251 -/*efine        HAS__FSETMODE   1               /* _fsetmode -- set file mode   */
252 +/*efine        HAS__FSETMODE   1               -* _fsetmode -- set file mode   */
253  
254  #define        HAS_STRING_H    1               /* /usr/include/string.h        */
255 -/*efine        HAS_STRINGS_H   1               /* /usr/include/strings.h       */
256 +/*efine        HAS_STRINGS_H   1               -* /usr/include/strings.h       */
257  
258  #define        HAS_UNISTD_H    1               /* /usr/include/unistd.h        */
259  #define        HAS_UTIME       1               /* POSIX utime(path, times)     */
260 -/*efine        HAS_UTIMES      1               /* use utimes() syscall instead */
261 +/*efine        HAS_UTIMES      1               -* use utimes() syscall instead */
262  #define        HAS_UTIME_H     1               /* UTIME header file            */
263 -/*efine        HAS_UTIMBUF     1               /* struct utimbuf               */
264 -/*efine        HAS_UTIMEUSEC   1               /* microseconds in utimbuf?     */
265 +/*efine        HAS_UTIMBUF     1               -* struct utimbuf               */
266 +/*efine        HAS_UTIMEUSEC   1               -* microseconds in utimbuf?     */
267  
268  #endif /* CONFIG_H */
269 diff -ruN gsm-1.0.10-orig/inc/gsm.h gsm-1.0.10-1/inc/gsm.h
270 --- gsm-1.0.10-orig/inc/gsm.h   1996-07-05 20:31:51.000000000 +0200
271 +++ gsm-1.0.10-1/inc/gsm.h      2005-04-08 18:24:31.000000000 +0200
272 @@ -54,6 +54,10 @@
273  #define        GSM_OPT_FRAME_INDEX     5
274  #define        GSM_OPT_FRAME_CHAIN     6
275  
276 +#ifdef __cplusplus
277 +extern "C" {
278 +#endif
279 +
280  extern gsm  gsm_create         GSM_P((void));
281  extern void gsm_destroy GSM_P((gsm));  
282  
283 @@ -66,6 +70,10 @@
284  extern int  gsm_explode GSM_P((gsm, gsm_byte   *, gsm_signal *));
285  extern void gsm_implode GSM_P((gsm, gsm_signal *, gsm_byte   *));
286  
287 +#ifdef __cplusplus
288 +}
289 +#endif
290 +
291  #undef GSM_P
292  
293  #endif /* GSM_H */
294 diff -ruN gsm-1.0.10-orig/inc/toast.h gsm-1.0.10-1/inc/toast.h
295 --- gsm-1.0.10-orig/inc/toast.h 1996-07-02 16:32:29.000000000 +0200
296 +++ gsm-1.0.10-1/inc/toast.h    2005-04-08 18:24:31.000000000 +0200
297 @@ -16,11 +16,12 @@
298  
299  #include <stdio.h>
300  #include <ctype.h>
301 +#include <pthread.h>
302  #include <signal.h>
303  
304  #include <errno.h>
305 -#ifndef        HAS_ERRNO_DECL
306 -        extern int     errno;
307 +#ifndef errno
308 + extern int    errno;
309  #endif
310  
311  #ifdef HAS_LIMITS_H
312 @@ -37,6 +38,10 @@
313  # endif
314  #endif
315  
316 +#ifdef  HAS_STDIO_H
317 +# include <stdio.h>
318 +#endif
319 +
320  #include "gsm.h"
321  
322  #ifndef        S_ISREG
323 diff -ruN gsm-1.0.10-orig/src/code.c gsm-1.0.10-1/src/code.c
324 --- gsm-1.0.10-orig/src/code.c  1996-07-02 16:32:36.000000000 +0200
325 +++ gsm-1.0.10-1/src/code.c     2005-04-08 18:24:31.000000000 +0200
326 @@ -9,8 +9,8 @@
327  #include       "config.h"
328  
329  
330 -#ifdef HAS_STDLIB_H
331 -#include       <stdlib.h>
332 +#ifdef HAS_STRING_H
333 +#include       <string.h>
334  #else
335  #      include "proto.h"
336         extern char     * memcpy P((char *, char *, int));
337 diff -ruN gsm-1.0.10-orig/src/debug.c gsm-1.0.10-1/src/debug.c
338 --- gsm-1.0.10-orig/src/debug.c 1996-07-02 16:32:37.000000000 +0200
339 +++ gsm-1.0.10-1/src/debug.c    2005-04-08 18:24:31.000000000 +0200
340 @@ -49,7 +49,7 @@
341         fprintf( stderr, "%s [%d .. %d]: ", name, from, to );
342         while (from <= to) {
343  
344 -               fprintf(stderr, "%d ", ptr[ from ] );
345 +               fprintf(stderr, "%ld ", ptr[ from ] );
346                 from++;
347                 if (nprinted++ >= 7) {
348                         nprinted = 0;
349 @@ -63,14 +63,14 @@
350         char            * name,
351         longword          value )
352  {
353 -       fprintf(stderr, "%s: %d\n", name, (long)value );
354 +       fprintf(stderr, "%s: %ld\n", name, (long)value );
355  }
356  
357  void gsm_debug_word P2(  (name, value),
358         char    * name,
359         word      value )
360  {
361 -       fprintf(stderr, "%s: %d\n", name, (long)value);
362 +       fprintf(stderr, "%s: %ld\n", name, (long)value);
363  }
364  
365  #endif
366 diff -ruN gsm-1.0.10-orig/src/toast.c gsm-1.0.10-1/src/toast.c
367 --- gsm-1.0.10-orig/src/toast.c 1996-07-02 16:32:55.000000000 +0200
368 +++ gsm-1.0.10-1/src/toast.c    2005-04-08 18:24:31.000000000 +0200
369 @@ -251,8 +251,8 @@
370  {
371         char * s;
372         if (!(s = malloc(len))) {
373 -               fprintf(stderr, "%s: failed to malloc %d bytes -- abort\n",
374 -                       progname, len);
375 +               fprintf(stderr, "%s: failed to malloc %ld bytes -- abort\n",
376 +                       progname, (long) len);
377                 onintr();
378                 exit(1);
379         }
380 @@ -270,7 +270,7 @@
381         maxlen = strlen(name) + 1 + strlen(want) + strlen(cut);
382         p = strcpy(emalloc(maxlen), name);
383  
384 -       if (s = suffix(p, cut)) strcpy(s, want);
385 +       if ((s = suffix(p, cut))) strcpy(s, want);
386         else if (*want && !suffix(p, want)) strcat(p, want);
387  
388         return p;
389 @@ -386,7 +386,7 @@
390                 ut[0] = instat.st_atime;
391                 ut[1] = instat.st_mtime;
392  
393 -               (void) utime(outname, ut);
394 +               (void) utime(outname, (struct utimbuf *)ut);
395  
396  #endif /* UTIMBUF */
397         }
398 @@ -416,7 +416,7 @@
399         }
400         if (st->st_nlink > 1 && !f_cat && !f_precious) {
401                 fprintf(stderr, 
402 -                     "%s: \"%s\" has %s other link%s -- unchanged.\n",
403 +                     "%s: \"%s\" has %d other link%s -- unchanged.\n",
404                         progname,name,st->st_nlink - 1,"s" + (st->st_nlink<=2));
405                 return 0;
406         }
407 @@ -585,8 +585,8 @@
408  
409                 if (cc != sizeof(s)) {
410                         if (cc >= 0) fprintf(stderr,
411 -                       "%s: incomplete frame (%d byte%s missing) from %s\n",
412 -                                       progname, sizeof(s) - cc,
413 +                       "%s: incomplete frame (%ld byte%s missing) from %s\n",
414 +                                       progname, (long) sizeof(s) - cc,
415                                         "s" + (sizeof(s) - cc == 1),
416                                         inname ? inname : "stdin" );
417                         gsm_destroy(r);
418 @@ -624,8 +624,6 @@
419  
420  static int process P1((name), char * name)
421  {
422 -       int step = 0;
423 -
424         out     = (FILE *)0;
425         in      = (FILE *)0;
426  
427 @@ -779,7 +777,6 @@
428         case 'h': help();    exit(0);
429  
430         default: 
431 -       usage:
432                 fprintf(stderr,
433         "Usage: %s [-fcpdhvuaslFC] [files...] (-h for help)\n",
434                         progname);