Skip to content

Commit

Permalink
option to build without curl (download) support
Browse files Browse the repository at this point in the history
  • Loading branch information
sezero authored and andrei-drexler committed Oct 6, 2023
1 parent 64a8b65 commit eaa830d
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 2 deletions.
7 changes: 7 additions & 0 deletions Quake/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ DO_USERDIRS=0
### Enable/Disable SDL2
USE_SDL2=1

### Enable/Disable Curl
USE_CURL=1

### Enable/Disable codecs for streaming music support
USE_CODEC_WAVE=1
USE_CODEC_FLAC=0
Expand Down Expand Up @@ -114,8 +117,12 @@ else
NET_LIBS :=
endif

ifeq ($(USE_CURL),1)
NET_LIBS += -lcurl
CFLAGS += $(shell $(PKG_CONFIG) --cflags libcurl)
else
CFLAGS += -DWITHOUT_CURL
endif

ifneq ($(VORBISLIB),vorbis)
ifneq ($(VORBISLIB),tremor)
Expand Down
7 changes: 7 additions & 0 deletions Quake/Makefile.w32
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
### Enable/disable SDL2
USE_SDL2=1

### Enable/Disable Curl
USE_CURL=1

### Enable/disable codecs for streaming music support
USE_CODEC_WAVE=1
USE_CODEC_FLAC=1
Expand Down Expand Up @@ -93,9 +96,13 @@ endif
CFLAGS += $(DEFWINSOCK)
NET_LIBS := $(LIBWINSOCK)

ifeq ($(USE_CURL),1)
NET_LIBS += -lcurl
CFLAGS += -I../Windows/curl/include
LDFLAGS += -L../Windows/curl/lib/x86
else
CFLAGS += -DWITHOUT_CURL
endif

ifneq ($(VORBISLIB),vorbis)
ifneq ($(VORBISLIB),tremor)
Expand Down
7 changes: 7 additions & 0 deletions Quake/Makefile.w64
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
### Enable/disable SDL2
USE_SDL2=1

### Enable/Disable Curl
USE_CURL=1

### Enable/disable codecs for streaming music support
USE_CODEC_WAVE=1
USE_CODEC_FLAC=1
Expand Down Expand Up @@ -86,9 +89,13 @@ LIBWINSOCK := -lws2_32
CFLAGS += $(DEFWINSOCK)
NET_LIBS := $(LIBWINSOCK)

ifeq ($(USE_CURL),1)
NET_LIBS += -lcurl
CFLAGS += -I../Windows/curl/include
LDFLAGS += -L../Windows/curl/lib/x64
else
CFLAGS += -DWITHOUT_CURL
endif

ifneq ($(VORBISLIB),vorbis)
ifneq ($(VORBISLIB),tremor)
Expand Down
9 changes: 8 additions & 1 deletion Quake/host_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "quakedef.h"
#include "q_ctype.h"
#include "json.h"

#include <time.h>
#ifndef WITHOUT_CURL
#include <curl/curl.h>
#endif
#define MAX_URL 2048

extern cvar_t pausable;
Expand Down Expand Up @@ -569,6 +571,10 @@ typedef struct download_s

static qboolean Download (const char *url, download_t *download)
{
#ifdef WITHOUT_CURL
download->error = "download support disabled at compile time.";
return false;
#else
CURL *curl;
CURLM *multi_handle;
CURLMcode mc;
Expand Down Expand Up @@ -647,6 +653,7 @@ static qboolean Download (const char *url, download_t *download)
curl_multi_cleanup (multi_handle);

return !download->error && !still_running && download->response == 200;
#endif
}

typedef struct
Expand Down
7 changes: 6 additions & 1 deletion Quake/net_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "net_sys.h"
#include "net_defs.h"

#ifndef WITHOUT_CURL
#include <curl/curl.h>
#endif

qsocket_t *net_activeSockets = NULL;
qsocket_t *net_freeSockets = NULL;
Expand Down Expand Up @@ -835,7 +837,9 @@ void NET_Init (void)
Con_DPrintf("TCP/IP address %s\n", my_tcpip_address);
}

#ifndef WITHOUT_CURL
curl_global_init (CURL_GLOBAL_DEFAULT);
#endif
}

/*
Expand All @@ -848,8 +852,9 @@ void NET_Shutdown (void)
{
qsocket_t *sock;

#ifndef WITHOUT_CURL
curl_global_cleanup ();

#endif
SetNetTime();

for (sock = net_activeSockets; sock; sock = sock->next)
Expand Down

0 comments on commit eaa830d

Please sign in to comment.