OSDN Git Service

* Makefile.in (DLL_OFILES): Add posix_ipc.o.
[pf3gnuchains/pf3gnuchains3x.git] / winsup / cygwin / Makefile.in
1 # Makefile.in for Cygwin.
2 # Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
3 # 2005, 2006, 2007 Red Hat, Inc.
4 #
5 # This file is part of Cygwin.
6 #
7 # This software is a copyrighted work licensed under the terms of the
8 # Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
9 # details.
10
11 # This makefile requires GNU make.
12
13 SHELL:=@SHELL@
14 srcdir:=@srcdir@
15 objdir:=.
16
17 CONFIG_DIR:=$(srcdir)/config/@CONFIG_DIR@
18 VPATH:=$(srcdir):$(CONFIG_DIR):$(srcdir)/regex:$(srcdir)/regexp:$(srcdir)/lib:$(srcdir)/libc
19
20 target_alias:=@target_alias@
21 build_alias:=@build_alias@
22 host_alias:=@host_alias@
23 prefix:=@prefix@
24
25 program_transform_name:=@program_transform_name@
26 exec_prefix:=@exec_prefix@
27 bindir:=@bindir@
28 libdir:=@libdir@
29 mandir:=@mandir@
30 ifeq ($(target_alias),$(host_alias))
31 ifeq ($(build_alias),$(host_alias))
32 tooldir:=$(exec_prefix)
33 else
34 tooldir:=$(exec_prefix)/$(target_alias)
35 endif
36 else
37 tooldir:=$(exec_prefix)/$(target_alias)
38 endif
39 datadir:=@datadir@
40 infodir:=@infodir@
41 includedir:=@includedir@
42
43 override INSTALL:=@INSTALL@
44 override INSTALL_PROGRAM:=@INSTALL_PROGRAM@
45 override INSTALL_DATA:=@INSTALL_DATA@
46
47 #
48 # --enable options from configure
49 #
50 MT_SAFE:=@MT_SAFE@
51 DEFS:=@DEFS@
52 CCEXTRA:=
53 CC:=@CC@
54 # FIXME: Which is it, CC or CC_FOR_TARGET?
55 CC_FOR_TARGET:=$(CC)
56 CFLAGS=@CFLAGS@
57 override CFLAGS+=-MMD ${$(*F)_CFLAGS} -fmerge-constants -ftracer $(CCEXTRA)
58 CXX=@CXX@
59 override CXXFLAGS=@CXXFLAGS@
60
61 AR:=@AR@
62 AR_FLAGS:=qv
63 RANLIB:=@RANLIB@
64 LD:=@LD@
65 DLLTOOL:=@DLLTOOL@
66 WINDRES:=@WINDRES@
67 AS:=@AS@
68 NM:=@NM@
69 OBJCOPY:=@OBJCOPY@
70 OBJDUMP:=@OBJDUMP@
71 STRIP:=@STRIP@
72 LDSCRIPT:=cygwin.sc
73 MKDIRP:=$(INSTALL) -m 755 -d
74
75 #
76 # Include common definitions for winsup directory
77 #
78 include $(srcdir)/../Makefile.common
79
80 @SET_MAKE@
81
82 # Setup the testing framework, if you have one
83 EXPECT = `if [ -f $${rootme}/../../expect/expect$(EXEEXT) ] ; then \
84             echo $${rootme}/../../expect/expect$(EXEEXT) ; \
85           else echo expect ; fi`
86
87 RUNTEST = `if [ -f $${srcdir}/../dejagnu/runtest ] ; then \
88                echo $${srcdir}/../dejagnu/runtest ; \
89             else echo runtest; fi`
90 RUNTESTFLAGS =
91
92 # Parameters used in building the cygwin.dll.
93 # We build as cygwin0.dll and rename at install time to overcome
94 # native rebuilding issues (we don't want the build tools to see a partially
95 # built cygwin.dll and attempt to use it instead of the old one).
96
97 DLL_NAME:=cygwin1.dll
98 TEST_DLL_NAME:=cygwin0.dll
99 TEST_LIB_NAME:=libcygwin0.a
100 DEF_FILE:=cygwin.def
101 DLL_ENTRY:=@DLL_ENTRY@
102
103 LIBGMON_A:=libgmon.a
104 CYGWIN_START:=crt0.o
105 GMON_START:=gcrt0.o
106
107 # Some things want these from libc, but they have their own static
108 # data which apps can get to, which is a pain in the dll, so we
109 # include them directly into the library.
110
111 LIBCOS:=${sort ${addsuffix .o,${basename ${notdir ${wildcard $(srcdir)/lib/*.c}}}} \
112                ${addsuffix .o,${basename ${notdir ${wildcard $(srcdir)/lib/*.cc}}}}}
113
114 # Build all source files in the config directory
115
116 EXTRA_DLL_OFILES:=${addsuffix .o,${basename ${notdir ${wildcard $(CONFIG_DIR)/*.c}}}}
117
118 EXTRA_OFILES=$(bupdir1)/libiberty/random.o
119
120 MALLOC_OFILES=@MALLOC_OFILES@
121
122 DLL_IMPORTS:=$(w32api_lib)/libkernel32.a $(w32api_lib)/libadvapi32.a
123
124 MT_SAFE_OBJECTS:=
125 # Please maintain this list in sorted order, with maximum files per 86 col line
126 #
127 DLL_OFILES:=assert.o autoload.o bsdlib.o ctype.o cxx.o cygheap.o cygthread.o \
128         cygtls.o dcrt0.o debug.o delqueue.o devices.o dir.o dlfcn.o dll_init.o \
129         dtable.o environ.o errno.o exceptions.o exec.o external.o fcntl.o \
130         fhandler.o fhandler_clipboard.o fhandler_console.o fhandler_disk_file.o \
131         fhandler_dsp.o fhandler_fifo.o fhandler_floppy.o fhandler_mailslot.o \
132         fhandler_mem.o fhandler_netdrive.o fhandler_nodevice.o fhandler_proc.o \
133         fhandler_process.o fhandler_procnet.o fhandler_random.o fhandler_raw.o \
134         fhandler_registry.o fhandler_serial.o fhandler_socket.o fhandler_tape.o \
135         fhandler_termios.o fhandler_tty.o fhandler_virtual.o fhandler_windows.o \
136         fhandler_zero.o flock.o fnmatch.o fork.o fts.o ftw.o getopt.o glob.o \
137         grp.o heap.o hookapi.o inet_addr.o inet_network.o init.o ioctl.o ipc.o \
138         localtime.o lsearch.o malloc_wrapper.o memmem.o minires-os-if.o \
139         minires.o miscfuncs.o mktemp.o mmap.o msg.o net.o netdb.o nftw.o ntea.o \
140         passwd.o path.o pinfo.o pipe.o poll.o posix_ipc.o pthread.o regcomp.o \
141         regerror.o regexec.o regfree.o registry.o resource.o rexec.o rcmd.o \
142         scandir.o sched.o sec_acl.o sec_helper.o security.o select.o sem.o \
143         shared.o shm.o sigfe.o signal.o sigproc.o smallprint.o spawn.o strace.o \
144         strptime.o strsep.o strsig.o sync.o syscalls.o sysconf.o syslog.o \
145         termios.o thread.o timelocal.o timer.o times.o tty.o uinfo.o uname.o \
146         v8_regexp.o v8_regerror.o v8_regsub.o wait.o wincap.o window.o winf.o \
147         $(EXTRA_DLL_OFILES) $(EXTRA_OFILES) $(MALLOC_OFILES) $(MT_SAFE_OBJECTS)
148
149 GMON_OFILES:=gmon.o mcount.o profil.o
150
151 OBSOLETE_FUNCTIONS:=regcomp regerror regexec regfree regsub \
152                     open acl aclcheck aclfrommode aclfrompbits \
153                     aclfromtext aclsort acltomode acltopbits \
154                     acltotext chown facl fchown fcntl fdopen fgetpos fopen \
155                     freopen fseeko fsetpos fstat ftello ftruncate \
156                     getegid geteuid getgid getgrent getgrgid getgrnam \
157                     getgroups getpwuid getpwuid_r getuid initgroups \
158                     lchown lseek lstat mknod mmap seekdir setegid seteuid \
159                     setgid setgroups setregid setreuid setuid stat \
160                     telldir tmpfile truncate
161
162 NEW_FUNCTIONS:=regcomp posix_regcomp \
163                regerror posix_regerror \
164                regexec posix_regexec \
165                regfree posix_regfree \
166                open _open64 \
167                acl _acl32 \
168                aclcheck _aclcheck32 \
169                aclfrommode _aclfrommode32 \
170                aclfrompbits _aclfrompbits32 \
171                aclfromtext _aclfromtext32 \
172                aclsort _aclsort32 \
173                acltomode _acltomode32 \
174                acltopbits _acltopbits32 \
175                acltotext _acltotext32 \
176                chown _chown32 \
177                facl _facl32 \
178                fchown _fchown32 \
179                fcntl _fcntl64 \
180                fdopen _fdopen64 \
181                fgetpos _fgetpos64 \
182                fopen _fopen64 \
183                freopen _freopen64 \
184                fseeko _fseeko64 \
185                fsetpos _fsetpos64 \
186                fstat _fstat64 \
187                ftello _ftello64 \
188                ftruncate _ftruncate64 \
189                getegid _getegid32 \
190                geteuid _geteuid32 \
191                getgid _getgid32 \
192                getgrent _getgrent32 \
193                getgrgid _getgrgid32 \
194                getgrnam _getgrnam32 \
195                getgroups _getgroups32 \
196                getpwuid _getpwuid32 \
197                getpwuid_r _getpwuid_r32 \
198                getuid _getuid32 \
199                initgroups _initgroups32 \
200                lchown _lchown32 \
201                lseek _lseek64 \
202                lstat _lstat64 \
203                mknod _mknod32 \
204                mmap _mmap64 \
205                seekdir _seekdir64 \
206                setegid _setegid32 \
207                seteuid _seteuid32 \
208                setgid _setgid32 \
209                setgroups _setgroups32 \
210                setregid _setregid32 \
211                setreuid _setreuid32 \
212                setuid _setuid32 \
213                stat _stat64 \
214                telldir _telldir64 \
215                tmpfile _tmpfile64 \
216                truncate _truncate64
217
218 API_VER:=$(srcdir)/include/cygwin/version.h
219
220 PWD:=${shell pwd}
221 LIB_NAME:=$(PWD)/libcygwin.a
222 LIBSERVER:=@LIBSERVER@
223 SUBLIBS:=$(PWD)/libpthread.a $(PWD)/libutil.a $(PWD)/libm.a $(PWD)/libc.a $(PWD)/libdl.a $(PWD)/libresolv.a
224 EXTRALIBS:=libautomode.a libbinmode.a libtextmode.a libtextreadmode.a
225 INSTOBJS:=automode.o binmode.o textmode.o textreadmode.o
226 TARGET_LIBS:=$(LIB_NAME) $(CYGWIN_START) $(GMON_START) $(LIBGMON_A) $(SUBLIBS) $(INSTOBJS) $(EXTRALIBS)
227
228 ifneq "${filter -O%,$(CFLAGS)}" ""
229 cygheap_CFLAGS:=-fomit-frame-pointer
230 cygthread_CFLAGS:=-fomit-frame-pointer
231 cygtls_CFLAGS:=-fomit-frame-pointer
232 delqueue_CFLAGS:=-fomit-frame-pointer
233 devices_CFLAGS:=-fomit-frame-pointer -Os
234 dir_CFLAGS:=-fomit-frame-pointer
235 dlfcn_CFLAGS:=-fomit-frame-pointer
236 dll_init_CFLAGS:=-fomit-frame-pointer
237 dtable_CFLAGS:=-fomit-frame-pointer -fcheck-new
238 fcntl_CFLAGS:=-fomit-frame-pointer
239 fhandler_CFLAGS:=-fomit-frame-pointer
240 fhandler_clipboard_CFLAGS:=-fomit-frame-pointer
241 fhandler_console_CFLAGS:=-fomit-frame-pointer
242 fhandler_disk_file_CFLAGS:=-fomit-frame-pointer
243 fhandler_dsp_CFLAGS:=-fomit-frame-pointer
244 fhandler_floppy_CFLAGS:=-fomit-frame-pointer
245 fhandler_mem_CFLAGS:=-fomit-frame-pointer
246 fhandler_netdrive_CFLAGS:=-fomit-frame-pointer
247 fhandler_proc_CFLAGS:=-fomit-frame-pointer
248 fhandler_process_CFLAGS:=-fomit-frame-pointer
249 fhandler_random_CFLAGS:=-fomit-frame-pointer
250 fhandler_raw_CFLAGS:=-fomit-frame-pointer
251 fhandler_registry_CFLAGS:=-fomit-frame-pointer
252 fhandler_serial_CFLAGS:=-fomit-frame-pointer
253 fhandler_socket_CFLAGS:=-fomit-frame-pointer
254 fhandler_syslog_CFLAGS:=-fomit-frame-pointer
255 fhandler_tape_CFLAGS:=-fomit-frame-pointer
256 fhandler_termios_CFLAGS:=-fomit-frame-pointer
257 fhandler_tty_CFLAGS:=-fomit-frame-pointer
258 fhandler_virtual_CFLAGS:=-fomit-frame-pointer
259 fhandler_windows_CFLAGS:=-fomit-frame-pointer
260 fhandler_zero_CFLAGS:=-fomit-frame-pointer
261 flock_CFLAGS:=-fomit-frame-pointer
262 grp_CFLAGS:=-fomit-frame-pointer
263 malloc_CFLAGS:=-fomit-frame-pointer
264 malloc_wrapper_CFLAGS:=-fomit-frame-pointer
265 miscfuncs_CFLAGS:=-fomit-frame-pointer
266 net_CFLAGS:=-fomit-frame-pointer
267 passwd_CFLAGS:=-fomit-frame-pointer
268 regcomp_CFLAGS=-fomit-frame-pointer
269 regerror_CFLAGS=-fomit-frame-pointer
270 regexec_CFLAGS=-fomit-frame-pointer
271 regfree_CFLAGS=-fomit-frame-pointer
272 shared_CFLAGS:=-fomit-frame-pointer
273 sync_CFLAGS:=-fomit-frame-pointer -O3
274 smallprint_CFLAGS:=-fomit-frame-pointer
275 syscalls_CFLAGS:=-fomit-frame-pointer
276 sysconf_CFLAGS:=-fomit-frame-pointer
277 uinfo_CFLAGS:=-fomit-frame-pointer
278 endif
279
280 .PHONY: all force dll_ofiles install all_target install_target all_host install_host \
281         install install-libs install-headers
282
283 .SUFFIXES:
284 .SUFFIXES: .c .cc .def .a .o .d .s
285
286 all_host=@all_host@
287 install_host=@install_host@
288
289 all: all_target $(all_host)
290
291 all_target: $(TARGET_LIBS)
292
293 all_host: $(TEST_LIB_NAME)
294
295 force:
296
297 install: install-libs install-headers install-man install_target \
298         $(install_host) $(install_target)
299
300 uninstall: uninstall-libs uninstall-headers uninstall-man
301
302 install-libs: $(TARGET_LIBS)
303         @$(MKDIRP) $(bindir)
304         $(INSTALL_PROGRAM) $(TEST_DLL_NAME) $(bindir)/$(DLL_NAME); \
305         for i in $^; do \
306             $(INSTALL_DATA) $$i $(tooldir)/lib/`basename $$i` ; \
307         done
308
309 install-headers:
310         cd $(srcdir); \
311         for sub in `find include -name '[a-z]*' -type d -print | sort`; do \
312             $(MKDIRP) $(tooldir)/$$sub; \
313             for i in $$sub/*.h ; do \
314               $(INSTALL_DATA) $$i $(tooldir)/$$sub/`basename $$i` ; \
315             done ; \
316         done ; \
317         $(INSTALL_DATA) regex/regex.h $(tooldir)/include/regex.h
318
319 install-man:
320         @$(MKDIRP) $(mandir)/man2 $(mandir)/man3 $(mandir)/man5 $(mandir)/man7
321         cd $(srcdir); \
322         for i in `find . -type f -name '*.2'`; do \
323             $(INSTALL_DATA) $$i $(mandir)/man2/`basename $$i` ; \
324         done; \
325         for i in `find . -type f -name '*.3'`; do \
326             $(INSTALL_DATA) $$i $(mandir)/man3/`basename $$i` ; \
327         done; \
328         for i in `find . -type f -name '*.5'`; do \
329             $(INSTALL_DATA) $$i $(mandir)/man5/`basename $$i` ; \
330         done; \
331         for i in `find . -type f -name '*.7'`; do \
332             $(INSTALL_DATA) $$i $(mandir)/man7/`basename $$i` ; \
333         done
334
335 install_target:
336
337 install_host:
338
339 uninstall-libs: $(TARGET_LIBS)
340         rm -f $(bindir)/$(DLL_NAME); \
341         for i in $^; do \
342             rm -f $(tooldir)/lib/$$i ; \
343         done
344
345 uninstall-headers:
346         cd $(srcdir); \
347         for sub in `find include -name '[a-z]*' -type d -print | sort`; do \
348             for i in $$sub/*.h ; do \
349               rm -f $(tooldir)/$$sub/`basename $$i` ; \
350             done ; \
351         done ; \
352         rm -f $(tooldir)/include/regex.h
353
354 uninstall-man:
355         cd $(srcdir); \
356         for i in `find . -type f -name '*.2'`; do \
357             rm -f $(tooldir)/man/man2/`basename $$i` ; \
358         done; \
359         for i in `find . -type f -name '*.3'`; do \
360             rm -f $(tooldir)/man/man3/`basename $$i` ; \
361         done; \
362         for i in `find . -type f -name '*.5'`; do \
363             rm -f $(tooldir)/man/man5/`basename $$i` ; \
364         done; \
365         for i in `find . -type f -name '*.7'`; do \
366             rm -f $(tooldir)/man/man7/`basename $$i` ; \
367         done
368
369 clean:
370         -rm -f *.o *.dll *.dbg *.a *.exp junk *.base version.cc regexp/*.o winver_stamp *.exe *.d *stamp* *_magic.h sigfe.s cygwin.def
371         -@$(MAKE) -C $(bupdir)/cygserver libclean
372
373 maintainer-clean realclean: clean
374         @echo "This command is intended for maintainers to use;"
375         @echo "it deletes files that may require special tools to rebuild."
376         -rm -fr configure
377
378
379 # Rule to build cygwin.dll
380 $(TEST_DLL_NAME): $(LDSCRIPT) dllfixdbg $(DLL_OFILES) $(DLL_IMPORTS) $(LIBSERVER) $(LIBC) $(LIBM) $(API_VER) Makefile winver_stamp
381         $(CXX) $(CXXFLAGS) -Wl,--gc-sections $(nostdlib) -Wl,-T$(firstword $^) \
382         -Wl,--heap=0 -Wl,--out-implib,cygdll.a -shared -o $@ \
383         -e $(DLL_ENTRY) $(DEF_FILE) $(DLL_OFILES) version.o winver.o \
384         $(MALLOC_OBJ) $(LIBSERVER) $(LIBM) $(LIBC) \
385         -lgcc $(DLL_IMPORTS)
386         @$(word 2,$^) $(OBJDUMP) $(OBJCOPY) $@ ${patsubst %0.dll,%1.dbg,$@}
387         @ln -f $@ new-$(DLL_NAME)
388
389 # Rule to build libcygwin.a
390 $(LIB_NAME): rmsym newsym $(TEST_DLL_NAME) $(LIBCOS)
391         /bin/sh ${word 1,$^} ./cygdll.a "$(NM)" "$(AR)" $(OBSOLETE_FUNCTIONS) || exit 0
392         /bin/sh ${word 2,$^} ./cygdll.a "$(AS)" "$(AR)" $(NEW_FUNCTIONS) || exit 0
393         (echo create $(LIB_NAME); echo addmod $(LIBCOS); echo addlib cygdll.a; echo save) | $(AR) -M
394         $(RANLIB) $@
395
396 # Rule to make stub library used by testsuite
397 # dependency set to $(LIB_NAME) to accommodate make -j2.
398 # Otherwise dlltool gets confused. cgf (11-16-2000)
399 $(TEST_LIB_NAME): $(LIB_NAME)
400         perl -p -e 'BEGIN{binmode(STDIN); binmode(STDOUT);}; s/cygwin1/cygwin0/g' < $? > $@
401
402 $(LIBSERVER): $(bupdir)/cygserver/Makefile
403         $(MAKE) -C $(bupdir)/cygserver libcygserver.a
404
405 dll_ofiles: $(DLL_OFILES)
406
407 $(LIBGMON_A): $(GMON_OFILES) $(GMON_START)
408         $(AR) rcv $(LIBGMON_A) $(GMON_OFILES)
409
410 $(API_VER): $(srcdir)/cygwin.din
411         @echo Error: Version info is older than DLL API!
412
413 version.cc winver.o: winver_stamp
414         @ :
415
416 shared_info_magic.h: cygmagic shared_info.h
417         /bin/sh ${word 1,$^} $@ "$(CC) -x c" ${word 2,$^} USER_MAGIC 'class user_info' SHARED_MAGIC 'class shared_info'
418
419 child_info_magic.h: cygmagic child_info.h
420         /bin/sh ${word 1,$^} $@ "$(CC) -x c" ${word 2,$^} CHILD_INFO_MAGIC 'class child_info'
421
422 dcrt0.o sigproc.o: child_info_magic.h
423
424 shared.o: shared_info_magic.h
425
426 $(srcdir)/qevices.cc: cygwin-gperf devices.gperf devices.h
427         $^ > $@
428
429 $(srcdir)/devices.cc: gendevices devices.in devices.h
430         ${wordlist 1,2,$^} $@
431
432 $(PWD)/libpthread.a: speclib $(LIB_NAME) pthread.o thread.o
433         /bin/sh ${word 1, $^} $@ "${NM}" "$(AR)" ${wordlist 2, 99, $^}
434
435 $(PWD)/libutil.a: speclib $(LIB_NAME) bsdlib.o
436         /bin/sh ${word 1, $^} $@ "${NM}" "$(AR)" ${wordlist 2, 99, $^}
437
438 $(PWD)/libm.a: speclib $(LIB_NAME) $(LIBM)
439         /bin/sh ${word 1, $^} $@ "${NM}" "$(AR)" ${wordlist 2, 99, $^}
440
441 $(PWD)/libc.a: speclib $(LIB_NAME) $(PWD)/libm.a libpthread.a libutil.a
442         /bin/sh ${word 1, $^} -v $@ "${NM}" "$(AR)" ${wordlist 2, 99, $^}
443
444 $(PWD)/libdl.a: speclib $(LIB_NAME) dlfcn.o
445         /bin/sh ${word 1, $^} $@ "${NM}" "$(AR)" ${wordlist 2, 99, $^}
446
447 $(PWD)/libresolv.a: speclib $(LIB_NAME) minires.o
448         /bin/sh ${word 1, $^} $@ "${NM}" "$(AR)" ${wordlist 2, 99, $^}
449
450 lib%.a: %.o
451         $(AR) cru $@ $?
452
453 winver_stamp: mkvers.sh include/cygwin/version.h winver.rc $(DLL_OFILES)
454         @echo "Making version.o and winver.o";\
455         $(SHELL) ${word 1,$^} ${word 2,$^} ${word 3,$^} $(WINDRES) && \
456         $(COMPILE_CXX) -o version.o version.cc && \
457         touch $@
458
459 Makefile: cygwin.din
460
461 $(DEF_FILE): gendef cygwin.din $(srcdir)/tlsoffsets.h
462         $^ $@ sigfe.s
463
464 $(srcdir)/tlsoffsets.h: gentls_offsets cygtls.h
465         $^ $@ $(COMPILE_CXX)
466
467 sigfe.s: $(DEF_FILE)
468         @[ -s $@ ] || \
469         { rm -f $(DEF_FILE); $(MAKE) -s -j1 $(DEF_FILE); }; \
470         [ -s $@ ] && touch $@
471
472 sigfe.o: sigfe.s
473         $(CC) -c -o $@ $?
474
475 winsup.h: config.h
476
477 deps:=${wildcard *.d}
478 ifneq (,$(deps))
479 include $(deps)
480 endif