Add new functions. Add new object files. Add threadpool-test. No need to
[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         gasyncqueue.o   \
56         gcache.o        \
57         gcompletion.o   \
58         gdataset.o      \
59         gdate.o         \
60         gerror.o        \
61         ghook.o         \
62         ghash.o         \
63         giochannel.o    \
64         giowin32.o      \
65         glist.o         \
66         gmain.o         \
67         gmem.o          \
68         gmessages.o     \
69         gnode.o         \
70         gprimes.o       \
71         gqueue.o        \
72         grand.o         \
73         gslist.o        \
74         gthread.o       \
75         gthreadpool.o   \
76         gtimer.o        \
77         gtree.o         \
78         grel.o          \
79         gstring.o       \
80         gstrfuncs.o     \
81         gscanner.o      \
82         gutils.o        \
83         gwin32.o        \
84         glib-win32res.o
85
86 glibconfig.h: glibconfig.h.win32
87         cp glibconfig.h.win32 glibconfig.h
88
89 config.h: config.h.win32
90         cp config.h.win32 config.h
91
92 ################ glib
93
94 # The *.stamp files aren't distributed. Thus, this takes care of only
95 # tml building libraries with nonzero build number.
96
97 ifeq ($(wildcard glib-build.stamp),glib-build.stamp)
98 # Bump the build number
99 glib-build.tmp :
100         bash -c "read number && echo $$[number+1]" <glib-build.stamp >glib-build.tmp
101         cp glib-build.tmp glib-build.stamp
102 else
103 # Use zero as build number.
104 glib-build.tmp :
105         echo 0 >glib-build.tmp
106 endif
107
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
112
113 glib-$(GLIB_VER).dll : $(glib_OBJECTS) glib.def
114         ./build-dll glib $(GLIB_VER) glib.def $(glib_OBJECTS) -luser32 -lwsock32
115
116
117 ################ gmodule
118
119 gmodule_OBJECTS = \
120         gmodule.o       \
121         gmodule-win32res.o
122
123 # Unfortunately I couldn't use a pattern rule for this, so copy-paste
124 # from above.
125 ifeq ($(wildcard glib-build.stamp),glib-build.stamp)
126 gmodule-build.tmp :
127         bash -c "read number && echo $$[number+1]" <gmodule-build.stamp >gmodule-build.tmp
128         cp gmodule-build.tmp gmodule-build.stamp
129 else
130 gmodule-build.tmp :
131         echo 0 >gmodule-build.tmp
132 endif
133
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
138
139
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
142
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
145
146 gmodule/gmoduleconf.h: gmodule/gmoduleconf.h.win32
147         cp gmodule/gmoduleconf.h.win32 gmodule/gmoduleconf.h
148
149 ################ gthread
150
151 gthread_OBJECTS = \
152         gthread-impl.o  \
153         gthread-win32res.o
154
155 # Ditto copy-pasting
156 ifeq ($(wildcard glib-build.stamp),glib-build.stamp)
157 gthread-build.tmp :
158         bash -c "read number && echo $$[number+1]" <gthread-build.stamp >gthread-build.tmp
159         cp gthread-build.tmp gthread-build.stamp
160 else
161 gthread-build.tmp :
162         echo 0 >gthread-build.tmp
163 endif
164
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
169
170
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)
173
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
176
177 ################ test progs
178
179 testglib.exe : glib-$(GLIB_VER).dll testglib.o
180         $(CC) $(CFLAGS) -o testglib testglib.o -L. -lglib-$(GLIB_VER) $(LDFLAGS)
181
182 testglib.o : testglib.c
183         $(CC) -c $(CFLAGS) testglib.c
184
185 testgdate.exe : glib-$(GLIB_VER).dll testgdate.o
186         $(CC) $(CFLAGS) -o testgdate.exe testgdate.o -L. -lglib-$(GLIB_VER) $(LDFLAGS)
187
188 testgdate.o : testgdate.c
189         $(CC) -c $(CFLAGS) testgdate.c
190
191 testgdateparser.exe : glib-$(GLIB_VER).dll testgdateparser.o
192         $(CC) $(CFLAGS) -o testgdateparser.exe testgdateparser.o -L. -lglib-$(GLIB_VER) $(LDFLAGS)
193
194 testgdateparser.o : testgdateparser.c
195         $(CC) -c $(CFLAGS) testgdateparser.c
196
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)
206
207 testgmodule.o : gmodule/testgmodule.c
208         $(CC) $(CFLAGS) -Igmodule -c gmodule/testgmodule.c
209
210 libgplugin_a.dll : libgplugin_a.o
211         ./build-dll libgplugin_a - - libgplugin_a.o -L. -lglib-$(GLIB_VER) -lgmodule-$(GLIB_VER)
212
213 libgplugin_a.o : gmodule/libgplugin_a.c
214         $(CC) $(CFLAGS) -Igmodule -c gmodule/libgplugin_a.c
215
216 libgplugin_b.dll : libgplugin_b.o
217         ./build-dll libgplugin_b - - libgplugin_b.o -L. -lglib-$(GLIB_VER) -lgmodule-$(GLIB_VER)
218
219 libgplugin_b.o : gmodule/libgplugin_b.c
220         $(CC) $(CFLAGS) -Igmodule -c gmodule/libgplugin_b.c
221
222 ################ other stuff
223
224 clean:
225         -rm config.h glibconfig.h gmodule/gmoduleconf.h
226         -rm *.exe *.o *.dll *.a *.base *.exp
227
228 .SUFFIXES: .c .o .i
229
230 .c.o :
231         $(CC) $(CFLAGS) -c -DGLIB_COMPILATION -DG_LOG_DOMAIN=g_log_domain_glib $<
232
233 .c.i :
234         $(CC) $(CFLAGS) -E -DGLIB_COMPILATION -DG_LOG_DOMAIN=g_log_domain_glib $< >$@
235