return parser.parse_args()

if __name__ == '__main__':
	opts = parse_cmd_args()

	if opts.debug: print ("Src Build Dir: "+ opts.build_dir)
	if opts.build_dir == ".":
		opts.build_dir = os.getcwd()
	else:
		os.chdir(opts.build_dir)
	if opts.debug: print ("Dep Check!!!!")
	if os.name == "nt":
		dep_check.win32(opts)
	else:
		dep_check.linux(opts)

	if opts.debug: print ("Fetching Pre-Build")
	if opts.fetch: fetch_repos.pre_build_fetch(opts)

	if opts.debug: print ("Building Server")
	if os.name == "nt":
		if opts.build: windows_build.make(opts)
		if opts.install: windows_build.install(opts)
	else:
		if opts.build: linux_build.make(opts)
	os.chdir(opts.build_dir)

	if opts.debug: print ("Fetching Post-Build")
	if opts.post_fetch: fetch_repos.post_build_fetch(opts)

import windows_build
import linux_build

def parse_cmd_args():
    parser = optparse.OptionParser(version="%prog 1.0")
    
    parser.add_option("--mangos-destdir", "--install", "--destdir"
        action="store",
        dest="mangos_destdir",
        default="/opt/mangos")

    parser.add_option("--sd2-patch", "--patch", "--sd2", 
        action="store",
        dest="sd2_patch",
        default="MaNGOS-2008-12-22-ScriptDev2.patch")

    (options, args) = parser.parse_args()
    return options

if __name__ == '__main__':
    build_dir = os.getcwd()
    opts = parse_cmd_args()
    fetch_repos.pre_build_fetch()
    if os.name == "nt":
        windows_build.make()
        windows_build.install()
    else:
        linux_build.make(build_dir, opts)
    fetch_repos.post_build_fetch()