1 # Makefile.in for Cygwin.
2 # Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
3 # 2005, 2006, 2007 Red Hat, Inc.
5 # This file is part of Cygwin.
7 # This software is a copyrighted work licensed under the terms of the
8 # Cygwin license. Please consult the file "CYGWIN_LICENSE" for
11 # This makefile requires GNU make.
17 CONFIG_DIR:=$(srcdir)/config/@CONFIG_DIR@
18 VPATH:=$(srcdir):$(CONFIG_DIR):$(srcdir)/regex:$(srcdir)/regexp:$(srcdir)/lib:$(srcdir)/libc
20 target_alias:=@target_alias@
21 build_alias:=@build_alias@
22 host_alias:=@host_alias@
25 program_transform_name:=@program_transform_name@
26 exec_prefix:=@exec_prefix@
30 ifeq ($(target_alias),$(host_alias))
31 ifeq ($(build_alias),$(host_alias))
32 tooldir:=$(exec_prefix)
34 tooldir:=$(exec_prefix)/$(target_alias)
37 tooldir:=$(exec_prefix)/$(target_alias)
41 includedir:=@includedir@
43 override INSTALL:=@INSTALL@
44 override INSTALL_PROGRAM:=@INSTALL_PROGRAM@
45 override INSTALL_DATA:=@INSTALL_DATA@
48 # --enable options from configure
54 # FIXME: Which is it, CC or CC_FOR_TARGET?
57 override CFLAGS+=-MMD ${$(*F)_CFLAGS} -fmerge-constants -ftracer $(CCEXTRA)
59 override CXXFLAGS=@CXXFLAGS@
73 MKDIRP:=$(INSTALL) -m 755 -d
76 # Include common definitions for winsup directory
78 include $(srcdir)/../Makefile.common
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`
87 RUNTEST = `if [ -f $${srcdir}/../dejagnu/runtest ] ; then \
88 echo $${srcdir}/../dejagnu/runtest ; \
89 else echo runtest; fi`
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).
98 TEST_DLL_NAME:=cygwin0.dll
99 TEST_LIB_NAME:=libcygwin0.a
101 DLL_ENTRY:=@DLL_ENTRY@
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.
111 LIBCOS:=${sort ${addsuffix .o,${basename ${notdir ${wildcard $(srcdir)/lib/*.c}}}} \
112 ${addsuffix .o,${basename ${notdir ${wildcard $(srcdir)/lib/*.cc}}}}}
114 # Build all source files in the config directory
116 EXTRA_DLL_OFILES:=${addsuffix .o,${basename ${notdir ${wildcard $(CONFIG_DIR)/*.c}}}}
118 EXTRA_OFILES=$(bupdir1)/libiberty/random.o
120 MALLOC_OFILES=@MALLOC_OFILES@
122 DLL_IMPORTS:=$(w32api_lib)/libkernel32.a $(w32api_lib)/libadvapi32.a
125 # Please maintain this list in sorted order, with maximum files per 86 col line
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)
149 GMON_OFILES:=gmon.o mcount.o profil.o
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
162 NEW_FUNCTIONS:=regcomp posix_regcomp \
163 regerror posix_regerror \
164 regexec posix_regexec \
165 regfree posix_regfree \
168 aclcheck _aclcheck32 \
169 aclfrommode _aclfrommode32 \
170 aclfrompbits _aclfrompbits32 \
171 aclfromtext _aclfromtext32 \
173 acltomode _acltomode32 \
174 acltopbits _acltopbits32 \
175 acltotext _acltotext32 \
188 ftruncate _ftruncate64 \
192 getgrent _getgrent32 \
193 getgrgid _getgrgid32 \
194 getgrnam _getgrnam32 \
195 getgroups _getgroups32 \
196 getpwuid _getpwuid32 \
197 getpwuid_r _getpwuid_r32 \
199 initgroups _initgroups32 \
209 setgroups _setgroups32 \
210 setregid _setregid32 \
211 setreuid _setreuid32 \
218 API_VER:=$(srcdir)/include/cygwin/version.h
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)
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
280 .PHONY: all force dll_ofiles install all_target install_target all_host install_host \
281 install install-libs install-headers
284 .SUFFIXES: .c .cc .def .a .o .d .s
287 install_host=@install_host@
289 all: all_target $(all_host)
291 all_target: $(TARGET_LIBS)
293 all_host: $(TEST_LIB_NAME)
297 install: install-libs install-headers install-man install_target \
298 $(install_host) $(install_target)
300 uninstall: uninstall-libs uninstall-headers uninstall-man
302 install-libs: $(TARGET_LIBS)
304 $(INSTALL_PROGRAM) $(TEST_DLL_NAME) $(bindir)/$(DLL_NAME); \
306 $(INSTALL_DATA) $$i $(tooldir)/lib/`basename $$i` ; \
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` ; \
317 $(INSTALL_DATA) regex/regex.h $(tooldir)/include/regex.h
320 @$(MKDIRP) $(mandir)/man2 $(mandir)/man3 $(mandir)/man5 $(mandir)/man7
322 for i in `find . -type f -name '*.2'`; do \
323 $(INSTALL_DATA) $$i $(mandir)/man2/`basename $$i` ; \
325 for i in `find . -type f -name '*.3'`; do \
326 $(INSTALL_DATA) $$i $(mandir)/man3/`basename $$i` ; \
328 for i in `find . -type f -name '*.5'`; do \
329 $(INSTALL_DATA) $$i $(mandir)/man5/`basename $$i` ; \
331 for i in `find . -type f -name '*.7'`; do \
332 $(INSTALL_DATA) $$i $(mandir)/man7/`basename $$i` ; \
339 uninstall-libs: $(TARGET_LIBS)
340 rm -f $(bindir)/$(DLL_NAME); \
342 rm -f $(tooldir)/lib/$$i ; \
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` ; \
352 rm -f $(tooldir)/include/regex.h
356 for i in `find . -type f -name '*.2'`; do \
357 rm -f $(tooldir)/man/man2/`basename $$i` ; \
359 for i in `find . -type f -name '*.3'`; do \
360 rm -f $(tooldir)/man/man3/`basename $$i` ; \
362 for i in `find . -type f -name '*.5'`; do \
363 rm -f $(tooldir)/man/man5/`basename $$i` ; \
365 for i in `find . -type f -name '*.7'`; do \
366 rm -f $(tooldir)/man/man7/`basename $$i` ; \
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
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."
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) \
386 @$(word 2,$^) $(OBJDUMP) $(OBJCOPY) $@ ${patsubst %0.dll,%1.dbg,$@}
387 @ln -f $@ new-$(DLL_NAME)
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
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' < $? > $@
402 $(LIBSERVER): $(bupdir)/cygserver/Makefile
403 $(MAKE) -C $(bupdir)/cygserver libcygserver.a
405 dll_ofiles: $(DLL_OFILES)
407 $(LIBGMON_A): $(GMON_OFILES) $(GMON_START)
408 $(AR) rcv $(LIBGMON_A) $(GMON_OFILES)
410 $(API_VER): $(srcdir)/cygwin.din
411 @echo Error: Version info is older than DLL API!
413 version.cc winver.o: winver_stamp
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'
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'
422 dcrt0.o sigproc.o: child_info_magic.h
424 shared.o: shared_info_magic.h
426 $(srcdir)/qevices.cc: cygwin-gperf devices.gperf devices.h
429 $(srcdir)/devices.cc: gendevices devices.in devices.h
430 ${wordlist 1,2,$^} $@
432 $(PWD)/libpthread.a: speclib $(LIB_NAME) pthread.o thread.o
433 /bin/sh ${word 1, $^} $@ "${NM}" "$(AR)" ${wordlist 2, 99, $^}
435 $(PWD)/libutil.a: speclib $(LIB_NAME) bsdlib.o
436 /bin/sh ${word 1, $^} $@ "${NM}" "$(AR)" ${wordlist 2, 99, $^}
438 $(PWD)/libm.a: speclib $(LIB_NAME) $(LIBM)
439 /bin/sh ${word 1, $^} $@ "${NM}" "$(AR)" ${wordlist 2, 99, $^}
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, $^}
444 $(PWD)/libdl.a: speclib $(LIB_NAME) dlfcn.o
445 /bin/sh ${word 1, $^} $@ "${NM}" "$(AR)" ${wordlist 2, 99, $^}
447 $(PWD)/libresolv.a: speclib $(LIB_NAME) minires.o
448 /bin/sh ${word 1, $^} $@ "${NM}" "$(AR)" ${wordlist 2, 99, $^}
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 && \
461 $(DEF_FILE): gendef cygwin.din $(srcdir)/tlsoffsets.h
464 $(srcdir)/tlsoffsets.h: gentls_offsets cygtls.h
469 { rm -f $(DEF_FILE); $(MAKE) -s -j1 $(DEF_FILE); }; \
470 [ -s $@ ] && touch $@
477 deps:=${wildcard *.d}