#
# possible make targets:
#
# make			-- build default os targeted #ud.exe
# make #udd.exe		-- dos
# make #uddw.exe	-- DOS/NT RSX32
# make #udw.exe		-- Win32/GUI
# make clean		-- cleanup
#

CFLAGS = -Wall -pedantic -O3 -fomit-frame-pointer -DNDEBUG -D_NO_COM

PROJECT = \#ud

# default target

$(PROJECT).exe : $(PROJECT).c
	gcc -s -o $@ $(CFLAGS) $<

# dos

$(PROJECT)d.exe : $(PROJECT)d.o
	gcc -s -o $@ -mcpu=i686 $(CFLAGS) $(PROJECT)d.o

$(PROJECT)d.o : $(PROJECT).c
	gcc -c -o $@ -mcpu=i686 $(CFLAGS) $<


# win32 console

$(PROJECT)dw.exe : $(PROJECT)dw.o $(PROJECT)dw.res
	gccw32 -Zrsx32 -o $@ -mcpu=i686 $(CFLAGS) $(PROJECT)dw.o
	rsrc $(PROJECT)dw.res $@

$(PROJECT)dw.res : udw.rc
	grc -o $@ $<

$(PROJECT)dw.o : $(PROJECT).c
	gccw32 -Zrsx32 -c -o $@ -mcpu=i686 $(CFLAGS) $<

# win32 gui

$(PROJECT)w.exe : $(PROJECT)w.o $(PROJECT)w.res
	gccw32 -Zsys -D_WINDOWS -o $@ -mcpu=i686 $(CFLAGS) $(PROJECT)w.o -lcomdlg32 -lshell32 -luser32 -lcomctl32
	rsrc $(PROJECT)w.res $@

$(PROJECT)w.res : udw.rc
	rc -D_WINDOWS -D_NO_COM -fo $@ $<

$(PROJECT)w.o : $(PROJECT).c
	gccw32 -Zsys -D_WINDOWS -c -o $@ -mcpu=i686 $(CFLAGS) $<

clean:
	rm -f $(PROJECT)*.exe
	rm -f $(PROJECT)*.o
	rm -f $(PROJECT)*.res
