#
# UnrealIRCd Makefile - codemastr
#
CC=cl
LINK=link
RC=rc

############################ USER CONFIGURATION ############################

##### REMOTE INCLUDES ####
#To enable remote include support you must have libcurl installed on your
#system and it must have ares support enabled.
#
#
#To enable remote includes uncomment the next line:
#USE_REMOTEINC=1
#
#If your libcurl library and include files are not in your compiler's
#default locations, specify the locations here:
#LIBCURL_INC_DIR="c:\dev\curl\include"
#LIBCURL_LIB_DIR="c:\dev\curl\lib"
#
#
### END REMOTE INCLUDES ##

#### ZIPLINKS SUPPORT ####
#To enable ziplinks support you must have zlib installed on your system
#you can get a pre-built zlib library from http://www.winimage.com/zLibDll/
#
#
#To enable ziplinks uncomment the next line:
#USE_ZIPLINKS=1
#
#If your zlib library and include files are not in your compiler's
#default locations, specify the locations here:
#ZLIB_INC_DIR="c:\dev\zlib"
#ZLIB_LIB_DIR="c:\dev\zlib\dll32"
#
#
###### END ZIPLINKS ######

####### SSL SUPPORT ######
#To enable SSL support you must have OpenSSL installed on your system
#
#
#To enable SSL uncomment the next line:
#USE_SSL=1
#
#If your OpenSSL library and include files are not in your compiler's
#default locations, specify the locations here:
#OPENSSL_INC_DIR="c:\openssl\include"
#OPENSSL_LIB_DIR="c:\openssl\lib"
#
#
######### END SSL ########

###### _EXTRA_ DEBUGGING #####
# We always build releases with debugging information, since otherwise
# we cannot trace the source of a crash. Plus we do not mind the extra
# performance hit caused by not enabling super-optimization, tracing
# crashes properly is more important.
# You can choose (at your own risk) to enable EVEN MORE debugging,
# note that this causes /MDd to be used instead of /MD which can make
# libraries incompatible, plus all the other side-effects such as
# requiring a different dll we do not ship (and maybe you are not even
# allowed to ship due to license agreements), etc...
# In any case, this probably should not be used, unless debugging a
# problem locally, in which case it can be useful.
#DEBUGEXTRA=1
#
#
#### END RELEASE BUILD ###

############################# END CONFIGURATION ############################

!IFDEF USE_REMOTEINC
CURLCFLAGS=/D USE_LIBCURL
CURLOBJ=SRC/URL.OBJ
CURLLIB=libcurl.lib
!IFDEF LIBCURL_INC_DIR
LIBCURL_INC=/I "$(LIBCURL_INC_DIR)"
!ENDIF
!IFDEF LIBCURL_LIB_DIR
LIBCURL_LIB=/LIBPATH:"$(LIBCURL_LIB_DIR)"
!ENDIF
!ENDIF

!IFDEF USE_ZIPLINKS
ZIPCFLAGS=/D ZIP_LINKS /D ZLIB_DLL
ZIPOBJ=SRC/ZIP.OBJ
ZIPLIB=zlibwapi.lib
!IFDEF ZLIB_INC_DIR
ZLIB_INC=/I "$(ZLIB_INC_DIR)"
!ENDIF
!IFDEF ZLIB_LIB_DIR
ZLIB_LIB=/LIBPATH:"$(ZLIB_LIB_DIR)"
!ENDIF
!ENDIF

!IFDEF USE_SSL
SSLCFLAGS=/D USE_SSL
SSLLIBS=ssleay32.lib libeay32.lib
!IFDEF OPENSSL_INC_DIR
OPENSSL_INC=/I "$(OPENSSL_INC_DIR)"
!ENDIF
!IFDEF OPENSSL_LIB_DIR
OPENSSL_LIB=/LIBPATH:"$(OPENSSL_LIB_DIR)"
!ENDIF
!ENDIF

!IFDEF DEBUGEXTRA
DBGCFLAG=/MDd /Zi /Od
DBGLFLAG=/debug
MODDBGCFLAG=/LDd /MDd /Zi
!ELSE
DBGCFLAG=/MD /Zi
DBGLFLAG=/debug
MODDBGCFLAG=/LDd /MD /Zi
!ENDIF 

FD_SETSIZE=/D FD_SETSIZE=16384
CFLAGS=$(DBGCFLAG) $(LIBCURL_INC) $(ZLIB_INC) $(OPENSSL_INC) /J /I ./INCLUDE /I ./INCLUDE/WIN32/ARES /Fosrc/ /nologo \
 $(ZIPCFLAGS) $(CURLCFLAGS) $(FD_SETSIZE) $(SSLCFLAGS) $(NS_ADDRESS) /D NOSPOOF=1 /c /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _USE_32BIT_TIME_T
LFLAGS=kernel32.lib user32.lib gdi32.lib shell32.lib ws2_32.lib advapi32.lib \
 dbghelp.lib oldnames.lib comctl32.lib comdlg32.lib $(ZLIB_LIB) $(ZIPLIB) \
 $(OPENSSL_LIB) $(SSLLIBS) $(LIBCURL_LIB) $(CURLLIB) /def:wircd.def /implib:wircd.lib \
 /nologo $(DBGLFLAG) /out:WIRCD.EXE
