23193ebe创建于 2025年8月14日历史提交
#  OpenWatcom makefile to build SDL for Win32
#
!ifndef %WATCOM
!error Environment variable WATCOM is not specified!
!endif

DLLNAME = SDL
VERSION = 1.2.68

# change SDL2INC to point to the SDL2 headers
SDL2INC = include
INCPATH = -I"$(%WATCOM)/h/nt" -I"$(%WATCOM)/h"
LIBNAME = $(DLLNAME)

DLLFILE = $(LIBNAME).dll
LIBFILE = $(LIBNAME).lib
LNKFILE = $(LIBNAME).lnk

CFLAGS =-bt=nt -d0 -zq -bm -5s -fp5 -fpi87 -sg -oeatxhn -ei
# max warnings:
CFLAGS+= -wx
# avoid bogus W200 from cpuid code
CFLAGS+= -wcd=200
# newer OpenWatcom versions enable W303 by default
CFLAGS+= -wcd=303
# the include paths :
CFLAGS+= $(INCPATH)
# misc
CFLAGS+= -DNDEBUG -DSDL_DISABLE_IMMINTRIN_H

CFLAGS_DLL = $(CFLAGS)
# building dll:
CFLAGS_DLL+= -bd
# the include paths :
CFLAGS_DLL+= -I"$(SDL2INC)"
# we override the DECLSPEC define in begin_code.h, because we are using
# an exports file to remove the _cdecl '_' prefix from the symbol names
CFLAGS_DLL+= -DDECLSPEC=

CFLAGS_SDLMAIN = $(CFLAGS)
# the include paths :
CFLAGS_SDLMAIN+= -I"../include/SDL"

object_files= SDL12_compat.obj
resource_obj= version.res

.extensions:
.extensions: .lib .dll .obj .c .asm .res .rc

.c.obj:
	wcc386 $(CFLAGS_DLL) -fo=$^@ $<
.rc.res:
	wrc -q -r -bt=nt -I"$(%WATCOM)/h/nt" -fo=$^@ $<

all: $(DLLFILE) $(LIBFILE) SDLmain.lib .symbolic

$(DLLFILE): compiling_info $(object_files) $(resource_obj) $(LNKFILE)
	@echo * Linking: $@
	@wlink @$(LNKFILE)

$(LIBFILE): $(DLLFILE)
	@echo * Creating LIB file: $@
	wlib -q -b -n -c -pa -s -t -zld -ii -io $* @SDL12.lbc

SDLmain.lib: SDL_win32_main.obj
	wlib -q -b -n $@ -+SDL_win32_main.obj

SDL_win32_main.obj : SDLmain/win32/SDL_win32_main.c
	wcc386 $(CFLAGS_SDLMAIN) -fo=$^@ $<

compiling_info : .symbolic
	@echo * Compiling...

$(LNKFILE):
	@echo * Creating linker file: $@
	@%create $@
	@%append $@ SYSTEM nt_dll INITINSTANCE TERMINSTANCE
	@%append $@ NAME $(DLLFILE)
	@for %i in ($(object_files)) do @%append $@ FILE %i
	@%append $@ EXPORT=SDL12.exports
	@%append $@ OPTION IMPF=SDL12.lbc
	@%append $@ OPTION RESOURCE=$(resource_obj)
	@%append $@ OPTION QUIET
	@%append $@ OPTION MAP=$^&.map
	@%append $@ OPTION ELIMINATE
	@%append $@ OPTION SHOWDEAD

clean: .SYMBOLIC
	@echo * Clean: $(LIBNAME) $(VERSION)
	@if exist *.obj rm *.obj
	@if exist *.res rm *.res
	@if exist *.lbc rm *.lbc
	@if exist *.map rm *.map
	@if exist $(LNKFILE) rm $(LNKFILE)

distclean: clean .SYMBOLIC
	@if exist *.err rm *.err
	@if exist $(DLLFILE) rm $(DLLFILE)
	@if exist $(LIBFILE) rm $(LIBFILE)
	@if exist SDLmain.lib rm SDLmain.lib