## Makefile for building the GLib dlls with Microsoft C
## Use: nmake -f makefile.msc

TOP = ..\..

!INCLUDE ..\build\win32\make.msc

################################################################

INCLUDES = -FImsvc_recommended_pragmas.h -I . -I ..
DEFINES = \
	-DHAVE_CONFIG_H -DGLIB_COMPILATION -DG_LOG_DOMAIN=\"GLib\" \
	-DG_ENABLE_DEBUG -DPCRE_STATIC -DG_DISABLE_DEPRECATED \
	-DDLL_EXPORT=1

DEPCFLAGS = -Zm400 $(INTL_CFLAGS) $(DIRENT_CFLAGS)

all :				\
	..\config.h		\
	..\glibconfig.h	\
	gnulib\gnulib.lib	\
	pcre\pcre.lib		\
	libglib-2.0-0.dll \
	glib-2.48s.lib \
	gspawn-win32-helper.exe	\
	gspawn-win32-helper-console.exe	\


gnulib\gnulib.lib :
	cd gnulib
	nmake -f makefile.msc
	cd ..

pcre\pcre.lib :
	cd pcre
	nmake -f makefile.msc
	cd ..

glib_OBJECTS =			\
	garray.obj		\
	gasyncqueue.obj		\
	gatomic.obj	\
	gbacktrace.obj		\
	gbase64.obj	\
	gbookmarkfile.obj \
	gcache.obj \
	gchecksum.obj	\
	gcompletion.obj	\
	gconvert.obj \
	gdataset.obj \
	gdate.obj \
	gdir.obj \
	gerror.obj \
	gfileutils.obj \
	ghash.obj \
	ghostutils.obj \
	ghook.obj \
	giochannel.obj \
	giowin32.obj \
	gpoll.obj \
	gkeyfile.obj \
	glist.obj \
	gmain.obj \
	gmappedfile.obj	\
	gmarkup.obj \
	gmem.obj \
	gmessages.obj \
	gnode.obj \
	goption.obj \
	gpattern.obj \
	gprimes.obj \
	gprintf.obj \
	gqsort.obj \
	gqueue.obj \
	grand.obj \
	gregex.obj \
	grel.obj \
	gscanner.obj \
	gsequence.obj \
	gshell.obj \
	gslice.obj \
	gslist.obj \
	gspawn-win32.obj \
	gstdio.obj \
	gstrfuncs.obj \
	gstring.obj \
	gtestutils.obj \
	gthread.obj \
	gthreadpool.obj \
	gtimer.obj \
	gtree.obj \
	gunibreak.obj \
	gunicollate.obj \
	gunidecomp.obj \
	guniprop.obj \
	gurifuncs.obj \
	gutf8.obj		\
	gutils.obj		\
	gwin32.obj		\
	localcharset.obj

..\glibconfig.h: ..\glibconfig.h.win32
	copy ..\glibconfig.h.win32 ..\glibconfig.h

..\config.h: ..\config.h.win32
	copy ..\config.h.win32 ..\config.h

localcharset.obj : libcharset\localcharset.c
	$(CC) $(CFLAGS) -DLIBDIR=\".\" -c libcharset\localcharset.c

glib.def: glib.symbols
	echo EXPORTS > glib.def
	cl /EP -DINCLUDE_VARIABLES -DG_OS_WIN32 -DINCLUDE_INTERNAL_SYMBOLS -DALL_FILES \
		-DG_GNUC_MALLOC= -DG_GNUC_CONST= -DG_GNUC_NULL_TERMINATED= -DG_GNUC_NORETURN= \
		-DG_GNUC_PRINTF=;G_GNUC_PRINTF -DG_GNUC_FORMAT=;G_GNUC_FORMAT glib.symbols >> glib.def

glib.res : glib.rc
	rc -DBUILDNUMBER=0 -r -fo glib.res glib.rc

################ glib

# create a static libary
# static library can well have the real version number in the name
glib-2.48s.lib : $(glib_OBJECTS) gnulib\gnulib.lib pcre\pcre.lib
	lib /out:glib-2.48s.lib $(glib_OBJECTS) gnulib\gnulib.lib pcre\pcre.lib

libglib-2.0-0.dll : $(glib_OBJECTS) gnulib\gnulib.lib pcre\pcre.lib glib.def glib.res
	$(CC) $(CFLAGS) -LD -Fe$@ $(glib_OBJECTS) glib.res $(INTL_LIBS) \
	gnulib\gnulib.lib pcre\pcre.lib $(DIRENT_LIBS) user32.lib advapi32.lib shell32.lib wsock32.lib ole32.lib ws2_32.lib winmm.lib \
	$(LDFLAGS) /implib:glib-2.0.lib /def:glib.def

gspawn-win32-helper.exe : gspawn-win32-helper.c libglib-2.0-0.dll
	$(CC) $(CFLAGS) -Fe$@ -DG_LOG_DOMAIN=\"gspawn-win32-helper\" gspawn-win32-helper.c glib-2.0.lib $(LDFLAGS) /subsystem:windows user32.lib

gspawn-win32-helper-console.exe : gspawn-win32-helper.c libglib-2.0-0.dll
	$(CC) $(CFLAGS) -Fe$@ -DG_LOG_DOMAIN=\"gspawn-win32-helper\" gspawn-win32-helper.c glib-2.0.lib $(LDFLAGS) /subsystem:console user32.lib

################ other stuff

clean::
	del ..\config.h
	del ..\glibconfig.h