MODCFLAGS=$(MODDBGCFLAG) $(SSLCFLAGS) $(ZIPCFLAGS) $(CURLCFLAGS) /J /Fesrc/modules/ \
 /Fosrc/modules/ /nologo $(LIBCURL_INC) $(ZLIB_INC) $(OPENSSL_INC) /I ./INCLUDE /D \
 DYNAMIC_LINKING /D NOSPOOF /D MODULE_COMPILE /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _USE_32BIT_TIME_T
MODLFLAGS=/link /def:src/modules/module.def wircd.lib $(OPENSSL_LIB) $(SSLLIBS) \
 $(ZLIB_LIB) $(ZIPLIB) $(LIBCURL_LIB) $(CURLLIB)

INCLUDES=./include/struct.h ./include/config.h ./include/sys.h \
 ./include/common.h ./include/version.h ./include/h.h ./include/numeric.h \
 ./include/msg.h ./include/setup.h ./include/dynconf.h

EXP_OBJ_FILES=SRC/CHANNEL.OBJ SRC/SEND.OBJ SRC/SOCKET.OBJ \
 SRC/S_CONF.OBJ SRC/FDLIST.OBJ SRC/DBUF.OBJ  \
 SRC/CLOAK.OBJ SRC/HASH.OBJ SRC/PARSE.OBJ SRC/IRCD.OBJ \
 SRC/S_NUMERIC.OBJ SRC/WHOWAS.OBJ  SRC/S_AUTH.OBJ \
 SRC/HELP.OBJ SRC/S_MISC.OBJ SRC/MATCH.OBJ SRC/CRULE.OBJ \
 SRC/S_DEBUG.OBJ  SRC/SUPPORT.OBJ SRC/LIST.OBJ \
 SRC/S_ERR.OBJ SRC/PACKET.OBJ SRC/S_BSD.OBJ \
 SRC/S_SERV.OBJ SRC/S_USER.OBJ SRC/CHARSYS.OBJ \
 SRC/VERSION.OBJ SRC/S_KLINE.OBJ SRC/S_EXTRA.OBJ SRC/IRCSPRINTF.OBJ SRC/LUSERS.OBJ \
 SRC/SCACHE.OBJ SRC/ALN.OBJ SRC/RES.OBJ SRC/MODULES.OBJ \
 SRC/S_SVS.OBJ SRC/EVENTS.OBJ SRC/UMODES.OBJ SRC/AUTH.OBJ SRC/CIDR.OBJ SRC/SSL.OBJ \
 SRC/RANDOM.OBJ SRC/EXTCMODES.OBJ SRC/MD5.OBJ SRC/API-ISUPPORT.OBJ SRC/API-COMMAND.OBJ \
 SRC/EXTBANS.OBJ SRC/TIMESYNCH.OBJ $(ZIPOBJ) $(CURLOBJ)

OBJ_FILES=$(EXP_OBJ_FILES) SRC/GUI.OBJ SRC/SERVICE.OBJ SRC/DEBUG.OBJ SRC/RTF.OBJ \
 SRC/EDITOR.OBJ SRC/WIN32.OBJ 

