Interpret EINTR as G_IO_ERROR_AGAIN.
[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
32 WIN32APIHEADERS = $(shell echo "\#include <winver.h>" | $(CC) -M -E - | tail -1 | sed -e 's!/winver.h!!')
33
34 all : \
35         config.h        \
36         glibconfig.h    \
37         glib-$(GLIB_VER).dll \
38         gmodule/gmoduleconf.h \
39         gmodule-$(GLIB_VER).dll \
40         gthread-$(GLIB_VER).dll \
41         testglib.exe    \
42         testgmodule.exe \
43         testgdate.exe   \
44         testgdateparser.exe
45
46 install : all
47         $(INSTALL) glib-$(GLIB_VER).dll $(BIN)
48         $(INSTALL) gmodule-$(GLIB_VER).dll $(BIN)
49         $(INSTALL) gthread-$(GLIB_VER).dll $(BIN)
50
51 glib_OBJECTS = \
52         garray.o        \
53         gcache.o        \
54         gcompletion.o   \
55         gdataset.o      \
56         gdate.o         \
57         gerror.o        \
58         ghook.o         \
59         ghash.o         \
60         giochannel.o    \
61         giowin32.o      \
62         glist.o         \
63         gmain.o         \
64         gmem.o          \
65         gmessages.o     \
66         gnode.o         \
67         gprimes.o       \
68         gqueue.o        \
69         grand.o         \
70         gslist.o        \
71         gthread.o       \
72         gtimer.o        \
73         gtree.o         \
74         grel.o          \
75         gstring.o       \
76         gstrfuncs.o     \
77         gscanner.o      \
78         gutils.o        \
79         gwin32.o        \
80         glib-win32res.o
81
82 glibconfig.h: glibconfig.h.win32
83         cp glibconfig.h.win32 glibconfig.h
84
85 config.h: config.h.win32
86         cp config.h.win32 config.h
87
88 ################ glib
89
90 # The *.stamp files aren't distributed. Thus, this takes care of only
91 # tml building libraries with nonzero build number.
92
93 ifeq ($(wildcard glib-build.stamp),glib-build.stamp)
94 # Bump the build number
95 glib-build.tmp :
96         bash -c "read number && echo $$[number+1]" <glib-build.stamp >glib-build.tmp
97         cp glib-build.tmp glib-build.stamp
98 else
99 # Use zero as build number.
100 glib-build.tmp :
101         echo 0 >glib-build.tmp
102 endif
103
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
108
109 glib-$(GLIB_VER).dll : $(glib_OBJECTS) glib.def
110         ./build-dll glib $(GLIB_VER) glib.def $(glib_OBJECTS) -luser32 -lwsock32
111
112
113 ################ gmodule
114
115 gmodule_OBJECTS = \
116         gmodule.o       \
117         gmodule-win32res.o
118
119 # Unfortunately I couldn't use a pattern rule for this, so copy-paste
120 # from above.
121 ifeq ($(wildcard glib-build.stamp),glib-build.stamp)
122 gmodule-build.tmp :
123         bash -c "read number && echo $$[number+1]" <gmodule-build.stamp >gmodule-build.tmp
124         cp gmodule-build.tmp gmodule-build.stamp
125 else
126 gmodule-build.tmp :
127         echo 0 >gmodule-build.tmp
128 endif
129
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
134
135
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
138
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
141
142 gmodule/gmoduleconf.h: gmodule/gmoduleconf.h.win32
143         cp gmodule/gmoduleconf.h.win32 gmodule/gmoduleconf.h
144
145 ################ gthread
146
147 gthread_OBJECTS = \
148         gthread-impl.o  \
149         gthread-win32res.o
150
151 # Ditto copy-pasting
152 ifeq ($(wildcard glib-build.stamp),glib-build.stamp)
153 gthread-build.tmp :
154         bash -c "read number && echo $$[number+1]" <gthread-build.stamp >gthread-build.tmp
155         cp gthread-build.tmp gthread-build.stamp
156 else
157 gthread-build.tmp :
158         echo 0 >gthread-build.tmp
159 endif
160
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
165
166
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)
169
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
172
173 ################ test progs
174
175 testglib.exe : glib-$(GLIB_VER).dll testglib.o
176         $(CC) $(CFLAGS) -o testglib testglib.o -L. -lglib-$(GLIB_VER) $(LDFLAGS)
177
178 testglib.o : testglib.c
179         $(CC) -c $(CFLAGS) testglib.c
180
181 testgdate.exe : glib-$(GLIB_VER).dll testgdate.o
182         $(CC) $(CFLAGS) -o testgdate.exe testgdate.o -L. -lglib-$(GLIB_VER) $(LDFLAGS)
183
184 testgdate.o : testgdate.c
185         $(CC) -c $(CFLAGS) testgdate.c
186
187 testgdateparser.exe : glib-$(GLIB_VER).dll testgdateparser.o
188         $(CC) $(CFLAGS) -o testgdateparser.exe testgdateparser.o -L. -lglib-$(GLIB_VER) $(LDFLAGS)
189
190 testgdateparser.o : testgdateparser.c
191         $(CC) -c $(CFLAGS) testgdateparser.c
192
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)
202
203 testgmodule.o : gmodule/testgmodule.c
204         $(CC) $(CFLAGS) -Igmodule -c gmodule/testgmodule.c
205
206 libgplugin_a.dll : libgplugin_a.o
207         ./build-dll libgplugin_a - - libgplugin_a.o -L. -lglib-$(GLIB_VER) -lgmodule-$(GLIB_VER)
208
209 libgplugin_a.o : gmodule/libgplugin_a.c
210         $(CC) $(CFLAGS) -Igmodule -c gmodule/libgplugin_a.c
211
212 libgplugin_b.dll : libgplugin_b.o
213         ./build-dll libgplugin_b - - libgplugin_b.o -L. -lglib-$(GLIB_VER) -lgmodule-$(GLIB_VER)
214
215 libgplugin_b.o : gmodule/libgplugin_b.c
216         $(CC) $(CFLAGS) -Igmodule -c gmodule/libgplugin_b.c
217
218 ################ other stuff
219
220 clean:
221         -rm config.h glibconfig.h gmodule/gmoduleconf.h
222         -rm *.exe *.o *.dll *.a *.base *.exp
223
224 .SUFFIXES: .c .o .i
225
226 .c.o :
227         $(CC) $(CFLAGS) -c -DGLIB_COMPILATION -DG_LOG_DOMAIN=g_log_domain_glib $<
228
229 .c.i :
230         $(CC) $(CFLAGS) -E -DGLIB_COMPILATION -DG_LOG_DOMAIN=g_log_domain_glib $< >$@
231