more random patches. who knows.
[patches.git] / libezv24.patch
1 Index: .cvsignore
2 ===================================================================
3 RCS file: /cvsroot/ezv24/libezv24/.cvsignore,v
4 retrieving revision 1.1
5 diff -u -p -r1.1 .cvsignore
6 --- .cvsignore 9 May 2003 09:45:16 -0000 1.1
7 +++ .cvsignore 26 Aug 2006 22:50:11 -0000
8 @@ -1,5 +1,6 @@
9 api-html
10 test-v24.exe
11 test-v24
12 -libez*_s.a
13 +libez*.a
14 libez*.so*
15 +*.lo
16 Index: Makefile
17 ===================================================================
18 RCS file: /cvsroot/ezv24/libezv24/Makefile,v
19 retrieving revision 1.10
20 diff -u -p -r1.10 Makefile
21 --- Makefile 3 Jun 2006 19:34:06 -0000 1.10
22 +++ Makefile 26 Aug 2006 22:50:11 -0000
23 @@ -19,9 +19,6 @@ PATCHLEVEL = 2
24 # the base name of the library
25 SOBASE = ezV24
26
27 -# define the destination OS (currently only linux)
28 -PLATFORM=__LINUX__
29 -
30 # the base path where the file should be installed to.
31 PREFIX = /usr/local
32
33 @@ -31,66 +28,53 @@ DESTDIR =
34
35 # generate the name of the output file in dependence of the development state.
36 #
37 -ifeq "${RELEASE}" "DEBUG"
38 +ifeq ($(RELEASE),DEBUG)
39 NAME = lib$(SOBASE).so.$(SORELEASE).dbg
40 else
41 NAME = lib$(SOBASE).so.$(VERSION)
42 endif
43 SONAME = lib$(SOBASE).so.$(SORELEASE)
44 -LIBNAME = lib$(SOBASE)-$(SORELEASE)_s.a
45 +LIBNAME = lib$(SOBASE).a
46 PLAINNAME = lib$(SOBASE).so
47
48 # basename of the project
49 PROJECTNAME = libezV24-$(VERSION).$(PATCHLEVEL)
50
51 -OBJS = ezV24.o snprintf.o
52 +STATIC_OBJS = ezV24.o snprintf.o
53 +SHARED_OBJS = $(patsubst %.o,%.lo,$(STATIC_OBJS))
54 LIBS =
55
56 -
57 -ifeq "${RELEASE}" "DEBUG"
58 -C_OPT = -O2
59 -C_FLAG = -c -Wall -fPIC $(C_OPT) -D$(PLATFORM) $(INCDIR)
60 -C_DEFS = -DDEBUG -DBETA
61 -LFLAGS = $(LIBDIR)
62 +ifeq ($(RELEASE),DEBUG)
63 +CPPFLAGS += -DDEBUG -DBETA
64 else
65 -ifeq "${RELEASE}" "BETA"
66 -C_OPT = -O2
67 -C_FLAG = -c -Wall -fPIC $(C_OPT) -D$(PLATFORM) $(INCDIR)
68 -C_DEFS = -DBETA
69 -LFLAGS = $(LIBDIR)
70 +ifeq ($(RELEASE),BETA)
71 +CPPFLAGS += -DBETA
72 else
73 -C_OPT = -O2
74 -C_FLAG = -c -Wall -fPIC $(C_OPT) -D$(PLATFORM) $(INCDIR)
75 -C_DEFS = -DFINAL
76 -LFLAGS = -s $(LIBDIR)
77 +CPPFLAGS += -DFINAL
78 endif
79 endif
80
81 +CPPFLAGS += -I.
82 +CFLAGS ?= -O2
83 +CFLAGS += -Wall
84 +LDFLAGS ?= -s
85 +
86 # tools to build the static library
87 ARFLAGS = cru
88 -AR = ar
89 -RANLIB = ranlib
90 +AR ?= ar
91 +RANLIB ?= ranlib
92
93 # some distros have a messed up path when in su -
94 -LDCONFIG = /sbin/ldconfig
95 -
96 -# concatenate the compile flags
97 -CFLAGS = $(C_FLAG) $(C_DEFS)
98 -
99 -
100 -
101 -# ------------------------------------------------------------------------
102 -# AUTOMATIC COMPILE INSTRUCTIONS
103 -# ------------------------------------------------------------------------
104 -
105 -.c.o:
106 - gcc $(CFLAGS) $<
107 +LDCONFIG ?= /sbin/ldconfig
108
109
110 # --------------------------------------------------------------------------
111 # DEPENDENCIES
112 # --------------------------------------------------------------------------
113
114 +%.lo: %.c
115 + $(CC) -fPIC $(CFLAGS) $(CPPFLAGS) -c $< -o $@
116 +
117 all: shared static test-v24
118
119 shared: $(NAME)
120 @@ -98,13 +82,12 @@ shared: $(NAME)
121 static: $(LIBNAME)
122
123
124 +$(NAME): $(SHARED_OBJS)
125 + $(CC) $(CFLAGS) -shared -Wl,-soname,$(SONAME) -o $@ $^ $(LDFLAGS)
126
127 -$(NAME): $(OBJS)
128 - gcc -shared -W1,soname,$(SONAME) -o $(NAME) $(OBJS)
129 -
130 -$(LIBNAME): $(OBJS)
131 - $(AR) $(ARFLAGS) $(LIBNAME) $(OBJS)
132 - $(RANLIB) $(LIBNAME)
133 +$(LIBNAME): $(STATIC_OBJS)
134 + $(AR) $(ARFLAGS) $@ $^
135 + $(RANLIB) $@
136
137
138 # source dependencies, but doesn't do anything if the automatism above
139 @@ -121,14 +104,14 @@ snprintf.o: snprintf.c snprintf.h
140 #
141
142 install:
143 - install -d -m 755 $(DESTDIR)$(PREFIX)/include/$(SOBASE)/
144 + install -d -m 755 $(DESTDIR)$(PREFIX)/include/
145 install -d -m 755 $(DESTDIR)$(PREFIX)/lib/
146 - install -m 644 ezV24.h $(DESTDIR)$(PREFIX)/include/$(SOBASE)/
147 - install -m 644 -s $(LIBNAME) $(DESTDIR)$(PREFIX)/lib/$(LIBNAME)
148 - install -m 755 -s $(NAME) $(DESTDIR)$(PREFIX)/lib/$(NAME)
149 + install -m 644 ezV24.h $(DESTDIR)$(PREFIX)/include/
150 + install -m 644 $(LIBNAME) $(DESTDIR)$(PREFIX)/lib/$(LIBNAME)
151 + install -m 755 $(NAME) $(DESTDIR)$(PREFIX)/lib/$(NAME)
152 rm -f $(DESTDIR)$(PREFIX)/lib/$(SONAME) $(DESTDIR)$(PREFIX)/lib/$(PLAINNAME)
153 - ln -s $(PREFIX)/lib/$(NAME) $(DESTDIR)$(PREFIX)/lib/$(SONAME)
154 - ln -s $(PREFIX)/lib/$(SONAME) $(DESTDIR)$(PREFIX)/lib/$(PLAINNAME)
155 + ln -s $(NAME) $(DESTDIR)$(PREFIX)/lib/$(SONAME)
156 + ln -s $(SONAME) $(DESTDIR)$(PREFIX)/lib/$(PLAINNAME)
157 if [ -z $$NO_LDCONFIG ]; then \
158 $(LDCONFIG); \
159 fi
160 @@ -173,7 +156,7 @@ api-ref: doc++.conf manual.dxx ezV24.h
161 # gcc -o test-v24 -Wall test-v24.c -l$(SOBASE)
162 #
163 test-v24: test-v24.c ezV24.h $(LIBNAME)
164 - gcc -o test-v24 -Wall -DUNINSTALLED test-v24.c -L./ $(LIBNAME)
165 + $(CC) -o test-v24 -Wall -DUNINSTALLED test-v24.c -L./ $(LIBNAME)
166
167
168 # --------------------------------------------------------------------------
169 @@ -181,7 +164,7 @@ test-v24: test-v24.c ezV24.h $(LIBNAME)
170 # --------------------------------------------------------------------------
171
172 clean:
173 - rm -f *.o core
174 + rm -f *.o *.lo core
175
176 clean-all:
177 rm -f *.o core test-v24 $(NAME) $(LIBNAME)
178 Index: ezV24.c
179 ===================================================================
180 RCS file: /cvsroot/ezv24/libezv24/ezV24.c,v
181 retrieving revision 1.6
182 diff -u -p -r1.6 ezV24.c
183 --- ezV24.c 3 Jun 2006 19:34:06 -0000 1.6
184 +++ ezV24.c 26 Aug 2006 22:50:11 -0000
185 @@ -128,7 +128,7 @@ int v24CountPorts ( unsigned long* BitMa
186 {
187 int count=-1;
188
189 -#if defined(__LINUX__) && !defined(__CYGWIN__)
190 +#if defined(__linux__) && !defined(__CYGWIN__)
191 FILE* proc_fd=NULL;
192 char proc_line[80];
193 int done=0;
194 @@ -194,7 +194,7 @@ const char* v24PortName ( int PortNo, ch
195 reportError(NULL,V24_E_NULL_POINTER,"v24PortName");
196 return NULL;
197 }
198 -#if defined(__LINUX__) && !defined(__CYGWIN__)
199 +#if defined(__linux__) && !defined(__CYGWIN__)
200 v24_snprintf(PortName,V24_SZ_PORTNAME-1,"/dev/ttyS%d",PortNo);
201 PortName[V24_SZ_PORTNAME]='\0';
202 #elif defined(__CYGWIN__)
203 @@ -737,7 +737,7 @@ int v24HaveData ( v24_port_t *port )
204 reportError(port,V24_E_ILLHANDLE,"v24HaveData");
205 return -1;
206 }
207 -#if defined(__LINUX__) && !defined(__CYGWIN__)
208 +#if defined(__linux__) && !defined(__CYGWIN__)
209 port->Errno=V24_E_OK;
210 ioctl(port->fd,FIONREAD,&CharsWaiting);
211 return CharsWaiting;
212 @@ -798,7 +798,7 @@ int v24SetDTR ( v24_port_t *port, int Ne
213 return V24_E_ILLHANDLE;
214 }
215 port->Errno=V24_E_OK;
216 -#if defined(__LINUX__) && !defined(__CYGWIN__)
217 +#if defined(__linux__) && !defined(__CYGWIN__)
218 ioctl(port->fd,TIOCMGET,&status);
219 if ( NewState )
220 status |= TIOCM_DTR;
221 @@ -829,7 +829,7 @@ int v24SetRTS ( v24_port_t *port, int Ne
222 return port->Errno;
223 }
224
225 -#if defined(__LINUX__) && !defined(__CYGWIN__)
226 +#if defined(__linux__) && !defined(__CYGWIN__)
227 ioctl(port->fd,TIOCMGET,&status);
228 if ( NewState )
229 status |= TIOCM_RTS;
230 @@ -856,7 +856,7 @@ int v24GetDSR ( v24_port_t *port, int *C
231 return V24_E_ILLHANDLE;
232 }
233 port->Errno=V24_E_OK;
234 -#if defined(__LINUX__) && !defined(__CYGWIN__)
235 +#if defined(__linux__) && !defined(__CYGWIN__)
236 ioctl(port->fd,TIOCMGET,&status);
237 if ( status & TIOCM_DSR )
238 *CurrState = V24_DSR_HIGH;
239 @@ -888,7 +888,7 @@ int v24GetCTS ( v24_port_t *port, int *C
240 return port->Errno;
241 }
242
243 -#if defined(__LINUX__) && !defined(__CYGWIN__)
244 +#if defined(__linux__) && !defined(__CYGWIN__)
245 ioctl(port->fd,TIOCMGET,&status);
246 if ( status & TIOCM_CTS )
247 *CurrState = V24_CTS_HIGH;
248 Index: ezV24_config.h
249 ===================================================================
250 RCS file: /cvsroot/ezv24/libezv24/ezV24_config.h,v
251 retrieving revision 1.2
252 diff -u -p -r1.2 ezV24_config.h
253 --- ezV24_config.h 13 Oct 2003 07:50:26 -0000 1.2
254 +++ ezV24_config.h 26 Aug 2006 22:50:11 -0000
255 @@ -48,7 +48,7 @@ extern "C" {
256 /* This is set to 1 (TRUE), if we need support for lock-files to protect the
257 * opened device.
258 */
259 -#ifdef __LINUX__
260 +#ifdef __linux__
261 # ifdef __CYGWIN__
262 # define EZV24_WANT_LOCKFILE 1
263 # else
264 @@ -62,7 +62,7 @@ extern "C" {
265 /* This is set 1 (TRUE), if we have POSIX complaint functions to access the
266 * serial port.
267 */
268 -#ifdef __LINUX__
269 +#ifdef __linux__
270 #define EZV24_POSIX_STYLE 1
271 #else
272 #define EZV24_POSIX_STYLE 0