MOD_FILES=SRC/MODULES/L_COMMANDS.C SRC/MODULES/M_CHGHOST.C SRC/MODULES/M_SDESC.C \
 SRC/MODULES/M_SETIDENT.C SRC/MODULES/M_SETNAME.C SRC/MODULES/M_SETHOST.C \
 SRC/MODULES/M_CHGIDENT.C SRC/MODULES/M_SVSMOTD.C SRC/MODULES/M_SVSNLINE.C \
 SRC/MODULES/M_WHO.C SRC/MODULES/M_SWHOIS.C SRC/MODULES/M_SVSMODE.C SRC/MODULES/M_AWAY.C \
 SRC/MODULES/M_SVSNOOP.C SRC/MODULES/M_MKPASSWD.C SRC/MODULES/M_SVSO.C \
 SRC/MODULES/M_SVSNICK.C SRC/MODULES/M_ADMINCHAT.C SRC/MODULES/M_AKILL.C \
 SRC/MODULES/M_CHGNAME.C SRC/MODULES/M_GUEST.C SRC/MODULES/M_HTM.C SRC/MODULES/M_LAG.C \
 SRC/MODULES/M_MESSAGE.C SRC/MODULES/WEBTV.C SRC/MODULES/M_NACHAT.C SRC/MODULES/M_OPER.C \
 SRC/MODULES/M_PINGPONG.C SRC/MODULES/M_QUIT.C SRC/MODULES/M_RAKILL.C SRC/MODULES/M_RPING.C \
 SRC/MODULES/M_SENDUMODE.C SRC/MODULES/M_SQLINE.C SRC/MODULES/M_KILL.C \
 SRC/MODULES/M_TSCTL.C SRC/MODULES/M_UNKLINE.C SRC/MODULES/M_UNSQLINE.C \
 SRC/MODULES/M_UNZLINE.C SRC/MODULES/M_WHOIS.C SRC/MODULES/M_TKL.C SRC/MODULES/M_VHOST.C \
 SRC/MODULES/M_CYCLE.C SRC/MODULES/M_SVSJOIN.C SRC/MODULES/M_SVSPART.C \
 SRC/MODULES/M_SVSLUSERS.C SRC/MODULES/M_SVSWATCH.C SRC/MODULES/M_SVSSILENCE.C \
 SRC/MODULES/M_SENDSNO.C SRC/MODULES/M_SVSSNO.C SRC/MODULES/M_SAJOIN.C \
 SRC/MODULES/M_SAPART.C SRC/MODULES/M_SAMODE.C SRC/MODULES/M_KICK.C SRC/MODULES/M_TOPIC.C \
 SRC/MODULES/M_INVITE.C SRC/MODULES/M_LIST.C SRC/MODULES/M_TIME.C SRC/MODULES/M_SVSKILL.C \
 SRC/MODULES/M_KNOCK.C SRC/MODULES/M_UMODE2.C SRC/MODULES/M_SQUIT.C \
 SRC/MODULES/M_PROTOCTL.C SRC/MODULES/M_SJOIN.C SRC/MODULES/M_PASS.C \
 SRC/MODULES/M_USERHOST.C SRC/MODULES/M_ISON.C SRC/MODULES/M_SILENCE.C \
 SRC/MODULES/M_ADDLINE.C SRC/MODULES/M_ADDMOTD.C SRC/MODULES/M_ADDOMOTD.C \
 SRC/MODULES/M_WALLOPS.C SRC/MODULES/M_GLOBOPS.C SRC/MODULES/M_LOCOPS.C \
 SRC/MODULES/M_CHATOPS.C SRC/MODULES/M_ADMIN.C SRC/MODULES/M_TRACE.C \
 SRC/MODULES/M_NETINFO.C SRC/MODULES/M_LINKS.C SRC/MODULES/M_HELP.C \
 SRC/MODULES/M_RULES.C SRC/MODULES/M_CLOSE.C SRC/MODULES/M_MAP.C SRC/MODULES/M_EOS.C \
 SRC/MODULES/M_SERVER.C SRC/MODULES/M_STATS.C SRC/MODULES/M_SVSFLINE.C \
 SRC/MODULES/M_DCCDENY.C SRC/MODULES/M_UNDCCDENY.C SRC/MODULES/M_WHOWAS.C \
 SRC/MODULES/M_CONNECT.C SRC/MODULES/M_DCCALLOW.C SRC/MODULES/M_USERIP.C \
 SRC/MODULES/M_NICK.C SRC/MODULES/M_USER.C SRC/MODULES/M_MODE.C \
 SRC/MODULES/M_WATCH.C SRC/MODULES/M_PART.C SRC/MODULES/M_JOIN.C \
 SRC/MODULES/M_MOTD.C SRC/MODULES/M_OPERMOTD.C SRC/MODULES/M_BOTMOTD.C \
 SRC/MODULES/M_LUSERS.C SRC/MODULES/M_NAMES.C

