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@
21 include ${srcdir}/..
/Makefile.common
23 VPATH
+=$(srcdir)/regex
$(srcdir)/lib
$(srcdir)/libc
$(srcdir)/math
$(srcdir)/tzcode
25 target_cpu
:=@target_cpu@
26 target_alias
:=@target_alias@
27 build_alias
:=@build_alias@
28 host_alias
:=@host_alias@
31 program_transform_name
:=@program_transform_name@
32 exec_prefix:=@
exec_prefix@
36 sysconfdir
:=@sysconfdir@
37 datarootdir
:=@datarootdir@
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@
55 cygserver_blddir
:=${target_builddir}/winsup
/cygserver
56 LIBSERVER
:=${cygserver_blddir}/libcygserver.a
58 LIBC
:=$(newlib_build
)/libc
/libc.a
59 LIBM
:=$(newlib_build
)/libm
/libm.a
60 CRT0
:=$(cygwin_build
)/crt0.o
63 # --enable options from configure
66 COMMON_CFLAGS
=-MMD
${$(*F
)_CFLAGS
} -Wimplicit-fallthrough
=5 -Werror
-fmerge-constants
-ftracer
$(CCEXTRA
)
67 ifeq ($(target_cpu
),x86_64
)
68 COMMON_CFLAGS
+=-mcmodel
=small
70 COMPILE.
cc+=${COMMON_CFLAGS} # -std=gnu++14
71 COMPILE.c
+=${COMMON_CFLAGS}
85 MKDIRP
:=$(INSTALL
) -m
755 -d
87 # Setup the testing framework, if you have one
88 EXPECT
= `if [ -f $${rootme}/../../expect/expect$(EXEEXT) ] ; then \
89 echo $${rootme}/../../expect/expect$(EXEEXT) ; \
90 else echo expect ; fi`
92 RUNTEST
= `if [ -f $${srcdir}/../dejagnu/runtest ] ; then \
93 echo $${srcdir}/../dejagnu/runtest ; \
94 else echo runtest; fi`
97 # Parameters used in building the cygwin.dll.
98 # We build as cygwin0.dll and rename at install time to overcome
99 # native rebuilding issues (we don't want the build tools to see a partially
100 # built cygwin.dll and attempt to use it instead of the old one).
103 TEST_DLL_NAME
:=${patsubst %1.dll
,%0.dll
,@DLL_NAME@
}
104 TEST_LIB_NAME
:=libcygwin0.a
105 STATIC_LIB_NAME
:=libcygwin_s.a
106 DIN_FILE
=@DIN_FILE@ common.din
108 TLSOFFSETS_H
:=@TLSOFFSETS_H@
109 DLL_ENTRY
:=@DLL_ENTRY@
115 toolopts
:=--cpu
=${target_cpu} --ar=${AR} --as=${AS} --nm
=${NM} --objcopy
=${OBJCOPY}
117 ${srcdir}/speclib
${toolopts} \
119 --exclude
='(?i:dll)' \
121 --exclude
='^main$$' \
122 --exclude
='^_main$$' \
125 # Some things want these from libc, but they have their own static
126 # data which apps can get to, which is a pain in the dll, so we
127 # include them directly into the library.
129 LIBCOS
:=${sort ${addsuffix .o
,${basename ${notdir ${wildcard $(srcdir)/lib
/*.c
}}}} \
130 ${addsuffix .o
,${basename ${notdir ${wildcard $(srcdir)/lib
/*.
cc}}}}}
132 # Build all source files in the config directory
136 MALLOC_OFILES
:=malloc.o
138 DLL_IMPORTS
:=${shell $(CC
) -print-file-name
=w32api
/libkernel32.a
} ${shell $(CC
) -print-file-name
=w32api
/libntdll.a
}
262 TZCODE_OFILES
:=localtime.o
292 fhandler_clipboard.o \
294 fhandler_cygdrive.o \
296 fhandler_disk_file.o \
300 fhandler_netdrive.o \
301 fhandler_nodevice.o \
305 fhandler_process_fd.o \
308 fhandler_procsysvipc.o \
311 fhandler_registry.o \
313 fhandler_signalfd.o \
315 fhandler_socket_inet.o \
316 fhandler_socket_local.o \
317 fhandler_socket_unix.o \
339 libstdcxx_wrapper.o \
413 EXCLUDE_STATIC_OFILES
:=$(addprefix --exclude
=,\
422 VERSION_OFILES
:=version.o winver.o
425 override DLL_OFILES
:=$(patsubst %.o
,%_E
,${DLL_OFILES})
426 override EXCLUDE_STATIC_OFILES
:=$(patsubst %.o
,%_E
,${EXCLUDE_STATIC_OFILES})
427 override EXTRA_OFILES
=$(patsubst %.o
,%_E
,${DLL_OFILES}))
428 override MALLOC_OFILES
:=$(patsubst %.o
,%.E
,${MALLOC_OFILES})
431 ifeq ($(target_cpu
),x86_64
)
432 # Needed by mcountFunc.S to choose the right code path and symbol names
436 GMON_OFILES
:=gmon.o mcount.o profil.o mcountFunc.o
438 NEW_FUNCTIONS
:=$(addprefix --replace
=,\
443 __xdrrec_setnonblock
= \
487 xdrrec_endofrecord
= \
492 ifeq ($(target_cpu
),x86_64
)
495 NEW_FUNCTIONS
+=$(addprefix --replace
=,\
497 aclcheck
=_aclcheck32 \
498 aclfrommode
=_aclfrommode32 \
499 aclfrompbits
=_aclfrompbits32 \
500 aclfromtext
=_aclfromtext32 \
502 acltomode
=_acltomode32 \
503 acltopbits
=_acltopbits32 \
504 acltotext
=_acltotext32 \
517 ftruncate
=_ftruncate64 \
521 getgrent
=_getgrent32 \
522 getgrgid
=_getgrgid32 \
523 getgrnam
=_getgrnam32 \
524 getgroups
=_getgroups32 \
525 getpwuid
=_getpwuid32 \
526 getpwuid_r
=_getpwuid_r32 \
528 initgroups
=_initgroups32 \
538 setgroups
=_setgroups32 \
539 setregid
=_setregid32 \
540 setreuid
=_setreuid32 \
544 truncate
=_truncate64 \
548 API_VER
:=$(srcdir)/include/cygwin
/version.h
550 LIB_NAME
:=libcygwin.a
551 SUBLIBS
:=libpthread.a libutil.a
${CURDIR}/libm.a
${CURDIR}/libc.a libdl.a libresolv.a librt.a libacl.a libssp.a
552 EXTRALIBS
:=libautomode.a libbinmode.a libtextmode.a libtextreadmode.a
553 INSTOBJS
:=automode.o binmode.o textmode.o textreadmode.o
554 TARGET_LIBS
:=$(LIB_NAME
) $(CYGWIN_START
) $(GMON_START
) $(LIBGMON_A
) $(SUBLIBS
) $(INSTOBJS
) $(EXTRALIBS
)
556 ifneq "${filter -O%,$(CFLAGS)}" ""
557 dtable_CFLAGS
:=-fcheck-new
558 localtime_CFLAGS
:=-fwrapv
561 ifeq ($(target_cpu
),i686
)
562 # on x86, exceptions.cc must be compiled with a frame-pointer as it uses RtlCaptureContext()
563 exceptions_CFLAGS
:=-fno-omit-frame-pointer
566 # required since gcc 9.x
567 exec_CFLAGS
:=-fno-builtin-execve
569 fhandler_proc_CFLAGS
+=-DUSERNAME
="\"$(USER)\"" -DHOSTNAME
="\"$(HOSTNAME)\""
570 fhandler_proc_CFLAGS
+=-DGCC_VERSION
="\"`$(CC) -v 2>&1 | tail -n 1`\""
572 .PHONY
: all force dll_ofiles
install all_target install_target all_host \
573 install install-libs install-headers \
574 clean distclean realclean maintainer-clean
578 all: all_target
$(all_host
)
580 all_target
: $(TARGET_LIBS
)
582 all_host
: $(TEST_LIB_NAME
)
586 install: install-libs install-headers install-man install-ldif install_target \
589 uninstall: uninstall-libs uninstall-headers uninstall-man
591 install-libs
: $(TARGET_LIBS
)
592 @
$(MKDIRP
) $(DESTDIR
)$(bindir) $(DESTDIR
)$(tooldir
)/lib
593 $(INSTALL_PROGRAM
) $(TEST_DLL_NAME
) $(DESTDIR
)$(bindir)/$(DLL_NAME
); \
595 $(INSTALL_DATA
) $$i $(DESTDIR
)$(tooldir
)/lib
/`basename $$i` ; \
597 cd
$(DESTDIR
)$(tooldir
)/lib
&& ln
-sf libcygwin.a libg.a
601 for sub in
`find include -name '[a-z]*' -type d -print | sort`; do \
602 $(MKDIRP
) $(DESTDIR
)$(tooldir
)/$$sub; \
603 for i in
$$sub/*.h
; do \
604 $(INSTALL_DATA
) $$i $(DESTDIR
)$(tooldir
)/$$sub/`basename $$i` ; \
609 @
$(MKDIRP
) $(DESTDIR
)$(mandir)/man2
$(DESTDIR
)$(mandir)/man3
$(DESTDIR
)$(mandir)/man5
$(DESTDIR
)$(mandir)/man7
611 for i in
`find . -type f ! -path './release/*' -name '*.2'`; do \
612 $(INSTALL_DATA
) $$i $(DESTDIR
)$(mandir)/man2
/`basename $$i` ; \
614 for i in
`find . -type f ! -path './release/*' -name '*.3'`; do \
615 $(INSTALL_DATA
) $$i $(DESTDIR
)$(mandir)/man3
/`basename $$i` ; \
617 for i in
`find . -type f ! -path './release/*' -name '*.5'`; do \
618 $(INSTALL_DATA
) $$i $(DESTDIR
)$(mandir)/man5
/`basename $$i` ; \
620 for i in
`find . -type f ! -path './release/*' -name '*.7'`; do \
621 $(INSTALL_DATA
) $$i $(DESTDIR
)$(mandir)/man7
/`basename $$i` ; \
625 @
$(MKDIRP
) $(DESTDIR
)$(datarootdir
)/cygwin
626 $(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";\
779 /bin
/sh
${word 1,$^
} ${word 2,$^
} ${word 3,$^
} $(WINDRES
) ${CFLAGS} -I
${srcdir}/include
780 $(VERSION_OFILES
): version.
cc
782 Makefile
: ${srcdir}/Makefile.in
783 /bin
/sh .
/config.status
785 $(DEF_FILE
) sigfe.s
: gendef
$(srcdir)/$(TLSOFFSETS_H
) $(DIN_FILE
)
786 $(word 1,$^
) --cpu
=${target_cpu} --output-def
=$(DEF_FILE
) --tlsoffsets
=$(word 2,$^
) $(wordlist
3,4,$^
)
788 $(srcdir)/$(TLSOFFSETS_H
): gentls_offsets cygtls.h
789 $^
$@
$(target_cpu
) $(COMPILE.
cc) -c ||
rm $@
793 sigfe.o
: sigfe.s
$(srcdir)/$(TLSOFFSETS_H
)
794 $(CC
) ${CFLAGS} -c
-o
$@
$<
800 ctags
-R
--c
++-kinds
=+p
--fields
=+iaS
--extra
=+q \
801 --regex-C
++='/EXPORT_ALIAS *\([a-zA-Z0-9_]*, *([a-zA-Z0-9_]*)\)/\1/' \
802 --regex-C
++='/__ASMNAME *\("([a-zA-Z0-9_]+)"\)/\1/' \
805 deps
:=${wildcard *.d
}