	# Hand-written makefile for Open Watcom, because Chocolate Doom is kind of complicated and Open Watcom's Posix-compatible-ish interface is a little bit terrible. 
	# Basically I just hope to god I can throw all the source files at wcl386 and it'll work. 
	# Eventually I'll have to fight it down into wcl for an 8088 (8086?) / 640K version, but first I need the damn thing to compile an EXE instead of a COM file. 
	# This is using the DOS/32A extender (for now), and I'm not sure why the license tells you to say that when it immediately announces itself at launch. 

# https://flaterco.com/kb/ow.html
# This brief guide is more useful than any Open Watcom documentation. OW's webpage about error codes just rephrases the label that the linker already told you. Their "programmer's guide" is somehow incredibly verbose and wide-reaching without saying anything you're actually looking for - an expertly cultivated mixture of excessively low-level details and broad sweeping indications which altogether avoids revealing how one might misuse their compiler to emit an executable. 

# Files originally in src/doom, because OWCC choked on libdoom.a. 

DOOM_DIR_FILES =             \
am_map.c           am_map.h     \
deh_ammo.c                      \
deh_bexstr.c                    \
deh_cheat.c                     \
deh_doom.c                      \
deh_frame.c                     \
deh_misc.c         deh_misc.h   \
deh_ptr.c                       \
deh_sound.c                     \
deh_thing.c                     \
deh_weapon.c                    \
                   d_englsh.h   \
d_items.c          d_items.h    \
d_main.c           d_main.h     \
d_net.c                         \
                   doomdata.h   \
doomdef.c          doomdef.h    \
doomstat.c         doomstat.h   \
                   d_player.h   \
dstrings.c         dstrings.h   \
                   d_textur.h   \
                   d_think.h    \
f_finale.c         f_finale.h   \
f_wipe.c           f_wipe.h     \
g_game.c           g_game.h     \
hu_lib.c           hu_lib.h     \
hu_stuff.c         hu_stuff.h   \
info.c             info.h       \
m_menu.c           m_menu.h     \
m_random.c         m_random.h   \
p_ceilng.c                      \
p_doors.c                       \
p_enemy.c                       \
p_floor.c                       \
p_inter.c          p_inter.h    \
p_lights.c                      \
                   p_local.h    \
p_map.c                         \
p_maputl.c                      \
p_mobj.c           p_mobj.h     \
p_plats.c                       \
p_pspr.c           p_pspr.h     \
p_saveg.c          p_saveg.h    \
p_setup.c          p_setup.h    \
p_sight.c                       \
p_spec.c           p_spec.h     \
p_switch.c                      \
p_telept.c                      \
p_tick.c           p_tick.h     \
p_user.c                        \
r_bsp.c            r_bsp.h      \
r_data.c           r_data.h     \
                   r_defs.h     \
r_draw.c           r_draw.h     \
                   r_local.h    \
r_main.c           r_main.h     \
r_plane.c          r_plane.h    \
r_segs.c           r_segs.h     \
r_sky.c            r_sky.h      \
                   r_state.h    \
r_things.c         r_things.h   \
s_sound.c          s_sound.h    \
sounds.c           sounds.h     \
statdump.c         statdump.h   \
st_lib.c           st_lib.h     \
st_stuff.c         st_stuff.h   \
wi_stuff.c         wi_stuff.h

# Common source files used by absolutely everything:

COMMON_SOURCE_FILES=\
i_main.c                                   \
i_system.c           i_system.h            \
m_argv.c             m_argv.h              \
m_misc.c             m_misc.h

# Source files used by the game binaries (chocolate-doom, etc.)

GAME_SOURCE_FILES=\
aes_prng.c           aes_prng.h            \
d_event.c            d_event.h             \
                     doomkeys.h            \
                     doomtype.h            \
d_iwad.c             d_iwad.h              \
d_loop.c             d_loop.h              \
d_mode.c             d_mode.h              \
                     d_ticcmd.h            \
deh_str.c            deh_str.h             \
gusconf.c            gusconf.h             \
i_endoom.c           i_endoom.h            \
i_input.c            i_input.h             \
                     i_swap.h              \
i_midipipe.c         i_midipipe.h          \
i_sdlmusic.c                               \
i_sdlsound.c                               \
i_sound.c            i_sound.h             \
i_timer.c            i_timer.h             \
i_video.c            i_video.h             \
midifile.c           midifile.h            \
mus2mid.c            mus2mid.h             \
m_bbox.c             m_bbox.h              \
m_cheat.c            m_cheat.h             \
m_config.c           m_config.h            \
m_controls.c         m_controls.h          \
m_fixed.c            m_fixed.h             \
sha1.c               sha1.h                \
memio.c              memio.h               \
tables.c             tables.h              \
v_diskicon.c         v_diskicon.h          \
v_video.c            v_video.h             \
                     v_patch.h             \
w_checksum.c         w_checksum.h          \
w_main.c             w_main.h              \
w_wad.c              w_wad.h               \
w_file.c             w_file.h              \
w_file_stdc.c                              \
w_file_posix.c                             \
w_file_win32.c                             \
w_merge.c            w_merge.h             \
z_zone.c             z_zone.h

DEHACKED_SOURCE_FILES =                    \
deh_defs.h                                 \
deh_io.c             deh_io.h              \
deh_main.c           deh_main.h            \
deh_mapping.c        deh_mapping.h         \
deh_text.c



# Formatting notes:
# -3 is 386 mode. Mostly those options are obvious: -0 for 8086, -2 for 286, you get the idea. 
# -mf is "memory = flat," which is XMS. Protected mode. Anything between 640K and 4GB. 
# stub32x is the DOS/32A extender, standing in for DOS/4GW. I have no strong opinions either way. 

# You may have to run this as "make -f wcl-makefile -B" because otherwise WCL insists everything's up-to-date. Always. I'm not sure if it's a Linux timestamp thing or if Open Watcom is inherently dodgy. 

# God, that is hideously unreadable. There's a full copyright notice printed for every fucking input file - so any relevant information is buried in the middle of a block of identical text. 
	# Mostly 'missing type' errors. Really, fuck Chocolate Doom for doing everything from a parent directly, and calling into src/ and src/doom/ and so on, also into directories parallel with src/, because it has been a goddamn NIGHTMARE finding out all the places they hid another Makefile.am that includes more fucking files that need more fucking libraries. I put config.h and config.hin into src/ just so it'd stop generating a .err file here for every single file. Now it's bitching like doomtype.h isn't RIGHT THERE. 

cdoom.exe:
	wcl386 -3 -mf -bt=dos -l=stub32x -fe=cdoom.exe $(COMMON_SOURCE_FILES) $(GAME_SOURCE_FILES) $(DOOM_DIR_FILES) $(DEHACKED_SOURCE_FILES) 

#libdoom_a_SOURCES = $(DOOM_DIR_FILES)

#libdoom.a:
#	wcl386 -3 -mf -bt=dos $(DOOM_DIR_FILES) 

#SUBDIRS=src

#gccdoom:
#	gcc config.h config.hin $(DOOM_DIR_FILES) $(COMMON_SOURCE_FILES) $(GAME_SOURCE_FILES) $(DEHACKED_SOURCE_FILES) 