DLL_FILES=SRC/MODULES/M_CHGHOST.DLL SRC/MODULES/M_SDESC.DLL SRC/MODULES/M_SETIDENT.DLL \
 SRC/MODULES/M_SETNAME.DLL SRC/MODULES/M_SETHOST.DLL SRC/MODULES/M_CHGIDENT.DLL \
 SRC/MODULES/M_SVSMOTD.DLL SRC/MODULES/M_SVSNLINE.DLL SRC/MODULES/M_WHO.DLL \
 SRC/MODULES/M_SWHOIS.DLL SRC/MODULES/M_SVSMODE.DLL SRC/MODULES/M_AWAY.DLL \
 SRC/MODULES/M_SVSNOOP.DLL SRC/MODULES/M_MKPASSWD.DLL SRC/MODULES/M_SVSO.DLL \
 SRC/MODULES/M_SVSNICK.DLL SRC/MODULES/M_ADMINCHAT.DLL SRC/MODULES/M_AKILL.DLL \
 SRC/MODULES/M_CHGNAME.DLL SRC/MODULES/M_GUEST.DLL SRC/MODULES/M_HTM.DLL \
 SRC/MODULES/M_LAG.DLL SRC/MODULES/M_MESSAGE.DLL SRC/MODULES/M_NACHAT.DLL \
 SRC/MODULES/M_OPER.DLL SRC/MODULES/M_PINGPONG.DLL SRC/MODULES/M_QUIT.DLL \
 SRC/MODULES/M_RAKILL.DLL SRC/MODULES/M_RPING.DLL SRC/MODULES/M_SENDUMODE.DLL \
 SRC/MODULES/M_SQLINE.DLL SRC/MODULES/M_KILL.DLL SRC/MODULES/M_TSCTL.DLL \
 SRC/MODULES/M_UNKLINE.DLL SRC/MODULES/M_UNSQLINE.DLL SRC/MODULES/M_UNZLINE.DLL \
 SRC/MODULES/M_WHOIS.DLL SRC/MODULES/M_TKL.DLL SRC/MODULES/M_VHOST.DLL \
 SRC/MODULES/M_CYCLE.DLL SRC/MODULES/M_SVSJOIN.DLL SRC/MODULES/M_SVSPART.DLL \
 SRC/MODULES/M_SVSLUSERS.DLL SRC/MODULES/M_SVSWATCH.DLL SRC/MODULES/M_SVSSILENCE.DLL \
 SRC/MODULES/M_SENDSNO.DLL SRC/MODULES/M_SVSSNO.DLL SRC/MODULES/M_SAJOIN.DLL \
 SRC/MODULES/M_SAPART.DLL SRC/MODULES/M_SAMODE.DLL SRC/MODULES/M_KICK.DLL \
 SRC/MODULES/M_TOPIC.DLL SRC/MODULES/M_INVITE.DLL SRC/MODULES/M_LIST.DLL \
 SRC/MODULES/M_TIME.DLL SRC/MODULES/M_SVSKILL.DLL SRC/MODULES/M_KNOCK.DLL \
 SRC/MODULES/M_UMODE2.DLL SRC/MODULES/M_SQUIT.DLL SRC/MODULES/M_PROTOCTL.DLL \
 SRC/MODULES/M_SJOIN.DLL SRC/MODULES/M_PASS.DLL SRC/MODULES/M_USERHOST.DLL \
 SRC/MODULES/M_ISON.DLL SRC/MODULES/M_SILENCE.DLL SRC/MODULES/M_ADDLINE.DLL \
 SRC/MODULES/M_ADDMOTD.DLL SRC/MODULES/M_ADDOMOTD.DLL SRC/MODULES/M_WALLOPS.DLL \
 SRC/MODULES/M_GLOBOPS.DLL SRC/MODULES/M_LOCOPS.DLL SRC/MODULES/M_CHATOPS.DLL \
 SRC/MODULES/M_ADMIN.DLL SRC/MODULES/M_TRACE.DLL SRC/MODULES/M_NETINFO.DLL \
 SRC/MODULES/M_LINKS.DLL SRC/MODULES/M_HELP.DLL SRC/MODULES/M_RULES.DLL \
 SRC/MODULES/M_CLOSE.DLL SRC/MODULES/M_MAP.DLL SRC/MODULES/M_EOS.DLL \
 SRC/MODULES/M_SERVER.DLL SRC/MODULES/M_STATS.DLL SRC/MODULES/M_SVSFLINE.DLL \
 SRC/MODULES/M_DCCDENY.DLL SRC/MODULES/M_UNDCCDENY.DLL SRC/MODULES/M_WHOWAS.DLL \
 SRC/MODULES/M_CONNECT.DLL SRC/MODULES/M_DCCALLOW.DLL SRC/MODULES/M_USERIP.DLL \
 SRC/MODULES/M_NICK.DLL SRC/MODULES/M_USER.DLL SRC/MODULES/M_MODE.DLL \
 SRC/MODULES/M_WATCH.DLL SRC/MODULES/M_PART.DLL SRC/MODULES/M_JOIN.DLL \
 SRC/MODULES/M_MOTD.DLL SRC/MODULES/M_OPERMOTD.DLL SRC/MODULES/M_BOTMOTD.DLL \
 SRC/MODULES/M_LUSERS.DLL SRC/MODULES/M_NAMES.DLL \
 SRC/MODULES/CLOAK.DLL


ALL: CONF UNREAL.EXE WIRCD.EXE src/modules/commands.dll MODULES 

CLEAN:
        -@erase src\*.obj >NUL
        -@erase src\win32.res >NUL
        -@erase src\version.c >NUL
        -@erase src\win32\*.obj >NUL
	-@erase src\modules\*.obj >NUL
	-@erase src\modules\*.dll >NUL
        -@erase .\*.exe >NUL
	-@erase wircd.lib >NUL
	-@erase src\modules\*.exp >NUL
	-@erase src\modules\*.lib >NUL
	-@erase src\modules\*.pdb >NUL
	-@erase src\modules\*.ilk >NUL

./UNREAL.EXE: SRC/UNREAL.OBJ SRC/WIN32/UNREAL.RES
	$(LINK) $(DBGLFLAG) advapi32.lib src/unreal.obj src/win32/unreal.res

CONF:
	-@copy include\win32\setup.h include\setup.h >NUL
	$(CC) src/win32/config.c
	-@config.exe

	

./WIRCD.EXE: $(OBJ_FILES) SRC/win32/WIN32.RES
        $(LINK) $(LFLAGS) $(OBJ_FILES) SRC/win32/WIN32.RES SRC/WIN32/TRE.LIB SRC/WIN32/ARESLIB.LIB /MAPINFO:LINES /MAP
	-@erase src\win32\win32.res
!IFNDEF DEBUGEXTRA
 @echo Standard version built 
!ELSE
 @echo Extra-Debug version built ... 
!ENDIF

#Source files

src/version.obj: src/version.c
        $(CC) $(CFLAGS) src/version.c

src/parse.obj: src/parse.c $(INCLUDES)
        $(CC) $(CFLAGS) src/parse.c

src/socket.obj: src/socket.c $(INCLUDES)
        $(CC) $(CFLAGS) src/socket.c

