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@
23 include ${srcdir}/..
/Makefile.common
25 # environment variables used by ccwrap
26 export CCWRAP_HEADERS
:=.
${srcdir}
27 export CCWRAP_SYSTEM_HEADERS
:=@cygwin_headers@ @newlib_headers@
28 export CCWRAP_DIRAFTER_HEADERS
:=@windows_headers@
30 VPATH
+=$(srcdir)/regex
$(srcdir)/lib
$(srcdir)/libc
$(srcdir)/math
$(srcdir)/tzcode
32 target_cpu
:=@target_cpu@
33 target_alias
:=@target_alias@
34 build_alias
:=@build_alias@
35 host_alias
:=@host_alias@
38 program_transform_name
:=@program_transform_name@
39 exec_prefix:=@
exec_prefix@
43 sysconfdir
:=@sysconfdir@
44 datarootdir
:=@datarootdir@
45 ifeq ($(target_alias
),$(host_alias
))
46 ifeq ($(build_alias
),$(host_alias
))
47 tooldir
:=$(exec_prefix)
49 tooldir
:=$(exec_prefix)/$(target_alias
)
52 tooldir
:=$(exec_prefix)/$(target_alias
)
56 includedir:=@
includedir@
58 override INSTALL
:=@INSTALL@
59 override INSTALL_PROGRAM
:=@INSTALL_PROGRAM@
60 override INSTALL_DATA
:=@INSTALL_DATA@
62 WINDOWS_LIBDIR
:=@windows_libdir@
64 cygserver_blddir
:=${target_builddir}/winsup
/cygserver
65 LIBSERVER
:=${cygserver_blddir}/libcygserver.a
67 LIBC
:=$(newlib_build
)/libc
/libc.a
68 LIBM
:=$(newlib_build
)/libm
/libm.a
69 CRT0
:=$(cygwin_build
)/crt0.o
72 # --enable options from configure
76 COMMON_CFLAGS
=-MMD
${$(*F
)_CFLAGS
} -Wimplicit-fallthrough
=5 -Werror
-fmerge-constants
-ftracer
$(CCEXTRA
)
77 ifeq ($(target_cpu
),x86_64
)
78 COMMON_CFLAGS
+=-mcmodel
=small
80 COMPILE.
cc+=${COMMON_CFLAGS} # -std=gnu++14
81 COMPILE.c
+=${COMMON_CFLAGS}
95 MKDIRP
:=$(INSTALL
) -m
755 -d
99 # Setup the testing framework, if you have one
100 EXPECT
= `if [ -f $${rootme}/../../expect/expect$(EXEEXT) ] ; then \
101 echo $${rootme}/../../expect/expect$(EXEEXT) ; \
102 else echo expect ; fi`
104 RUNTEST
= `if [ -f $${srcdir}/../dejagnu/runtest ] ; then \
105 echo $${srcdir}/../dejagnu/runtest ; \
106 else echo runtest; fi`
109 # Parameters used in building the cygwin.dll.
110 # We build as cygwin0.dll and rename at install time to overcome
111 # native rebuilding issues (we don't want the build tools to see a partially
112 # built cygwin.dll and attempt to use it instead of the old one).
115 TEST_DLL_NAME
:=${patsubst %1.dll
,%0.dll
,@DLL_NAME@
}
116 TEST_LIB_NAME
:=libcygwin0.a
117 STATIC_LIB_NAME
:=libcygwin_s.a
118 DIN_FILE
=@DIN_FILE@ common.din
120 TLSOFFSETS_H
:=@TLSOFFSETS_H@
121 DLL_ENTRY
:=@DLL_ENTRY@
127 toolopts
:=--cpu
=${target_cpu} --ar=${AR} --as=${AS} --nm
=${NM} --objcopy
=${OBJCOPY}
129 ${srcdir}/speclib
${toolopts} \
131 --exclude
='(?i:dll)' \
133 --exclude
='^main$$' \
134 --exclude
='^_main$$' \
137 # Some things want these from libc, but they have their own static
138 # data which apps can get to, which is a pain in the dll, so we
139 # include them directly into the library.
141 LIBCOS
:=${sort ${addsuffix .o
,${basename ${notdir ${wildcard $(srcdir)/lib
/*.c
}}}} \
142 ${addsuffix .o
,${basename ${notdir ${wildcard $(srcdir)/lib
/*.
cc}}}}}
144 # Build all source files in the config directory
148 MALLOC_OFILES
:=malloc.o
150 DLL_IMPORTS
:=${shell $(CC
) -print-file-name
=w32api
/libkernel32.a
} ${shell $(CC
) -print-file-name
=w32api
/libntdll.a
}
249 TZCODE_OFILES
:=localtime.o
282 fhandler_clipboard.o \
284 fhandler_cygdrive.o \
286 fhandler_disk_file.o \
290 fhandler_netdrive.o \
291 fhandler_nodevice.o \
295 fhandler_process_fd.o \
298 fhandler_procsysvipc.o \
301 fhandler_registry.o \
303 fhandler_signalfd.o \
305 fhandler_socket_inet.o \
306 fhandler_socket_local.o \
307 fhandler_socket_unix.o \
336 libstdcxx_wrapper.o \
419 EXCLUDE_STATIC_OFILES
:=$(addprefix --exclude
=,\
428 VERSION_OFILES
:=version.o winver.o
431 override DLL_OFILES
:=$(patsubst %.o
,%_E
,${DLL_OFILES})
432 override EXCLUDE_STATIC_OFILES
:=$(patsubst %.o
,%_E
,${EXCLUDE_STATIC_OFILES})
433 override EXTRA_OFILES
=$(patsubst %.o
,%_E
,${DLL_OFILES}))
434 override MALLOC_OFILES
:=$(patsubst %.o
,%.E
,${MALLOC_OFILES})
437 ifeq ($(target_cpu
),x86_64
)
438 # Needed by mcountFunc.S to choose the right code path and symbol names
442 GMON_OFILES
:=gmon.o mcount.o profil.o mcountFunc.o
444 NEW_FUNCTIONS
:=$(addprefix --replace
=,\
449 __xdrrec_setnonblock
= \
493 xdrrec_endofrecord
= \
498 ifeq ($(target_cpu
),x86_64
)
501 NEW_FUNCTIONS
+=$(addprefix --replace
=,\
503 aclcheck
=_aclcheck32 \
504 aclfrommode
=_aclfrommode32 \
505 aclfrompbits
=_aclfrompbits32 \
506 aclfromtext
=_aclfromtext32 \
508 acltomode
=_acltomode32 \
509 acltopbits
=_acltopbits32 \
510 acltotext
=_acltotext32 \
523 ftruncate
=_ftruncate64 \
527 getgrent
=_getgrent32 \
528 getgrgid
=_getgrgid32 \
529 getgrnam
=_getgrnam32 \
530 getgroups
=_getgroups32 \
531 getpwuid
=_getpwuid32 \
532 getpwuid_r
=_getpwuid_r32 \
534 initgroups
=_initgroups32 \
544 setgroups
=_setgroups32 \
545 setregid
=_setregid32 \
546 setreuid
=_setreuid32 \
550 truncate
=_truncate64 \
554 API_VER
:=$(srcdir)/include/cygwin
/version.h
556 LIB_NAME
:=libcygwin.a
557 SUBLIBS
:=libpthread.a libutil.a
${CURDIR}/libm.a
${CURDIR}/libc.a libdl.a libresolv.a librt.a libacl.a libssp.a
558 EXTRALIBS
:=libautomode.a libbinmode.a libtextmode.a libtextreadmode.a
559 INSTOBJS
:=automode.o binmode.o textmode.o textreadmode.o
560 TARGET_LIBS
:=$(LIB_NAME
) $(CYGWIN_START
) $(GMON_START
) $(LIBGMON_A
) $(SUBLIBS
) $(INSTOBJS
) $(EXTRALIBS
)
562 ifneq "${filter -O%,$(CFLAGS)}" ""
563 dtable_CFLAGS
:=-fcheck-new
564 localtime_CFLAGS
:=-fwrapv
567 ifeq ($(target_cpu
),i686
)
568 # on x86, exceptions.cc must be compiled with a frame-pointer as it uses RtlCaptureContext()
569 exceptions_CFLAGS
:=-fno-omit-frame-pointer
572 # required since gcc 9.x
573 exec_CFLAGS
:=-fno-builtin-execve
575 fhandler_proc_CFLAGS
+=-DUSERNAME
="\"$(USER)\"" -DHOSTNAME
="\"$(HOSTNAME)\""
576 fhandler_proc_CFLAGS
+=-DGCC_VERSION
="\"`$(CC) -v 2>&1 | tail -n 1`\""
578 _cygwin_crt0_common_STDINCFLAGS
:=yes
579 libstdcxx_wrapper_STDINCFLAGS
:=yes
582 .PHONY
: all force dll_ofiles
install all_target install_target all_host \
583 install_host
install install-libs install-headers \
584 clean distclean realclean maintainer-clean
587 install_host
=@install_host@
589 all: all_target
$(all_host
)
591 all_target
: $(TARGET_LIBS
)
593 all_host
: $(TEST_LIB_NAME
)
597 install: install-libs install-headers install-man install-ldif install_target \
598 $(install_host
) $(install_target
)
600 uninstall: uninstall-libs uninstall-headers uninstall-man
602 install-libs
: $(TARGET_LIBS
)
603 @
$(MKDIRP
) $(DESTDIR
)$(bindir)
604 $(INSTALL_PROGRAM
) $(TEST_DLL_NAME
) $(DESTDIR
)$(bindir)/$(DLL_NAME
); \
606 $(INSTALL_DATA
) $$i $(DESTDIR
)$(tooldir
)/lib
/`basename $$i` ; \
608 cd
$(DESTDIR
)$(tooldir
)/lib
&& ln
-sf libcygwin.a libg.a
612 for sub in
`find include -name '[a-z]*' -type d -print | sort`; do \
613 $(MKDIRP
) $(DESTDIR
)$(tooldir
)/$$sub; \
614 for i in
$$sub/*.h
; do \
615 $(INSTALL_DATA
) $$i $(DESTDIR
)$(tooldir
)/$$sub/`basename $$i` ; \
620 @
$(MKDIRP
) $(DESTDIR
)$(mandir)/man2
$(DESTDIR
)$(mandir)/man3
$(DESTDIR
)$(mandir)/man5
$(DESTDIR
)$(mandir)/man7
622 for i in
`find . -type f ! -path './release/*' -name '*.2'`; do \
623 $(INSTALL_DATA
) $$i $(DESTDIR
)$(mandir)/man2
/`basename $$i` ; \
625 for i in
`find . -type f ! -path './release/*' -name '*.3'`; do \
626 $(INSTALL_DATA
) $$i $(DESTDIR
)$(mandir)/man3
/`basename $$i` ; \
628 for i in
`find . -type f ! -path './release/*' -name '*.5'`; do \
629 $(INSTALL_DATA
) $$i $(DESTDIR
)$(mandir)/man5
/`basename $$i` ; \
631 for i in
`find . -type f ! -path './release/*' -name '*.7'`; do \
632 $(INSTALL_DATA
) $$i $(DESTDIR
)$(mandir)/man7
/`basename $$i` ; \
636 @
$(MKDIRP
) $(DESTDIR
)$(datarootdir
)/cygwin
637 $(INSTALL_DATA
) $(srcdir)/cygwin.ldif
$(DESTDIR
)$(datarootdir
)/cygwin
643 uninstall-libs
: $(TARGET_LIBS
)
644 rm -f
$(bindir)/$(DLL_NAME
); \
646 rm -f
$(tooldir
)/lib
/$$i ; \
651 for sub in
`find include -name '[a-z]*' -type d -print | sort`; do \
652 for i in
$$sub/*.h
; do \
653 rm -f
$(tooldir
)/$$sub/`basename $$i` ; \
659 for i in
`find . -type f -name '*.2'`; do \
660 rm -f
$(DESTDIR
)$(mandir)/man2
/`basename $$i` ; \
662 for i in
`find . -type f -name '*.3'`; do \
663 rm -f
$(DESTDIR
)$(mandir)/man3
/`basename $$i` ; \
665 for i in
`find . -type f -name '*.5'`; do \
666 rm -f
$(DESTDIR
)$(mandir)/man5
/`basename $$i` ; \
668 for i in
`find . -type f -name '*.7'`; do \
669 rm -f
$(DESTDIR
)$(mandir)/man7
/`basename $$i` ; \
672 clean distclean realclean:
673 -rm -f
*.o
*.dll
*.dbg
*.a
*.exp junk
*.base version.
cc *.exe
*.d \
674 *stamp
* *_magic.h sigfe.s cygwin.def cygwin.map cygwin.sc \
675 globals.h localtime.patched.c
676 -@
$(MAKE
) -C
${cygserver_blddir} libclean
678 maintainer-clean
: clean
679 @echo
"This command is intended for maintainers to use;"
680 @echo
"it deletes files that may require special tools to rebuild."
682 -rm -f
$(srcdir)/$(TLSOFFSETS_H
) $(srcdir)/devices.
cc
684 # Rule to build LDSCRIPT
685 $(LDSCRIPT
): $(LDSCRIPT
).in
686 $(CC
) -E
- -P
< $^
-o
$@
688 # Rule to build cygwin.dll
689 $(TEST_DLL_NAME
): $(LDSCRIPT
) dllfixdbg
$(DLL_OFILES
) $(LIBSERVER
) $(LIBC
) $(LIBM
) $(API_VER
) Makefile
$(VERSION_OFILES
)
691 -mno-use-libstdc-wrappers
-L
${WINDOWS_LIBDIR} \
692 -Wl
,--gc-sections
$(nostdlib
) -Wl
,-T
$(firstword $^
) -static \
693 -Wl
,--heap
=0 -Wl
,--out-implib
,cygdll.a
-shared
-o
$@ \
694 -e
$(DLL_ENTRY
) $(DEF_FILE
) $(DLL_OFILES
) $(VERSION_OFILES
) \
695 $(MALLOC_OBJ
) $(LIBSERVER
) $(LIBM
) $(LIBC
) \
696 -lgcc
$(DLL_IMPORTS
) -Wl
,-Map
,cygwin.map
697 @
$(word 2,$^
) $(OBJDUMP
) $(OBJCOPY
) $@
${patsubst %0.dll
,%1.dbg
,$@
}
698 @ln
-f
$@ new-
$(DLL_NAME
)
700 # Rule to build libcygwin.a
701 $(LIB_NAME
): $(DEF_FILE
) $(LIBCOS
) |
$(TEST_DLL_NAME
)
702 ${srcdir}/mkimport
${toolopts} ${NEW_FUNCTIONS} $@ cygdll.a
$(wordlist
2,99,$^
)
704 ${STATIC_LIB_NAME}: mkstatic
${TEST_DLL_NAME}
705 perl
-d
$< -x
${EXCLUDE_STATIC_OFILES} --library
=${LIBC} --library
=${LIBM} --ar=${AR} $@ cygwin.map
707 # Rule to make stub library used by testsuite
708 # dependency set to $(LIB_NAME) to accommodate make -j2.
709 $(TEST_LIB_NAME
): $(LIB_NAME
)
710 perl
-p
-e
'BEGIN{binmode(STDIN); binmode(STDOUT);}; s/cygwin1/cygwin0/g' < $?
> $@
712 $(LIBSERVER
): ${cygserver_blddir}/Makefile
713 $(MAKE
) -C
${cygserver_blddir} libcygserver.a
715 ${cygserver_blddir}/Makefile
:
717 cd
${@D
} && exec
/bin
/sh
$(dir ${srcdir})/cygserver
/configure
${configure_args}
719 dll_ofiles
: $(DLL_OFILES
)
721 $(LIBGMON_A
): $(GMON_OFILES
) $(GMON_START
)
722 $(AR
) rcv
$(LIBGMON_A
) $(GMON_OFILES
)
724 globals.h
: mkglobals_h globals.
cc
727 ${DLL_OFILES} ${LIBCOS}: globals.h
$(srcdir)/$(TLSOFFSETS_H
)
729 shared_info_magic.h
: cygmagic shared_info.h
730 /bin
/sh
$(word 1,$^
) $@
"${COMPILE.cc} -E -x c++" $(word 2,$^
) SHARED_MAGIC
'class shared_info' USER_MAGIC
'class user_info'
732 child_info_magic.h
: cygmagic child_info.h
733 /bin
/sh
$(word 1,$^
) $@
"${COMPILE.cc} -E -x c++" $(word 2,$^
) CHILD_INFO_MAGIC
'class child_info'
735 dcrt0.o sigproc.o
: child_info_magic.h
737 shared.o
: shared_info_magic.h
739 localtime.patched.c
: tzcode
/localtime.c tzcode
/localtime.c.patch
740 patch
-u
-o localtime.patched.c \
741 $(srcdir)/tzcode
/localtime.c \
742 $(srcdir)/tzcode
/localtime.c.patch
744 localtime.o
: tzcode
/localtime_wrapper.c localtime.patched.c
745 $(CC
) ${COMMON_CFLAGS} ${localtime_CFLAGS} \
746 -I
$(target_builddir
)/winsup
/cygwin \
747 -I
$(srcdir) -I
$(srcdir)/tzcode
-c
-o
$@
$<
749 $(srcdir)/devices.
cc: gendevices devices.in devices.h
750 ${wordlist
1,2,$^
} $@
752 ${CURDIR}/libc.a
: ${LIB_NAME} ${CURDIR}/libm.a libpthread.a libutil.a
755 ${CURDIR}/libm.a
: ${LIB_NAME} $(LIBM
) $(MATH_OFILES
)
758 libpthread.a
: ${LIB_NAME} pthread.o thread.o
761 libutil.a
: ${LIB_NAME} bsdlib.o
764 libdl.a
: ${LIB_NAME} dlfcn.o
767 libresolv.a
: ${LIB_NAME} minires.o
770 librt.a
: ${LIB_NAME} posix_ipc.o
773 libacl.a
: ${LIB_NAME} sec_posixacl.o
776 libssp.a
: ${LIB_NAME} $(newlib_build
)/libc
/ssp
/lib.a
779 ${EXTRALIBS}: lib
%.a
: %.o
782 # Every time we touch a source file, the version info has to be rebuilt
783 # to maintain a correct build date, especially in uname release output
784 find_src_files
= $(wildcard $(dir)/*.
[chS
]) $(wildcard $(dir)/*.
cc)
785 src_files
:= $(foreach dir,$(VPATH
),$(find_src_files
))
787 # mkvers.sh creates version.cc in the first place, winver.o always
788 # second, so version.cc is always older than winver.o
789 version.
cc: mkvers.sh
include/cygwin
/version.h winver.rc
$(src_files
)
790 @echo
"Making version.cc and winver.o";\
791 /bin
/sh
${word 1,$^
} ${word 2,$^
} ${word 3,$^
} $(WINDRES
) ${CFLAGS} $(addprefix -I
,${CCWRAP_SYSTEM_HEADERS} ${CCWRAP_DIRAFTER_HEADERS})
792 $(VERSION_OFILES
): version.
cc
794 Makefile
: ${srcdir}/Makefile.in
795 /bin
/sh .
/config.status
797 $(DEF_FILE
): gendef
$(srcdir)/$(TLSOFFSETS_H
) $(DIN_FILE
)
798 $(word 1,$^
) --cpu
=${target_cpu} --output-def
=$@
--tlsoffsets
=$(word 2,$^
) $(wordlist
3,99,$^
)
800 $(srcdir)/$(TLSOFFSETS_H
): gentls_offsets cygtls.h
801 $^
$@
$(target_cpu
) $(COMPILE.
cc) -c ||
rm $@
805 { rm -f
$(DEF_FILE
); $(MAKE
) -s
-j1
$(DEF_FILE
); }; \
806 [ -s
$@
] && touch
$@
808 sigfe.o
: sigfe.s
$(srcdir)/$(TLSOFFSETS_H
)
809 $(CC
) ${CFLAGS} -c
-o
$@
$<
815 ctags
-R
--c
++-kinds
=+p
--fields
=+iaS
--extra
=+q \
816 --regex-C
++='/EXPORT_ALIAS *\([a-zA-Z0-9_]*, *([a-zA-Z0-9_]*)\)/\1/' \
817 --regex-C
++='/__ASMNAME *\("([a-zA-Z0-9_]+)"\)/\1/' \
820 deps
:=${wildcard *.d
}