Merge pull request #290 from rcgordon/autoupdater
Initial shot at writing an ioquake3 autoupdater. Thank you icculus, and everyone who contributed to his patreon! https://www.patreon.com/icculus
This commit is contained in:
commit
87eecd7bc1
7 changed files with 1468 additions and 22 deletions
101
Makefile
101
Makefile
|
@ -35,6 +35,9 @@ endif
|
|||
ifndef BUILD_RENDERER_OPENGL2
|
||||
BUILD_RENDERER_OPENGL2=
|
||||
endif
|
||||
ifndef BUILD_AUTOUPDATER # DON'T build unless you mean to!
|
||||
BUILD_AUTOUPDATER=0
|
||||
endif
|
||||
|
||||
#############################################################################
|
||||
#
|
||||
|
@ -228,6 +231,10 @@ ifndef USE_YACC
|
|||
USE_YACC=0
|
||||
endif
|
||||
|
||||
ifndef USE_AUTOUPDATER # DON'T include unless you mean to!
|
||||
USE_AUTOUPDATER=0
|
||||
endif
|
||||
|
||||
ifndef DEBUG_CFLAGS
|
||||
DEBUG_CFLAGS=-ggdb -O0
|
||||
endif
|
||||
|
@ -262,6 +269,7 @@ LBURGDIR=$(MOUNT_DIR)/tools/lcc/lburg
|
|||
Q3CPPDIR=$(MOUNT_DIR)/tools/lcc/cpp
|
||||
Q3LCCETCDIR=$(MOUNT_DIR)/tools/lcc/etc
|
||||
Q3LCCSRCDIR=$(MOUNT_DIR)/tools/lcc/src
|
||||
AUTOUPDATERSRCDIR=$(MOUNT_DIR)/autoupdater
|
||||
LOKISETUPDIR=misc/setup
|
||||
NSISDIR=misc/nsis
|
||||
SDLHDIR=$(MOUNT_DIR)/SDL2
|
||||
|
@ -269,29 +277,30 @@ LIBSDIR=$(MOUNT_DIR)/libs
|
|||
|
||||
bin_path=$(shell which $(1) 2> /dev/null)
|
||||
|
||||
# The autoupdater uses curl, so figure out its flags no matter what.
|
||||
# We won't need this if we only build the server
|
||||
ifneq ($(BUILD_CLIENT),0)
|
||||
# set PKG_CONFIG_PATH to influence this, e.g.
|
||||
# PKG_CONFIG_PATH=/opt/cross/i386-mingw32msvc/lib/pkgconfig
|
||||
ifneq ($(call bin_path, pkg-config),)
|
||||
CURL_CFLAGS ?= $(shell pkg-config --silence-errors --cflags libcurl)
|
||||
CURL_LIBS ?= $(shell pkg-config --silence-errors --libs libcurl)
|
||||
OPENAL_CFLAGS ?= $(shell pkg-config --silence-errors --cflags openal)
|
||||
OPENAL_LIBS ?= $(shell pkg-config --silence-errors --libs openal)
|
||||
SDL_CFLAGS ?= $(shell pkg-config --silence-errors --cflags sdl2|sed 's/-Dmain=SDL_main//')
|
||||
SDL_LIBS ?= $(shell pkg-config --silence-errors --libs sdl2)
|
||||
FREETYPE_CFLAGS ?= $(shell pkg-config --silence-errors --cflags freetype2)
|
||||
else
|
||||
# assume they're in the system default paths (no -I or -L needed)
|
||||
CURL_LIBS ?= -lcurl
|
||||
OPENAL_LIBS ?= -lopenal
|
||||
endif
|
||||
# Use sdl2-config if all else fails
|
||||
ifeq ($(SDL_CFLAGS),)
|
||||
ifneq ($(call bin_path, sdl2-config),)
|
||||
SDL_CFLAGS ?= $(shell sdl2-config --cflags)
|
||||
SDL_LIBS ?= $(shell sdl2-config --libs)
|
||||
endif
|
||||
|
||||
# set PKG_CONFIG_PATH to influence this, e.g.
|
||||
# PKG_CONFIG_PATH=/opt/cross/i386-mingw32msvc/lib/pkgconfig
|
||||
ifneq ($(call bin_path, pkg-config),)
|
||||
CURL_CFLAGS ?= $(shell pkg-config --silence-errors --cflags libcurl)
|
||||
CURL_LIBS ?= $(shell pkg-config --silence-errors --libs libcurl)
|
||||
OPENAL_CFLAGS ?= $(shell pkg-config --silence-errors --cflags openal)
|
||||
OPENAL_LIBS ?= $(shell pkg-config --silence-errors --libs openal)
|
||||
SDL_CFLAGS ?= $(shell pkg-config --silence-errors --cflags sdl2|sed 's/-Dmain=SDL_main//')
|
||||
SDL_LIBS ?= $(shell pkg-config --silence-errors --libs sdl2)
|
||||
FREETYPE_CFLAGS ?= $(shell pkg-config --silence-errors --cflags freetype2)
|
||||
else
|
||||
# assume they're in the system default paths (no -I or -L needed)
|
||||
CURL_LIBS ?= -lcurl
|
||||
OPENAL_LIBS ?= -lopenal
|
||||
endif
|
||||
|
||||
# Use sdl2-config if all else fails
|
||||
ifeq ($(SDL_CFLAGS),)
|
||||
ifneq ($(call bin_path, sdl2-config),)
|
||||
SDL_CFLAGS ?= $(shell sdl2-config --cflags)
|
||||
SDL_LIBS ?= $(shell sdl2-config --libs)
|
||||
endif
|
||||
endif
|
||||
|
||||
|
@ -367,6 +376,7 @@ ifneq (,$(findstring "$(PLATFORM)", "linux" "gnu_kfreebsd" "kfreebsd-gnu" "gnu")
|
|||
|
||||
THREAD_LIBS=-lpthread
|
||||
LIBS=-ldl -lm
|
||||
AUTOUPDATER_LIBS += -ldl
|
||||
|
||||
CLIENT_LIBS=$(SDL_LIBS)
|
||||
RENDERER_LIBS = $(SDL_LIBS) -lGL
|
||||
|
@ -594,6 +604,8 @@ ifdef MINGW
|
|||
endif
|
||||
|
||||
LIBS= -lws2_32 -lwinmm -lpsapi
|
||||
AUTOUPDATER_LIBS += -lwininet
|
||||
|
||||
# clang 3.4 doesn't support this
|
||||
ifneq ("$(CC)", $(findstring "$(CC)", "clang" "clang++"))
|
||||
CLIENT_LDFLAGS += -mwindows
|
||||
|
@ -834,6 +846,8 @@ ifeq ($(PLATFORM),irix64)
|
|||
SHLIBLDFLAGS=-shared
|
||||
|
||||
LIBS=-ldl -lm -lgen
|
||||
AUTOUPDATER_LIBS += -ldl
|
||||
|
||||
# FIXME: The X libraries probably aren't necessary?
|
||||
CLIENT_LIBS=-L/usr/X11/$(LIB) $(SDL_LIBS) \
|
||||
-lX11 -lXext -lm
|
||||
|
@ -888,6 +902,7 @@ ifeq ($(PLATFORM),sunos)
|
|||
|
||||
THREAD_LIBS=-lpthread
|
||||
LIBS=-lsocket -lnsl -ldl -lm
|
||||
AUTOUPDATER_LIBS += -ldl
|
||||
|
||||
BOTCFLAGS=-O0
|
||||
|
||||
|
@ -986,6 +1001,16 @@ ifneq ($(BUILD_GAME_QVM),0)
|
|||
endif
|
||||
endif
|
||||
|
||||
ifneq ($(BUILD_AUTOUPDATER),0)
|
||||
# PLEASE NOTE that if you run an exe on Windows Vista or later
|
||||
# with "setup", "install", "update" or other related terms, it
|
||||
# will unconditionally trigger a UAC prompt, and in the case of
|
||||
# ioq3 calling CreateProcess() on it, it'll just fail immediately.
|
||||
# So don't call this thing "autoupdater" here!
|
||||
AUTOUPDATER_BIN := autosyncerator$(FULLBINEXT)
|
||||
TARGETS += $(B)/$(AUTOUPDATER_BIN)
|
||||
endif
|
||||
|
||||
ifeq ($(USE_OPENAL),1)
|
||||
CLIENT_CFLAGS += -DUSE_OPENAL
|
||||
ifeq ($(USE_OPENAL_DLOPEN),1)
|
||||
|
@ -1086,6 +1111,11 @@ ifeq ($(USE_FREETYPE),1)
|
|||
RENDERER_LIBS += $(FREETYPE_LIBS)
|
||||
endif
|
||||
|
||||
ifeq ($(USE_AUTOUPDATER),1)
|
||||
CLIENT_CFLAGS += -DUSE_AUTOUPDATER -DAUTOUPDATER_BIN=\\\"$(AUTOUPDATER_BIN)\\\"
|
||||
SERVER_CFLAGS += -DUSE_AUTOUPDATER -DAUTOUPDATER_BIN=\\\"$(AUTOUPDATER_BIN)\\\"
|
||||
endif
|
||||
|
||||
ifeq ("$(CC)", $(findstring "$(CC)", "clang" "clang++"))
|
||||
BASE_CFLAGS += -Qunused-arguments
|
||||
endif
|
||||
|
@ -1317,6 +1347,9 @@ endif
|
|||
@echo " CLIENT_LIBS:"
|
||||
$(call print_wrapped, $(CLIENT_LIBS))
|
||||
@echo ""
|
||||
@echo " AUTOUPDATER_LIBS:"
|
||||
$(call print_wrapped, $(AUTOUPDATER_LIBS))
|
||||
@echo ""
|
||||
@echo " Output:"
|
||||
$(call print_list, $(NAKED_TARGETS))
|
||||
@echo ""
|
||||
|
@ -1342,6 +1375,7 @@ endif
|
|||
makedirs:
|
||||
@if [ ! -d $(BUILD_DIR) ];then $(MKDIR) $(BUILD_DIR);fi
|
||||
@if [ ! -d $(B) ];then $(MKDIR) $(B);fi
|
||||
@if [ ! -d $(B)/autoupdater ];then $(MKDIR) $(B)/autoupdater;fi
|
||||
@if [ ! -d $(B)/client ];then $(MKDIR) $(B)/client;fi
|
||||
@if [ ! -d $(B)/client/opus ];then $(MKDIR) $(B)/client/opus;fi
|
||||
@if [ ! -d $(B)/client/vorbis ];then $(MKDIR) $(B)/client/vorbis;fi
|
||||
|
@ -1561,6 +1595,27 @@ $(Q3ASM): $(Q3ASMOBJ)
|
|||
$(Q)$(TOOLS_CC) $(TOOLS_CFLAGS) $(TOOLS_LDFLAGS) -o $@ $^ $(TOOLS_LIBS)
|
||||
|
||||
|
||||
#############################################################################
|
||||
# AUTOUPDATER
|
||||
#############################################################################
|
||||
|
||||
define DO_AUTOUPDATER_CC
|
||||
$(echo_cmd) "AUTOUPDATER_CC $<"
|
||||
$(Q)$(CC) $(CFLAGS) $(CURL_CFLAGS) -o $@ -c $<
|
||||
endef
|
||||
|
||||
Q3AUTOUPDATEROBJ = \
|
||||
$(B)/autoupdater/autoupdater.o \
|
||||
$(B)/autoupdater/sha256.o
|
||||
|
||||
$(B)/autoupdater/%.o: $(AUTOUPDATERSRCDIR)/%.c
|
||||
$(DO_AUTOUPDATER_CC)
|
||||
|
||||
$(B)/$(AUTOUPDATER_BIN): $(Q3AUTOUPDATEROBJ)
|
||||
$(echo_cmd) "AUTOUPDATER_LD $@"
|
||||
$(Q)$(CC) $(LDFLAGS) -o $@ $(Q3AUTOUPDATEROBJ) $(AUTOUPDATER_LIBS)
|
||||
|
||||
|
||||
#############################################################################
|
||||
# CLIENT/SERVER
|
||||
#############################################################################
|
||||
|
@ -1664,6 +1719,7 @@ Q3OBJ = \
|
|||
$(B)/client/sdl_snd.o \
|
||||
\
|
||||
$(B)/client/con_log.o \
|
||||
$(B)/client/sys_autoupdater.o \
|
||||
$(B)/client/sys_main.o
|
||||
|
||||
ifdef MINGW
|
||||
|
@ -2200,6 +2256,7 @@ Q3DOBJ = \
|
|||
$(B)/ded/null_snddma.o \
|
||||
\
|
||||
$(B)/ded/con_log.o \
|
||||
$(B)/ded/sys_autoupdater.o \
|
||||
$(B)/ded/sys_main.o
|
||||
|
||||
ifeq ($(ARCH),x86)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue