1 # Makefile.in for Cygwin.
2 # Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
3 # 2005, 2006, 2007, 2008, 2009 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)/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 sysconfdir:=@sysconfdir@
31 ifeq ($(target_alias),$(host_alias))
32 ifeq ($(build_alias),$(host_alias))
33 tooldir:=$(exec_prefix)
35 tooldir:=$(exec_prefix)/$(target_alias)
38 tooldir:=$(exec_prefix)/$(target_alias)
42 includedir:=@includedir@
44 override INSTALL:=@INSTALL@
45 override INSTALL_PROGRAM:=@INSTALL_PROGRAM@
46 override INSTALL_DATA:=@INSTALL_DATA@
49 # --enable options from configure
55 # FIXME: Which is it, CC or CC_FOR_TARGET?
58 override CFLAGS+=-MMD ${$(*F)_CFLAGS} -Werror -fmerge-constants -ftracer \
59 -mno-use-libstdc-wrappers $(CCEXTRA)
61 override CXXFLAGS=@CXXFLAGS@
75 MKDIRP:=$(INSTALL) -m 755 -d
77 # Include common definitions for winsup directory
79 include $(srcdir)/../Makefile.common
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)/libkernel32.a $(w32api_lib)/libadvapi32.a $(w32api_lib)/libntdll.a
136 # Please maintain this list in sorted order, with maximum files per 86 col line
138 DLL_OFILES:=assert.o autoload.o bsdlib.o ctype.o cxx.o cygheap.o cygthread.o \
139 cygtls.o dcrt0.o debug.o devices.o dir.o dlfcn.o dll_init.o \
140 dtable.o environ.o errno.o exceptions.o exec.o external.o fcntl.o \
141 fhandler.o fhandler_clipboard.o fhandler_console.o fhandler_disk_file.o \
142 fhandler_dsp.o fhandler_fifo.o fhandler_floppy.o fhandler_mailslot.o \
143 fhandler_mem.o fhandler_netdrive.o fhandler_nodevice.o fhandler_proc.o \
144 fhandler_process.o fhandler_procnet.o fhandler_random.o fhandler_raw.o \
145 fhandler_registry.o fhandler_serial.o fhandler_socket.o fhandler_tape.o \
146 fhandler_termios.o fhandler_tty.o fhandler_virtual.o fhandler_windows.o \
147 fhandler_zero.o flock.o fnmatch.o fork.o fts.o ftw.o getopt.o glob.o \
148 glob_pattern_p.o globals.o grp.o heap.o hookapi.o inet_addr.o inet_network.o \
149 init.o ioctl.o ipc.o kernel32.o libstdcxx_wrapper.o localtime.o lsearch.o \
150 malloc_wrapper.o minires-os-if.o minires.o miscfuncs.o mktemp.o mmap.o msg.o \
151 mount.o net.o netdb.o nfs.o nftw.o ntea.o passwd.o path.o pinfo.o pipe.o \
152 poll.o posix_ipc.o pthread.o random.o regcomp.o regerror.o regexec.o \
153 regfree.o registry.o resource.o rexec.o rcmd.o scandir.o sched.o \
154 sec_acl.o sec_auth.o sec_helper.o security.o select.o sem.o \
155 setlsapwd.o shared.o shm.o sigfe.o signal.o sigproc.o smallprint.o \
156 spawn.o strace.o strfuncs.o strptime.o strsep.o strsig.o sync.o \
157 syscalls.o sysconf.o syslog.o termios.o thread.o timer.o times.o \
158 tls_pbuf.o tty.o uinfo.o uname.o wait.o wincap.o window.o winf.o \
160 $(EXTRA_DLL_OFILES) $(EXTRA_OFILES) $(MALLOC_OFILES) $(MT_SAFE_OBJECTS)
162 EXCLUDE_STATIC_OFILES:=$(addprefix --exclude=,\
171 GMON_OFILES:=gmon.o mcount.o profil.o
173 NEW_FUNCTIONS:=$(addprefix --replace=,\
175 aclcheck=_aclcheck32 \
176 aclfrommode=_aclfrommode32 \
177 aclfrompbits=_aclfrompbits32 \
178 aclfromtext=_aclfromtext32 \
180 acltomode=_acltomode32 \
181 acltopbits=_acltopbits32 \
182 acltotext=_acltotext32 \
195 ftruncate=_ftruncate64 \
199 getgrent=_getgrent32 \
200 getgrgid=_getgrgid32 \
201 getgrnam=_getgrnam32 \
202 getgroups=_getgroups32 \
203 getpwuid=_getpwuid32 \
204 getpwuid_r=_getpwuid_r32 \
206 initgroups=_initgroups32 \
217 setgroups=_setgroups32 \
218 setregid=_setregid32 \
219 setreuid=_setreuid32 \
225 truncate=_truncate64 \
228 API_VER:=$(srcdir)/include/cygwin/version.h
230 LIB_NAME:=libcygwin.a
231 LIBSERVER:=@LIBSERVER@
232 SUBLIBS:=libpthread.a libutil.a ${CURDIR}/libm.a ${CURDIR}/libc.a libdl.a libresolv.a librt.a
233 EXTRALIBS:=libautomode.a libbinmode.a libtextmode.a libtextreadmode.a
234 INSTOBJS:=automode.o binmode.o textmode.o textreadmode.o
235 TARGET_LIBS:=$(LIB_NAME) $(CYGWIN_START) $(GMON_START) $(LIBGMON_A) $(SUBLIBS) $(INSTOBJS) $(EXTRALIBS)
237 ifneq "${filter -O%,$(CFLAGS)}" ""
238 cygheap_CFLAGS:=-fomit-frame-pointer
239 cygthread_CFLAGS:=-fomit-frame-pointer
240 cygtls_CFLAGS:=-fomit-frame-pointer
241 delqueue_CFLAGS:=-fomit-frame-pointer
242 devices_CFLAGS:=-fomit-frame-pointer -Os
243 dir_CFLAGS:=-fomit-frame-pointer
244 dlfcn_CFLAGS:=-fomit-frame-pointer
245 dll_init_CFLAGS:=-fomit-frame-pointer
246 dtable_CFLAGS:=-fomit-frame-pointer -fcheck-new
247 fcntl_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 _cygwin_crt0_common_STDINCFLAGS:=yes
291 libstdcxx_wrapper_STDINCFLAGS:=yes
294 .PHONY: all force dll_ofiles install all_target install_target all_host install_host \
295 install install-libs install-headers
298 .SUFFIXES: .c .cc .def .a .o .d .s
301 install_host=@install_host@
303 all: all_target $(all_host)
305 all_target: $(TARGET_LIBS)
307 all_host: $(TEST_LIB_NAME)
311 install: install-libs install-headers install-man install_target \
312 $(install_host) $(install_target)
314 uninstall: uninstall-libs uninstall-headers uninstall-man
316 install-libs: $(TARGET_LIBS)
317 @$(MKDIRP) $(DESTDIR)$(bindir)
318 $(INSTALL_PROGRAM) $(TEST_DLL_NAME) $(DESTDIR)$(bindir)/$(DLL_NAME); \
320 $(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/lib/`basename $$i` ; \
322 cd $(DESTDIR)$(tooldir)/lib && ln -sf libcygwin.a libg.a
326 for sub in `find include -name '[a-z]*' -type d -print | sort`; do \
327 $(MKDIRP) $(DESTDIR)$(tooldir)/$$sub; \
328 for i in $$sub/*.h ; do \
329 $(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/$$sub/`basename $$i` ; \
332 $(INSTALL_DATA) regex/regex.h $(DESTDIR)$(tooldir)/include/regex.h
335 @$(MKDIRP) $(DESTDIR)$(mandir)/man2 $(DESTDIR)$(mandir)/man3 $(DESTDIR)$(mandir)/man5 $(DESTDIR)$(mandir)/man7
337 for i in `find . -type f -name '*.2'`; do \
338 $(INSTALL_DATA) $$i $(DESTDIR)$(mandir)/man2/`basename $$i` ; \
340 for i in `find . -type f -name '*.3'`; do \
341 $(INSTALL_DATA) $$i $(DESTDIR)$(mandir)/man3/`basename $$i` ; \
343 for i in `find . -type f -name '*.5'`; do \
344 $(INSTALL_DATA) $$i $(DESTDIR)$(mandir)/man5/`basename $$i` ; \
346 for i in `find . -type f -name '*.7'`; do \
347 $(INSTALL_DATA) $$i $(DESTDIR)$(mandir)/man7/`basename $$i` ; \
354 uninstall-libs: $(TARGET_LIBS)
355 rm -f $(bindir)/$(DLL_NAME); \
357 rm -f $(tooldir)/lib/$$i ; \
362 for sub in `find include -name '[a-z]*' -type d -print | sort`; do \
363 for i in $$sub/*.h ; do \
364 rm -f $(tooldir)/$$sub/`basename $$i` ; \
367 rm -f $(tooldir)/include/regex.h
371 for i in `find . -type f -name '*.2'`; do \
372 rm -f $(tooldir)/man/man2/`basename $$i` ; \
374 for i in `find . -type f -name '*.3'`; do \
375 rm -f $(tooldir)/man/man3/`basename $$i` ; \
377 for i in `find . -type f -name '*.5'`; do \
378 rm -f $(tooldir)/man/man5/`basename $$i` ; \
380 for i in `find . -type f -name '*.7'`; do \
381 rm -f $(tooldir)/man/man7/`basename $$i` ; \
385 -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
386 -@$(MAKE) -C $(bupdir)/cygserver libclean
388 maintainer-clean realclean: clean
389 @echo "This command is intended for maintainers to use;"
390 @echo "it deletes files that may require special tools to rebuild."
394 # Rule to build cygwin.dll
395 $(TEST_DLL_NAME): $(LDSCRIPT) dllfixdbg $(DLL_OFILES) $(DLL_IMPORTS) $(LIBSERVER) $(LIBC) $(LIBM) $(API_VER) Makefile winver_stamp
396 $(CXX) $(CXXFLAGS) -Wl,--gc-sections $(nostdlib) -Wl,-T$(firstword $^) \
397 -Wl,--heap=0 -Wl,--out-implib,cygdll.a -shared -o $@ \
398 -e $(DLL_ENTRY) $(DEF_FILE) $(DLL_OFILES) version.o winver.o \
399 $(MALLOC_OBJ) $(LIBSERVER) $(LIBM) $(LIBC) \
400 -lgcc $(DLL_IMPORTS) -Wl,-Map,cygwin.map
401 @$(word 2,$^) $(OBJDUMP) $(OBJCOPY) $@ ${patsubst %0.dll,%1.dbg,$@}
402 @ln -f $@ new-$(DLL_NAME)
404 # Rule to build libcygwin.a
405 $(LIB_NAME): $(LIBCOS) | $(TEST_DLL_NAME)
406 ${srcdir}/mkimport ${toolopts} ${NEW_FUNCTIONS} $@ cygdll.a $^
408 ${STATIC_LIB_NAME}: mkstatic ${TEST_DLL_NAME}
409 perl -d $< -x ${EXCLUDE_STATIC_OFILES} --library=${LIBC} --library=${LIBM} --ar=${AR} $@ cygwin.map
411 # Rule to make stub library used by testsuite
412 # dependency set to $(LIB_NAME) to accommodate make -j2.
413 $(TEST_LIB_NAME): $(LIB_NAME)
414 perl -p -e 'BEGIN{binmode(STDIN); binmode(STDOUT);}; s/cygwin1/cygwin0/g' < $? > $@
416 $(LIBSERVER): $(bupdir)/cygserver/Makefile
417 $(MAKE) -C $(bupdir)/cygserver libcygserver.a
419 dll_ofiles: $(DLL_OFILES)
421 $(LIBGMON_A): $(GMON_OFILES) $(GMON_START)
422 $(AR) rcv $(LIBGMON_A) $(GMON_OFILES)
424 $(API_VER): $(srcdir)/cygwin.din
425 @echo Error: Version info is older than DLL API!
427 version.cc winver.o: winver_stamp
430 globals.h: mkglobals_h globals.cc
433 ${DLL_OFILES} ${LIBCOS}: globals.h
435 shared_info_magic.h: cygmagic shared_info.h
436 /bin/sh $(word 1,$^) $@ "${COMPILE_CXX} -E -x c++" $(word 2,$^) SHARED_MAGIC 'class shared_info' USER_MAGIC 'class user_info'
438 child_info_magic.h: cygmagic child_info.h
439 /bin/sh $(word 1,$^) $@ "${COMPILE_CXX} -E -x c++" $(word 2,$^) CHILD_INFO_MAGIC 'class child_info'
441 dcrt0.o sigproc.o: child_info_magic.h
443 shared.o: shared_info_magic.h
445 $(srcdir)/devices.cc: gendevices devices.in devices.h
446 ${wordlist 1,2,$^} $@
448 ${CURDIR}/libc.a: ${LIB_NAME} ./libm.a libpthread.a libutil.a
451 ${CURDIR}/libm.a: ${LIB_NAME} $(LIBM)
454 libpthread.a: ${LIB_NAME} pthread.o thread.o
457 libutil.a: ${LIB_NAME} bsdlib.o
460 libdl.a: ${LIB_NAME} dlfcn.o
463 libresolv.a: ${LIB_NAME} minires.o
466 librt.a: ${LIB_NAME} posix_ipc.o
469 ${EXTRALIBS}: lib%.a: %.o
472 winver_stamp: mkvers.sh include/cygwin/version.h winver.rc $(DLL_OFILES)
473 @echo "Making version.o and winver.o";\
474 $(SHELL) ${word 1,$^} ${word 2,$^} ${word 3,$^} $(WINDRES) && \
475 $(COMPILE_CXX) -c -o version.o version.cc && \
480 $(DEF_FILE): gendef cygwin.din $(srcdir)/tlsoffsets.h
483 $(srcdir)/tlsoffsets.h: gentls_offsets cygtls.h
484 $^ $@ $(COMPILE_CXX) -c
488 { rm -f $(DEF_FILE); $(MAKE) -s -j1 $(DEF_FILE); }; \
489 [ -s $@ ] && touch $@
496 deps:=${wildcard *.d}