c5f9f2bb996f394a935b98a4dd8d241ef6da4c6c
[platform/upstream/glib.git] / makefile.cygwin.in
1 ## Makefile for building the GLib, gmodule and gthread DLLs with
2 ## gcc on mingw or cygwin.
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 GLIB_VER = @GLIB_MAJOR_VERSION@.@GLIB_MINOR_VERSION@
19
20 TOP = ..
21
22 include $(TOP)/build/win32/make.mingw
23
24 ################################################################
25
26 # Nothing much configurable below
27
28 DLLTOOL = dlltool
29 INSTALL = install
30
31 INCLUDES = -I .
32 DEFINES = -DHAVE_CONFIG_H -DGLIB_COMPILATION -DG_LOG_DOMAIN=g_log_domain_glib
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         gasyncqueue.o   \
54         gcache.o        \
55         gcompletion.o   \
56         gdataset.o      \
57         gdate.o         \
58         gerror.o        \
59         ghook.o         \
60         ghash.o         \
61         giochannel.o    \
62         giowin32.o      \
63         glist.o         \
64         gmain.o         \
65         gmem.o          \
66         gmessages.o     \
67         gnode.o         \
68         gprimes.o       \
69         gqueue.o        \
70         grand.o         \
71         gslist.o        \
72         gthread.o       \
73         gthreadpool.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 testgdate.exe : glib-$(GLIB_VER).dll testgdate.o
181         $(CC) $(CFLAGS) -o testgdate.exe testgdate.o -L. -lglib-$(GLIB_VER) $(LDFLAGS)
182
183 testgdate.o : testgdate.c
184         $(CC) -c $(CFLAGS) testgdate.c
185
186 testgdateparser.exe : glib-$(GLIB_VER).dll testgdateparser.o
187         $(CC) $(CFLAGS) -o testgdateparser.exe testgdateparser.o -L. -lglib-$(GLIB_VER) $(LDFLAGS)
188
189 testgdateparser.o : testgdateparser.c
190         $(CC) -c $(CFLAGS) testgdateparser.c
191
192 testgmodule.exe : glib-$(GLIB_VER).dll gmodule-$(GLIB_VER).dll testgmodule.o libgplugin_a.dll libgplugin_b.dll
193 # Wow, do we really have to do it like this to get some symbols
194 # exported from a .exe? Apparently yes. Does the __declspec(dllexport) 
195 # actually do anything in egcs-1.1.2?
196         $(CC) $(CFLAGS) -Wl,--base-file,testgmodule.base -o testgmodule.exe testgmodule.o -L. -lglib-$(GLIB_VER) -lgmodule-$(GLIB_VER) $(LDFLAGS)
197         $(DLLTOOL) --base-file testgmodule.base --output-exp testgmodule.exp testgmodule.o
198         $(CC) $(CFLAGS) -Wl,--base-file,testgmodule.base,testgmodule.exp -o testgmodule.exe testgmodule.o -L. -lglib-$(GLIB_VER) -lgmodule-$(GLIB_VER) $(LDFLAGS)
199         $(DLLTOOL) --base-file testgmodule.base --output-exp testgmodule.exp testgmodule.o
200         $(CC) $(CFLAGS) -Wl,testgmodule.exp -o testgmodule.exe testgmodule.o -L. -lglib-$(GLIB_VER) -lgmodule-$(GLIB_VER) $(LDFLAGS)
201
202 testgmodule.o : gmodule/testgmodule.c
203         $(CC) $(CFLAGS) -Igmodule -c gmodule/testgmodule.c
204
205 libgplugin_a.dll : libgplugin_a.o
206         ./build-dll libgplugin_a - - libgplugin_a.o -L. -lglib-$(GLIB_VER) -lgmodule-$(GLIB_VER)
207
208 libgplugin_a.o : gmodule/libgplugin_a.c
209         $(CC) $(CFLAGS) -Igmodule -c gmodule/libgplugin_a.c
210
211 libgplugin_b.dll : libgplugin_b.o
212         ./build-dll libgplugin_b - - libgplugin_b.o -L. -lglib-$(GLIB_VER) -lgmodule-$(GLIB_VER)
213
214 libgplugin_b.o : gmodule/libgplugin_b.c
215         $(CC) $(CFLAGS) -Igmodule -c gmodule/libgplugin_b.c
216
217 ################ other stuff
218
219 clean::
220         -rm config.h glibconfig.h gmodule/gmoduleconf.h