win32: Allow POSIX threads to be used if --with-threads=posix
[platform/upstream/glib.git] / glib / Makefile.am
1 ## Process this file with automake to produce Makefile.in
2 include $(top_srcdir)/Makefile.decl
3
4 BUILT_SOURCES =
5 DISTCLEANFILES =
6 CLEANFILES =
7
8 #
9 # Generate glibconfig.h
10 #
11 # The timestamp of the stamp file is used to indicate if glibconfig.h is
12 # up to date with respect to config.status.  In the usual case, changes
13 # to config.status will not result in changes to glibconfig.h so we
14 # avoid touching its timestamp (in order not to rebuild the whole tree).
15 #
16 DISTCLEANFILES += glibconfig-stamp glibconfig.h
17 BUILT_SOURCES += glibconfig-stamp
18 configexecincludedir = $(libdir)/glib-2.0/include
19 nodist_configexecinclude_HEADERS = glibconfig.h
20 glibconfig-stamp: ../config.status
21         $(AM_V_GEN) cd $(top_builddir) && \
22           $(SHELL) ./config.status glib/glibconfig.h
23         @touch glibconfig-stamp
24
25
26
27 if HAVE_GOOD_PRINTF
28 else
29 PRINTF_SUBDIR = gnulib
30 printf_la = gnulib/libgnulib.la
31 endif 
32
33 if USE_SYSTEM_PCRE
34 else
35 MAYBE_PCRE = pcre 
36 endif
37
38 SUBDIRS = libcharset $(PRINTF_SUBDIR) $(MAYBE_PCRE) update-pcre .
39 DIST_SUBDIRS = libcharset gnulib pcre update-pcre tests
40 if BUILD_MODULAR_TESTS
41 SUBDIRS += tests 
42 endif
43
44 AM_CPPFLAGS =                           \
45         $(glib_INCLUDES)                \
46         $(pcre_inc)                     \
47         -DG_LOG_DOMAIN=\"GLib\"         \
48         $(GLIB_DEBUG_FLAGS)             \
49         -DGLIB_COMPILATION              \
50         -DPCRE_STATIC
51
52 AM_CFLAGS = $(GLIB_WARN_CFLAGS)
53
54 MIRRORING_TAB_SOURCE =                          \
55         glib-mirroring-tab/Makefile             \
56         glib-mirroring-tab/gen-mirroring-tab.c  \
57         glib-mirroring-tab/packtab.h            \
58         glib-mirroring-tab/packtab.c
59
60 # The compilation of GRegex can be disabled, but the source files must
61 # be distributed.
62 EXTRA_DIST +=                   \
63         makefile.msc.in         \
64         glib.rc.in              \
65         gen-iswide-table.py     \
66         gen-unicode-tables.pl   \
67         gen-script-table.pl     \
68         glibconfig.h.win32.in   \
69         gregex.c                \
70         gregex.h                \
71         win_iconv.c             \
72         libglib-gdb.py.in       \
73         docs.c                  \
74         gconstructor.h          \
75         $(MIRRORING_TAB_SOURCE)
76
77 CLEANFILES += libglib-gdb.py
78
79 # These may be in the builddir too
80 BUILT_EXTRA_DIST =              \
81         makefile.msc            \
82         glibconfig.h.win32      \
83         glib.rc
84
85 lib_LTLIBRARIES = libglib-2.0.la
86
87 if OS_WIN32_AND_DLL_COMPILATION
88 if MS_LIB_AVAILABLE
89 noinst_DATA = glib-2.0.lib
90
91 install_ms_lib_cmd = $(INSTALL) glib-2.0.lib $(DESTDIR)$(libdir)
92 uninstall_ms_lib_cmd = -rm $(DESTDIR)$(libdir)/glib-2.0.lib
93 endif
94 endif
95
96 install-ms-lib:
97         $(install_ms_lib_cmd)
98
99 uninstall-ms-lib:
100         $(uninstall_ms_lib_cmd)
101
102 deprecated_sources = \
103         deprecated/gallocator.c         \
104         deprecated/gcache.c             \
105         deprecated/gcompletion.c        \
106         deprecated/grel.c               \
107         deprecated/gthread-deprecated.c
108
109 libglib_2_0_la_SOURCES =        \
110         $(deprecated_sources)   \
111         glib_probes.d           \
112         garray.c                \
113         gasyncqueue.c           \
114         gasyncqueueprivate.h    \
115         gatomic.c               \
116         gbacktrace.c            \
117         gbase64.c               \
118         gbitlock.c              \
119         gbookmarkfile.c         \
120         gbsearcharray.h         \
121         gbytes.c                \
122         gbytes.h                \
123         gcharset.c              \
124         gcharsetprivate.h       \
125         gchecksum.c             \
126         gconvert.c              \
127         gdataset.c              \
128         gdatasetprivate.h       \
129         gdate.c                 \
130         gdatetime.c             \
131         gdir.c                  \
132         genviron.c              \
133         gerror.c                \
134         gfileutils.c            \
135         ggettext.c              \
136         ghash.c                 \
137         ghmac.c                 \
138         ghook.c                 \
139         ghostutils.c            \
140         giochannel.c            \
141         gkeyfile.c              \
142         glibintl.h              \
143         glib_trace.h            \
144         glib-init.h             \
145         glib-init.c             \
146         glib-private.h          \
147         glib-private.c          \
148         glist.c                 \
149         gmain-internal.h        \
150         gmain.c                 \
151         gmappedfile.c           \
152         gmarkup.c               \
153         gmem.c                  \
154         gmessages.c             \
155         gmirroringtable.h       \
156         gnode.c                 \
157         goption.c               \
158         gpattern.c              \
159         gpoll.c                 \
160         gprimes.c               \
161         gqsort.c                \
162         gquark.c                \
163         gqueue.c                \
164         grand.c                 \
165         gregex.c                \
166         gscanner.c              \
167         gscripttable.h          \
168         gsequence.c             \
169         gshell.c                \
170         gslice.c                \
171         gslist.c                \
172         gstdio.c                \
173         gstrfuncs.c             \
174         gstring.c               \
175         gstringchunk.c          \
176         gtestutils.c            \
177         gthread.c               \
178         gthreadprivate.h        \
179         gthreadpool.c           \
180         gtimer.c                \
181         gtimezone.c             \
182         gtrashstack.c           \
183         gtree.c                 \
184         guniprop.c              \
185         gutf8.c                 \
186         gunibreak.h             \
187         gunibreak.c             \
188         gunichartables.h        \
189         gunicollate.c           \
190         gunicomp.h              \
191         gunidecomp.h            \
192         gunidecomp.c            \
193         gunicodeprivate.h       \
194         gurifuncs.c             \
195         gutils.c                \
196         gvariant.h              \
197         gvariant.c              \
198         gvariant-core.h         \
199         gvariant-core.c         \
200         gvariant-internal.h     \
201         gvariant-parser.c       \
202         gvariant-serialiser.h   \
203         gvariant-serialiser.c   \
204         gvarianttypeinfo.h      \
205         gvarianttypeinfo.c      \
206         gvarianttype.c          \
207         gversion.c              \
208         gwakeup.h               \
209         gwakeup.c               \
210         gprintf.c               \
211         gprintfint.h
212
213 if OS_UNIX
214 libglib_2_0_la_SOURCES += glib-unix.c
215 endif
216
217 if THREADS_WIN32
218 libglib_2_0_la_SOURCES += gthread-win32.c
219 else
220 if THREADS_POSIX
221 libglib_2_0_la_SOURCES += gthread-posix.c
222 endif
223 endif
224
225 EXTRA_libglib_2_0_la_SOURCES = \
226         giounix.c       \
227         giowin32.c      \
228         gspawn.c        \
229         gspawn-win32.c  \
230         gwin32.c
231
232 glibincludedir=$(includedir)/glib-2.0
233 glibinclude_HEADERS =   \
234         glib-unix.h     \
235         glib-object.h   \
236         glib.h
237
238 deprecatedincludedir=$(includedir)/glib-2.0/glib/deprecated
239 deprecatedinclude_HEADERS = \
240         deprecated/gallocator.h         \
241         deprecated/gcache.h             \
242         deprecated/gcompletion.h        \
243         deprecated/gmain.h              \
244         deprecated/grel.h               \
245         deprecated/gthread.h
246
247 glibsubincludedir=$(includedir)/glib-2.0/glib
248 glibsubinclude_HEADERS = \
249         galloca.h       \
250         garray.h        \
251         gasyncqueue.h   \
252         gatomic.h       \
253         gbacktrace.h    \
254         gbase64.h       \
255         gbitlock.h      \
256         gbookmarkfile.h \
257         gbytes.h        \
258         gcharset.h      \
259         gchecksum.h     \
260         gconvert.h      \
261         gdataset.h      \
262         gdate.h         \
263         gdatetime.h     \
264         gdir.h          \
265         genviron.h      \
266         gerror.h        \
267         gfileutils.h    \
268         ggettext.h      \
269         ghash.h         \
270         ghmac.h         \
271         ghook.h         \
272         ghostutils.h    \
273         gi18n.h         \
274         gi18n-lib.h     \
275         giochannel.h    \
276         gkeyfile.h      \
277         glist.h         \
278         gmacros.h       \
279         gmain.h         \
280         gmappedfile.h   \
281         gmarkup.h       \
282         gmem.h          \
283         gmessages.h     \
284         gnode.h         \
285         goption.h       \
286         gpattern.h      \
287         gpoll.h         \
288         gprimes.h       \
289         gqsort.h        \
290         gquark.h        \
291         gqueue.h        \
292         grand.h         \
293         gregex.h        \
294         gscanner.h      \
295         gsequence.h     \
296         gshell.h        \
297         gslice.h        \
298         gslist.h        \
299         gspawn.h        \
300         gstdio.h        \
301         gstrfuncs.h     \
302         gtestutils.h    \
303         gstring.h       \
304         gstringchunk.h  \
305         gthread.h       \
306         gthreadpool.h   \
307         gtimer.h        \
308         gtimezone.h     \
309         gtrashstack.h   \
310         gtree.h         \
311         gtypes.h        \
312         gunicode.h      \
313         gurifuncs.h     \
314         gutils.h        \
315         gvarianttype.h  \
316         gvariant.h      \
317         gversion.h      \
318         gversionmacros.h \
319         gwin32.h        \
320         gprintf.h
321
322 # This is read by gobject-introspection/misc/ and gtk-doc
323 glib-public-headers.txt: Makefile
324         echo $(glibinclude_HEADERS) $(glibsubinclude_HEADERS) > $@.tmp && mv $@.tmp $@
325
326 CLEANFILES += glib-public-headers.txt
327
328 all-local: glib-public-headers.txt
329
330 install-data-local: install-ms-lib
331         @if test -f $(glibincludedir)/glist.h ; then                                    \
332           echo "*** Old headers found in $(glibincludedir). You should remove the" ;    \
333           echo "*** contents of this directory and type 'make install' again." ;        \
334           false ;                                                                       \
335         fi
336
337 uninstall-local: uninstall-ms-lib uninstall-gdb
338
339 if PLATFORM_WIN32
340 no_undefined = -no-undefined
341 endif
342
343 if OS_WIN32_AND_DLL_COMPILATION
344 glib_win32_res = glib-win32-res.o
345 glib_win32_res_ldflag = -Wl,$(glib_win32_res)
346 endif
347
348 if USE_SYSTEM_PCRE
349 pcre_lib = $(PCRE_LIBS)
350 pcre_inc = $(PCRE_CFLAGS)
351 else
352 pcre_lib = pcre/libpcre.la
353 pcre_inc =
354 endif
355
356 libglib_2_0_la_CFLAGS = $(AM_CFLAGS) $(GLIB_HIDDEN_VISIBILITY_CFLAGS)
357 libglib_2_0_la_LIBADD = libcharset/libcharset.la $(printf_la) @GIO@ @GSPAWN@ @PLATFORMDEP@ @ICONV_LIBS@ @G_LIBS_EXTRA@ $(pcre_lib) $(G_THREAD_LIBS_EXTRA) $(G_THREAD_LIBS_FOR_GTHREAD)
358 libglib_2_0_la_DEPENDENCIES = libcharset/libcharset.la $(printf_la) @GIO@ @GSPAWN@ @PLATFORMDEP@ $(glib_win32_res) $(glib_def)
359
360 libglib_2_0_la_LDFLAGS = $(GLIB_LINK_FLAGS) \
361          $(glib_win32_res_ldflag) \
362         -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
363         -export-dynamic $(no_undefined)
364
365 INSTALL_PROGS=
366
367 if ENABLE_DTRACE
368 glib_probes.h: glib_probes.d Makefile
369         $(AM_V_GEN) $(DTRACE) -C -h -s $< -o $@.tmp
370         @$(SED) -e "s,define STAP_HAS_SEMAPHORES 1,undef STAP_HAS_SEMAPHORES," < $@.tmp > $@ && rm -f $@.tmp
371 glib_probes.o: glib_probes.d Makefile
372         $(AM_V_GEN) $(DTRACE) -G -s $< -o $@
373 BUILT_SOURCES += glib_probes.h glib_probes.o
374 CLEANFILES += glib_probes.h glib_probes.h.tmp
375 libglib_2_0_la_LIBADD += glib_probes.o
376 endif
377
378 if ENABLE_SYSTEMTAP
379 tapset_in_files = glib.stp.in
380 tapsetdir   = @ABS_TAPSET_DIR@
381 tapset_DATA = $(tapset_in_files:.stp.in=.stp)
382 EXTRA_DIST += $(tapset_in_files)
383 endif
384
385 gspawn-win32-helper-console.c:
386         echo '#define HELPER_CONSOLE' >$@
387         echo '#include "gspawn-win32-helper.c"' >>$@
388
389 gspawn-win64-helper.c:
390         echo '#include "gspawn-win32-helper.c"' >$@
391
392 gspawn-win64-helper-console.c:
393         echo '#define HELPER_CONSOLE' >$@
394         echo '#include "gspawn-win32-helper.c"' >>$@
395
396
397 if OS_WIN32
398 if OS_WIN32_X64
399 INSTALL_PROGS += gspawn-win64-helper gspawn-win64-helper-console
400 gspawn_win64_helper_LDADD = libglib-2.0.la
401 gspawn_win64_helper_LDFLAGS = -mwindows
402 gspawn_win64_helper_console_LDADD = libglib-2.0.la
403 else
404 INSTALL_PROGS += gspawn-win32-helper gspawn-win32-helper-console
405 gspawn_win32_helper_LDADD = libglib-2.0.la
406 gspawn_win32_helper_LDFLAGS = -mwindows
407 gspawn_win32_helper_console_LDADD = libglib-2.0.la
408 endif
409 endif
410
411 glib-win32-res.o: glib.rc
412         $(WINDRES) glib.rc $@
413
414 bin_PROGRAMS     = ${INSTALL_PROGS}
415
416 if OS_UNIX
417
418 INSTALL_PROGS   += gtester
419 gtester_SOURCES  = gtester.c
420 gtester_LDADD    = libglib-2.0.la 
421
422 auto_config_binscripts = gtester-report
423 bin_SCRIPTS = ${auto_config_binscripts}
424 EXTRA_DIST += ${auto_config_binscripts}
425
426 CONFIGVARS = \
427         "bindir"        : "${bindir}",          \
428         "glib-version"  : "${GLIB_VERSION}"
429
430 install-exec-hook:
431         for sf in ${auto_config_binscripts} ; do \
432           mv -f "$(DESTDIR)$(bindir)/$$sf" "$(DESTDIR)$(bindir)/$$sf".tmp \
433           && sed < "$(DESTDIR)$(bindir)/$$sf".tmp > "$(DESTDIR)$(bindir)/$$sf" \
434             -e '1,24s|^ *#@PKGINSTALL_CONFIGVARS_IN24LINES@|  ${CONFIGVARS}|' \
435             -e '1,1s|#! /usr/bin/env python.*|#!${PYTHON}|' \
436           || exit $$? ; \
437           chmod a+x $(DESTDIR)$(bindir)/$$sf ; \
438           rm -f "$(DESTDIR)$(bindir)/$$sf".tmp ; \
439         done
440
441 endif
442
443 glib-2.0.lib: libglib-2.0.la glib.def
444         lib -machine:@LIB_EXE_MACHINE_FLAG@ -name:libglib-2.0-$(LT_CURRENT_MINUS_AGE).dll -def:$(builddir)/glib.def -out:$@
445
446 dist-hook: $(BUILT_EXTRA_DIST) ../build/win32/vs9/glib.vcproj ../build/win32/vs10/glib.vcxproj ../build/win32/vs10/glib.vcxproj.filters
447         files='$(BUILT_EXTRA_DIST)'; \
448         for f in $$files; do \
449           if test -f $$f; then d=.; else d=$(srcdir); fi; \
450           cp $$d/$$f $(distdir) || exit 1; done
451
452 ../build/win32/vs9/glib.vcproj: $(top_srcdir)/build/win32/vs9/glib.vcprojin
453         for F in `echo $(libglib_2_0_la_SOURCES) | tr '/' '\\'`; do \
454                 case $$F in \
455                 *-unix.c|gthread-*.c) \
456                         ;; \
457                 *.c)    echo '   <File RelativePath="..\..\..\glib\'$$F'" />' \
458                         ;; \
459                 esac; \
460         done >libglib.sourcefiles
461         $(CPP) -P - <$(top_srcdir)/build/win32/vs9/glib.vcprojin >$@
462         rm libglib.sourcefiles
463
464 ../build/win32/vs10/glib.vcxproj: $(top_srcdir)/build/win32/vs10/glib.vcxprojin
465         for F in `echo $(libglib_2_0_la_SOURCES) | tr '/' '\\'`; do \
466                 case $$F in \
467                 *-unix.c|gthread-*.c) \
468                         ;; \
469                 *.c) echo '    <ClCompile Include="..\..\..\glib\'$$F'" />' \
470                      ;; \
471                 esac; \
472         done >libglib.vs10.sourcefiles
473         $(CPP) -P - <$(top_srcdir)/build/win32/vs10/glib.vcxprojin >$@
474         rm libglib.vs10.sourcefiles
475
476 ../build/win32/vs10/glib.vcxproj.filters: $(top_srcdir)/build/win32/vs10/glib.vcxproj.filtersin
477         for F in `echo $(libglib_2_0_la_SOURCES) | tr '/' '\\'`; do \
478                 case $$F in \
479                 *-unix.c|gthread-*.c) \
480                         ;; \
481                 *.c) echo '    <ClCompile Include="..\..\..\glib\'$$F'"><Filter>Source Files</Filter></ClCompile>' \
482                      ;; \
483                 esac; \
484         done >libglib.vs10.sourcefiles.filters
485         $(CPP) -P - <$(top_srcdir)/build/win32/vs10/glib.vcxproj.filtersin >$@  
486         rm libglib.vs10.sourcefiles.filters
487
488 # install gdb scripts
489 gdbdir = $(datadir)/glib-2.0/gdb
490 dist_gdb_SCRIPTS = glib.py
491
492 libglib-gdb.py: libglib-gdb.py.in
493         $(AM_V_GEN) $(SED) -e "s|\@datadir\@|$(datadir)|" $(srcdir)/libglib-gdb.py.in > $(builddir)/libglib-gdb.py
494
495
496 install-data-hook: libglib-gdb.py
497         mkdir -p $(DESTDIR)$(datadir)/gdb/auto-load$(ABS_GLIB_RUNTIME_LIBDIR)
498         $(INSTALL) $(builddir)/libglib-gdb.py $(DESTDIR)$(datadir)/gdb/auto-load$(ABS_GLIB_RUNTIME_LIBDIR)/libglib-2.0.so.0.$(LT_CURRENT).$(LT_REVISION)-gdb.py
499 if HAVE_GLIB_RUNTIME_LIBDIR
500         mkdir -p $(DESTDIR)$(libdir)/$(GLIB_RUNTIME_LIBDIR)
501         mv $(DESTDIR)$(libdir)/libglib-2.0.so.0 $(DESTDIR)$(libdir)/$(GLIB_RUNTIME_LIBDIR)
502         mv $(DESTDIR)$(libdir)/libglib-2.0.so.0.$(LT_CURRENT).$(LT_REVISION) $(DESTDIR)$(libdir)/$(GLIB_RUNTIME_LIBDIR)
503         rm -f $(DESTDIR)$(libdir)/libglib-2.0.so
504         ln -s $(GLIB_RUNTIME_LIBDIR)/libglib-2.0.so.0.$(LT_CURRENT).$(LT_REVISION) $(DESTDIR)$(libdir)/libglib-2.0.so
505 endif
506
507 uninstall-gdb:
508         -rm -r $(DESTDIR)$(datadir)/gdb