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)
84 glibconfig.h: glibconfig.h.win32
85 cp glibconfig.h.win32 glibconfig.h
87 config.h: config.h.win32
88 cp config.h.win32 config.h
92 # The *.stamp files aren't distributed. Thus, this takes care of only
93 # tml building libraries with nonzero build number.
95 ifeq ($(wildcard glib-build.stamp),glib-build.stamp)
96 # Bump the build number
98 bash -c "read number && echo $$[number+1]" <glib-build.stamp >glib-build.tmp
99 cp glib-build.tmp glib-build.stamp
101 # Use zero as build number.
103 echo 0 >glib-build.tmp
106 glib-win32res.o : glib.rc glib-build.tmp
107 m4 -DBUILDNUMBER=`cat glib-build.tmp` <glib.rc >glib-win32res.rc
108 windres --include-dir $(WIN32APIHEADERS) glib-win32res.rc glib-win32res.o
109 rm glib-build.tmp glib-win32res.rc
111 glib-$(GLIB_VER).dll : $(glib_OBJECTS) glib.def
112 ./build-dll glib $(GLIB_VER) glib.def $(glib_OBJECTS) -luser32 -lwsock32
115 ################ gmodule
121 # Unfortunately I couldn't use a pattern rule for this, so copy-paste
123 ifeq ($(wildcard glib-build.stamp),glib-build.stamp)
125 bash -c "read number && echo $$[number+1]" <gmodule-build.stamp >gmodule-build.tmp
126 cp gmodule-build.tmp gmodule-build.stamp
129 echo 0 >gmodule-build.tmp
132 gmodule-win32res.o : gmodule/gmodule.rc gmodule-build.tmp
133 m4 -DBUILDNUMBER=`cat gmodule-build.tmp` <gmodule/gmodule.rc >gmodule-win32res.rc
134 windres --include-dir $(WIN32APIHEADERS) gmodule-win32res.rc gmodule-win32res.o
135 rm gmodule-build.tmp gmodule-win32res.rc
138 gmodule-$(GLIB_VER).dll : $(gmodule_OBJECTS) gmodule/gmodule.def
139 ./build-dll gmodule $(GLIB_VER) gmodule/gmodule.def $(gmodule_OBJECTS) -L. -lglib-$(GLIB_VER) -lwsock32
141 gmodule.o : gmodule/gmodule.c gmodule/gmodule-win32.c
142 $(CC) $(CFLAGS) -Igmodule -c -DG_LOG_DOMAIN=g_log_domain_gmodule gmodule/gmodule.c
144 gmodule/gmoduleconf.h: gmodule/gmoduleconf.h.win32
145 cp gmodule/gmoduleconf.h.win32 gmodule/gmoduleconf.h
147 ################ gthread
154 ifeq ($(wildcard glib-build.stamp),glib-build.stamp)
156 bash -c "read number && echo $$[number+1]" <gthread-build.stamp >gthread-build.tmp
157 cp gthread-build.tmp gthread-build.stamp
160 echo 0 >gthread-build.tmp
163 gthread-win32res.o : gthread/gthread.rc gthread-build.tmp
164 m4 -DBUILDNUMBER=`cat gthread-build.tmp` <gthread/gthread.rc >gthread-win32res.rc
165 windres --include-dir $(WIN32APIHEADERS) gthread-win32res.rc gthread-win32res.o
166 rm gthread-build.tmp gthread-win32res.rc
169 gthread-$(GLIB_VER).dll : $(gthread_OBJECTS) glib-$(GLIB_VER).dll gthread/gthread.def
170 ./build-dll gthread $(GLIB_VER) gthread/gthread.def $(gthread_OBJECTS) -L. -lglib-$(GLIB_VER) $(PTHREAD_LIB)
172 gthread-impl.o : gthread/gthread-impl.c gthread/gthread-posix.c
173 $(CC) $(CFLAGS) $(PTHREAD_INC) -DG_LOG_DOMAIN=\"GThread\" -c gthread/gthread-impl.c
175 ################ test progs
177 testglib.exe : glib-$(GLIB_VER).dll testglib.o
178 $(CC) $(CFLAGS) -o testglib testglib.o -L. -lglib-$(GLIB_VER) $(LDFLAGS)
180 testglib.o : testglib.c
181 $(CC) -c $(CFLAGS) testglib.c
183 testgdate.exe : glib-$(GLIB_VER).dll testgdate.o
184 $(CC) $(CFLAGS) -o testgdate.exe testgdate.o -L. -lglib-$(GLIB_VER) $(LDFLAGS)
186 testgdate.o : testgdate.c
187 $(CC) -c $(CFLAGS) testgdate.c
189 testgdateparser.exe : glib-$(GLIB_VER).dll testgdateparser.o
190 $(CC) $(CFLAGS) -o testgdateparser.exe testgdateparser.o -L. -lglib-$(GLIB_VER) $(LDFLAGS)
192 testgdateparser.o : testgdateparser.c
193 $(CC) -c $(CFLAGS) testgdateparser.c
195 testgmodule.exe : glib-$(GLIB_VER).dll gmodule-$(GLIB_VER).dll testgmodule.o libgplugin_a.dll libgplugin_b.dll
196 # Wow, do we really have to do it like this to get some symbols
197 # exported from a .exe? Apparently yes. Does the __declspec(dllexport)
198 # actually do anything in egcs-1.1.2?
199 $(CC) $(CFLAGS) -Wl,--base-file,testgmodule.base -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,--base-file,testgmodule.base,testgmodule.exp -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,testgmodule.exp -o testgmodule.exe testgmodule.o -L. -lglib-$(GLIB_VER) -lgmodule-$(GLIB_VER) $(LDFLAGS)
205 testgmodule.o : gmodule/testgmodule.c
206 $(CC) $(CFLAGS) -Igmodule -c gmodule/testgmodule.c
208 libgplugin_a.dll : libgplugin_a.o
209 ./build-dll libgplugin_a - - libgplugin_a.o -L. -lglib-$(GLIB_VER) -lgmodule-$(GLIB_VER)
211 libgplugin_a.o : gmodule/libgplugin_a.c
212 $(CC) $(CFLAGS) -Igmodule -c gmodule/libgplugin_a.c
214 libgplugin_b.dll : libgplugin_b.o
215 ./build-dll libgplugin_b - - libgplugin_b.o -L. -lglib-$(GLIB_VER) -lgmodule-$(GLIB_VER)
217 libgplugin_b.o : gmodule/libgplugin_b.c
218 $(CC) $(CFLAGS) -Igmodule -c gmodule/libgplugin_b.c
220 ################ other stuff
223 -rm config.h glibconfig.h gmodule/gmoduleconf.h
224 -rm *.exe *.o *.dll *.a *.base *.exp
229 $(CC) $(CFLAGS) -c -DGLIB_COMPILATION -DG_LOG_DOMAIN=g_log_domain_glib $<
232 $(CC) $(CFLAGS) -E -DGLIB_COMPILATION -DG_LOG_DOMAIN=g_log_domain_glib $< >$@