Skip to content

Commit 9b54d33

Browse files
committed
Workaround for the absence of 'zlib' on Microsoft Windows. (Ideally, the workaround would be to actually have the relevant library. I'll deal with that if/when a Windows version becomes an issue.)
1 parent 5fcf745 commit 9b54d33

4 files changed

Lines changed: 27 additions & 18 deletions

File tree

makefile

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,6 @@ endif
3232
EXE=
3333
RM=rm -f
3434

35-
# I'm using 'mkdir -p' to avoid error messages if the directory exists.
36-
# It may fail on very old systems, and will probably fail on non-POSIX
37-
# systems. If so, change to '-mkdir' and ignore errors.
38-
39-
ifdef MSWIN
40-
EXE=.exe
41-
MKDIR=-mkdir
42-
else
43-
MKDIR=mkdir -p
44-
endif
45-
4635
LIB_DIR=$(INSTALL_DIR)/lib
4736

4837
ifdef W64
@@ -59,6 +48,17 @@ ifdef W32
5948
LIB_DIR=$(INSTALL_DIR)/win_lib32
6049
endif
6150

51+
# I'm using 'mkdir -p' to avoid error messages if the directory exists.
52+
# It may fail on very old systems, and will probably fail on non-POSIX
53+
# systems. If so, change to '-mkdir' and ignore errors.
54+
55+
ifeq ($(EXE),.exe)
56+
MKDIR=-mkdir
57+
else
58+
ZLIB=-lz
59+
MKDIR=mkdir -p
60+
endif
61+
6262
# You can have your include files in ~/include and libraries in
6363
# ~/lib, in which case only the current user can use them; or
6464
# (with root privileges) you can install them to /usr/local/include
@@ -179,19 +179,19 @@ libsatell.a: $(OBJS)
179179
ar rv libsatell.a $(OBJS)
180180

181181
sat_eph$(EXE): sat_eph.c observe.o libsatell.a
182-
$(CC) $(CFLAGS) -o sat_eph$(EXE) -I $(INCL) sat_eph.c observe.o libsatell.a -lm -L $(LIB_DIR) -llunar -lz
182+
$(CC) $(CFLAGS) -o sat_eph$(EXE) -I $(INCL) sat_eph.c observe.o libsatell.a -lm -L $(LIB_DIR) -llunar $(ZLIB)
183183

184184
sat_cgi$(EXE): sat_eph.c observe.o libsatell.a
185-
$(CC) $(CFLAGS) -o sat_cgi$(EXE) -I $(INCL) sat_eph.c observe.o -DON_LINE_VERSION libsatell.a -lm -L $(LIB_DIR) -llunar -lz
185+
$(CC) $(CFLAGS) -o sat_cgi$(EXE) -I $(INCL) sat_eph.c observe.o -DON_LINE_VERSION libsatell.a -lm -L $(LIB_DIR) -llunar $(ZLIB)
186186

187187
sat_id$(EXE): sat_id.cpp sat_util.o observe.o libsatell.a
188-
$(CXX) $(CFLAGS) -o sat_id$(EXE) -I $(INCL) sat_id.cpp sat_util.o observe.o libsatell.a -lm -L $(LIB_DIR) -llunar -lz
188+
$(CXX) $(CFLAGS) -o sat_id$(EXE) -I $(INCL) sat_id.cpp sat_util.o observe.o libsatell.a -lm -L $(LIB_DIR) -llunar $(ZLIB)
189189

190190
sat_id2$(EXE): sat_id2.cpp sat_id.cpp sat_util.o observe.o libsatell.a
191-
$(CXX) $(CFLAGS) -o sat_id2$(EXE) -I $(INCL) -DON_LINE_VERSION sat_id2.cpp sat_id.cpp sat_util.o observe.o libsatell.a -lm -L $(LIB_DIR) -llunar -lz
191+
$(CXX) $(CFLAGS) -o sat_id2$(EXE) -I $(INCL) -DON_LINE_VERSION sat_id2.cpp sat_id.cpp sat_util.o observe.o libsatell.a -lm -L $(LIB_DIR) -llunar $(ZLIB)
192192

193193
sat_id3$(EXE): sat_id3.cpp sat_id.cpp sat_util.o observe.o libsatell.a
194-
$(CXX) $(CFLAGS) -o sat_id3$(EXE) -I $(INCL) -DON_LINE_VERSION sat_id3.cpp sat_id.cpp sat_util.o observe.o libsatell.a -lm -L $(LIB_DIR) -llunar -lz
194+
$(CXX) $(CFLAGS) -o sat_id3$(EXE) -I $(INCL) -DON_LINE_VERSION sat_id3.cpp sat_id.cpp sat_util.o observe.o libsatell.a -lm -L $(LIB_DIR) -llunar $(ZLIB)
195195

196196
summarize$(EXE): summarize.c observe.o libsatell.a
197197
$(CC) $(CFLAGS) -o summarize$(EXE) -I $(INCL) summarize.c observe.o libsatell.a -lm -L $(LIB_DIR) -llunar

sat_eph.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
#include <assert.h>
77
#include <math.h>
88
#include <time.h>
9-
#include <zlib.h>
9+
#if defined( _WIN32) || defined( __WATCOMC__)
10+
#include "zlibstub.h"
11+
#else
12+
#include <zlib.h>
13+
#endif
1014
#include "watdefs.h"
1115
#include "afuncs.h"
1216
#include "comets.h"

sat_id.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,12 @@ should be used, and the others are suppressed. */
6565
#include <ctype.h>
6666
#include <stdlib.h>
6767
#include <assert.h>
68-
#include <zlib.h>
6968
#if defined( _WIN32) || defined( __WATCOMC__)
7069
#include <malloc.h> /* for alloca() prototype */
70+
#include "zlibstub.h"
7171
#else
7272
#include <unistd.h>
73+
#include <zlib.h>
7374
#endif
7475

7576
#if defined(_MSC_VER) && _MSC_VER < 1900

zlibstub.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#define gzFile FILE *
2+
#define gzopen fopen
3+
#define gzgets( ifile, buff, buffsize) fgets( buff, buffsize, ifile)
4+
#define gzclose fclose

0 commit comments

Comments
 (0)