src/dbuf.obj: src/dbuf.c $(INCLUDES) ./include/dbuf.h
        $(CC) $(CFLAGS) src/dbuf.c

src/ircsprintf.obj: src/ircsprintf.c $(INCLUDES)
	$(CC) $(CFLAGS) src/ircsprintf.c

src/packet.obj: src/packet.c $(INCLUDES)
        $(CC) $(CFLAGS) src/packet.c

src/fdlist.obj: src/fdlist.c $(INCLUDES)
        $(CC) $(CFLAGS) src/fdlist.c

src/dynconf.obj: src/dynconf.c $(INCLUDES) ./include/dbuf.h \
                ./include/channel.h ./include/whowas.h
        $(CC) $(CFLAGS) src/dynconf.c

src/send.obj: src/send.c $(INCLUDES)
        $(CC) $(CFLAGS) src/send.c

src/match.obj: src/match.c $(INCLUDES)
        $(CC) $(CFLAGS) src/match.c

src/support.obj: src/support.c $(INCLUDES)
        $(CC) $(CFLAGS) src/support.c

src/channel.obj: src/channel.c $(INCLUDES) ./include/channel.h
        $(CC) $(CFLAGS) src/channel.c

src/class.obj: src/class.c $(INCLUDES) ./include/class.h
        $(CC) $(CFLAGS) src/class.c

src/lusers.obj: src/lusers.c $(INCLUDES)
        $(CC) $(CFLAGS) src/lusers.c

src/aln.obj: src/aln.c $(INCLUDES)
	$(CC) $(CFLAGS) src/aln.c

src/ircd.obj: src/ircd.c $(INCLUDES)
        $(CC) $(CFLAGS) src/ircd.c

src/list.obj: src/list.c $(INCLUDES)
        $(CC) $(CFLAGS) src/list.c

src/res.obj: src/res.c $(INCLUDES)
        $(CC) $(CFLAGS) src/res.c

src/timesynch.obj: src/timesynch.c $(INCLUDES)
        $(CC) $(CFLAGS) src/timesynch.c

src/s_bsd.obj: src/s_bsd.c $(INCLUDES)
        $(CC) $(CFLAGS) src/s_bsd.c

src/s_auth.obj: src/s_auth.c $(INCLUDES)
        $(CC) $(CFLAGS) src/s_auth.c

src/s_conf.obj: src/s_conf.c $(INCLUDES)
        $(CC) $(CFLAGS) src/s_conf.c

src/s_debug.obj: src/s_debug.c $(INCLUDES)
        $(CC) $(CFLAGS) src/s_debug.c

src/s_err.obj: src/s_err.c $(INCLUDES)
        $(CC) $(CFLAGS) src/s_err.c

src/s_kline.obj: src/s_kline.c $(INCLUDES)
        $(CC) $(CFLAGS) src/s_kline.c

src/s_misc.obj: src/s_misc.c $(INCLUDES) ./include/dbuf.h
        $(CC) $(CFLAGS) src/s_misc.c

src/scache.obj: src/scache.c $(INCLUDES) ./include/dbuf.h
        $(CC) $(CFLAGS) src/scache.c

src/s_socks.obj: src/s_socks.c $(INCLUDES)
        $(CC) $(CFLAGS) src/s_socks.c

src/s_svs.obj: src/s_svs.c $(INCLUDES)
	  $(CC) $(CFLAGS) src/s_svs.c

src/s_user.obj: src/s_user.c $(INCLUDES) ./include/dbuf.h \
                ./include/channel.h ./include/whowas.h
        $(CC) $(CFLAGS) src/s_user.c

src/charsys.obj: src/charsys.c $(INCLUDES) ./include/dbuf.h \
                ./include/channel.h ./include/whowas.h
        $(CC) $(CFLAGS) src/charsys.c

src/s_extra.obj: src/s_extra.c $(INCLUDES) ./include/dbuf.h \
                ./include/channel.h ./include/whowas.h
        $(CC) $(CFLAGS) src/s_extra.c

src/s_serv.obj: src/s_serv.c $(INCLUDES) ./include/dbuf.h ./include/whowas.h
        $(CC) $(CFLAGS) src/s_serv.c

src/s_numeric.obj: src/s_numeric.c $(INCLUDES) ./include/dbuf.h
        $(CC) $(CFLAGS) src/s_numeric.c

src/whowas.obj: src/whowas.c $(INCLUDES) ./include/dbuf.h ./include/whowas.h
        $(CC) $(CFLAGS) src/whowas.c

src/hash.obj: src/hash.c $(INCLUDES) ./include/hash.h
        $(CC) $(CFLAGS) src/hash.c

src/crule.obj: src/crule.c $(INCLUDES)
        $(CC) $(CFLAGS) src/crule.c

src/gui.obj: src/win32/gui.c $(INCLUDES) ./include/resource.h
        $(CC) $(CFLAGS) src/win32/gui.c

src/rtf.obj: src/win32/rtf.c $(INCLUDES) ./src/win32/win32.h
	$(CC) $(CFLAGS) src/win32/rtf.c

src/editor.obj: src/win32/editor.c $(INCLUDES) ./include/resource.h ./src/win32/win32.h
        $(CC) $(CFLAGS) src/win32/editor.c

