Add configure test for garbage collector friendliness for GLib. If
[platform/upstream/glib.git] / makefile.cygwin.in
1 ## Makefile for building the GLib, gmodule and gthread DLLs with
2 ## gcc on cygwin or mingw32.
3 ## Use: make -f makefile.cygwin install
4
5 # Change this to wherever you want to install the DLLs. This directory
6 # should be in your PATH.
7 BIN = /bin
8
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)
15
16 OPTIMIZE = -g -O
17
18 ################################################################
19
20 # Nothing much configurable below
21
22 CC = gcc -mno-cygwin -mpentium -fnative-struct
23
24 DLLTOOL = dlltool
25 INSTALL = install
26
27 GLIB_VER = @GLIB_MAJOR_VERSION@.@GLIB_MINOR_VERSION@
28
29 CFLAGS = $(OPTIMIZE) -I. -DHAVE_CONFIG_H
30
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')
35
36 all : \
37         config.h        \
38         glibconfig.h    \
39         glib-$(GLIB_VER).dll \
40         gmodule/gmoduleconf.h \
41         gmodule-$(GLIB_VER).dll \
42         gthread-$(GLIB_VER).dll \
43         testglib.exe    \
44         testgmodule.exe \
45         testgdate.exe   \
46         testgdateparser.exe
47
48 install : all
49         $(INSTALL) glib-$(GLIB_VER).dll $(BIN)
50         $(INSTALL) gmodule-$(GLIB_VER).dll $(BIN)
51         $(INSTALL) gthread-$(GLIB_VER).dll $(BIN)
52
53 glib_OBJECTS = \
54         garray.o        \
55         gcache.o        \
56         gcompletion.o   \
57         gdataset.o      \
58         gdate.o         \
59         gerror.o        \
60         ghook.o         \
61         ghash.o         \
62         giochannel.o    \
63         giowin32.o      \
64         glist.o         \
65         gmain.o         \
66         gmem.o          \
67         gmessages.o     \
68         gnode.o         \
69         gprimes.o       \
70         gqueue.o        \
71         grand.o         \
72         gslist.o        \
73         gthread.o       \
74         gtimer.o        \
75         gtree.o         \
76         grel.o          \
77         gstring.o       \
78         gstrfuncs.o     \
79         gscanner.o      \
80         gutils.o        \
81         gwin32.o        \
82         glib-win32res.o
83
84 glibconfig.h: glibconfig.h.win32
85         cp glibconfig.h.win32 glibconfig.h
86
87 config.h: config.h.win32
88         cp config.h.win32 config.h
89
90 ################ glib
91
92 # The *.stamp files aren't distributed. Thus, this takes care of only
93 # tml building libraries with nonzero build number.
94
95 ifeq ($(wildcard glib-build.stamp),glib-build.stamp)
96 # Bump the build number
97 glib-build.tmp :
98         bash -c "read number && echo $$[number+1]" <glib-build.stamp >glib-build.tmp
99         cp glib-build.tmp glib-build.stamp
100 else
101 # Use zero as build number.
102 glib-build.tmp :
103         echo 0 >glib-build.tmp
104 endif
105
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
110
111 glib-$(GLIB_VER).dll : $(glib_OBJECTS) glib.def
112         ./build-dll glib $(GLIB_VER) glib.def $(glib_OBJECTS) -luser32 -lwsock32
113
114
115 ################ gmodule
116
117 gmodule_OBJECTS = \
118         gmodule.o       \
119         gmodule-win32res.o
120
121 # Unfortunately I couldn't use a pattern rule for this, so copy-paste
122 # from above.
123 ifeq ($(wildcard glib-build.stamp),glib-build.stamp)
124 gmodule-build.tmp :
125         bash -c "read number && echo $$[number+1]" <gmodule-build.stamp >gmodule-build.tmp
126         cp gmodule-build.tmp gmodule-build.stamp
127 else
128 gmodule-build.tmp :
129         echo 0 >gmodule-build.tmp
130 endif
131
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
136
137
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
140
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
143
144 gmodule/gmoduleconf.h: gmodule/gmoduleconf.h.win32
145         cp gmodule/gmoduleconf.h.win32 gmodule/gmoduleconf.h
146
147 ################ gthread
148
149 gthread_OBJECTS = \
150         gthread-impl.o  \
151         gthread-win32res.o
152
153 # Ditto copy-pasting
154 ifeq ($(wildcard glib-build.stamp),glib-build.stamp)
155 gthread-build.tmp :
156         bash -c "read number && echo $$[number+1]" <gthread-build.stamp >gthread-build.tmp
157         cp gthread-build.tmp gthread-build.stamp
158 else
159 gthread-build.tmp :
160         echo 0 >gthread-build.tmp
161 endif
162
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
167
168
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)
171
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
174
175 ################ test progs
176
177 testglib.exe : glib-$(GLIB_VER).dll testglib.o
178         $(CC) $(CFLAGS) -o testglib testglib.o -L. -lglib-$(GLIB_VER) $(LDFLAGS)
179
180 testglib.o : testglib.c
181         $(CC) -c $(CFLAGS) testglib.c
182
183 testgdate.exe : glib-$(GLIB_VER).dll testgdate.o
184         $(CC) $(CFLAGS) -o testgdate.exe testgdate.o -L. -lglib-$(GLIB_VER) $(LDFLAGS)
185
186 testgdate.o : testgdate.c
187         $(CC) -c $(CFLAGS) testgdate.c
188
189 testgdateparser.exe : glib-$(GLIB_VER).dll testgdateparser.o
190         $(CC) $(CFLAGS) -o testgdateparser.exe testgdateparser.o -L. -lglib-$(GLIB_VER) $(LDFLAGS)
191
192 testgdateparser.o : testgdateparser.c
193         $(CC) -c $(CFLAGS) testgdateparser.c
194
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)
204
205 testgmodule.o : gmodule/testgmodule.c
206         $(CC) $(CFLAGS) -Igmodule -c gmodule/testgmodule.c
207
208 libgplugin_a.dll : libgplugin_a.o
209         ./build-dll libgplugin_a - - libgplugin_a.o -L. -lglib-$(GLIB_VER) -lgmodule-$(GLIB_VER)
210
211 libgplugin_a.o : gmodule/libgplugin_a.c
212         $(CC) $(CFLAGS) -Igmodule -c gmodule/libgplugin_a.c
213
214 libgplugin_b.dll : libgplugin_b.o
215         ./build-dll libgplugin_b - - libgplugin_b.o -L. -lglib-$(GLIB_VER) -lgmodule-$(GLIB_VER)
216
217 libgplugin_b.o : gmodule/libgplugin_b.c
218         $(CC) $(CFLAGS) -Igmodule -c gmodule/libgplugin_b.c
219
220 ################ other stuff
221
222 clean:
223         -rm config.h glibconfig.h gmodule/gmoduleconf.h
224         -rm *.exe *.o *.dll *.a *.base *.exp
225
226 .SUFFIXES: .c .o .i
227
228 .c.o :
229         $(CC) $(CFLAGS) -c -DGLIB_COMPILATION -DG_LOG_DOMAIN=g_log_domain_glib $<
230
231 .c.i :
232         $(CC) $(CFLAGS) -E -DGLIB_COMPILATION -DG_LOG_DOMAIN=g_log_domain_glib $< >$@
233