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. Should work for both
32 # gcc running on cygwin, and bare mingw gcc, even if the make is
33 # running on cygwin (whew).
34 WIN32APIHEADERS = $(shell echo "\#include <winver.h>" | $(CC) -M -E - | tail -1 | sed -e 's![\\/]winver.h!!' | tr -d '\015')
39 glib-$(GLIB_VER).dll \
40 gmodule/gmoduleconf.h \
41 gmodule-$(GLIB_VER).dll \
42 gthread-$(GLIB_VER).dll \
49 $(INSTALL) glib-$(GLIB_VER).dll $(BIN)
50 $(INSTALL) gmodule-$(GLIB_VER).dll $(BIN)
51 $(INSTALL) gthread-$(GLIB_VER).dll $(BIN)
86 glibconfig.h: glibconfig.h.win32
87 cp glibconfig.h.win32 glibconfig.h
89 config.h: config.h.win32
90 cp config.h.win32 config.h
94 # The *.stamp files aren't distributed. Thus, this takes care of only
95 # tml building libraries with nonzero build number.
97 ifeq ($(wildcard glib-build.stamp),glib-build.stamp)
98 # Bump the build number
100 bash -c "read number && echo $$[number+1]" <glib-build.stamp >glib-build.tmp
101 cp glib-build.tmp glib-build.stamp
103 # Use zero as build number.
105 echo 0 >glib-build.tmp
108 glib-win32res.o : glib.rc glib-build.tmp
109 m4 -DBUILDNUMBER=`cat glib-build.tmp` <glib.rc >glib-win32res.rc
110 windres --include-dir $(WIN32APIHEADERS) glib-win32res.rc glib-win32res.o
111 rm glib-build.tmp glib-win32res.rc
113 glib-$(GLIB_VER).dll : $(glib_OBJECTS) glib.def
114 ./build-dll glib $(GLIB_VER) glib.def $(glib_OBJECTS) -luser32 -lwsock32
117 ################ gmodule
123 # Unfortunately I couldn't use a pattern rule for this, so copy-paste
125 ifeq ($(wildcard glib-build.stamp),glib-build.stamp)
127 bash -c "read number && echo $$[number+1]" <gmodule-build.stamp >gmodule-build.tmp
128 cp gmodule-build.tmp gmodule-build.stamp
131 echo 0 >gmodule-build.tmp
134 gmodule-win32res.o : gmodule/gmodule.rc gmodule-build.tmp
135 m4 -DBUILDNUMBER=`cat gmodule-build.tmp` <gmodule/gmodule.rc >gmodule-win32res.rc
136 windres --include-dir $(WIN32APIHEADERS) gmodule-win32res.rc gmodule-win32res.o
137 rm gmodule-build.tmp gmodule-win32res.rc
140 gmodule-$(GLIB_VER).dll : $(gmodule_OBJECTS) gmodule/gmodule.def
141 ./build-dll gmodule $(GLIB_VER) gmodule/gmodule.def $(gmodule_OBJECTS) -L. -lglib-$(GLIB_VER) -lwsock32
143 gmodule.o : gmodule/gmodule.c gmodule/gmodule-win32.c
144 $(CC) $(CFLAGS) -Igmodule -c -DG_LOG_DOMAIN=g_log_domain_gmodule gmodule/gmodule.c
146 gmodule/gmoduleconf.h: gmodule/gmoduleconf.h.win32
147 cp gmodule/gmoduleconf.h.win32 gmodule/gmoduleconf.h
149 ################ gthread
156 ifeq ($(wildcard glib-build.stamp),glib-build.stamp)
158 bash -c "read number && echo $$[number+1]" <gthread-build.stamp >gthread-build.tmp
159 cp gthread-build.tmp gthread-build.stamp
162 echo 0 >gthread-build.tmp
165 gthread-win32res.o : gthread/gthread.rc gthread-build.tmp
166 m4 -DBUILDNUMBER=`cat gthread-build.tmp` <gthread/gthread.rc >gthread-win32res.rc
167 windres --include-dir $(WIN32APIHEADERS) gthread-win32res.rc gthread-win32res.o
168 rm gthread-build.tmp gthread-win32res.rc
171 gthread-$(GLIB_VER).dll : $(gthread_OBJECTS) glib-$(GLIB_VER).dll gthread/gthread.def
172 ./build-dll gthread $(GLIB_VER) gthread/gthread.def $(gthread_OBJECTS) -L. -lglib-$(GLIB_VER) $(PTHREAD_LIB)
174 gthread-impl.o : gthread/gthread-impl.c gthread/gthread-posix.c
175 $(CC) $(CFLAGS) $(PTHREAD_INC) -DG_LOG_DOMAIN=\"GThread\" -c gthread/gthread-impl.c
177 ################ test progs
179 testglib.exe : glib-$(GLIB_VER).dll testglib.o
180 $(CC) $(CFLAGS) -o testglib testglib.o -L. -lglib-$(GLIB_VER) $(LDFLAGS)
182 testglib.o : testglib.c
183 $(CC) -c $(CFLAGS) testglib.c
185 testgdate.exe : glib-$(GLIB_VER).dll testgdate.o
186 $(CC) $(CFLAGS) -o testgdate.exe testgdate.o -L. -lglib-$(GLIB_VER) $(LDFLAGS)
188 testgdate.o : testgdate.c
189 $(CC) -c $(CFLAGS) testgdate.c
191 testgdateparser.exe : glib-$(GLIB_VER).dll testgdateparser.o
192 $(CC) $(CFLAGS) -o testgdateparser.exe testgdateparser.o -L. -lglib-$(GLIB_VER) $(LDFLAGS)
194 testgdateparser.o : testgdateparser.c
195 $(CC) -c $(CFLAGS) testgdateparser.c
197 testgmodule.exe : glib-$(GLIB_VER).dll gmodule-$(GLIB_VER).dll testgmodule.o libgplugin_a.dll libgplugin_b.dll
198 # Wow, do we really have to do it like this to get some symbols
199 # exported from a .exe? Apparently yes. Does the __declspec(dllexport)
200 # actually do anything in egcs-1.1.2?
201 $(CC) $(CFLAGS) -Wl,--base-file,testgmodule.base -o testgmodule.exe testgmodule.o -L. -lglib-$(GLIB_VER) -lgmodule-$(GLIB_VER) $(LDFLAGS)
202 $(DLLTOOL) --base-file testgmodule.base --output-exp testgmodule.exp testgmodule.o
203 $(CC) $(CFLAGS) -Wl,--base-file,testgmodule.base,testgmodule.exp -o testgmodule.exe testgmodule.o -L. -lglib-$(GLIB_VER) -lgmodule-$(GLIB_VER) $(LDFLAGS)
204 $(DLLTOOL) --base-file testgmodule.base --output-exp testgmodule.exp testgmodule.o
205 $(CC) $(CFLAGS) -Wl,testgmodule.exp -o testgmodule.exe testgmodule.o -L. -lglib-$(GLIB_VER) -lgmodule-$(GLIB_VER) $(LDFLAGS)
207 testgmodule.o : gmodule/testgmodule.c
208 $(CC) $(CFLAGS) -Igmodule -c gmodule/testgmodule.c
210 libgplugin_a.dll : libgplugin_a.o
211 ./build-dll libgplugin_a - - libgplugin_a.o -L. -lglib-$(GLIB_VER) -lgmodule-$(GLIB_VER)
213 libgplugin_a.o : gmodule/libgplugin_a.c
214 $(CC) $(CFLAGS) -Igmodule -c gmodule/libgplugin_a.c
216 libgplugin_b.dll : libgplugin_b.o
217 ./build-dll libgplugin_b - - libgplugin_b.o -L. -lglib-$(GLIB_VER) -lgmodule-$(GLIB_VER)
219 libgplugin_b.o : gmodule/libgplugin_b.c
220 $(CC) $(CFLAGS) -Igmodule -c gmodule/libgplugin_b.c
222 ################ other stuff
225 -rm config.h glibconfig.h gmodule/gmoduleconf.h
226 -rm *.exe *.o *.dll *.a *.base *.exp
231 $(CC) $(CFLAGS) -c -DGLIB_COMPILATION -DG_LOG_DOMAIN=g_log_domain_glib $<
234 $(CC) $(CFLAGS) -E -DGLIB_COMPILATION -DG_LOG_DOMAIN=g_log_domain_glib $< >$@