p54spi: Compile in the default eeprom image
[openwrt.git] / package / zlib / patches / 100-cross_compile.patch
1 --- a/Makefile.in
2 +++ b/Makefile.in
3 @@ -25,20 +25,23 @@ CFLAGS=-O
4 # -Wstrict-prototypes -Wmissing-prototypes
5
6 LDFLAGS=libz.a
7 -LDSHARED=$(CC)
8 +LDSHARED=$(CC) -shared -Wl,-soname,$(SHAREDLIBM)
9 CPP=$(CC) -E
10
11 -LIBS=libz.a
12 +LIBS=
13 +STATICLIB=libz.a
14 SHAREDLIB=libz.so
15 SHAREDLIBV=libz.so.1.2.3
16 SHAREDLIBM=libz.so.1
17
18 -AR=ar rc
19 +AR=ar
20 RANLIB=ranlib
21 TAR=tar
22 SHELL=/bin/sh
23 EXE=
24
25 +DESTDIR =
26 +
27 prefix = /usr/local
28 exec_prefix = ${prefix}
29 libdir = ${exec_prefix}/lib
30 @@ -67,8 +70,8 @@ test: all
31 echo ' *** zlib test FAILED ***'; \
32 fi
33
34 -libz.a: $(OBJS) $(OBJA)
35 - $(AR) $@ $(OBJS) $(OBJA)
36 +$(STATICLIB): $(OBJS) $(OBJA)
37 + $(AR) rc $@ $(OBJS) $(OBJA)
38 -@ ($(RANLIB) $@ || true) >/dev/null 2>&1
39
40 match.o: match.S
41 @@ -77,8 +80,10 @@ match.o: match.S
42 mv _match.o match.o
43 rm -f _match.s
44
45 +$(SHAREDLIB): $(SHAREDLIBV)
46 +
47 $(SHAREDLIBV): $(OBJS)
48 - $(LDSHARED) -o $@ $(OBJS)
49 + $(LDSHARED) -lc -o $@ $(OBJS)
50 rm -f $(SHAREDLIB) $(SHAREDLIBM)
51 ln -s $@ $(SHAREDLIB)
52 ln -s $@ $(SHAREDLIBM)
53 @@ -90,23 +95,22 @@ minigzip$(EXE): minigzip.o $(LIBS)
54 $(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS)
55
56 install: $(LIBS)
57 - -@if [ ! -d $(exec_prefix) ]; then mkdir -p $(exec_prefix); fi
58 - -@if [ ! -d $(includedir) ]; then mkdir -p $(includedir); fi
59 - -@if [ ! -d $(libdir) ]; then mkdir -p $(libdir); fi
60 - -@if [ ! -d $(man3dir) ]; then mkdir -p $(man3dir); fi
61 - cp zlib.h zconf.h $(includedir)
62 - chmod 644 $(includedir)/zlib.h $(includedir)/zconf.h
63 - cp $(LIBS) $(libdir)
64 - cd $(libdir); chmod 755 $(LIBS)
65 - -@(cd $(libdir); $(RANLIB) libz.a || true) >/dev/null 2>&1
66 - cd $(libdir); if test -f $(SHAREDLIBV); then \
67 + -@if [ ! -d $(DESTDIR)$(exec_prefix) ]; then mkdir -p $(DESTDIR)$(exec_prefix); fi
68 + -@if [ ! -d $(DESTDIR)$(includedir) ]; then mkdir -p $(DESTDIR)$(includedir); fi
69 + -@if [ ! -d $(DESTDIR)$(libdir) ]; then mkdir -p $(DESTDIR)$(libdir); fi
70 + -@if [ ! -d $(DESTDIR)$(man3dir) ]; then mkdir -p $(DESTDIR)$(man3dir); fi
71 + cp zlib.h zconf.h $(DESTDIR)$(includedir)
72 + chmod 644 $(DESTDIR)$(includedir)/zlib.h $(DESTDIR)$(includedir)/zconf.h
73 + cp $(STATICLIB) $(SHAREDLIBV) $(DESTDIR)$(libdir)
74 + cd $(DESTDIR)$(libdir); chmod 755 $(LIBS)
75 + -@(cd $(DESTDIR)$(libdir); $(RANLIB) libz.a || true) >/dev/null 2>&1
76 + cd $(DESTDIR)$(libdir); if test -f $(SHAREDLIBV); then \
77 rm -f $(SHAREDLIB) $(SHAREDLIBM); \
78 ln -s $(SHAREDLIBV) $(SHAREDLIB); \
79 ln -s $(SHAREDLIBV) $(SHAREDLIBM); \
80 - (ldconfig || true) >/dev/null 2>&1; \
81 fi
82 - cp zlib.3 $(man3dir)
83 - chmod 644 $(man3dir)/zlib.3
84 + cp zlib.3 $(DESTDIR)$(man3dir)
85 + chmod 644 $(DESTDIR)$(man3dir)/zlib.3
86 # The ranlib in install is needed on NeXTSTEP which checks file times
87 # ldconfig is for Linux
88
89 --- a/configure
90 +++ b/configure
91 @@ -23,7 +23,7 @@ LDFLAGS="-L. ${LIBS}"
92 VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`
93 VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < zlib.h`
94 VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < zlib.h`
95 -AR=${AR-"ar rc"}
96 +AR=${AR-"ar"}
97 RANLIB=${RANLIB-"ranlib"}
98 prefix=${prefix-/usr/local}
99 exec_prefix=${exec_prefix-'${prefix}'}
100 @@ -73,32 +73,9 @@ esac
101
102 if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then
103 CC="$cc"
104 - SFLAGS=${CFLAGS-"-fPIC -O3"}
105 + SFLAGS=${CFLAGS-"-D_REENTRANT -fPIC -O3"}
106 CFLAGS="$cflags"
107 - case `(uname -s || echo unknown) 2>/dev/null` in
108 - Linux | linux | GNU | GNU/*) LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1"};;
109 - CYGWIN* | Cygwin* | cygwin* | OS/2* )
110 - EXE='.exe';;
111 - QNX*) # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4
112 - # (alain.bonnefoy@icbt.com)
113 - LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"};;
114 - HP-UX*)
115 - LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"}
116 - case `(uname -m || echo unknown) 2>/dev/null` in
117 - ia64)
118 - shared_ext='.so'
119 - SHAREDLIB='libz.so';;
120 - *)
121 - shared_ext='.sl'
122 - SHAREDLIB='libz.sl';;
123 - esac;;
124 - Darwin*) shared_ext='.dylib'
125 - SHAREDLIB=libz$shared_ext
126 - SHAREDLIBV=libz.$VER$shared_ext
127 - SHAREDLIBM=libz.$VER1$shared_ext
128 - LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER"};;
129 - *) LDSHARED=${LDSHARED-"$cc -shared"};;
130 - esac
131 + LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1"}
132 else
133 # find system name and corresponding cc options
134 CC=${CC-cc}
135 @@ -424,6 +401,29 @@ else
136 echo Checking for mmap support... No.
137 fi
138
139 +cat > $test.c <<EOF
140 +#include <stdio.h>
141 +int main() { char buf[10]; snprintf(buf, sizeof(buf), "%s", "F"); return 0; }
142 +EOF
143 +if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
144 + echo "Checking for snprintf... Yes."
145 + CFLAGS="$CFLAGS -DHAS_snprintf"
146 +else
147 + echo "Checking for snprintf.. No."
148 +fi
149 +
150 +cat > $test.c <<EOF
151 +#include <stdio.h>
152 +#include <stdarg.h>
153 +int main(void) { va_list a; vsnprintf(0, 0, "", a); return 0; }
154 +EOF
155 +if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
156 + echo "Checking for vsnprintf... Yes."
157 + CFLAGS="$CFLAGS -DHAS_vsnprintf"
158 +else
159 + echo "Checking for vsnprintf.. No."
160 +fi
161 +
162 CPP=${CPP-"$CC -E"}
163 case $CFLAGS in
164 *ASMV*)
165 @@ -440,20 +440,21 @@ rm -f $test.[co] $test $test$shared_ext
166 # udpate Makefile
167 sed < Makefile.in "
168 /^CC *=/s#=.*#=$CC#
169 -/^CFLAGS *=/s#=.*#=$CFLAGS#
170 -/^CPP *=/s#=.*#=$CPP#
171 -/^LDSHARED *=/s#=.*#=$LDSHARED#
172 -/^LIBS *=/s#=.*#=$LIBS#
173 -/^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
174 -/^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
175 -/^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
176 -/^AR *=/s#=.*#=$AR#
177 -/^RANLIB *=/s#=.*#=$RANLIB#
178 -/^EXE *=/s#=.*#=$EXE#
179 -/^prefix *=/s#=.*#=$prefix#
180 -/^exec_prefix *=/s#=.*#=$exec_prefix#
181 -/^libdir *=/s#=.*#=$libdir#
182 -/^includedir *=/s#=.*#=$includedir#
183 -/^mandir *=/s#=.*#=$mandir#
184 -/^LDFLAGS *=/s#=.*#=$LDFLAGS#
185 +/^CC *=/s%=.*%= $CC%
186 +/^CFLAGS *=/s%=.*%= $CFLAGS%
187 +/^CPP *=/s%=.*%= $CPP%
188 +/^LDSHARED *=/s%=.*%= $LDSHARED%
189 +/^LIBS *=/s%=.*%= $LIBS%
190 +/^SHAREDLIB *=/s%=.*%= $SHAREDLIB%
191 +/^SHAREDLIBV *=/s%=.*%= $SHAREDLIBV%
192 +/^SHAREDLIBM *=/s%=.*%= $SHAREDLIBM%
193 +/^AR *=/s%=.*%= $AR%
194 +/^RANLIB *=/s%=.*%= $RANLIB%
195 +/^EXE *=/s%=.*%= $EXE%
196 +/^prefix *=/s%=.*%= $prefix%
197 +/^exec_prefix *=/s%=.*%= $exec_prefix%
198 +/^libdir *=/s%=.*%= $libdir%
199 +/^includedir *=/s%=.*%= $includedir%
200 +/^mandir *=/s%=.*%= $mandir%
201 +/^LDFLAGS *=/s%=.*%= $LDFLAGS%
202 " > Makefile
203 --- a/contrib/minizip/Makefile
204 +++ b/contrib/minizip/Makefile
205 @@ -1,8 +1,8 @@
206 CC=cc
207 -CFLAGS=-O -I../..
208 +CFLAGS=-O2 -g -I../.. -Dunix
209
210 -UNZ_OBJS = miniunz.o unzip.o ioapi.o ../../libz.a
211 -ZIP_OBJS = minizip.o zip.o ioapi.o ../../libz.a
212 +UNZ_OBJS = miniunz.o unzip.o ioapi.o
213 +ZIP_OBJS = minizip.o zip.o ioapi.o
214
215 .c.o:
216 $(CC) -c $(CFLAGS) $*.c
217 @@ -10,10 +10,10 @@ ZIP_OBJS = minizip.o zip.o ioapi.o ../
218 all: miniunz minizip
219
220 miniunz: $(UNZ_OBJS)
221 - $(CC) $(CFLAGS) -o $@ $(UNZ_OBJS)
222 + $(CC) $(CFLAGS) -o $@ $(UNZ_OBJS) -L ../.. -lz
223
224 minizip: $(ZIP_OBJS)
225 - $(CC) $(CFLAGS) -o $@ $(ZIP_OBJS)
226 + $(CC) $(CFLAGS) -o $@ $(ZIP_OBJS) -L ../.. -lz
227
228 test: miniunz minizip
229 ./minizip test readme.txt
This page took 0.070717 seconds and 5 git commands to generate.