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
}
275 TZCODE_OFILES
:=localtime.o
305 fhandler_clipboard.o \
307 fhandler_cygdrive.o \
309 fhandler_disk_file.o \
313 fhandler_netdrive.o \
314 fhandler_nodevice.o \
318 fhandler_process_fd.o \
321 fhandler_procsysvipc.o \
324 fhandler_registry.o \
326 fhandler_signalfd.o \
328 fhandler_socket_inet.o \
329 fhandler_socket_local.o \
330 fhandler_socket_unix.o \
352 libstdcxx_wrapper.o \
427 EXCLUDE_STATIC_OFILES
:=$(addprefix --exclude
=,\
436 VERSION_OFILES
:=version.o winver.o
439 override DLL_OFILES
:=$(patsubst %.o
,%_E
,${DLL_OFILES})
440 override EXCLUDE_STATIC_OFILES
:=$(patsubst %.o
,%_E
,${EXCLUDE_STATIC_OFILES})
441 override EXTRA_OFILES
=$(patsubst %.o
,%_E
,${DLL_OFILES}))
442 override MALLOC_OFILES
:=$(patsubst %.o
,%.E
,${MALLOC_OFILES})
445 ifeq ($(target_cpu
),x86_64
)
446 # Needed by mcountFunc.S to choose the right code path and symbol names
450 GMON_OFILES
:=gmon.o mcount.o profil.o mcountFunc.o
452 NEW_FUNCTIONS
:=$(addprefix --replace
=,\
457 __xdrrec_setnonblock
= \
501 xdrrec_endofrecord
= \
506 ifeq ($(target_cpu
),x86_64
)
509 NEW_FUNCTIONS
+=$(addprefix --replace
=,\
511 aclcheck
=_aclcheck32 \
512 aclfrommode
=_aclfrommode32 \
513 aclfrompbits
=_aclfrompbits32 \
514 aclfromtext
=_aclfromtext32 \
516 acltomode
=_acltomode32 \
517 acltopbits
=_acltopbits32 \
518 acltotext
=_acltotext32 \
531 ftruncate
=_ftruncate64 \
535 getgrent
=_getgrent32 \
536 getgrgid
=_getgrgid32 \
537 getgrnam
=_getgrnam32 \
538 getgroups
=_getgroups32 \
539 getpwuid
=_getpwuid32 \
540 getpwuid_r
=_getpwuid_r32 \
542 initgroups
=_initgroups32 \
552 setgroups
=_setgroups32 \
553 setregid
=_setregid32 \
554 setreuid
=_setreuid32 \
558 truncate
=_truncate64 \
562 API_VER
:=$(srcdir)/include/cygwin
/version.h
564 LIB_NAME
:=libcygwin.a
565 SUBLIBS
:=libpthread.a libutil.a
${CURDIR}/libm.a
${CURDIR}/libc.a libdl.a libresolv.a librt.a libacl.a libssp.a
566 EXTRALIBS
:=libautomode.a libbinmode.a libtextmode.a libtextreadmode.a
567 INSTOBJS
:=automode.o binmode.o textmode.o textreadmode.o
568 TARGET_LIBS
:=$(LIB_NAME
) $(CYGWIN_START
) $(GMON_START
) $(LIBGMON_A
) $(SUBLIBS
) $(INSTOBJS
) $(EXTRALIBS
)
570 ifneq "${filter -O%,$(CFLAGS)}" ""
571 dtable_CFLAGS
:=-fcheck-new
572 localtime_CFLAGS
:=-fwrapv
575 ifeq ($(target_cpu
),i686
)
576 # on x86, exceptions.cc must be compiled with a frame-pointer as it uses RtlCaptureContext()
577 exceptions_CFLAGS
:=-fno-omit-frame-pointer
580 # required since gcc 9.x
581 exec_CFLAGS
:=-fno-builtin-execve
583 fhandler_proc_CFLAGS
+=-DUSERNAME
="\"$(USER)\"" -DHOSTNAME
="\"$(HOSTNAME)\""
584 fhandler_proc_CFLAGS
+=-DGCC_VERSION
="\"`$(CC) -v 2>&1 | tail -n 1`\""
586 .PHONY
: all force dll_ofiles
install all_target install_target all_host \
587 install_host
install install-libs install-headers \
588 clean distclean realclean maintainer-clean
591 install_host
=@install_host@
593 all: all_target
$(all_host
)
595 all_target
: $(TARGET_LIBS
)
597 all_host
: $(TEST_LIB_NAME
)
601 install: install-libs install-headers install-man install-ldif install_target \
602 $(install_host
) $(install_target
)
604 uninstall: uninstall-libs uninstall-headers uninstall-man
606 install-libs
: $(TARGET_LIBS
)
607 @
$(MKDIRP
) $(DESTDIR
)$(bindir) $(DESTDIR
)$(tooldir
)/lib
608 $(INSTALL_PROGRAM
) $(TEST_DLL_NAME
) $(DESTDIR
)$(bindir)/$(DLL_NAME
); \
610 $(INSTALL_DATA
) $$i $(DESTDIR
)$(tooldir
)/lib
/`basename $$i` ; \
612 cd
$(DESTDIR
)$(tooldir
)/lib
&& ln
-sf libcygwin.a libg.a
616 for sub in
`find include -name '[a-z]*' -type d -print | sort`; do \
617 $(MKDIRP
) $(DESTDIR
)$(tooldir
)/$$sub; \
618 for i in
$$sub/*.h
; do \
619 $(INSTALL_DATA
) $$i $(DESTDIR
)$(tooldir
)/$$sub/`basename $$i` ; \
624 @
$(MKDIRP
) $(DESTDIR
)$(mandir)/man2
$(DESTDIR
)$(mandir)/man3
$(DESTDIR
)$(mandir)/man5
$(DESTDIR
)$(mandir)/man7
626 for i in
`find . -type f ! -path './release/*' -name '*.2'`; do \
627 $(INSTALL_DATA
) $$i $(DESTDIR
)$(mandir)/man2
/`basename $$i` ; \
629 for i in
`find . -type f ! -path './release/*' -name '*.3'`; do \
630 $(INSTALL_DATA
) $$i $(DESTDIR
)$(mandir)/man3
/`basename $$i` ; \
632 for i in
`find . -type f ! -path './release/*' -name '*.5'`; do \
633 $(INSTALL_DATA
) $$i $(DESTDIR
)$(mandir)/man5
/`basename $$i` ; \
635 for i in
`find . -type f ! -path './release/*' -name '*.7'`; do \
636 $(INSTALL_DATA
) $$i $(DESTDIR
)$(mandir)/man7
/`basename $$i` ; \
640 @
$(MKDIRP
) $(DESTDIR
)$(datarootdir
)/cygwin
641 $(INSTALL_DATA
) $(srcdir)/cygwin.ldif
$(DESTDIR
)$(datarootdir
)/cygwin
647 uninstall-libs
: $(TARGET_LIBS
)
648 rm -f
$(bindir)/$(DLL_NAME
); \
650 rm -f
$(tooldir
)/lib
/$$i ; \
655 for sub in
`find include -name '[a-z]*' -type d -print | sort`; do \
656 for i in
$$sub/*.h
; do \
657 rm -f
$(tooldir
)/$$sub/`basename $$i` ; \
663 for i in
`find . -type f -name '*.2'`; do \
664 rm -f
$(DESTDIR
)$(mandir)/man2
/`basename $$i` ; \
666 for i in
`find . -type f -name '*.3'`; do \
667 rm -f
$(DESTDIR
)$(mandir)/man3
/`basename $$i` ; \
669 for i in
`find . -type f -name '*.5'`; do \
670 rm -f
$(DESTDIR
)$(mandir)/man5
/`basename $$i` ; \
672 for i in
`find . -type f -name '*.7'`; do \
673 rm -f
$(DESTDIR
)$(mandir)/man7
/`basename $$i` ; \
676 clean distclean realclean:
677 -rm -f
*.o
*.dll
*.dbg
*.a
*.exp junk
*.base version.
cc *.exe
*.d \
678 *stamp
* *_magic.h sigfe.s cygwin.def cygwin.map cygwin.sc \
679 globals.h localtime.patched.c
680 -@
$(MAKE
) -C
${cygserver_blddir} libclean
682 maintainer-clean
: clean
683 @echo
"This command is intended for maintainers to use;"
684 @echo
"it deletes files that may require special tools to rebuild."
686 -rm -f
$(srcdir)/$(TLSOFFSETS_H
) $(srcdir)/devices.
cc
688 # Rule to build LDSCRIPT
689 $(LDSCRIPT
): $(LDSCRIPT
).in
690 $(CC
) -E
- -P
< $^
-o
$@
692 # Rule to build cygwin.dll
693 $(TEST_DLL_NAME
): $(LDSCRIPT
) dllfixdbg
$(DLL_OFILES
) $(LIBSERVER
) $(LIBC
) $(LIBM
) $(API_VER
) Makefile
$(VERSION_OFILES
)
695 -mno-use-libstdc-wrappers
-L
${WINDOWS_LIBDIR} \
696 -Wl
,--gc-sections
$(nostdlib
) -Wl
,-T
$(firstword $^
) -static \
697 -Wl
,--heap
=0 -Wl
,--out-implib
,cygdll.a
-shared
-o
$@ \
698 -e
$(DLL_ENTRY
) $(DEF_FILE
) $(DLL_OFILES
) $(VERSION_OFILES
) \
699 $(MALLOC_OBJ
) $(LIBSERVER
) $(LIBM
) $(LIBC
) \
700 -lgcc
$(DLL_IMPORTS
) -Wl
,-Map
,cygwin.map
701 @
$(word 2,$^
) $(OBJDUMP
) $(OBJCOPY
) $@
${patsubst %0.dll
,%1.dbg
,$@
}
702 @ln
-f
$@ new-
$(DLL_NAME
)
704 # Rule to build libcygwin.a
705 $(LIB_NAME
): $(DEF_FILE
) $(LIBCOS
) |
$(TEST_DLL_NAME
)
706 ${srcdir}/mkimport
${toolopts} ${NEW_FUNCTIONS} $@ cygdll.a
$(wordlist
2,99,$^
)
708 ${STATIC_LIB_NAME}: mkstatic
${TEST_DLL_NAME}
709 perl
-d
$< -x
${EXCLUDE_STATIC_OFILES} --library
=${LIBC} --library
=${LIBM} --ar=${AR} $@ cygwin.map
711 # Rule to make stub library used by testsuite
712 # dependency set to $(LIB_NAME) to accommodate make -j2.
713 $(TEST_LIB_NAME
): $(LIB_NAME
)
714 perl
-p
-e
'BEGIN{binmode(STDIN); binmode(STDOUT);}; s/cygwin1/cygwin0/g' < $?
> $@
716 $(LIBSERVER
): ${cygserver_blddir}/Makefile
717 $(MAKE
) -C
${cygserver_blddir} libcygserver.a
719 ${cygserver_blddir}/Makefile
:
721 cd
${@D
} && exec
/bin
/sh
$(dir ${srcdir})/cygserver
/configure
${configure_args}
723 dll_ofiles
: $(DLL_OFILES
)
725 $(LIBGMON_A
): $(GMON_OFILES
) $(GMON_START
)
726 $(AR
) rcv
$(LIBGMON_A
) $(GMON_OFILES
)
728 globals.h
: mkglobals_h globals.
cc
731 ${DLL_OFILES} ${LIBCOS}: globals.h
$(srcdir)/$(TLSOFFSETS_H
)
733 shared_info_magic.h
: cygmagic shared_info.h
734 /bin
/sh
$(word 1,$^
) $@
"${COMPILE.cc} -E -x c++" $(word 2,$^
) SHARED_MAGIC
'class shared_info' USER_MAGIC
'class user_info'
736 child_info_magic.h
: cygmagic child_info.h
737 /bin
/sh
$(word 1,$^
) $@
"${COMPILE.cc} -E -x c++" $(word 2,$^
) CHILD_INFO_MAGIC
'class child_info'
739 dcrt0.o sigproc.o
: child_info_magic.h
741 shared.o
: shared_info_magic.h
743 localtime.patched.c
: tzcode
/localtime.c tzcode
/localtime.c.patch
744 patch
-u
-o localtime.patched.c \
745 $(srcdir)/tzcode
/localtime.c \
746 $(srcdir)/tzcode
/localtime.c.patch
748 localtime.o
: tzcode
/localtime_wrapper.c localtime.patched.c
749 $(CC
) ${COMMON_CFLAGS} ${localtime_CFLAGS} \
750 -I
$(target_builddir
)/winsup
/cygwin \
751 -I
$(srcdir) -I
$(srcdir)/tzcode
-c
-o
$@
$<
753 $(srcdir)/devices.
cc: gendevices devices.in devices.h
754 ${wordlist
1,2,$^
} $@
756 ${CURDIR}/libc.a
: ${LIB_NAME} ${CURDIR}/libm.a libpthread.a libutil.a
759 ${CURDIR}/libm.a
: ${LIB_NAME} $(LIBM
) $(MATH_OFILES
)
762 libpthread.a
: ${LIB_NAME} pthread.o thread.o call_once.o cnd.o mtx.o \
766 libutil.a
: ${LIB_NAME} bsdlib.o
769 libdl.a
: ${LIB_NAME} dlfcn.o
772 libresolv.a
: ${LIB_NAME} minires.o
775 librt.a
: ${LIB_NAME} posix_ipc.o
778 libacl.a
: ${LIB_NAME} sec_posixacl.o
781 libssp.a
: ${LIB_NAME} $(newlib_build
)/libc
/ssp
/lib.a
784 ${EXTRALIBS}: lib
%.a
: %.o
787 # Every time we touch a source file, the version info has to be rebuilt
788 # to maintain a correct build date, especially in uname release output
789 find_src_files
= $(wildcard $(dir)/*.
[chS
]) $(wildcard $(dir)/*.
cc)
790 src_files
:= $(foreach dir,$(VPATH
),$(find_src_files
))
792 # mkvers.sh creates version.cc in the first place, winver.o always
793 # second, so version.cc is always older than winver.o
794 version.
cc: mkvers.sh
include/cygwin
/version.h winver.rc
$(src_files
)
795 @echo
"Making version.cc and winver.o";\
796 /bin
/sh
${word 1,$^
} ${word 2,$^
} ${word 3,$^
} $(WINDRES
) ${CFLAGS} $(addprefix -I
,${CCWRAP_SYSTEM_HEADERS} ${CCWRAP_DIRAFTER_HEADERS})
797 $(VERSION_OFILES
): version.
cc
799 Makefile
: ${srcdir}/Makefile.in
800 /bin
/sh .
/config.status
802 $(DEF_FILE
): gendef
$(srcdir)/$(TLSOFFSETS_H
) $(DIN_FILE
)
803 $(word 1,$^
) --cpu
=${target_cpu} --output-def
=$@
--tlsoffsets
=$(word 2,$^
) $(wordlist
3,99,$^
)
805 $(srcdir)/$(TLSOFFSETS_H
): gentls_offsets cygtls.h
806 $^
$@
$(target_cpu
) $(COMPILE.
cc) -c ||
rm $@
810 { rm -f
$(DEF_FILE
); $(MAKE
) -s
-j1
$(DEF_FILE
); }; \
811 [ -s
$@
] && touch
$@
813 sigfe.o
: sigfe.s
$(srcdir)/$(TLSOFFSETS_H
)
814 $(CC
) ${CFLAGS} -c
-o
$@
$<
820 ctags
-R
--c
++-kinds
=+p
--fields
=+iaS
--extra
=+q \
821 --regex-C
++='/EXPORT_ALIAS *\([a-zA-Z0-9_]*, *([a-zA-Z0-9_]*)\)/\1/' \
822 --regex-C
++='/__ASMNAME *\("([a-zA-Z0-9_]+)"\)/\1/' \
825 deps
:=${wildcard *.d
}