1 ## Makefile for building the GLib, gmodule and gthread DLLs with
2 ## gcc on cygwin or mingw32.
3 ## Use: make -f makefile.cygwin install
5 # Change this to wherever you want to install the DLLs. This directory
6 # should be in your PATH.
9 # This is the location of pthreads for Win32,
10 # see http://sourceware.cygnus.com/pthreads-win32/
11 # We want the 1999-05-30 snapshot.
12 PTHREADS = ../pthreads-snap-1999-05-30
13 PTHREAD_LIB = -L$(PTHREADS) -lpthread32
14 PTHREAD_INC = -I $(PTHREADS)
18 ################################################################
20 # Nothing much configurable below
22 CC = gcc -mno-cygwin -mpentium -fnative-struct
27 GLIB_VER = @GLIB_MAJOR_VERSION@.@GLIB_MINOR_VERSION@
29 CFLAGS = $(OPTIMIZE) -I. -DHAVE_CONFIG_H
31 # Kludge to get the path to the win32 headers
32 WIN32APIHEADERS = $(shell echo "\#include <winver.h>" | $(CC) -M -E - | tail -1 | sed -e 's!/winver.h!!')
37 glib-$(GLIB_VER).dll \
38 gmodule/gmoduleconf.h \
39 gmodule-$(GLIB_VER).dll \
40 gthread-$(GLIB_VER).dll \
47 $(INSTALL) glib-$(GLIB_VER).dll $(BIN)
48 $(INSTALL) gmodule-$(GLIB_VER).dll $(BIN)
49 $(INSTALL) gthread-$(GLIB_VER).dll $(BIN)
82 glibconfig.h: glibconfig.h.win32
83 cp glibconfig.h.win32 glibconfig.h
85 config.h: config.h.win32
86 cp config.h.win32 config.h
90 # The *.stamp files aren't distributed. Thus, this takes care of only
91 # tml building libraries with nonzero build number.
93 ifeq ($(wildcard glib-build.stamp),glib-build.stamp)
94 # Bump the build number
96 bash -c "read number && echo $$[number+1]" <glib-build.stamp >glib-build.tmp
97 cp glib-build.tmp glib-build.stamp
99 # Use zero as build number.
101 echo 0 >glib-build.tmp
104 glib-win32res.o : glib.rc glib-build.tmp
105 m4 -DBUILDNUMBER=`cat glib-build.tmp` <glib.rc >glib-win32res.rc
106 windres --include-dir $(WIN32APIHEADERS) glib-win32res.rc glib-win32res.o
107 rm glib-build.tmp glib-win32res.rc
109 glib-$(GLIB_VER).dll : $(glib_OBJECTS) glib.def
110 ./build-dll glib $(GLIB_VER) glib.def $(glib_OBJECTS) -luser32 -lwsock32
113 ################ gmodule
119 # Unfortunately I couldn't use a pattern rule for this, so copy-paste
121 ifeq ($(wildcard glib-build.stamp),glib-build.stamp)
123 bash -c "read number && echo $$[number+1]" <gmodule-build.stamp >gmodule-build.tmp
124 cp gmodule-build.tmp gmodule-build.stamp
127 echo 0 >gmodule-build.tmp
130 gmodule-win32res.o : gmodule/gmodule.rc gmodule-build.tmp
131 m4 -DBUILDNUMBER=`cat gmodule-build.tmp` <gmodule/gmodule.rc >gmodule-win32res.rc
132 windres --include-dir $(WIN32APIHEADERS) gmodule-win32res.rc gmodule-win32res.o
133 rm gmodule-build.tmp gmodule-win32res.rc
136 gmodule-$(GLIB_VER).dll : $(gmodule_OBJECTS) gmodule/gmodule.def
137 ./build-dll gmodule $(GLIB_VER) gmodule/gmodule.def $(gmodule_OBJECTS) -L. -lglib-$(GLIB_VER) -lwsock32
139 gmodule.o : gmodule/gmodule.c gmodule/gmodule-win32.c
140 $(CC) $(CFLAGS) -Igmodule -c -DG_LOG_DOMAIN=g_log_domain_gmodule gmodule/gmodule.c
142 gmodule/gmoduleconf.h: gmodule/gmoduleconf.h.win32
143 cp gmodule/gmoduleconf.h.win32 gmodule/gmoduleconf.h
145 ################ gthread
152 ifeq ($(wildcard glib-build.stamp),glib-build.stamp)
154 bash -c "read number && echo $$[number+1]" <gthread-build.stamp >gthread-build.tmp
155 cp gthread-build.tmp gthread-build.stamp
158 echo 0 >gthread-build.tmp
161 gthread-win32res.o : gthread/gthread.rc gthread-build.tmp
162 m4 -DBUILDNUMBER=`cat gthread-build.tmp` <gthread/gthread.rc >gthread-win32res.rc
163 windres --include-dir $(WIN32APIHEADERS) gthread-win32res.rc gthread-win32res.o
164 rm gthread-build.tmp gthread-win32res.rc
167 gthread-$(GLIB_VER).dll : $(gthread_OBJECTS) glib-$(GLIB_VER).dll gthread/gthread.def
168 ./build-dll gthread $(GLIB_VER) gthread/gthread.def $(gthread_OBJECTS) -L. -lglib-$(GLIB_VER) $(PTHREAD_LIB)
170 gthread-impl.o : gthread/gthread-impl.c gthread/gthread-posix.c
171 $(CC) $(CFLAGS) $(PTHREAD_INC) -DG_LOG_DOMAIN=\"GThread\" -c gthread/gthread-impl.c
173 ################ test progs
175 testglib.exe : glib-$(GLIB_VER).dll testglib.o
176 $(CC) $(CFLAGS) -o testglib testglib.o -L. -lglib-$(GLIB_VER) $(LDFLAGS)
178 testglib.o : testglib.c
179 $(CC) -c $(CFLAGS) testglib.c
181 testgdate.exe : glib-$(GLIB_VER).dll testgdate.o
182 $(CC) $(CFLAGS) -o testgdate.exe testgdate.o -L. -lglib-$(GLIB_VER) $(LDFLAGS)
184 testgdate.o : testgdate.c
185 $(CC) -c $(CFLAGS) testgdate.c
187 testgdateparser.exe : glib-$(GLIB_VER).dll testgdateparser.o
188 $(CC) $(CFLAGS) -o testgdateparser.exe testgdateparser.o -L. -lglib-$(GLIB_VER) $(LDFLAGS)
190 testgdateparser.o : testgdateparser.c
191 $(CC) -c $(CFLAGS) testgdateparser.c
193 testgmodule.exe : glib-$(GLIB_VER).dll gmodule-$(GLIB_VER).dll testgmodule.o libgplugin_a.dll libgplugin_b.dll
194 # Wow, do we really have to do it like this to get some symbols
195 # exported from a .exe? Apparently yes. Does the __declspec(dllexport)
196 # actually do anything in egcs-1.1.2?
197 $(CC) $(CFLAGS) -Wl,--base-file,testgmodule.base -o testgmodule.exe testgmodule.o -L. -lglib-$(GLIB_VER) -lgmodule-$(GLIB_VER) $(LDFLAGS)
198 $(DLLTOOL) --base-file testgmodule.base --output-exp testgmodule.exp testgmodule.o
199 $(CC) $(CFLAGS) -Wl,--base-file,testgmodule.base,testgmodule.exp -o testgmodule.exe testgmodule.o -L. -lglib-$(GLIB_VER) -lgmodule-$(GLIB_VER) $(LDFLAGS)
200 $(DLLTOOL) --base-file testgmodule.base --output-exp testgmodule.exp testgmodule.o
201 $(CC) $(CFLAGS) -Wl,testgmodule.exp -o testgmodule.exe testgmodule.o -L. -lglib-$(GLIB_VER) -lgmodule-$(GLIB_VER) $(LDFLAGS)
203 testgmodule.o : gmodule/testgmodule.c
204 $(CC) $(CFLAGS) -Igmodule -c gmodule/testgmodule.c
206 libgplugin_a.dll : libgplugin_a.o
207 ./build-dll libgplugin_a - - libgplugin_a.o -L. -lglib-$(GLIB_VER) -lgmodule-$(GLIB_VER)
209 libgplugin_a.o : gmodule/libgplugin_a.c
210 $(CC) $(CFLAGS) -Igmodule -c gmodule/libgplugin_a.c
212 libgplugin_b.dll : libgplugin_b.o
213 ./build-dll libgplugin_b - - libgplugin_b.o -L. -lglib-$(GLIB_VER) -lgmodule-$(GLIB_VER)
215 libgplugin_b.o : gmodule/libgplugin_b.c
216 $(CC) $(CFLAGS) -Igmodule -c gmodule/libgplugin_b.c
218 ################ other stuff
221 -rm config.h glibconfig.h gmodule/gmoduleconf.h
222 -rm *.exe *.o *.dll *.a *.base *.exp
227 $(CC) $(CFLAGS) -c -DGLIB_COMPILATION -DG_LOG_DOMAIN=g_log_domain_glib $<
230 $(CC) $(CFLAGS) -E -DGLIB_COMPILATION -DG_LOG_DOMAIN=g_log_domain_glib $< >$@