shithub: qk1

Download patch

ref: a4cbb5ee6ff9af7ec74f2c72204971a4091139f1
parent: 5a6ed7f45e6d79d0a555c26ac87b0c0c2f0bfc6d
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Thu Jan 25 19:59:30 EST 2024

move to meson

--- a/Makefile
+++ /dev/null
@@ -1,167 +1,0 @@
-TARG=qk1
-DESTDIR?=
-PREFIX?=/usr/local
-BIN=${DESTDIR}${PREFIX}/bin
-EXTRA_CFLAGS=$$(pkg-config --cflags sdl2 openal)
-EXTRA_LDFLAGS=$$(pkg-config --libs sdl2 openal)
-CFLAGS?=-O3 -g -march=native # do NOT add -ffast-math
-CFLAGS+=-Wall -Wextra -Wno-unknown-pragmas -Wno-missing-field-initializers -Wno-implicit-fallthrough -Wno-microsoft-anon-tag
-CFLAGS+=-fms-extensions
-CFLAGS+=-I3rd/parg -Iunix -I. ${EXTRA_CFLAGS}
-LDFLAGS?=
-LDFLAGS+=-lm ${EXTRA_LDFLAGS}
-
-OBJS=\
-	3rd/parg/parg.o\
-	cd.o\
-	chase.o\
-	cl_demo.o\
-	cl_input.o\
-	cl_main.o\
-	cl_parse.o\
-	cl_tent.o\
-	cmd.o\
-	common.o\
-	console.o\
-	cvar.o\
-	d_alpha.o\
-	d_edge.o\
-	d_init.o\
-	d_modech.o\
-	d_part.o\
-	d_polyse.o\
-	d_scan.o\
-	d_sky.o\
-	d_sprite.o\
-	d_surf.o\
-	d_vars.o\
-	draw.o\
-	fs.o\
-	host.o\
-	host_cmd.o\
-	i_external.o\
-	i_resize.o\
-	i_tga.o\
-	i_wad.o\
-	in_sdl.o\
-	keys.o\
-	mathlib.o\
-	menu.o\
-	model.o\
-	model_alias.o\
-	model_brush.o\
-	model_bsp.o\
-	model_bsp2.o\
-	model_bsp30.o\
-	model_sprite.o\
-	net_loop.o\
-	net_main.o\
-	net_udp_unix.o\
-	pal.o\
-	pr_cmds.o\
-	pr_edict.o\
-	pr_exec.o\
-	protocol.o\
-	r_aclip.o\
-	r_alias.o\
-	r_bsp.o\
-	r_draw.o\
-	r_edge.o\
-	r_efrag.o\
-	r_fog.o\
-	r_light.o\
-	r_main.o\
-	r_misc.o\
-	r_part.o\
-	r_sky.o\
-	r_sprite.o\
-	r_surf.o\
-	sbar.o\
-	screen.o\
-	seprint.o\
-	snd_openal.o\
-	softfloat.o\
-	sv_main.o\
-	sv_move.o\
-	sv_phys.o\
-	sv_user.o\
-	sys_snail.o\
-	sys_unix.o\
-	vid_sdl.o\
-	view.o\
-	wav.o\
-	world.o\
-	zone.o\
-
-HDRS=\
-	adivtab.h\
-	anorms.h\
-	bspfile.h\
-	client.h\
-	cmd.h\
-	common.h\
-	console.h\
-	cvar.h\
-	d_iface.h\
-	d_local.h\
-	dat.h\
-	draw.h\
-	fns.h\
-	i_tga.h\
-	i_wad.h\
-	input.h\
-	keys.h\
-	mathlib.h\
-	menu.h\
-	model.h\
-	modelgen.h\
-	net.h\
-	pr_comp.h\
-	progdefs.h\
-	progs.h\
-	protocol.h\
-	quakedef.h\
-	r_local.h\
-	r_shared.h\
-	render.h\
-	sbar.h\
-	screen.h\
-	server.h\
-	softfloat.h\
-	spritegn.h\
-	unix/platform.h\
-	vid.h\
-	view.h\
-	world.h\
-	zone.h\
-
-.PHONY: all default install uninstall clean
-
-all: default
-
-default: ${TARG}
-
-install: ${TARG}
-	install -d ${BIN}
-	install -m 755 ${TARG} ${BIN}
-
-uninstall:
-	rm -f ${BIN}/${TARG}
-
-${TARG}: ${OBJS}
-	${CC} -o $@ ${OBJS} ${LDFLAGS}
-
-.SUFFIXES: .c .o
-.c.o:
-	${CC} -o $@ -c $< ${CFLAGS}
-
-${OBJS}: ${HDRS}
-
-d_scan.o: r_fog.h unix/d_scan.h
-
-i_resize.o: stb_image_resize2.h
-
-r_surf.o: r_surf_block.h r_surf_light.h r_surf_x.h
-
-clean:
-	rm -f ${TARG} ${OBJS}
--- a/fs.c
+++ b/fs.c
@@ -1002,24 +1002,22 @@
 void
 initfs(char **paths)
 {
-	byte swaptest[2] = {1,0};
+#ifdef QUAKE_LITTLE_ENDIAN
+	BigShort = ShortSwap;
+	LittleShort = ShortNoSwap;
+	BigLong = LongSwap;
+	LittleLong = LongNoSwap;
+	BigFloat = FloatSwap;
+	LittleFloat = FloatNoSwap;
+#else
+	BigShort = ShortNoSwap;
+	LittleShort = ShortSwap;
+	BigLong = LongNoSwap;
+	LittleLong = LongSwap;
+	BigFloat = FloatNoSwap;
+	LittleFloat = FloatSwap;
+#endif
 
-	if(*(short *)swaptest == 1)
-	{
-		BigShort = ShortSwap;
-		LittleShort = ShortNoSwap;
-		BigLong = LongSwap;
-		LittleLong = LongNoSwap;
-		BigFloat = FloatSwap;
-		LittleFloat = FloatNoSwap;
-	}else{
-		BigShort = ShortNoSwap;
-		LittleShort = ShortSwap;
-		BigLong = LongNoSwap;
-		LittleLong = LongSwap;
-		BigFloat = FloatNoSwap;
-		LittleFloat = FloatSwap;
-	}
 	initns(paths);
 	chkreg();
 	Cmd_AddCommand("path", path);
--- /dev/null
+++ b/meson.build
@@ -1,0 +1,135 @@
+project(
+	'qk1',
+	'c',
+	version: '1.09',
+	default_options: [
+		'c_std=c2x',
+		'warning_level=2',
+		'buildtype=debugoptimized',
+		#'b_coverage=true',
+	],
+)
+
+add_global_arguments(
+	'-Wno-unknown-pragmas',
+	'-Wno-missing-field-initializers',
+	'-Wno-implicit-fallthrough',
+	'-fms-extensions',
+	'-D_DEFAULT_SOURCE',
+	language: 'c',
+)
+
+src_common = [
+	'cd.c',
+	'chase.c',
+	'cl_demo.c',
+	'cl_input.c',
+	'cl_main.c',
+	'cl_parse.c',
+	'cl_tent.c',
+	'cmd.c',
+	'common.c',
+	'console.c',
+	'cvar.c',
+	'd_alpha.c',
+	'd_edge.c',
+	'd_init.c',
+	'd_modech.c',
+	'd_part.c',
+	'd_polyse.c',
+	'd_scan.c',
+	'd_sky.c',
+	'd_sprite.c',
+	'd_surf.c',
+	'd_vars.c',
+	'draw.c',
+	'fs.c',
+	'host.c',
+	'host_cmd.c',
+	'i_external.c',
+	'i_resize.c',
+	'i_tga.c',
+	'i_wad.c',
+	'keys.c',
+	'mathlib.c',
+	'menu.c',
+	'model.c',
+	'model_alias.c',
+	'model_brush.c',
+	'model_bsp.c',
+	'model_bsp2.c',
+	'model_bsp30.c',
+	'model_sprite.c',
+	'net_loop.c',
+	'net_main.c',
+	'pal.c',
+	'pr_cmds.c',
+	'pr_edict.c',
+	'pr_exec.c',
+	'protocol.c',
+	'r_aclip.c',
+	'r_alias.c',
+	'r_bsp.c',
+	'r_draw.c',
+	'r_edge.c',
+	'r_efrag.c',
+	'r_fog.c',
+	'r_light.c',
+	'r_main.c',
+	'r_misc.c',
+	'r_part.c',
+	'r_sky.c',
+	'r_sprite.c',
+	'r_surf.c',
+	'sbar.c',
+	'screen.c',
+	'softfloat.c',
+	'sv_main.c',
+	'sv_move.c',
+	'sv_phys.c',
+	'sv_user.c',
+	'view.c',
+	'wav.c',
+	'world.c',
+	'zone.c',
+]
+
+src_unix = [
+	'3rd/parg/parg.c',
+	'in_sdl.c',
+	'net_udp_unix.c',
+	'seprint.c',
+	'snd_openal.c',
+	'sys_snail.c',
+	'sys_unix.c',
+	'vid_sdl.c',
+]
+
+sdl2 = dependency('sdl2')
+openal = dependency('openal')
+threads = dependency('threads')
+
+cc = meson.get_compiler('c')
+if cc.get_id() == 'clang'
+	add_global_arguments(
+		'-Wno-microsoft-anon-tag',
+		language: 'c',
+	)
+endif
+
+libm = cc.find_library('m', required: false)
+
+executable(
+	'qk1',
+	sources: src_common + src_unix,
+	dependencies: [
+		sdl2,
+		openal,
+		threads,
+		libm,
+	],
+	include_directories: include_directories(
+		'3rd/parg',
+		'unix',
+	),
+)
--- a/net_udp_unix.c
+++ b/net_udp_unix.c
@@ -1,12 +1,12 @@
 #include "quakedef.h"
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
 #include <arpa/inet.h>
+#include <errno.h>
 #include <netdb.h>
-#include <sys/param.h>
+#include <netinet/in.h>
 #include <sys/ioctl.h>
-#include <errno.h>
+#include <sys/param.h>
+#include <sys/socket.h>
+#include <sys/types.h>
 
 extern cvar_t hostname;
 
--- a/shell.nix
+++ b/shell.nix
@@ -5,6 +5,8 @@
   SDL2
   openal
   pkg-config
+  meson
+  ninja
   gcc13
  ];
 }
--- a/unix/platform.h
+++ b/unix/platform.h
@@ -11,6 +11,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <strings.h>
 #include <sys/stat.h>
 #include <unistd.h>