1 # Makefile.in for Cygwin.
3 # This file is part of Cygwin.
5 # This software is a copyrighted work licensed under the terms of the
6 # Cygwin license. Please consult the file "CYGWIN_LICENSE" for
8 # configure_input: @configure_input@
10 # This makefile requires GNU make.
13 target_builddir
:=@target_builddir@
14 winsup_srcdir
:=@winsup_srcdir@
15 configure_args
=@configure_args@
24 include ${srcdir}/..
/Makefile.common
26 VPATH
+=$(srcdir)/regex
$(srcdir)/lib
$(srcdir)/libc
$(srcdir)/math
$(srcdir)/tzcode
28 target_cpu
:=@target_cpu@
29 target_alias
:=@target_alias@
30 build_alias
:=@build_alias@
31 host_alias
:=@host_alias@
34 program_transform_name
:=@program_transform_name@
35 exec_prefix:=@
exec_prefix@
39 sysconfdir
:=@sysconfdir@
40 datarootdir
:=@datarootdir@
41 ifeq ($(target_alias
),$(host_alias
))
42 ifeq ($(build_alias
),$(host_alias
))
43 tooldir
:=$(exec_prefix)
45 tooldir
:=$(exec_prefix)/$(target_alias
)
48 tooldir
:=$(exec_prefix)/$(target_alias
)
52 includedir:=@
includedir@
54 override INSTALL
:=@INSTALL@
55 override INSTALL_PROGRAM
:=@INSTALL_PROGRAM@
56 override INSTALL_DATA
:=@INSTALL_DATA@
58 cygserver_blddir
:=${target_builddir}/winsup
/cygserver
59 LIBSERVER
:=${cygserver_blddir}/libcygserver.a
61 LIBC
:=$(newlib_build
)/libc
/libc.a
62 LIBM
:=$(newlib_build
)/libm
/libm.a
63 CRT0
:=$(cygwin_build
)/crt0.o
66 # --enable options from configure
69 COMMON_CFLAGS
=-MMD
${$(*F
)_CFLAGS
} -Wimplicit-fallthrough
=5 -Werror
-fmerge-constants
-ftracer
$(CCEXTRA
)
70 ifeq ($(target_cpu
),x86_64
)
71 COMMON_CFLAGS
+=-mcmodel
=small
73 COMPILE.
cc+=${COMMON_CFLAGS} # -std=gnu++14
74 COMPILE.c
+=${COMMON_CFLAGS}
88 MKDIRP
:=$(INSTALL
) -m
755 -d
90 # Setup the testing framework, if you have one
91 EXPECT
= `if [ -f $${rootme}/../../expect/expect$(EXEEXT) ] ; then \
92 echo $${rootme}/../../expect/expect$(EXEEXT) ; \
93 else echo expect ; fi`
95 RUNTEST
= `if [ -f $${srcdir}/../dejagnu/runtest ] ; then \
96 echo $${srcdir}/../dejagnu/runtest ; \
97 else echo runtest; fi`
100 # Parameters used in building the cygwin.dll.
101 # We build as cygwin0.dll and rename at install time to overcome
102 # native rebuilding issues (we don't want the build tools to see a partially
103 # built cygwin.dll and attempt to use it instead of the old one).
105 DLL_NAME
:=cygwin1.dll
106 TEST_DLL_NAME
:=${patsubst %1.dll
,%0.dll
,$(DLL_NAME
)}
107 TEST_LIB_NAME
:=libcygwin0.a
108 STATIC_LIB_NAME
:=libcygwin_s.a
109 DIN_FILE
=@DIN_FILE@ common.din
111 TLSOFFSETS_H
:=@TLSOFFSETS_H@
112 DLL_ENTRY
:=@DLL_ENTRY@
118 toolopts
:=--cpu
=${target_cpu} --ar=${AR} --as=${AS} --nm
=${NM} --objcopy
=${OBJCOPY}
120 ${srcdir}/speclib
${toolopts} \
122 --exclude
='(?i:dll)' \
124 --exclude
='^main$$' \
125 --exclude
='^_main$$' \
128 # Some things want these from libc, but they have their own static
129 # data which apps can get to, which is a pain in the dll, so we
130 # include them directly into the library.
132 LIBCOS
:=${sort ${addsuffix .o
,${basename ${notdir ${wildcard $(srcdir)/lib
/*.c
}}}} \
133 ${addsuffix .o
,${basename ${notdir ${wildcard $(srcdir)/lib
/*.
cc}}}}}
135 # Build all source files in the config directory
139 MALLOC_OFILES
:=malloc.o
141 DLL_IMPORTS
:=${shell $(CC
) -print-file-name
=w32api
/libkernel32.a
} ${shell $(CC
) -print-file-name
=w32api
/libntdll.a
}
265 TZCODE_OFILES
:=localtime.o
295 fhandler_clipboard.o \
297 fhandler_cygdrive.o \
299 fhandler_disk_file.o \
303 fhandler_netdrive.o \
304 fhandler_nodevice.o \
308 fhandler_process_fd.o \
311 fhandler_procsysvipc.o \
314 fhandler_registry.o \
316 fhandler_signalfd.o \
318 fhandler_socket_inet.o \
319 fhandler_socket_local.o \
320 fhandler_socket_unix.o \
342 libstdcxx_wrapper.o \
416 EXCLUDE_STATIC_OFILES
:=$(addprefix --exclude
=,\
425 VERSION_OFILES
:=version.o winver.o
428 override DLL_OFILES
:=$(patsubst %.o
,%_E
,${DLL_OFILES})
429 override EXCLUDE_STATIC_OFILES
:=$(patsubst %.o
,%_E
,${EXCLUDE_STATIC_OFILES})
430 override EXTRA_OFILES
=$(patsubst %.o
,%_E
,${DLL_OFILES}))
431 override MALLOC_OFILES
:=$(patsubst %.o
,%.E
,${MALLOC_OFILES})
434 ifeq ($(target_cpu
),x86_64
)
435 # Needed by mcountFunc.S to choose the right code path and symbol names
439 GMON_OFILES
:=gmon.o mcount.o profil.o mcountFunc.o
441 NEW_FUNCTIONS
:=$(addprefix --replace
=,\
446 __xdrrec_setnonblock
= \
490 xdrrec_endofrecord
= \
495 ifeq ($(target_cpu
),x86_64
)
498 NEW_FUNCTIONS
+=$(addprefix --replace
=,\
500 aclcheck
=_aclcheck32 \
501 aclfrommode
=_aclfrommode32 \
502 aclfrompbits
=_aclfrompbits32 \
503 aclfromtext
=_aclfromtext32 \
505 acltomode
=_acltomode32 \
506 acltopbits
=_acltopbits32 \
507 acltotext
=_acltotext32 \
520 ftruncate
=_ftruncate64 \
524 getgrent
=_getgrent32 \
525 getgrgid
=_getgrgid32 \
526 getgrnam
=_getgrnam32 \
527 getgroups
=_getgroups32 \
528 getpwuid
=_getpwuid32 \
529 getpwuid_r
=_getpwuid_r32 \
531 initgroups
=_initgroups32 \
541 setgroups
=_setgroups32 \
542 setregid
=_setregid32 \
543 setreuid
=_setreuid32 \
547 truncate
=_truncate64 \
551 API_VER
:=$(srcdir)/include/cygwin
/version.h
553 LIB_NAME
:=libcygwin.a
554 SUBLIBS
:=libpthread.a libutil.a
${CURDIR}/libm.a
${CURDIR}/libc.a libdl.a libresolv.a librt.a libacl.a libssp.a
555 EXTRALIBS
:=libautomode.a libbinmode.a libtextmode.a libtextreadmode.a
556 INSTOBJS
:=automode.o binmode.o textmode.o textreadmode.o
557 TARGET_LIBS
:=$(LIB_NAME
) $(CYGWIN_START
) $(GMON_START
) $(LIBGMON_A
) $(SUBLIBS
) $(INSTOBJS
) $(EXTRALIBS
)
559 ifneq "${filter -O%,$(CFLAGS)}" ""
560 dtable_CFLAGS
:=-fcheck-new
561 localtime_CFLAGS
:=-fwrapv
564 ifeq ($(target_cpu
),i686
)
565 # on x86, exceptions.cc must be compiled with a frame-pointer as it uses RtlCaptureContext()
566 exceptions_CFLAGS
:=-fno-omit-frame-pointer
569 # required since gcc 9.x
570 exec_CFLAGS
:=-fno-builtin-execve
572 fhandler_proc_CFLAGS
+=-DUSERNAME
="\"$(USER)\"" -DHOSTNAME
="\"$(HOSTNAME)\""
573 fhandler_proc_CFLAGS
+=-DGCC_VERSION
="\"`$(CC) -v 2>&1 | tail -n 1`\""
575 .PHONY
: all force dll_ofiles
install all_target all_host \
576 install install-libs install-headers \
577 clean distclean realclean maintainer-clean
581 all: all_target
$(all_host
)
583 all_target
: $(TARGET_LIBS
)
585 all_host
: $(TEST_LIB_NAME
)
589 install: install-libs install-headers install-man install-ldif
591 uninstall: uninstall-libs uninstall-headers uninstall-man
593 install-libs
: $(TARGET_LIBS
)
594 @
$(MKDIRP
) $(DESTDIR
)$(bindir) $(DESTDIR
)$(tooldir
)/lib
595 $(INSTALL_PROGRAM
) $(TEST_DLL_NAME
) $(DESTDIR
)$(bindir)/$(DLL_NAME
); \
597 $(INSTALL_DATA
) $$i $(DESTDIR
)$(tooldir
)/lib
/`basename $$i` ; \
599 cd
$(DESTDIR
)$(tooldir
)/lib
&& ln
-sf libcygwin.a libg.a
603 for sub in
`find include -name '[a-z]*' -type d -print | sort`; do \
604 $(MKDIRP
) $(DESTDIR
)$(tooldir
)/$$sub; \
605 for i in
$$sub/*.h
; do \
606 $(INSTALL_DATA
) $$i $(DESTDIR
)$(tooldir
)/$$sub/`basename $$i` ; \
611 @
$(MKDIRP
) $(DESTDIR
)$(mandir)/man2
$(DESTDIR
)$(mandir)/man3
$(DESTDIR
)$(mandir)/man5
$(DESTDIR
)$(mandir)/man7
613 for i in
`find . -type f ! -path './release/*' -name '*.2'`; do \
614 $(INSTALL_DATA
) $$i $(DESTDIR
)$(mandir)/man2
/`basename $$i` ; \
616 for i in
`find . -type f ! -path './release/*' -name '*.3'`; do \
617 $(INSTALL_DATA
) $$i $(DESTDIR
)$(mandir)/man3
/`basename $$i` ; \
619 for i in
`find . -type f ! -path './release/*' -name '*.5'`; do \
620 $(INSTALL_DATA
) $$i $(DESTDIR
)$(mandir)/man5
/`basename $$i` ; \
622 for i in
`find . -type f ! -path './release/*' -name '*.7'`; do \
623 $(INSTALL_DATA
) $$i $(DESTDIR
)$(mandir)/man7
/`basename $$i` ; \
627 @
$(MKDIRP
) $(DESTDIR
)$(datarootdir
)/cygwin
628 $(INSTALL_DATA
) $(srcdir)/cygwin.ldif
$(DESTDIR
)$(datarootdir
)/cygwin
630 uninstall-libs
: $(TARGET_LIBS
)
631 rm -f
$(bindir)/$(DLL_NAME
); \
633 rm -f
$(tooldir
)/lib
/$$i ; \
638 for sub in
`find include -name '[a-z]*' -type d -print | sort`; do \
639 for i in
$$sub/*.h
; do \
640 rm -f
$(tooldir
)/$$sub/`basename $$i` ; \
646 for i in
`find . -type f -name '*.2'`; do \
647 rm -f
$(DESTDIR
)$(mandir)/man2
/`basename $$i` ; \
649 for i in
`find . -type f -name '*.3'`; do \
650 rm -f
$(DESTDIR
)$(mandir)/man3
/`basename $$i` ; \
652 for i in
`find . -type f -name '*.5'`; do \
653 rm -f
$(DESTDIR
)$(mandir)/man5
/`basename $$i` ; \
655 for i in
`find . -type f -name '*.7'`; do \
656 rm -f
$(DESTDIR
)$(mandir)/man7
/`basename $$i` ; \
659 clean distclean realclean:
660 -rm -f
*.o
*.dll
*.dbg
*.a
*.exp junk
*.base version.
cc *.exe
*.d \
661 *stamp
* *_magic.h sigfe.s cygwin.def cygwin.map cygwin.sc \
662 globals.h localtime.patched.c
663 -@
$(MAKE
) -C
${cygserver_blddir} libclean
665 maintainer-clean
: clean
666 @echo
"This command is intended for maintainers to use;"
667 @echo
"it deletes files that may require special tools to rebuild."
669 -rm -f
$(srcdir)/$(TLSOFFSETS_H
) $(srcdir)/devices.
cc
671 # Rule to build LDSCRIPT
672 $(LDSCRIPT
): $(LDSCRIPT
).in
673 $(CC
) -E
- -P
< $^
-o
$@
675 # Rule to build cygwin.dll
676 $(TEST_DLL_NAME
): $(LDSCRIPT
) dllfixdbg
$(DLL_OFILES
) $(LIBSERVER
) $(LIBC
) $(LIBM
) $(API_VER
) Makefile
$(VERSION_OFILES
)
678 -mno-use-libstdc-wrappers \
679 -Wl
,--gc-sections
-nostdlib
-Wl
,-T
$(firstword $^
) -static \
680 -Wl
,--heap
=0 -Wl
,--out-implib
,cygdll.a
-shared
-o
$@ \
681 -e
$(DLL_ENTRY
) $(DEF_FILE
) $(DLL_OFILES
) $(VERSION_OFILES
) \
682 $(MALLOC_OBJ
) $(LIBSERVER
) $(LIBM
) $(LIBC
) \
683 -lgcc
$(DLL_IMPORTS
) -Wl
,-Map
,cygwin.map
684 @
$(word 2,$^
) $(OBJDUMP
) $(OBJCOPY
) $@
${patsubst %0.dll
,%1.dbg
,$@
}
685 @ln
-f
$@ new-
$(DLL_NAME
)
687 # Rule to build libcygwin.a
688 $(LIB_NAME
): $(DEF_FILE
) $(LIBCOS
) |
$(TEST_DLL_NAME
)
689 ${srcdir}/mkimport
${toolopts} ${NEW_FUNCTIONS} $@ cygdll.a
$(wordlist
2,99,$^
)
691 ${STATIC_LIB_NAME}: mkstatic
${TEST_DLL_NAME}
692 perl
-d
$< -x
${EXCLUDE_STATIC_OFILES} --library
=${LIBC} --library
=${LIBM} --ar=${AR} $@ cygwin.map
694 # Rule to make stub library used by testsuite
695 # dependency set to $(LIB_NAME) to accommodate make -j2.
696 $(TEST_LIB_NAME
): $(LIB_NAME
)
697 perl
-p
-e
'BEGIN{binmode(STDIN); binmode(STDOUT);}; s/cygwin1/cygwin0/g' < $?
> $@
699 $(LIBSERVER
): ${cygserver_blddir}/Makefile
700 $(MAKE
) -C
${cygserver_blddir} libcygserver.a
702 ${cygserver_blddir}/Makefile
:
704 cd
${@D
} && exec
/bin
/sh
$(dir ${srcdir})/cygserver
/configure
${configure_args}
706 dll_ofiles
: $(DLL_OFILES
)
708 $(LIBGMON_A
): $(GMON_OFILES
) $(GMON_START
)
709 $(AR
) rcv
$(LIBGMON_A
) $(GMON_OFILES
)
711 globals.h
: mkglobals_h globals.
cc
714 ${DLL_OFILES} ${LIBCOS}: globals.h
$(srcdir)/$(TLSOFFSETS_H
)
716 shared_info_magic.h
: cygmagic shared_info.h
717 /bin
/sh
$(word 1,$^
) $@
"${COMPILE.cc} -E -x c++" $(word 2,$^
) SHARED_MAGIC
'class shared_info' USER_MAGIC
'class user_info'
719 child_info_magic.h
: cygmagic child_info.h
720 /bin
/sh
$(word 1,$^
) $@
"${COMPILE.cc} -E -x c++" $(word 2,$^
) CHILD_INFO_MAGIC
'class child_info'
722 dcrt0.o sigproc.o
: child_info_magic.h
724 shared.o
: shared_info_magic.h
726 localtime.patched.c
: tzcode
/localtime.c tzcode
/localtime.c.patch
727 patch
-u
-o localtime.patched.c \
728 $(srcdir)/tzcode
/localtime.c \
729 $(srcdir)/tzcode
/localtime.c.patch
731 localtime.o
: tzcode
/localtime_wrapper.c localtime.patched.c
732 $(CC
) ${COMMON_CFLAGS} ${localtime_CFLAGS} \
733 -I
$(target_builddir
)/winsup
/cygwin \
734 -I
$(srcdir) -I
$(srcdir)/tzcode
-c
-o
$@
$<
736 $(srcdir)/devices.
cc: gendevices devices.in devices.h
737 ${wordlist
1,2,$^
} $@
739 ${CURDIR}/libc.a
: ${LIB_NAME} ${CURDIR}/libm.a libpthread.a libutil.a
742 ${CURDIR}/libm.a
: ${LIB_NAME} $(LIBM
) $(MATH_OFILES
)
745 libpthread.a
: ${LIB_NAME} pthread.o thread.o call_once.o cnd.o mtx.o \
749 libutil.a
: ${LIB_NAME} bsdlib.o
752 libdl.a
: ${LIB_NAME} dlfcn.o
755 libresolv.a
: ${LIB_NAME} minires.o
758 librt.a
: ${LIB_NAME} posix_ipc.o
761 libacl.a
: ${LIB_NAME} sec_posixacl.o
764 libssp.a
: ${LIB_NAME} $(newlib_build
)/libc
/ssp
/lib.a
767 ${EXTRALIBS}: lib
%.a
: %.o
770 # Every time we touch a source file, the version info has to be rebuilt
771 # to maintain a correct build date, especially in uname release output
772 find_src_files
= $(wildcard $(dir)/*.
[chS
]) $(wildcard $(dir)/*.
cc)
773 src_files
:= $(foreach dir,$(VPATH
),$(find_src_files
))
775 # mkvers.sh creates version.cc in the first place, winver.o always
776 # second, so version.cc is always older than winver.o
777 version.
cc: mkvers.sh
include/cygwin
/version.h winver.rc
$(src_files
)
778 @echo
"Making version.cc and winver.o";\
780 /bin
/sh
${word 1,$^
} ${word 2,$^
} ${word 3,$^
} $(WINDRES
) ${CFLAGS} -I
${srcdir}/include
781 $(VERSION_OFILES
): version.
cc
783 Makefile
: ${srcdir}/Makefile.in
784 /bin
/sh .
/config.status
786 $(DEF_FILE
): gendef
$(srcdir)/$(TLSOFFSETS_H
) $(DIN_FILE
)
787 $(word 1,$^
) --cpu
=${target_cpu} --output-def
=$@
--tlsoffsets
=$(word 2,$^
) $(wordlist
3,99,$^
)
789 $(srcdir)/$(TLSOFFSETS_H
): gentls_offsets cygtls.h
790 $^
$@
$(target_cpu
) $(COMPILE.
cc) -c ||
rm $@
794 { rm -f
$(DEF_FILE
); $(MAKE
) -s
-j1
$(DEF_FILE
); }; \
795 [ -s
$@
] && touch
$@
797 sigfe.o
: sigfe.s
$(srcdir)/$(TLSOFFSETS_H
)
798 $(CC
) ${CFLAGS} -c
-o
$@
$<
804 ctags
-R
--c
++-kinds
=+p
--fields
=+iaS
--extra
=+q \
805 --regex-C
++='/EXPORT_ALIAS *\([a-zA-Z0-9_]*, *([a-zA-Z0-9_]*)\)/\1/' \
806 --regex-C
++='/__ASMNAME *\("([a-zA-Z0-9_]+)"\)/\1/' \
809 deps
:=${wildcard *.d
}