src/service.obj: src/win32/service.c $(INCLUDES)
	$(CC) $(CFLAGS) src/win32/service.c

src/debug.obj: src/win32/debug.c $(INCLUDES)
	$(CC) $(CFLAGS) src/win32/debug.c

src/win32.obj: src/win32/win32.c $(INCLUDES)
	$(CC) $(CFLAGS) src/win32/win32.c

src/unreal.obj: src/win32/unreal.c $(INCLUDES)
	$(CC) $(CFLAGS) src/win32/unreal.c

src/help.obj: src/help.c $(INCLUDES)
        $(CC) $(CFLAGS) src/help.c

src/modules.obj: src/modules.c $(INCLUDES)
	$(CC) $(CFLAGS) src/modules.c

src/events.obj: src/events.c $(INCLUDES)
	$(CC) $(CFLAGS) src/events.c

src/umodes.obj: src/umodes.c $(INCLUDES)
	$(CC) $(CFLAGS) src/umodes.c

src/auth.obj: src/auth.c $(INCLUDES)
	$(CC) $(CFLAGS) src/auth.c

src/cidr.obj: src/cidr.c $(INCLUDES)
	$(CC) $(CFLAGS) src/cidr.c

src/random.obj: src/random.c $(INCLUDES)
	$(CC) $(CFLAGS) src/random.c

src/extcmodes.obj: src/extcmodes.c $(INCLUDES)
	$(CC) $(CFLAGS) src/extcmodes.c

src/md5.obj: src/md5.c $(INCLUDES)
	$(CC) $(CFLAGS) src/md5.c

src/url.obj: src/url.c $(INCLUDES) ./include/url.h
	$(CC) $(CFLAGS) src/url.c

src/extbans.obj: src/extbans.c $(INCLUDES)
	$(CC) $(CFLAGS) src/extbans.c

src/api-isupport.obj: src/api-isupport.c $(INCLUDES)
	$(CC) $(CFLAGS) src/api-isupport.c

src/api-command.obj: src/api-command.c $(INCLUDES)
	$(CC) $(CFLAGS) src/api-command.c

src/zip.obj: src/zip.c $(INCLUDES)
	$(CC) $(CFLAGS) src/zip.c

src/ssl.obj: src/ssl.c $(INCLUDES)
	$(CC) $(CFLAGS) src/ssl.c

src/win32/win32.res: src/win32/win32gui.rc
        $(RC) /l 0x409 /fosrc/win32/win32.res /i ./include /i ./src \
              /d NDEBUG src/win32/win32gui.rc

src/win32/unreal.res: src/win32/unreal.rc
        $(RC) /l 0x409 /fosrc/win32/unreal.res /i ./include /i ./src \
              /d NDEBUG src/win32/unreal.rc

################# Modules #################

CUSTOMMODULE: src/modules/$(MODULEFILE).c
	$(CC) $(MODCFLAGS) src/modules/$(MODULEFILE).c $(MODLFLAGS) \
	      /OUT:src/modules/$(MODULEFILE).dll $(EXLIBS)

SYMBOLFILE: 
	$(CC) src/win32/def-clean.c
	dlltool --output-def wircd.def.in --export-all-symbols $(EXP_OBJ_FILES)
	def-clean wircd.def.in wircd.def

MODULES: $(DLL_FILES)

src/modules/commands.dll: $(MOD_FILES) $(INCLUDES)
	$(CC) $(MODDBGCFLAG) $(LIBCURL_INC) $(ZLIB_INC) $(OPENSSL_INC) /nologo \
	      $(SSLCFLAGS) $(ZIPCFLAGS) $(CURLCFLAGS) /Fosrc/modules/ \
	      /I ./INCLUDE /D NOSPOOF /D MODULE_COMPILE /D _CRT_SECURE_NO_DEPRECATE \
	      /D _USE_32BIT_TIME_T $(MOD_FILES) \
	      $(MODLFLAGS) src/win32/tre.lib /OUT:src/modules/commands.dll

src/modules/m_chghost.dll: src/modules/m_chghost.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_chghost.c $(MODLFLAGS)

src/modules/m_chgident.dll: src/modules/m_chgident.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_chgident.c $(MODLFLAGS)

src/modules/m_sdesc.dll: src/modules/m_sdesc.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_sdesc.c $(MODLFLAGS)

src/modules/m_sethost.dll: src/modules/m_sethost.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_sethost.c $(MODLFLAGS)

src/modules/m_setident.dll: src/modules/m_setident.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_setident.c $(MODLFLAGS)

src/modules/m_setname.dll: src/modules/m_setname.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_setname.c $(MODLFLAGS)

src/modules/m_svsmotd.dll: src/modules/m_svsmotd.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_svsmotd.c $(MODLFLAGS)

src/modules/m_svsmode.dll: src/modules/m_svsmode.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_svsmode.c $(MODLFLAGS)

src/modules/m_tkl.dll: src/modules/m_tkl.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_tkl.c $(MODLFLAGS) src/win32/tre.lib

src/modules/m_swhois.dll: src/modules/m_swhois.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_swhois.c $(MODLFLAGS)

