2 # Higanbana Project makefile
5 # Possible optimizations for 8088 class processors
7 # -oa Relax alias checking
8 # -ob Try to generate straight line code
9 # -oe - expand user functions inline (-oe=20 is default, adds lots of code)
10 # -oh Enable repeated optimizations
11 # -oi generate certain lib funcs inline
12 # -oi +Set max inline depth (C++ only, use -oi for C)
13 # -ok Flowing of register save into function flow graph
14 # -ol loop optimizations
15 # -ol+ loop optimizations plus unrolling
16 # -or Reorder for pipelined (486+ procs); not sure if good to use
17 # -os Favor space over time
18 # -ot Favor time over space
19 # -ei Allocate an "int" for all enum types
20 # -zp2 Allow compiler to add padding to structs
21 # -zpw Use with above; make sure you are warning free!
22 # -0 8088/8086 class code generation
23 # -s disable stack overflow checking
25 # -zk0u translate kanji to unicode... wwww
27 # -zkl current codepage
29 # this enables debug output to the serial port.
30 # comment this out on game release.
31 # serial output goes to COM1 at 9600 baud 1 stop bit odd parity.
32 # serial output is plain text ASCII.
45 DOSLIBMAKE=./make.sh build all
46 DOSLIBMAKEALL=./buildall.sh build all
55 DOSLIBMAKEALL=.\build.bat
61 BUILD_ROOT=$+$(%__CWD__)$-
62 #EXMMTESTDIR=16$(DIRSEP)exmmtest$(DIRSEP)
68 JSMNLIB=$(SRCLIB)/jsmn
69 NYANLIB=$(SRCLIB)/nyan
70 EXMMLIB=$(SRCLIB)/exmm
71 MODEXLIB16=$(SRCLIB)/16_vl
72 MODEXLIB=$(SRCLIB)/modex
73 VGMSNDLIB=$(SRCLIB)/vgmsnd
74 DOSLIBDIR=$(SRCLIB)/doslib
75 WCPULIB=$(SRCLIB)/wcpu
77 DOSLIB_CPU=$(DOSLIBDIR)/hw/cpu
78 DOSLIB_DOS=$(DOSLIBDIR)/hw/dos
79 DOSLIB_VGA=$(DOSLIBDIR)/hw/vga
80 DOSLIB_8250=$(DOSLIBDIR)/hw/8250
81 DOSLIB_JOYSTICK=$(DOSLIBDIR)/hw/joystick
82 DOSLIB_MEMMODE=dos86$(MEMORYMODE)
84 # remote host (for sparky4)
90 # 2nd remote host (for sparky4)
92 HOST2ADDR=beta.latech.edu
93 HOST2DIR=~/public_html/
107 S_FLAGS=-sg -st -of+ -zu -zdf -zff -zgf -k32768
108 Z_FLAGS=-zk0 -zc -zp8 -zm
109 O_FLAGS=-opmilr -oe=24 -outback -ei -ohnl+ -zp4
110 T_FLAGS=-bt=dos -wx -m$(MEMORYMODE) -0 -fpi87 -d1##-fo=.$(OBJ) -e=65536
112 DBUGFLAGS=-fm=$^&.mah -fd=$^&
113 CPPFLAGS=-DTARGET_MSDOS=16 -DMSDOS=1
115 CPPFLAGS += -DDEBUGSERIAL
117 AFLAGS=$(WCLQ) $(T_FLAGS)
118 CFLAGS=$(WCLQ) $(T_FLAGS) -wo -i"$(DOSLIBDIR)" $(O_FLAGS) $(S_FLAGS) $(Z_FLAGS)
119 LFLAGS=$(WCLQ) -l=dos $(S_FLAGS) $(DBUGFLAGS)
120 LIBFLAGS=$(WLIBQ) -b -n
125 VGMSNDOBJ = vgmSnd.$(OBJ) 16_snd.$(OBJ)
126 #OLDLIBOBJS=bitmap.$(OBJ) 16render.$(OBJ)
127 GFXLIBOBJS = 16_vl.$(OBJ) 16_vlpal.$(OBJ) 16text.$(OBJ) bakapee.$(OBJ) scroll16.$(OBJ) 16_vrs.$(OBJ) 16_spri.$(OBJ) $(OLDLIBOBJS)
128 16LIBOBJS = 16_mm.$(OBJ) 16_pm.$(OBJ) 16_ca.$(OBJ) 16_tail.$(OBJ) 16_in.$(OBJ) 16_head.$(OBJ) 16_dbg.$(OBJ) kitten.$(OBJ) 16_hc.$(OBJ) 16_wcpu.$(OBJ) 16_timer.$(OBJ) jsmn.$(OBJ) 16_map.$(OBJ) 16text.$(OBJ) 16_enti.$(OBJ)
129 DOSLIBOBJ = adlib.$(OBJ) 8254.$(OBJ) 8259.$(OBJ) dos.$(OBJ) cpu.$(OBJ)
131 DOSLIBOBJ += 8250.$(OBJ)
137 DOSLIBLIBS = $(DOSLIB_CPU)/$(DOSLIB_MEMMODE)/cpu.lib $(DOSLIB_DOS)/$(DOSLIB_MEMMODE)/dos.lib $(DOSLIB_VGA)/$(DOSLIB_MEMMODE)/vga.lib
139 DOSLIBLIBS += $(DOSLIB_8250)/$(DOSLIB_MEMMODE)/8250.lib
147 .c : $(SRC);$(SRCLIB);$(MODEXLIB16);$(JSMNLIB);$(NYANLIB);$(VGMSNDLIB);$(WCPULIB);$(UTIL)
149 .asm : $(MODEXLIB);$(UTIL)
151 .lib : .;$(DOSLIB_CPU)/$(DOSLIB_MEMMODE);$(DOSLIB_DOS)/$(DOSLIB_MEMMODE);$(DOSLIB_VGA)/$(DOSLIB_MEMMODE);$(DOSLIB_8250)/$(DOSLIB_MEMMODE)
159 *wcl $(CFLAGS) $(extra_$^&_obj_opts) $(CPPFLAGS) -c $[@
162 *wcl $(AFLAGS) $(extra_$^&_obj_opts) -c $[@
164 #CFLAGS is neccessary here
166 *wcl $(LFLAGS) $(extra_$^&_exe_opts)$< -fe=$@
168 LIBMAKERULE=*wlib $(LIBFLAGS) $(extra_$^&_lib_opts)$@ $<
173 # List of executables to build
209 #UTILEXEC += $(SPRIUTILEXEC)
218 all: $(EXEC) $(EXTERNTESTEXEC)
219 testexec: $(EXEC) $(TESTEXEC2)
222 # game and bakapi executables
224 16.exe: 16.$(OBJ) $(16LIB) gfx.lib $(DOSLIB)
225 bakapi.exe: bakapi.$(OBJ) gfx.lib $(DOSLIB)
230 scroll.exe: scroll.$(OBJ) $(16LIB) gfx.lib $(DOSLIB)
231 scroll.$(OBJ): $(SRC)/scroll.c
232 zcroll.exe: zcroll.$(OBJ) $(16LIB) gfx.lib $(DOSLIB)
233 zcroll.$(OBJ): $(SRC)/zcroll.c
234 tesuto.exe: tesuto.$(OBJ) 16_head.$(OBJ) gfx.lib $(DOSLIB)
235 tesuto.$(OBJ): $(SRC)/tesuto.c
236 0.exe: 0.$(OBJ) $(16LIB) gfx.lib $(DOSLIB)
238 test.exe: test.$(OBJ) $(16LIB) gfx.lib $(DOSLIB)
239 #test2.exe: test2.$(OBJ) gfx.lib $(DOSLIB)
240 test0.exe: test0.$(OBJ)
241 fonttest.exe: fonttest.$(OBJ) gfx.lib
242 #fonttes0.exe: fonttes0.$(OBJ) $(16LIB)
243 fontgfx.exe: fontgfx.$(OBJ) gfx.lib $(DOSLIB)
244 inputest.exe: inputest.$(OBJ) $(16LIB) $(DOSLIB)
245 #sountest.exe: sountest.$(OBJ) $(16LIB)
246 pcxtest.exe: pcxtest.$(OBJ) gfx.lib $(DOSLIB) $(16LIB)
247 vrstest.exe: vrstest.$(OBJ) $(16LIB) gfx.lib $(DOSLIB)
248 #vgacamm.exe: vgacamm.$(OBJ) $(16LIB) gfx.lib $(DOSLIB)
249 palettec.exe: palettec.$(OBJ) gfx.lib $(DOSLIB)
250 palettel.exe: palettel.$(OBJ) gfx.lib $(DOSLIB)
251 palllist.exe: palllist.$(OBJ) gfx.lib $(DOSLIB) ll.$(OBJ)
252 pcxtest2.exe: pcxtest2.$(OBJ) gfx.lib $(DOSLIB)
253 #planrpcx.exe: planrpcx.$(OBJ) gfx.lib
254 maptest.exe: maptest.$(OBJ) 16_map.$(OBJ) 16_head.$(OBJ) gfx.lib $(DOSLIB) $(16LIB)
255 fmemtest.exe: fmemtest.$(OBJ)
256 exmmtest.exe: exmmtest.$(OBJ) $(16LIB) $(DOSLIB)
257 vgmtest.exe: vgmtest.$(OBJ) vgmsnd.lib $(16LIB) $(DOSLIB)
259 wcpu.exe: wcpu.$(OBJ) $(16LIB) $(DOSLIB)
262 # executable's objects
264 16.$(OBJ): $(SRC)/16.c $(SRC)/16.h
265 bakapi.$(OBJ): $(SRC)/bakapi.c $(SRC)/bakapi.h
266 test.$(OBJ): $(SRC)/test.c $(SRCLIB)/16_vl.h
267 #test2.$(OBJ): $(SRC)/test2.c $(SRCLIB)/16_vl.h
268 test0.$(OBJ): $(SRC)/test0.c
269 pcxtest.$(OBJ):$(SRC)/pcxtest.c $(SRCLIB)/16_vl.h
270 vrstest.$(OBJ):$(SRC)/vrstest.c $(SRCLIB)/16_vl.h
271 #vgacamm.$(OBJ):$(SRC)/vgacamm.c $(SRCLIB)/16_vl.h
272 #planrpcx.$(OBJ): $(SRC)/planrpcx.c $(SRCLIB)/16_vl.h
273 pcxtest2.$(OBJ):$(SRC)/pcxtest2.c $(SRCLIB)/16_vl.h
274 palettec.$(OBJ): $(SRC)/palettec.c
275 palettel.$(OBJ): $(SRC)/palettel.c
276 palllist.$(OBJ): $(SRC)/palllist.c
277 maptest.$(OBJ):$(SRC)/maptest.c $(SRCLIB)/16_vl.h
278 #emmtest.$(OBJ):$(SRC)/emmtest.c
279 #emsdump.$(OBJ):$(SRC)/emsdump.c
280 fmemtest.$(OBJ):$(SRC)/fmemtest.c
281 fonttest.$(OBJ):$(SRC)/fonttest.c
282 #fonttes0.$(OBJ): $(SRC)/fonttes0.c
283 fontgfx.$(OBJ):$(SRC)/fontgfx.c
284 inputest.$(OBJ):$(SRC)/inputest.c
285 #sountest.$(OBJ): $(SRC)/sountest.c
286 #miditest.$(OBJ): $(SRC)/miditest.c
287 #testemm.$(OBJ):$(SRC)/testemm.c
288 #testemm0.$(OBJ): $(SRC)/testemm0.c
289 #tsthimem.$(OBJ): $(SRC)/tsthimem.c
290 exmmtest.$(OBJ):$(SRC)/exmmtest.c
291 vgmtest.$(OBJ):$(SRC)/vgmtest.c
292 db.$(OBJ): $(UTIL)/db.c
295 # non executable objects libraries
298 vgmsnd.lib: $(VGMSNDOBJ)
299 gfx.lib: $(GFXLIBOBJS)
301 doslib.lib: $(DOSLIBLIBS)
307 # library deps 16-bit large
308 $(DOSLIB_CPU)/$(DOSLIB_MEMMODE)/cpu.lib:
309 cd $(DOSLIB_CPU:$(to_os_path)) && $(DOSLIBMAKE) $(DOSLIB_MEMMODE) && cd $(BUILD_ROOT)
310 $(DOSLIB_DOS)/$(DOSLIB_MEMMODE)/dos.lib:
311 cd $(DOSLIB_DOS:$(to_os_path)) && $(DOSLIBMAKE) $(DOSLIB_MEMMODE) && cd $(BUILD_ROOT)
312 $(DOSLIB_VGA)/$(DOSLIB_MEMMODE)/vgatty.lib:
313 cd $(DOSLIB_VGA:$(to_os_path)) && $(DOSLIBMAKE) $(DOSLIB_MEMMODE) && cd $(BUILD_ROOT)
314 $(DOSLIB_VGA)/$(DOSLIB_MEMMODE)/vga.lib:
315 cd $(DOSLIB_VGA:$(to_os_path)) && $(DOSLIBMAKE) $(DOSLIB_MEMMODE) && cd $(BUILD_ROOT)
316 $(DOSLIB_8250)/$(DOSLIB_MEMMODE)/8250.lib:
317 cd $(DOSLIB_8250:$(to_os_path)) && $(DOSLIBMAKE) $(DOSLIB_MEMMODE) && cd $(BUILD_ROOT)
320 cd $(DOSLIB_JOYSTICK:$(to_os_path)) && $(DOSLIBMAKE) $(DOSLIB_MEMMODE) && cd $(BUILD_ROOT)
321 $(COPYCOMMAND) $(DOSLIB_JOYSTICK:$(to_os_path))$(DIRSEP)$(DOSLIB_MEMMODE)$(DIRSEP)test.exe joytest.exe
323 16_vl.$(OBJ): $(SRCLIB)/16_vl.c $(SRCLIB)/16_vl.h
324 16_vlpal.$(OBJ): $(SRCLIB)/16_vlpa_.c $(SRCLIB)/16_vlpal.c $(SRCLIB)/16_vlpal.h
325 bakapee.$(OBJ):$(SRCLIB)/bakapee.c $(SRCLIB)/bakapee.h
326 16render.$(OBJ):$(SRCLIB)/16render.c $(SRCLIB)/16render.h
327 16planar.$(OBJ):$(MODEXLIB16)/16planar.c $(MODEXLIB16)/16planar.h
328 16_vrs.$(OBJ): $(SRCLIB)/16_vrs.c $(SRCLIB)/16_vrs.h $(DOSLIB)
329 16_spri.$(OBJ):$(SRCLIB)/16_spri.c $(SRCLIB)/16_spri.h
330 bitmap.$(OBJ): $(SRCLIB)/bitmap.c $(SRCLIB)/bitmap.h
331 planar.$(OBJ): $(SRCLIB)/planar.c $(SRCLIB)/planar.h
332 scroll16.$(OBJ):$(SRCLIB)/scroll16.c $(SRCLIB)/scroll16.h
333 16text.$(OBJ): $(SRCLIB)/16text.c $(SRCLIB)/16text.h
334 16_enti.$(OBJ): $(SRCLIB)/16_enti.c $(SRCLIB)/16_enti.h
335 mapread.$(OBJ):$(SRCLIB)/mapread.c $(SRCLIB)/mapread.h
336 16_map.$(OBJ):$(SRCLIB)/16_map.c $(SRCLIB)/16_map.h
337 16_timer.$(OBJ):$(SRCLIB)/16_timer.c $(SRCLIB)/16_timer.h
338 16_in.$(OBJ): $(SRCLIB)/16_in.c $(SRCLIB)/16_in.h
339 16_rf.$(OBJ): $(SRCLIB)/16_rf.c $(SRCLIB)/16_rf.h
340 16_mm.$(OBJ): $(SRCLIB)/16_mm.c $(SRCLIB)/16_mm.h
341 16_pm.$(OBJ): $(SRCLIB)/16_pm.c $(SRCLIB)/16_pm.h
342 16_ca.$(OBJ): $(SRCLIB)/16_ca.c $(SRCLIB)/16_ca.h
343 16_dbg.$(OBJ): $(SRCLIB)/16_dbg.c $(SRCLIB)/16_dbg.h
344 midi.$(OBJ): $(SRCLIB)/midi.c $(SRCLIB)/midi.h
345 16_head.$(OBJ):$(SRCLIB)/16_head.c $(SRCLIB)/16_head.h
346 16_tail.$(OBJ):$(SRCLIB)/16_tail.c $(SRCLIB)/16_tail.h
347 16_hc.$(OBJ): $(SRCLIB)/16_hc.c $(SRCLIB)/16_hc.h
348 16_snd.$(OBJ): $(SRCLIB)/16_snd.c $(SRCLIB)/16_snd.h
349 jsmn.$(OBJ): $(JSMNLIB)/jsmn.c $(JSMNLIB)/jsmn.h
350 kitten.$(OBJ): $(NYANLIB)/kitten.c $(NYANLIB)/kitten.h
351 vgmSnd.$(OBJ): $(VGMSNDLIB)/vgmSnd.c $(VGMSNDLIB)/vgmSnd.h
352 16_wcpu.$(OBJ): $(WCPULIB)/16_wcpu.c $(WCPULIB)/16_wcpu.h
353 #memory.$(OBJ):$(EXMMLIB)/memory.c $(EXMMLIB)/memory.h
354 c_utils.$(OBJ):$(MODEXLIB)/c_utils.asm
355 modex.$(OBJ): $(MODEXLIB)/modex.asm
356 ll.$(OBJ): $(SRCLIB)/ll.c $(SRCLIB)/ll.h
362 @if not exist $(DOSLIBDIR)/buildall.sh wmake -h initlibs
363 @for %f in ($(EXEC)) do @if exist %f $(REMOVECOMMAND) %f
366 @. src/util/bcexmm.sh
368 @if exist *.OBJ $(REMOVECOMMAND) *.OBJ
370 @if exist *.o $(REMOVECOMMAND) *.o
372 @if exist *.$(OBJ) $(REMOVECOMMAND) *.$(OBJ)
373 @if exist *.bco $(REMOVECOMMAND) *.bco
374 @if exist *.BCO $(REMOVECOMMAND) *.BCO
375 @if exist *.LIB $(REMOVECOMMAND) *.LIB
376 @if exist *.lnk $(REMOVECOMMAND) *.lnk
377 @if exist *.LNK $(REMOVECOMMAND) *.LNK
378 @if exist *.smp $(REMOVECOMMAND) *.smp
379 @if exist *.SMP $(REMOVECOMMAND) *.SMP
380 @if exist *.hed $(REMOVECOMMAND) *.hed
381 @if exist *.mah $(REMOVECOMMAND) *.mah
382 @if exist *.MAH $(REMOVECOMMAND) *.MAH
383 @if exist *.err $(REMOVECOMMAND) *.err
384 @if exist TC*.SWP $(REMOVECOMMAND) TC*.SWP
385 # @if exist *.16W $(REMOVECOMMAND) *.16W
386 # @if exist *.16B $(REMOVECOMMAND) *.16B
388 # @$(COPYCOMMAND) $(SRC)exmmtest.c $(EXMMTESTDIR)$(SRC)
389 # @$(COPYCOMMAND) $(SRCLIB)16_mm.* $(EXMMTESTDIR)$(SRCLIB)
390 # @$(COPYCOMMAND) $(SRCLIB)16_head.* $(EXMMTESTDIR)$(SRCLIB)
391 # @$(COPYCOMMAND) $(SRCLIB)16_ca.* $(EXMMTESTDIR)$(SRCLIB)
392 # @$(COPYCOMMAND) $(SRCLIB)16_hc.* $(EXMMTESTDIR)$(SRCLIB)
393 # @$(COPYCOMMAND) $(SRCLIB)types.h $(EXMMTESTDIR)$(SRCLIB)
394 # @$(COPYCOMMAND) $(NYANLIB)* $(EXMMTESTDIR)$(NYANLIB)
402 backupconfig: .symbolic
403 @$(COPYCOMMAND) .git$(DIRSEP)config git_con.fig
404 @$(COPYCOMMAND) .gitmodules git_modu.les
405 @$(COPYCOMMAND) .gitignore git_igno.re
411 @*upx -9 $(UPXQ) $(EXEC)
414 @for %f in (/var/www/$(EXEC)) do @if exist /var/www/%f $(REMOVECOMMAND) /var/www/%f
415 @$(REMOVECOMMAND) /var/www/*.exe.zip*
416 @for %f in ($(EXEC)) do @if exist %f @$(COPYCOMMAND) %f /var/www/
417 @./src/util/z.sh $(EXEC) $(EXEC)
425 ####----@ssh -p $(HOSTPORT) $(HOSTUSER)@$(HOSTADDR) 'rm -f $(HOSTDIR)/16/*exe*'
427 @scp -r -P $(HOSTPORT) *.exe $(HOSTUSER)@$(HOSTADDR):$(HOSTDIR)/16/
428 @scp -r -P $(HOSTPORT) *get.bat $(HOSTUSER)@$(HOSTADDR):$(HOSTDIR)/16/
429 @scp -r -P $(HOSTPORT) /var/www/*.exe.zip.* $(HOSTUSER)@$(HOSTADDR):$(HOSTDIR)/16/
430 @scp -r -P $(HOSTPORT) $(DATADIR)spri.zip $(HOSTUSER)@$(HOSTADDR):$(HOSTDIR)/16/
434 @scp -r -P $(HOST2PORT) *.exe $(HOST2USER)@$(HOST2ADDR):$(HOST2DIR)/16/
435 @scp -r -P $(HOST2PORT) *get.bat $(HOST2USER)@$(HOST2ADDR):$(HOST2DIR)/16/
436 @scp -r -P $(HOST2PORT) /var/www/*.exe.zip.* $(HOST2USER)@$(HOST2ADDR):$(HOST2DIR)/16/
437 @scp -r -P $(HOST2PORT) $(DATADIR)spri.zip $(HOST2USER)@$(HOST2ADDR):$(HOST2DIR)/16/
443 @if exist *.err $(DUMP) *.err
446 ## External library management~ ^^
448 #git submodule add <repo>
450 @cd $(DOSLIBDIR:$(to_os_path))
451 @$(DOSLIBMAKEALL) $(DOSLIB_MEMMODE)
455 @cd $(DOSLIBDIR:$(to_os_path))
456 @$(DOSLIBMAKEALL) $(DOSLIB_MEMMODE) clean
460 @cd $(JSMNLIB:$(to_os_path))
463 @cd $(DOSLIBDIR:$(to_os_path))
467 reinitlibs: .symbolic
468 @$(REMOVECOMMAND) -rf $(DOSLIBDIR)
469 @$(REMOVECOMMAND) -rf $(JSMNLIB)
470 @$(REMOVECOMMAND) -rf 16/CatacombApocalypse
471 @$(REMOVECOMMAND) -rf 16/wolf3d
472 @$(REMOVECOMMAND) -rf 16/keen
473 @$(REMOVECOMMAND) -rf 16/Catacomb3D
477 @$(COPYCOMMAND) git_con.fig .git/config
478 @$(COPYCOMMAND) git_modu.les .gitmodules
479 @$(COPYCOMMAND) git_igno.re .gitignore
482 @git clone https://github.com/FlatRockSoft/CatacombApocalypse.git
483 @git clone https://github.com/id-Software/wolf3d.git
484 @git clone https://github.com/keendreams/keen.git
485 @git clone https://github.com/FlatRockSoft/Catacomb3D.git
487 @$(COPYCOMMAND) $(DOSLIBDIR)/make-lowercase .
490 @cd $(SRCLIB:$(to_os_path))
491 @git clone https://github.com/joncampbell123/doslib.git
492 @git clone https://github.com/zserge/jsmn.git
512 @wmake -h -f makefile all
518 @cd $(DOSLIB_VGA:$(to_os_path))
521 @for %f in ($(SPRIUTILEXEC)) do @if exist %f $(COPYCOMMAND) %f $(BUILD_ROOT)#$(DIRSEP)