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) 16text.$(OBJ) bakapee.$(OBJ) scroll16.$(OBJ) 16_vrs.$(OBJ) 16_sprit.$(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)
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 bakapee.$(OBJ):$(SRCLIB)/bakapee.c $(SRCLIB)/bakapee.h
325 16render.$(OBJ):$(SRCLIB)/16render.c $(SRCLIB)/16render.h
326 16planar.$(OBJ):$(MODEXLIB16)/16planar.c $(MODEXLIB16)/16planar.h
327 16_vrs.$(OBJ): $(SRCLIB)/16_vrs.c $(SRCLIB)/16_vrs.h $(DOSLIB)
328 16_sprit.$(OBJ):$(SRCLIB)/16_sprit.c $(SRCLIB)/16_sprit.h
329 bitmap.$(OBJ): $(SRCLIB)/bitmap.c $(SRCLIB)/bitmap.h
330 planar.$(OBJ): $(SRCLIB)/planar.c $(SRCLIB)/planar.h
331 scroll16.$(OBJ):$(SRCLIB)/scroll16.c $(SRCLIB)/scroll16.h
332 16text.$(OBJ): $(SRCLIB)/16text.c $(SRCLIB)/16text.h
333 16_enti.$(OBJ): $(SRCLIB)/16_enti.c $(SRCLIB)/16_enti.h
334 mapread.$(OBJ):$(SRCLIB)/mapread.c $(SRCLIB)/mapread.h
335 16_map.$(OBJ):$(SRCLIB)/16_map.c $(SRCLIB)/16_map.h
336 16_timer.$(OBJ):$(SRCLIB)/16_timer.c $(SRCLIB)/16_timer.h
337 16_in.$(OBJ): $(SRCLIB)/16_in.c $(SRCLIB)/16_in.h
338 16_rf.$(OBJ): $(SRCLIB)/16_rf.c $(SRCLIB)/16_rf.h
339 16_mm.$(OBJ): $(SRCLIB)/16_mm.c $(SRCLIB)/16_mm.h
340 16_pm.$(OBJ): $(SRCLIB)/16_pm.c $(SRCLIB)/16_pm.h
341 16_ca.$(OBJ): $(SRCLIB)/16_ca.c $(SRCLIB)/16_ca.h
342 16_dbg.$(OBJ): $(SRCLIB)/16_dbg.c $(SRCLIB)/16_dbg.h
343 midi.$(OBJ): $(SRCLIB)/midi.c $(SRCLIB)/midi.h
344 16_head.$(OBJ):$(SRCLIB)/16_head.c $(SRCLIB)/16_head.h
345 16_tail.$(OBJ):$(SRCLIB)/16_tail.c $(SRCLIB)/16_tail.h
346 16_hc.$(OBJ): $(SRCLIB)/16_hc.c $(SRCLIB)/16_hc.h
347 16_snd.$(OBJ): $(SRCLIB)/16_snd.c $(SRCLIB)/16_snd.h
348 jsmn.$(OBJ): $(JSMNLIB)/jsmn.c $(JSMNLIB)/jsmn.h
349 kitten.$(OBJ): $(NYANLIB)/kitten.c $(NYANLIB)/kitten.h
350 vgmSnd.$(OBJ): $(VGMSNDLIB)/vgmSnd.c $(VGMSNDLIB)/vgmSnd.h
351 16_wcpu.$(OBJ): $(WCPULIB)/16_wcpu.c $(WCPULIB)/16_wcpu.h
352 #memory.$(OBJ):$(EXMMLIB)/memory.c $(EXMMLIB)/memory.h
353 c_utils.$(OBJ):$(MODEXLIB)/c_utils.asm
354 modex.$(OBJ): $(MODEXLIB)/modex.asm
360 @if not exist $(DOSLIBDIR)/buildall.sh wmake -h initlibs
361 @for %f in ($(EXEC)) do @if exist %f $(REMOVECOMMAND) %f
364 @. src/util/bcexmm.sh
366 @if exist *.OBJ $(REMOVECOMMAND) *.OBJ
368 @if exist *.o $(REMOVECOMMAND) *.o
370 @if exist *.$(OBJ) $(REMOVECOMMAND) *.$(OBJ)
371 @if exist *.bco $(REMOVECOMMAND) *.bco
372 @if exist *.BCO $(REMOVECOMMAND) *.BCO
373 @if exist *.LIB $(REMOVECOMMAND) *.LIB
374 @if exist *.lnk $(REMOVECOMMAND) *.lnk
375 @if exist *.LNK $(REMOVECOMMAND) *.LNK
376 @if exist *.smp $(REMOVECOMMAND) *.smp
377 @if exist *.SMP $(REMOVECOMMAND) *.SMP
378 @if exist *.hed $(REMOVECOMMAND) *.hed
379 @if exist *.mah $(REMOVECOMMAND) *.mah
380 @if exist *.MAH $(REMOVECOMMAND) *.MAH
381 @if exist *.err $(REMOVECOMMAND) *.err
382 # @if exist *.16W $(REMOVECOMMAND) *.16W
383 # @if exist *.16B $(REMOVECOMMAND) *.16B
385 # @$(COPYCOMMAND) $(SRC)exmmtest.c $(EXMMTESTDIR)$(SRC)
386 # @$(COPYCOMMAND) $(SRCLIB)16_mm.* $(EXMMTESTDIR)$(SRCLIB)
387 # @$(COPYCOMMAND) $(SRCLIB)16_head.* $(EXMMTESTDIR)$(SRCLIB)
388 # @$(COPYCOMMAND) $(SRCLIB)16_ca.* $(EXMMTESTDIR)$(SRCLIB)
389 # @$(COPYCOMMAND) $(SRCLIB)16_hc.* $(EXMMTESTDIR)$(SRCLIB)
390 # @$(COPYCOMMAND) $(SRCLIB)types.h $(EXMMTESTDIR)$(SRCLIB)
391 # @$(COPYCOMMAND) $(NYANLIB)* $(EXMMTESTDIR)$(NYANLIB)
399 backupconfig: .symbolic
400 @$(COPYCOMMAND) .git$(DIRSEP)config git_con.fig
401 @$(COPYCOMMAND) .gitmodules git_modu.les
402 @$(COPYCOMMAND) .gitignore git_igno.re
408 @*upx -9 $(UPXQ) $(EXEC)
411 @for %f in (/var/www/$(EXEC)) do @if exist /var/www/%f $(REMOVECOMMAND) /var/www/%f
412 @$(REMOVECOMMAND) /var/www/*.exe.zip*
413 @for %f in ($(EXEC)) do @if exist %f @$(COPYCOMMAND) %f /var/www/
414 @./src/util/z.sh $(EXEC) $(EXEC)
418 ####----@ssh -p $(HOSTPORT) $(HOSTUSER)@$(HOSTADDR) 'rm -f $(HOSTDIR)/16/*exe*'
420 @scp -r -P $(HOSTPORT) *.exe $(HOSTUSER)@$(HOSTADDR):$(HOSTDIR)/16/
421 @scp -r -P $(HOSTPORT) *get.bat $(HOSTUSER)@$(HOSTADDR):$(HOSTDIR)/16/
422 @scp -r -P $(HOSTPORT) /var/www/*.exe.zip.* $(HOSTUSER)@$(HOSTADDR):$(HOSTDIR)/16/
423 @scp -r -P $(HOSTPORT) $(DATADIR)spri.zip $(HOSTUSER)@$(HOSTADDR):$(HOSTDIR)/16/
425 @scp -r -P $(HOST2PORT) *.exe $(HOST2USER)@$(HOST2ADDR):$(HOST2DIR)/16/
426 @scp -r -P $(HOST2PORT) *get.bat $(HOST2USER)@$(HOST2ADDR):$(HOST2DIR)/16/
427 @scp -r -P $(HOST2PORT) /var/www/*.exe.zip.* $(HOST2USER)@$(HOST2ADDR):$(HOST2DIR)/16/
428 @scp -r -P $(HOST2PORT) $(DATADIR)spri.zip $(HOST2USER)@$(HOST2ADDR):$(HOST2DIR)/16/
434 @if exist *.err $(DUMP) *.err
437 ## External library management~ ^^
439 #git submodule add <repo>
441 @cd $(DOSLIBDIR:$(to_os_path))
442 @$(DOSLIBMAKEALL) $(DOSLIB_MEMMODE)
446 @cd $(DOSLIBDIR:$(to_os_path))
447 @$(DOSLIBMAKEALL) $(DOSLIB_MEMMODE) clean
451 @cd $(JSMNLIB:$(to_os_path))
454 @cd $(DOSLIBDIR:$(to_os_path))
458 reinitlibs: .symbolic
459 @$(REMOVECOMMAND) -rf $(DOSLIBDIR)
460 @$(REMOVECOMMAND) -rf $(JSMNLIB)
461 @$(REMOVECOMMAND) -rf 16/CatacombApocalypse
462 @$(REMOVECOMMAND) -rf 16/wolf3d
463 @$(REMOVECOMMAND) -rf 16/keen
464 @$(REMOVECOMMAND) -rf 16/Catacomb3D
468 @$(COPYCOMMAND) git_con.fig .git/config
469 @$(COPYCOMMAND) git_modu.les .gitmodules
470 @$(COPYCOMMAND) git_igno.re .gitignore
473 @git clone https://github.com/FlatRockSoft/CatacombApocalypse.git
474 @git clone https://github.com/id-Software/wolf3d.git
475 @git clone https://github.com/keendreams/keen.git
476 @git clone https://github.com/FlatRockSoft/Catacomb3D.git
478 @$(COPYCOMMAND) $(DOSLIBDIR)/make-lowercase .
481 @cd $(SRCLIB:$(to_os_path))
482 @git clone https://github.com/joncampbell123/doslib.git
483 @git clone https://github.com/zserge/jsmn.git
503 @wmake -h -f makefile all
509 @cd $(DOSLIB_VGA:$(to_os_path))
512 @for %f in ($(SPRIUTILEXEC)) do @if exist %f $(COPYCOMMAND) %f $(BUILD_ROOT)#$(DIRSEP)