src/modules/m_svsnline.dll: src/modules/m_svsnline.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_svsnline.c $(MODLFLAGS)

src/modules/m_who.dll: src/modules/m_who.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_who.c $(MODLFLAGS)

src/modules/m_away.dll: src/modules/m_away.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_away.c $(MODLFLAGS)

src/modules/m_mkpasswd.dll: src/modules/m_mkpasswd.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_mkpasswd.c $(MODLFLAGS)

src/modules/m_svsnoop.dll: src/modules/m_svsnoop.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_svsnoop.c $(MODLFLAGS)

src/modules/m_svso.dll: src/modules/m_svso.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_svso.c $(MODLFLAGS)

src/modules/m_svsnick.dll: src/modules/m_svsnick.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_svsnick.c $(MODLFLAGS)

src/modules/m_adminchat.dll: src/modules/m_adminchat.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_adminchat.c $(MODLFLAGS)

src/modules/m_akill.dll: src/modules/m_akill.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_akill.c $(MODLFLAGS)

src/modules/m_chgname.dll: src/modules/m_chgname.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_chgname.c $(MODLFLAGS)

src/modules/m_guest.dll: src/modules/m_guest.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_guest.c $(MODLFLAGS)

src/modules/m_htm.dll: src/modules/m_htm.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_htm.c $(MODLFLAGS)

src/modules/m_kill.dll: src/modules/m_kill.c $(INCLUDES) 
	$(CC) $(MODCFLAGS) src/modules/m_kill.c $(MODLFLAGS)

src/modules/m_lag.dll: src/modules/m_lag.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_lag.c $(MODLFLAGS)

src/modules/m_message.dll: src/modules/m_message.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_message.c src/modules/webtv.c $(MODLFLAGS) src/win32/tre.lib

src/modules/m_nachat.dll: src/modules/m_nachat.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_nachat.c $(MODLFLAGS)

src/modules/m_oper.dll: src/modules/m_oper.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_oper.c $(MODLFLAGS)

src/modules/m_pingpong.dll: src/modules/m_pingpong.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_pingpong.c $(MODLFLAGS)

src/modules/m_quit.dll: src/modules/m_quit.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_quit.c $(MODLFLAGS)

src/modules/m_rakill.dll: src/modules/m_rakill.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_rakill.c $(MODLFLAGS)

src/modules/m_rping.dll: src/modules/m_rping.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_rping.c $(MODLFLAGS)

src/modules/m_sendumode.dll: src/modules/m_sendumode.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_sendumode.c $(MODLFLAGS)

src/modules/m_sqline.dll: src/modules/m_sqline.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_sqline.c $(MODLFLAGS)

src/modules/m_tsctl.dll: src/modules/m_tsctl.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_tsctl.c $(MODLFLAGS)

src/modules/m_unkline.dll: src/modules/m_unkline.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_unkline.c $(MODLFLAGS)

src/modules/m_unsqline.dll: src/modules/m_unsqline.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_unsqline.c $(MODLFLAGS)

src/modules/m_unzline.dll: src/modules/m_unzline.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_unzline.c $(MODLFLAGS)

src/modules/m_whois.dll: src/modules/m_whois.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_whois.c $(MODLFLAGS)

src/modules/m_vhost.dll: src/modules/m_vhost.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_vhost.c $(MODLFLAGS)

src/modules/m_cycle.dll: src/modules/m_cycle.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_cycle.c $(MODLFLAGS)

src/modules/m_svsjoin.dll: src/modules/m_svsjoin.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_svsjoin.c $(MODLFLAGS)

src/modules/m_svspart.dll: src/modules/m_svspart.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_svspart.c $(MODLFLAGS)

src/modules/m_svslusers.dll: src/modules/m_svslusers.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_svslusers.c $(MODLFLAGS)

src/modules/m_svswatch.dll: src/modules/m_svswatch.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_svswatch.c $(MODLFLAGS)

src/modules/m_svssilence.dll: src/modules/m_svssilence.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_svssilence.c $(MODLFLAGS)

src/modules/m_sendsno.dll: src/modules/m_sendsno.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_sendsno.c $(MODLFLAGS)

src/modules/m_svssno.dll: src/modules/m_svssno.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_svssno.c $(MODLFLAGS)

src/modules/m_sajoin.dll: src/modules/m_sajoin.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_sajoin.c $(MODLFLAGS)

src/modules/m_sapart.dll: src/modules/m_sapart.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_sapart.c $(MODLFLAGS)

src/modules/m_samode.dll: src/modules/m_samode.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_samode.c $(MODLFLAGS)

src/modules/m_kick.dll: src/modules/m_kick.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_kick.c $(MODLFLAGS)

src/modules/m_topic.dll: src/modules/m_topic.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_topic.c $(MODLFLAGS)

src/modules/m_invite.dll: src/modules/m_invite.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_invite.c $(MODLFLAGS)

src/modules/m_list.dll: src/modules/m_list.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_list.c $(MODLFLAGS)

src/modules/m_time.dll: src/modules/m_time.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_time.c $(MODLFLAGS)

