+LDFLAGS+=-lm -lz $(PTHREAD_LIBS)
Why did you add this? Unnecessary libs are bad. If it's absolutely necessary, guard it with bsd-specific ifeq.
These are for -pthread (the variable is to maintain compatibility with FreeBSD 4.x, but it's unsupported since a few months). If it's not needed for Linux then just add the 'ifeq'.
same here about cflags and ldflags, please don't break the linux build
This doesn't break the Linux build, it just adds "-I$(LOCALBASE)/include -I$(X11BASE)/include". They aren't required if everything is in the compiler's default search path, but there are systems (and maybe even Linux distributions) which have them in other locations. The only problem here is that LOCALBASE/X11BASE are undefined. So please add a:
Or whatever values you consider more "general", since the "?=" is to allow overriding it from the environment. That's defined by the port by default.
-LDFLAGS+=$(shell sdl-config --libs) -lm -lGL -ljpeg -lpng12
+LDFLAGS+=$(shell sdl-config --libs) -lm -lGL -ljpeg -lpng
This might break linux build, haven't tested. Guard it.
I never saw the PNG library installed as png12 in any application I ported, maybe it was detected or there is a symlink. This is not specific to Linux/FreeBSD but to OSes in general and Linux distributions (in fact to what their package management system considers better).
Please test it if you have time.
Sys_DebugBreak should have something in it. R1CH?
Maybe "abort()"? It would make the program dump the core so it can be debugged (or if inside the debugger, will stop). At least the signal is catched by a custom signal handler.
Are you sure this doesn't break anything?
No, it just does the following:
* Adds DATADIR/<game> to the search path.
* Adds LIBDIR/<game> to the search path.
* Adds ~/.r1q2/<game> to the search path.
* Writes to ~/.r1q2/<game> (and creates it if doesn't exist) because it's the last added entry.
This is to keep a global binary/data that all users can access, but keeping their configuration and saved games in their homes. The use of 2 data directories is to respect FreeBSD's hierarchy and to share the Q2 data between all the engines, so Q2 data goes to DATADIR and R1Q2 specific data/libs to LIBDIR.
If you want you can keep only some parts of it, and the rest of them will be applied locally.
Now that I think of it, maybe this should be removed for Win32 with #ifndef _WIN32 or #ifdef __unix__, as it has everything on one directory.
Other than these it looks ok.
Thanks for the review. If you have more comments or questions, tell me.