1 # Makefile.in for Cygwin.
2 # Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
3 # 2005, 2006, 2007, 2008, 2009, 2010 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.
13 # Include common definitions for winsup directory
14 # The following assignments are "inputs" to Makefile.common
18 CONFIG_DIR:=$(srcdir)/config/@CONFIG_DIR@
20 include ${srcdir}/../Makefile.common
25 VPATH:=$(srcdir):$(CONFIG_DIR):$(srcdir)/regex:$(srcdir)/lib:$(srcdir)/libc
27 target_alias:=@target_alias@
28 build_alias:=@build_alias@
29 host_alias:=@host_alias@
32 program_transform_name:=@program_transform_name@
33 exec_prefix:=@exec_prefix@
37 sysconfdir:=@sysconfdir@
38 ifeq ($(target_alias),$(host_alias))
39 ifeq ($(build_alias),$(host_alias))
40 tooldir:=$(exec_prefix)
42 tooldir:=$(exec_prefix)/$(target_alias)
45 tooldir:=$(exec_prefix)/$(target_alias)
49 includedir:=@includedir@
51 override INSTALL:=@INSTALL@
52 override INSTALL_PROGRAM:=@INSTALL_PROGRAM@
53 override INSTALL_DATA:=@INSTALL_DATA@
56 # --enable options from configure
62 override CFLAGS+=-MMD ${$(*F)_CFLAGS} -Werror -fmerge-constants -ftracer \
63 -mno-use-libstdc-wrappers $(CCEXTRA)
65 override CXXFLAGS=@CXXFLAGS@
79 MKDIRP:=$(INSTALL) -m 755 -d
83 # Setup the testing framework, if you have one
84 EXPECT = `if [ -f $${rootme}/../../expect/expect$(EXEEXT) ] ; then \
85 echo $${rootme}/../../expect/expect$(EXEEXT) ; \
86 else echo expect ; fi`
88 RUNTEST = `if [ -f $${srcdir}/../dejagnu/runtest ] ; then \
89 echo $${srcdir}/../dejagnu/runtest ; \
90 else echo runtest; fi`
93 # Parameters used in building the cygwin.dll.
94 # We build as cygwin0.dll and rename at install time to overcome
95 # native rebuilding issues (we don't want the build tools to see a partially
96 # built cygwin.dll and attempt to use it instead of the old one).
99 TEST_DLL_NAME:=cygwin0.dll
100 TEST_LIB_NAME:=libcygwin0.a
101 STATIC_LIB_NAME:=libcygwin_s.a
103 DLL_ENTRY:=@DLL_ENTRY@
109 toolopts:=--ar=${AR} --as=${AS} --nm=${NM} --objcopy=${OBJCOPY}
111 ${srcdir}/speclib ${toolopts} \
113 --exclude='(?i:dll)' \
115 --exclude='^_main$$' \
118 # Some things want these from libc, but they have their own static
119 # data which apps can get to, which is a pain in the dll, so we
120 # include them directly into the library.
122 LIBCOS:=${sort ${addsuffix .o,${basename ${notdir ${wildcard $(srcdir)/lib/*.c}}}} \
123 ${addsuffix .o,${basename ${notdir ${wildcard $(srcdir)/lib/*.cc}}}}}
125 # Build all source files in the config directory
127 EXTRA_DLL_OFILES:=${addsuffix .o,${basename ${notdir ${wildcard $(CONFIG_DIR)/*.c}}}}
131 MALLOC_OFILES:=@MALLOC_OFILES@
133 DLL_IMPORTS:=$(w32api_lib)/libadvapi32.a $(w32api_lib)/libkernel32.a $(w32api_lib)/libntdll.a
136 # Please maintain this list in sorted order, with maximum files per 86 col line
138 DLL_OFILES:=advapi32.o assert.o autoload.o bsdlib.o ctype.o cxx.o cygheap.o \
139 cygthread.o cygtls.o cygxdr.o dcrt0.o debug.o devices.o dir.o dlfcn.o \
140 dll_init.o dtable.o environ.o errno.o exceptions.o exec.o external.o \
141 fcntl.o fenv.o fhandler.o fhandler_clipboard.o fhandler_console.o \
142 fhandler_disk_file.o fhandler_dsp.o fhandler_fifo.o fhandler_floppy.o \
143 fhandler_mailslot.o fhandler_mem.o fhandler_netdrive.o fhandler_nodevice.o \
144 fhandler_proc.o fhandler_process.o fhandler_procnet.o fhandler_procsys.o \
145 fhandler_procsysvipc.o fhandler_random.o fhandler_raw.o fhandler_registry.o \
146 fhandler_serial.o fhandler_socket.o fhandler_tape.o fhandler_termios.o \
147 fhandler_tty.o fhandler_virtual.o fhandler_windows.o fhandler_zero.o \
148 flock.o fnmatch.o fork.o fts.o ftw.o getopt.o glob.o glob_pattern_p.o \
149 globals.o grp.o heap.o hookapi.o inet_addr.o inet_network.o init.o ioctl.o \
150 ipc.o kernel32.o libstdcxx_wrapper.o localtime.o lsearch.o malloc_wrapper.o \
151 minires-os-if.o minires.o miscfuncs.o mktemp.o mmap.o msg.o \
152 mount.o net.o netdb.o nfs.o nftw.o nlsfuncs.o ntea.o passwd.o path.o \
153 pinfo.o pipe.o poll.o posix_ipc.o pseudo-reloc.o pthread.o random.o \
154 regcomp.o regerror.o regexec.o regfree.o registry.o resource.o rexec.o \
155 rcmd.o scandir.o sched.o sec_acl.o sec_auth.o sec_helper.o security.o \
156 select.o sem.o setlsapwd.o shared.o shm.o sigfe.o signal.o sigproc.o \
157 smallprint.o spawn.o strace.o strfmon.o strfuncs.o strptime.o strsep.o \
158 strsig.o sync.o syscalls.o sysconf.o syslog.o termios.o thread.o \
159 timer.o times.o tls_pbuf.o tty.o uinfo.o uname.o wait.o wincap.o \
160 window.o winf.o xsique.o \
161 $(EXTRA_DLL_OFILES) $(EXTRA_OFILES) $(MALLOC_OFILES) $(MT_SAFE_OBJECTS)
163 EXCLUDE_STATIC_OFILES:=$(addprefix --exclude=,\
172 GMON_OFILES:=gmon.o mcount.o profil.o
174 NEW_FUNCTIONS:=$(addprefix --replace=,\
176 aclcheck=_aclcheck32 \
177 aclfrommode=_aclfrommode32 \
178 aclfrompbits=_aclfrompbits32 \
179 aclfromtext=_aclfromtext32 \
181 acltomode=_acltomode32 \
182 acltopbits=_acltopbits32 \
183 acltotext=_acltotext32 \
196 ftruncate=_ftruncate64 \
200 getgrent=_getgrent32 \
201 getgrgid=_getgrgid32 \
202 getgrnam=_getgrnam32 \
203 getgroups=_getgroups32 \
204 getpwuid=_getpwuid32 \
205 getpwuid_r=_getpwuid_r32 \
207 initgroups=_initgroups32 \
217 setgroups=_setgroups32 \
218 setregid=_setregid32 \
219 setreuid=_setreuid32 \
224 truncate=_truncate64 \
227 API_VER:=$(srcdir)/include/cygwin/version.h
229 LIB_NAME:=libcygwin.a
230 LIBSERVER:=@LIBSERVER@
231 SUBLIBS:=libpthread.a libutil.a ${CURDIR}/libm.a ${CURDIR}/libc.a libdl.a libresolv.a librt.a
232 EXTRALIBS:=libautomode.a libbinmode.a libtextmode.a libtextreadmode.a
233 INSTOBJS:=automode.o binmode.o textmode.o textreadmode.o
234 TARGET_LIBS:=$(LIB_NAME) $(CYGWIN_START) $(GMON_START) $(LIBGMON_A) $(SUBLIBS) $(INSTOBJS) $(EXTRALIBS)
236 ifneq "${filter -O%,$(CFLAGS)}" ""
237 cygheap_CFLAGS:=-fomit-frame-pointer
238 cygthread_CFLAGS:=-fomit-frame-pointer
239 cygtls_CFLAGS:=-fomit-frame-pointer
240 delqueue_CFLAGS:=-fomit-frame-pointer
241 devices_CFLAGS:=-fomit-frame-pointer -Os
242 dir_CFLAGS:=-fomit-frame-pointer
243 dlfcn_CFLAGS:=-fomit-frame-pointer
244 dll_init_CFLAGS:=-fomit-frame-pointer
245 dtable_CFLAGS:=-fomit-frame-pointer -fcheck-new
246 fcntl_CFLAGS:=-fomit-frame-pointer
247 fenv_CFLAGS:=-fomit-frame-pointer
248 fhandler_CFLAGS:=-fomit-frame-pointer
249 fhandler_clipboard_CFLAGS:=-fomit-frame-pointer
250 fhandler_console_CFLAGS:=-fomit-frame-pointer
251 fhandler_disk_file_CFLAGS:=-fomit-frame-pointer
252 fhandler_dsp_CFLAGS:=-fomit-frame-pointer
253 fhandler_floppy_CFLAGS:=-fomit-frame-pointer
254 fhandler_mem_CFLAGS:=-fomit-frame-pointer
255 fhandler_netdrive_CFLAGS:=-fomit-frame-pointer
256 fhandler_proc_CFLAGS:=-fomit-frame-pointer
257 fhandler_process_CFLAGS:=-fomit-frame-pointer
258 fhandler_random_CFLAGS:=-fomit-frame-pointer
259 fhandler_raw_CFLAGS:=-fomit-frame-pointer
260 fhandler_registry_CFLAGS:=-fomit-frame-pointer
261 fhandler_serial_CFLAGS:=-fomit-frame-pointer
262 fhandler_socket_CFLAGS:=-fomit-frame-pointer
263 fhandler_syslog_CFLAGS:=-fomit-frame-pointer
264 fhandler_tape_CFLAGS:=-fomit-frame-pointer
265 fhandler_termios_CFLAGS:=-fomit-frame-pointer
266 fhandler_tty_CFLAGS:=-fomit-frame-pointer
267 fhandler_virtual_CFLAGS:=-fomit-frame-pointer
268 fhandler_windows_CFLAGS:=-fomit-frame-pointer
269 fhandler_zero_CFLAGS:=-fomit-frame-pointer
270 flock_CFLAGS:=-fomit-frame-pointer
271 grp_CFLAGS:=-fomit-frame-pointer
272 libstdcxx_wrapper_CFLAGS:=-fomit-frame-pointer
273 malloc_CFLAGS:=-fomit-frame-pointer
274 malloc_wrapper_CFLAGS:=-fomit-frame-pointer
275 miscfuncs_CFLAGS:=-fomit-frame-pointer
276 net_CFLAGS:=-fomit-frame-pointer
277 passwd_CFLAGS:=-fomit-frame-pointer
278 regcomp_CFLAGS=-fomit-frame-pointer
279 regerror_CFLAGS=-fomit-frame-pointer
280 regexec_CFLAGS=-fomit-frame-pointer
281 regfree_CFLAGS=-fomit-frame-pointer
282 shared_CFLAGS:=-fomit-frame-pointer
283 sync_CFLAGS:=-fomit-frame-pointer -O3
284 smallprint_CFLAGS:=-fomit-frame-pointer
285 syscalls_CFLAGS:=-fomit-frame-pointer
286 sysconf_CFLAGS:=-fomit-frame-pointer
287 uinfo_CFLAGS:=-fomit-frame-pointer
290 fhandler_proc_CFLAGS+=-DUSERNAME="\"$(USER)\"" -DHOSTNAME="\"$(HOSTNAME)\""
291 fhandler_proc_CFLAGS+=-DGCC_VERSION="\"`$(CC) -v 2>&1 | tail -n 1`\""
293 _cygwin_crt0_common_STDINCFLAGS:=yes
294 libstdcxx_wrapper_STDINCFLAGS:=yes
297 .PHONY: all force dll_ofiles install all_target install_target all_host install_host \
298 install install-libs install-headers
301 .SUFFIXES: .c .cc .def .a .o .d .s
304 install_host=@install_host@
306 all: all_target $(all_host)
308 all_target: $(TARGET_LIBS)
310 all_host: $(TEST_LIB_NAME)
314 install: install-libs install-headers install-man install_target \
315 $(install_host) $(install_target)
317 uninstall: uninstall-libs uninstall-headers uninstall-man
319 install-libs: $(TARGET_LIBS)
320 @$(MKDIRP) $(DESTDIR)$(bindir)
321 $(INSTALL_PROGRAM) $(TEST_DLL_NAME) $(DESTDIR)$(bindir)/$(DLL_NAME); \
323 $(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/lib/`basename $$i` ; \
325 cd $(DESTDIR)$(tooldir)/lib && ln -sf libcygwin.a libg.a
329 for sub in `find include -name '[a-z]*' -type d -print | sort`; do \
330 $(MKDIRP) $(DESTDIR)$(tooldir)/$$sub; \
331 for i in $$sub/*.h ; do \
332 $(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/$$sub/`basename $$i` ; \
337 @$(MKDIRP) $(DESTDIR)$(mandir)/man2 $(DESTDIR)$(mandir)/man3 $(DESTDIR)$(mandir)/man5 $(DESTDIR)$(mandir)/man7
339 for i in `find . -type f -name '*.2'`; do \
340 $(INSTALL_DATA) $$i $(DESTDIR)$(mandir)/man2/`basename $$i` ; \
342 for i in `find . -type f -name '*.3'`; do \
343 $(INSTALL_DATA) $$i $(DESTDIR)$(mandir)/man3/`basename $$i` ; \
345 for i in `find . -type f -name '*.5'`; do \
346 $(INSTALL_DATA) $$i $(DESTDIR)$(mandir)/man5/`basename $$i` ; \
348 for i in `find . -type f -name '*.7'`; do \
349 $(INSTALL_DATA) $$i $(DESTDIR)$(mandir)/man7/`basename $$i` ; \
356 uninstall-libs: $(TARGET_LIBS)
357 rm -f $(bindir)/$(DLL_NAME); \
359 rm -f $(tooldir)/lib/$$i ; \
364 for sub in `find include -name '[a-z]*' -type d -print | sort`; do \
365 for i in $$sub/*.h ; do \
366 rm -f $(tooldir)/$$sub/`basename $$i` ; \
372 for i in `find . -type f -name '*.2'`; do \
373 rm -f $(tooldir)/man/man2/`basename $$i` ; \
375 for i in `find . -type f -name '*.3'`; do \
376 rm -f $(tooldir)/man/man3/`basename $$i` ; \
378 for i in `find . -type f -name '*.5'`; do \
379 rm -f $(tooldir)/man/man5/`basename $$i` ; \
381 for i in `find . -type f -name '*.7'`; do \
382 rm -f $(tooldir)/man/man7/`basename $$i` ; \
386 -rm -f *.o *.dll *.dbg *.a *.exp junk *.base version.cc regexp/*.o winver_stamp *.exe *.d *stamp* *_magic.h sigfe.s cygwin.def globals.h $(srcdir)/tlsoffsets.h $(srcdir)/devices.cc
387 -@$(MAKE) -C $(bupdir)/cygserver libclean
389 maintainer-clean realclean: clean
390 @echo "This command is intended for maintainers to use;"
391 @echo "it deletes files that may require special tools to rebuild."
395 # Rule to build cygwin.dll
396 $(TEST_DLL_NAME): $(LDSCRIPT) dllfixdbg $(DLL_OFILES) $(DLL_IMPORTS) $(LIBSERVER) $(LIBC) $(LIBM) $(API_VER) Makefile winver_stamp
397 $(CXX) $(CXXFLAGS) -Wl,--gc-sections $(nostdlib) -Wl,-T$(firstword $^) \
398 -Wl,--heap=0 -Wl,--out-implib,cygdll.a -shared -o $@ \
399 -e $(DLL_ENTRY) $(DEF_FILE) $(DLL_OFILES) version.o winver.o \
400 $(MALLOC_OBJ) $(LIBSERVER) $(LIBM) $(LIBC) \
401 -lgcc $(DLL_IMPORTS) -Wl,-Map,cygwin.map
402 @$(word 2,$^) $(OBJDUMP) $(OBJCOPY) $@ ${patsubst %0.dll,%1.dbg,$@}
403 @ln -f $@ new-$(DLL_NAME)
405 # Rule to build libcygwin.a
406 $(LIB_NAME): $(LIBCOS) | $(TEST_DLL_NAME)
407 ${srcdir}/mkimport ${toolopts} ${NEW_FUNCTIONS} $@ cygdll.a $^
409 ${STATIC_LIB_NAME}: mkstatic ${TEST_DLL_NAME}
410 perl -d $< -x ${EXCLUDE_STATIC_OFILES} --library=${LIBC} --library=${LIBM} --ar=${AR} $@ cygwin.map
412 # Rule to make stub library used by testsuite
413 # dependency set to $(LIB_NAME) to accommodate make -j2.
414 $(TEST_LIB_NAME): $(LIB_NAME)
415 perl -p -e 'BEGIN{binmode(STDIN); binmode(STDOUT);}; s/cygwin1/cygwin0/g' < $? > $@
417 $(LIBSERVER): $(bupdir)/cygserver/Makefile
418 $(MAKE) -C $(bupdir)/cygserver libcygserver.a
420 dll_ofiles: $(DLL_OFILES)
422 $(LIBGMON_A): $(GMON_OFILES) $(GMON_START)
423 $(AR) rcv $(LIBGMON_A) $(GMON_OFILES)
425 $(API_VER): $(srcdir)/cygwin.din
426 @echo Error: Version info is older than DLL API!
428 version.cc winver.o: winver_stamp
431 globals.h: mkglobals_h globals.cc
434 ${DLL_OFILES} ${LIBCOS}: globals.h
436 shared_info_magic.h: cygmagic shared_info.h
437 /bin/sh $(word 1,$^) $@ "${COMPILE_CXX} -E -x c++" $(word 2,$^) SHARED_MAGIC 'class shared_info' USER_MAGIC 'class user_info'
439 child_info_magic.h: cygmagic child_info.h
440 /bin/sh $(word 1,$^) $@ "${COMPILE_CXX} -E -x c++" $(word 2,$^) CHILD_INFO_MAGIC 'class child_info'
442 dcrt0.o sigproc.o: child_info_magic.h
444 shared.o: shared_info_magic.h
446 $(srcdir)/devices.cc: gendevices devices.in devices.h
447 ${wordlist 1,2,$^} $@
449 ${CURDIR}/libc.a: ${LIB_NAME} ./libm.a libpthread.a libutil.a
452 ${CURDIR}/libm.a: ${LIB_NAME} $(LIBM)
455 libpthread.a: ${LIB_NAME} pthread.o thread.o
458 libutil.a: ${LIB_NAME} bsdlib.o
461 libdl.a: ${LIB_NAME} dlfcn.o
464 libresolv.a: ${LIB_NAME} minires.o
467 librt.a: ${LIB_NAME} posix_ipc.o
470 ${EXTRALIBS}: lib%.a: %.o
473 winver_stamp: mkvers.sh include/cygwin/version.h winver.rc $(DLL_OFILES)
474 @echo "Making version.o and winver.o";\
475 $(SHELL) ${word 1,$^} ${word 2,$^} ${word 3,$^} $(WINDRES) && \
476 $(COMPILE_CXX) -c -o version.o version.cc && \
481 $(DEF_FILE): gendef cygwin.din $(srcdir)/tlsoffsets.h
484 $(srcdir)/tlsoffsets.h: gentls_offsets cygtls.h
485 $^ $@ $(COMPILE_CXX) -c
489 { rm -f $(DEF_FILE); $(MAKE) -s -j1 $(DEF_FILE); }; \
490 [ -s $@ ] && touch $@
500 -cd $(srcdir) && ctags -R --regex-C++='/^([a-zA-Z0-9_]*::[a-zA-Z0-9_]*) /\1/f/' .
502 deps:=${wildcard *.d}