src/modules/m_svskill.dll: src/modules/m_svskill.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_svskill.c $(MODLFLAGS)

src/modules/m_sjoin.dll: src/modules/m_sjoin.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_sjoin.c $(MODLFLAGS)

src/modules/m_pass.dll: src/modules/m_pass.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_pass.c $(MODLFLAGS)

src/modules/m_userhost.dll: src/modules/m_userhost.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_userhost.c $(MODLFLAGS)

src/modules/m_ison.dll: src/modules/m_ison.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_ison.c $(MODLFLAGS)

src/modules/m_silence.dll: src/modules/m_silence.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_silence.c $(MODLFLAGS)

src/modules/m_knock.dll: src/modules/m_knock.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_knock.c $(MODLFLAGS)

src/modules/m_umode2.dll: src/modules/m_umode2.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_umode2.c $(MODLFLAGS)

src/modules/m_squit.dll: src/modules/m_squit.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_squit.c $(MODLFLAGS)

src/modules/m_protoctl.dll: src/modules/m_protoctl.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_protoctl.c $(MODLFLAGS)

src/modules/m_addline.dll: src/modules/m_addline.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_addline.c $(MODLFLAGS)

src/modules/m_addmotd.dll: src/modules/m_addmotd.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_addmotd.c $(MODLFLAGS)

src/modules/m_addomotd.dll: src/modules/m_addomotd.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_addomotd.c $(MODLFLAGS)

src/modules/m_wallops.dll: src/modules/m_wallops.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_wallops.c $(MODLFLAGS)

src/modules/m_admin.dll: src/modules/m_admin.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_admin.c $(MODLFLAGS)

src/modules/m_globops.dll: src/modules/m_globops.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_globops.c $(MODLFLAGS)

src/modules/m_locops.dll: src/modules/m_locops.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_locops.c $(MODLFLAGS)

src/modules/m_chatops.dll: src/modules/m_chatops.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_chatops.c $(MODLFLAGS)

src/modules/m_trace.dll: src/modules/m_trace.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_trace.c $(MODLFLAGS)

src/modules/m_netinfo.dll: src/modules/m_netinfo.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_netinfo.c $(MODLFLAGS)

src/modules/m_links.dll: src/modules/m_links.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_links.c $(MODLFLAGS)

src/modules/m_help.dll: src/modules/m_help.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_help.c $(MODLFLAGS)

src/modules/m_rules.dll: src/modules/m_rules.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_rules.c $(MODLFLAGS)
 
src/modules/m_close.dll: src/modules/m_close.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_close.c $(MODLFLAGS)

src/modules/m_map.dll: src/modules/m_map.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_map.c $(MODLFLAGS)

src/modules/m_eos.dll: src/modules/m_eos.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_eos.c $(MODLFLAGS)

src/modules/m_server.dll: src/modules/m_server.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_server.c $(MODLFLAGS)

src/modules/m_stats.dll: src/modules/m_stats.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_stats.c $(MODLFLAGS)

src/modules/m_svsfline.dll: src/modules/m_svsfline.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_svsfline.c $(MODLFLAGS)

src/modules/m_dccdeny.dll: src/modules/m_dccdeny.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_dccdeny.c $(MODLFLAGS)

src/modules/m_undccdeny.dll: src/modules/m_undccdeny.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_undccdeny.c $(MODLFLAGS)

src/modules/m_whowas.dll: src/modules/m_whowas.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_whowas.c $(MODLFLAGS)

src/modules/m_connect.dll: src/modules/m_connect.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_connect.c $(MODLFLAGS)

src/modules/m_dccallow.dll: src/modules/m_dccallow.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/m_dccallow.c $(MODLFLAGS)

src/modules/m_userip.dll: src/modules/m_userip.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_userip.c $(MODLFLAGS)

src/modules/m_nick.dll: src/modules/m_nick.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_nick.c $(MODLFLAGS)

src/modules/m_user.dll: src/modules/m_user.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_user.c $(MODLFLAGS)

src/modules/m_mode.dll: src/modules/m_mode.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_mode.c $(MODLFLAGS)

src/modules/m_watch.dll: src/modules/m_watch.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_watch.c $(MODLFLAGS)

src/modules/m_part.dll: src/modules/m_part.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_part.c $(MODLFLAGS)

src/modules/m_join.dll: src/modules/m_join.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_join.c $(MODLFLAGS)

src/modules/m_motd.dll: src/modules/m_motd.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_motd.c $(MODLFLAGS)

src/modules/m_opermotd.dll: src/modules/m_opermotd.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_opermotd.c $(MODLFLAGS)

src/modules/m_botmotd.dll: src/modules/m_botmotd.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_botmotd.c $(MODLFLAGS)

src/modules/m_lusers.dll: src/modules/m_lusers.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_lusers.c $(MODLFLAGS)

src/modules/m_names.dll: src/modules/m_names.c $(INCLUDES)
	$(CC) $(MODCFLAGS) src/modules/m_names.c $(MODLFLAGS)

src/modules/cloak.dll: src/modules/cloak.c $(INCLUDES)
        $(CC) $(MODCFLAGS) src/modules/cloak.c $(MODLFLAGS)

dummy:



