Support added for building using a GNU toolchain on Win32,
[platform/upstream/glib.git] / makefile.cygwin
1 ## Makefile for building the GLib, gmodule and gthread DLLs with
2 ## egcs on 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 PTHREADS = ../pthreads-snap-1999-04-07
12 PTHREAD_LIB = -L$(PTHREADS) -lpthread
13 PTHREAD_INC = -I $(PTHREADS)
14
15 ################################################################
16
17 # Nothing much configurable below
18
19 CC = gcc -mno-cygwin -mpentium
20
21 CP = cp
22 LD = ld
23 DLLTOOL = dlltool
24 INSTALL = install
25
26 GLIB_VER = 1.3
27
28 CFLAGS = -g -O2 -I. -DHAVE_CONFIG_H
29
30 all : \
31         glibconfig.h    \
32         config.h        \
33         glib-$(GLIB_VER).dll    \
34         gthread-$(GLIB_VER).dll \
35         gmodule/gmoduleconf.h \
36         gmodule-$(GLIB_VER).dll \
37         testglib.exe    \
38         testgmodule.exe \
39         testgdate.exe   \
40         testgdateparser.exe \
41         testgthread.exe
42
43 install : all
44         $(INSTALL) glib-$(GLIB_VER).dll $(BIN)
45         $(INSTALL) gmodule-$(GLIB_VER).dll $(BIN)
46         $(INSTALL) gthread-$(GLIB_VER).dll $(BIN)
47
48 glib_OBJECTS = \
49         garray.o        \
50         gcache.o        \
51         gcompletion.o   \
52         gdataset.o      \
53         gdate.o         \
54         gerror.o        \
55         ghook.o         \
56         ghash.o         \
57         giochannel.o    \
58         giowin32.o      \
59         glist.o         \
60         gmain.o         \
61         gmem.o          \
62         gmessages.o     \
63         gmutex.o        \
64         gnode.o         \
65         gprimes.o       \
66         gqueue.o        \
67         grand.o         \
68         gslist.o        \
69         gstack.o        \
70         gtimer.o        \
71         gtree.o         \
72         grel.o          \
73         gstring.o       \
74         gstrfuncs.o     \
75         gscanner.o      \
76         gutils.o
77
78 glib-$(GLIB_VER).dll : $(glib_OBJECTS) glib.def
79         ./build-dll glib $(GLIB_VER) glib.def $(glib_OBJECTS) -lmsvcrt -lkernel32 -luser32 -ladvapi32 -lwsock32
80
81 glibconfig.h: glibconfig.h.win32
82         $(CP) glibconfig.h.win32 glibconfig.h
83
84 config.h: config.h.win32
85         $(CP) config.h.win32 config.h
86
87 .c.o :
88         $(CC) $(CFLAGS) -c -DGLIB_COMPILATION -DG_LOG_DOMAIN=g_log_domain_glib $<
89
90 gmodule_OBJECTS = \
91         gmodule.o
92
93 gmodule-$(GLIB_VER).dll : $(gmodule_OBJECTS) gmodule/gmodule.def
94         ./build-dll gmodule $(GLIB_VER) gmodule/gmodule.def $(gmodule_OBJECTS) -L. -lglib-$(GLIB_VER) -lmsvcrt -lkernel32 -luser32 -ladvapi32 -lwsock32
95
96 gmodule.o : gmodule/gmodule.c gmodule/gmodule-win32.c
97         $(CC) $(CFLAGS) -Igmodule -c -DG_LOG_DOMAIN=g_log_domain_gmodule gmodule/gmodule.c
98
99 gmodule/gmoduleconf.h: gmodule/gmoduleconf.h.win32
100         $(CP) gmodule/gmoduleconf.h.win32 gmodule/gmoduleconf.h
101
102 gthread_OBJECTS = \
103         gthread.o
104
105 gthread-$(GLIB_VER).dll : $(gthread_OBJECTS) glib-$(GLIB_VER).dll gthread/gthread.def
106         ./build-dll gthread $(GLIB_VER) gthread/gthread.def $(gthread_OBJECTS)  -L. -lglib-$(GLIB_VER) $(PTHREAD_LIB) -lmsvcrt -lkernel32 -luser32 -ladvapi32 -lwsock32
107
108 gthread.o : gthread/gthread.c gthread/gthread-posix.c
109         $(CC) $(CFLAGS) $(PTHREAD_INC) -DG_LOG_DOMAIN=\"GThread\" -c gthread/gthread.c
110
111 testglib.exe : glib-$(GLIB_VER).dll testglib.o
112         $(CC) $(CFLAGS) -o testglib testglib.o -L. -lglib-$(GLIB_VER) -lmsvcrt $(LDFLAGS)
113
114 testglib.o : testglib.c
115         $(CC) -c $(CFLAGS) testglib.c
116
117 testgdate.exe : glib-$(GLIB_VER).dll testgdate.o
118         $(CC) $(CFLAGS) -o testgdate.exe testgdate.o -L. -lglib-$(GLIB_VER) -lmsvcrt $(LDFLAGS)
119
120 testgdate.o : testgdate.c
121         $(CC) -c $(CFLAGS) testgdate.c
122
123 testgdateparser.exe : glib-$(GLIB_VER).dll testgdateparser.o
124         $(CC) $(CFLAGS) -o testgdateparser.exe testgdateparser.o -L. -lglib-$(GLIB_VER) -lmsvcrt $(LDFLAGS)
125
126 testgdateparser.o : testgdateparser.c
127         $(CC) -c $(CFLAGS) testgdateparser.c
128
129 testgmodule.exe : glib-$(GLIB_VER).dll gmodule-$(GLIB_VER).dll testgmodule.o libgplugin_a.dll libgplugin_b.dll
130 # Wow, do we really have to do it like this to get some symbols
131 # exported from a .exe? Apparently yes. Does the __declspec(dllexport) 
132 # actually do anything in egcs-1.1.2?
133         $(CC) $(CFLAGS) -Wl,--base-file,testgmodule.base -o testgmodule.exe testgmodule.o -L. -lglib-$(GLIB_VER) -lgmodule-$(GLIB_VER) -lmsvcrt $(LDFLAGS)
134         $(DLLTOOL) --base-file testgmodule.base --output-exp testgmodule.exp testgmodule.o
135         $(CC) $(CFLAGS) -Wl,--base-file,testgmodule.base,testgmodule.exp -o testgmodule.exe testgmodule.o -L. -lglib-$(GLIB_VER) -lgmodule-$(GLIB_VER) -lmsvcrt $(LDFLAGS)
136         $(DLLTOOL) --base-file testgmodule.base --output-exp testgmodule.exp testgmodule.o
137         $(CC) $(CFLAGS) -Wl,testgmodule.exp -o testgmodule.exe testgmodule.o -L. -lglib-$(GLIB_VER) -lgmodule-$(GLIB_VER) -lmsvcrt $(LDFLAGS)
138
139 testgmodule.o : gmodule/testgmodule.c
140         $(CC) $(CFLAGS) -Igmodule -c gmodule/testgmodule.c
141
142 libgplugin_a.dll : libgplugin_a.o
143         ./build-dll libgplugin_a - - libgplugin_a.o -L. -lglib-$(GLIB_VER) -lgmodule-$(GLIB_VER) -lmsvcrt
144
145 libgplugin_a.o : gmodule/libgplugin_a.c
146         $(CC) $(CFLAGS) -Igmodule -c gmodule/libgplugin_a.c
147
148 libgplugin_b.dll : libgplugin_b.o
149         ./build-dll libgplugin_b - - libgplugin_b.o -L. -lglib-$(GLIB_VER) -lgmodule-$(GLIB_VER) -lmsvcrt
150
151 libgplugin_b.o : gmodule/libgplugin_b.c
152         $(CC) $(CFLAGS) -Igmodule -c gmodule/libgplugin_b.c
153
154 testgthread.exe : glib-$(GLIB_VER).dll gthread-$(GLIB_VER).dll testgthread.o
155         $(CC) $(CFLAGS) -o testgthread.exe testgthread.o -L. -lglib-$(GLIB_VER) -lgthread-$(GLIB_VER) $(PTHREAD_LIB) $(LDFLAGS)
156
157 testgthread.o : gthread/testgthread.c
158         $(CC) $(CFLAGS) $(PTHREAD_INC) -c gthread/testgthread.c
159
160 clean:
161         -rm config.h
162         -rm glibconfig.h
163         -rm gmodule/gmoduleconf.h
164         -rm *.exe
165         -rm *.o
166         -rm *.dll
167         -rm *.a
168         -rm *.base
169         -rm *.exp