]>
Commit | Line | Data |
---|---|---|
1fd5e000 | 1 | # Makefile for Cygwin utilities |
1fd5e000 CF |
2 | |
3 | # This file is part of Cygwin. | |
4 | ||
5 | # This software is a copyrighted work licensed under the terms of the | |
6 | # Cygwin license. Please consult the file "CYGWIN_LICENSE" for | |
7 | # details. | |
8 | ||
1fd5e000 | 9 | srcdir:=@srcdir@ |
4c36016b CF |
10 | target_builddir:=@target_builddir@ |
11 | winsup_srcdir:=@winsup_srcdir@ | |
12 | configure_args=@configure_args@ | |
13 | ||
acfed136 | 14 | CFLAGS_COMMON=-Wimplicit-fallthrough=4 -Werror |
29413f06 CF |
15 | CFLAGS:=@CFLAGS@ |
16 | CXXFLAGS:=@CXXFLAGS@ | |
b55e3f19 | 17 | INCLUDES:=@INCLUDES@ |
acfed136 CV |
18 | override CFLAGS+=${CFLAGS_COMMON} |
19 | override CXXFLAGS+=-fno-exceptions -fno-rtti ${CFLAGS_COMMON} | |
29413f06 | 20 | |
4c36016b CF |
21 | include ${srcdir}/../Makefile.common |
22 | ||
23 | cygwin_build:=${target_builddir}/winsup/cygwin | |
24 | ||
4c36016b CF |
25 | WINDOWS_LIBDIR:=@windows_libdir@ |
26 | ||
1fd5e000 CF |
27 | prefix:=@prefix@ |
28 | exec_prefix:=@exec_prefix@ | |
29 | ||
30 | bindir:=@bindir@ | |
1fd5e000 | 31 | |
9ddd929f CF |
32 | override INSTALL:=@INSTALL@ |
33 | override INSTALL_PROGRAM:=@INSTALL_PROGRAM@ | |
34 | override INSTALL_DATA:=@INSTALL_DATA@ | |
1fd5e000 CF |
35 | |
36 | EXEEXT:=@EXEEXT@ | |
37 | EXEEXT_FOR_BUILD:=@EXEEXT_FOR_BUILD@ | |
38 | ||
68d2dd03 BD |
39 | .PHONY: all install clean realclean warn_dumper warn_cygcheck_zlib |
40 | ||
29413f06 | 41 | LDLIBS := -lnetapi32 -ladvapi32 -lkernel32 -luser32 |
7e38f161 | 42 | CYGWIN_LDFLAGS := -static -Wl,--enable-auto-import -L${WINDOWS_LIBDIR} $(LDLIBS) |
4c36016b | 43 | DEP_LDLIBS := $(cygwin_build)/libcygwin.a |
68d2dd03 | 44 | |
4c36016b | 45 | MINGW_CXX := @MINGW_CXX@ |
68d2dd03 BD |
46 | |
47 | # List all binaries to be linked in Cygwin mode. Each binary on this list | |
48 | # must have a corresponding .o of the same name. | |
0d4b39d3 | 49 | CYGWIN_BINS := ${addsuffix .exe,chattr cygpath gencat getconf getfacl ldd locale lsattr kill minidumper mkgroup \ |
e2bf82d3 | 50 | mkpasswd mount passwd pldd ps regtool setfacl setmetamode ssp tzset umount} |
68d2dd03 BD |
51 | |
52 | # List all binaries to be linked in MinGW mode. Each binary on this list | |
53 | # must have a corresponding .o of the same name. | |
cea37699 | 54 | MINGW_BINS := ${addsuffix .exe,cygcheck cygwin-console-helper ldh strace} |
68d2dd03 BD |
55 | |
56 | # List all objects to be compiled in MinGW mode. Any object not on this | |
57 | # list will will be compiled in Cygwin mode implicitly, so there is no | |
58 | # need for a CYGWIN_OBJS. | |
f96f7bec | 59 | MINGW_OBJS := bloda.o cygcheck.o cygwin-console-helper.o dump_setup.o ldh.o path.o strace.o |
7df2c73d | 60 | MINGW_LDFLAGS:=-static |
4c36016b CF |
61 | |
62 | CYGCHECK_OBJS:=cygcheck.o bloda.o path.o dump_setup.o | |
7e38f161 | 63 | ZLIB:=-lz |
4c36016b CF |
64 | |
65 | .PHONY: all | |
66 | all: | |
68d2dd03 BD |
67 | |
68 | # If a binary should link in any objects besides the .o with the same | |
69 | # name as the binary, then list those here. | |
70 | strace.exe: path.o | |
4c36016b | 71 | cygcheck.exe: cygcheck.o bloda.o path.o dump_setup.o |
68d2dd03 | 72 | |
1e497ebd | 73 | path-mount.o: path.cc |
4c36016b | 74 | ${COMPILE.cc} -c -DFSTAB_ONLY -o $@ $< |
1e497ebd CV |
75 | mount.exe: path-mount.o |
76 | ||
4c2380d3 CV |
77 | .PHONY: tzmap |
78 | tzmap: | |
79 | ${srcdir}/tzmap-from-unicode.org > ${srcdir}/$@.h | |
80 | ||
81 | tzmap.h: | |
82 | [ -f "${srcdir}/tzmap.h" ] || ${srcdir}/tzmap-from-unicode.org > ${srcdir}/$@ | |
83 | ||
84 | tzset.o: tzmap.h | |
85 | ||
68d2dd03 | 86 | # Provide any necessary per-target variable overrides. |
4c36016b | 87 | |
700a3783 | 88 | cygcheck.exe: MINGW_LDFLAGS += ${ZLIB} -lwininet -lpsapi -lntdll |
4c36016b CF |
89 | cygcheck.exe: ${CYGCHECK_OBJS} |
90 | ||
91 | cygpath.o: CXXFLAGS += -fno-threadsafe-statics | |
649619b5 CV |
92 | cygpath.exe: CYGWIN_LDFLAGS += -lcygwin -luserenv -lntdll |
93 | ps.exe: CYGWIN_LDFLAGS += -lcygwin -lpsapi -lntdll | |
02a7f96e | 94 | strace.exe: MINGW_LDFLAGS += -lntdll |
68d2dd03 | 95 | |
e3ca53d9 | 96 | ldd.exe:CYGWIN_LDFLAGS += -lpsapi -lntdll |
4c36016b | 97 | pldd.exe: CYGWIN_LDFLAGS += -lpsapi |
8f8e7757 | 98 | minidumper.exe: CYGWIN_LDFLAGS += -ldbghelp |
086dc27f | 99 | |
4c36016b | 100 | ldh.exe: MINGW_LDFLAGS += -nostdlib -lkernel32 |
2e13058e | 101 | |
68d2dd03 | 102 | # Check for dumper's requirements and enable it if found. |
4c36016b CF |
103 | libbfd := $(call libname,libbfd.a) |
104 | build_dumper := $(shell test -r "$(libbfd)" && echo 1) | |
105 | ||
68d2dd03 BD |
106 | ifdef build_dumper |
107 | CYGWIN_BINS += dumper.exe | |
0302c691 JT |
108 | dumper.o module_info.o: CXXFLAGS += -I$(top_srcdir)/include |
109 | dumper.o: dumper.h | |
110 | dumper.exe: module_info.o | |
b245014a | 111 | dumper.exe: CYGWIN_LDFLAGS += -lpsapi -lbfd -lintl -liconv -liberty ${ZLIB} -lntdll |
2fac517d | 112 | else |
68d2dd03 | 113 | all: warn_dumper |
2fac517d CF |
114 | endif |
115 | ||
68d2dd03 | 116 | all: Makefile $(CYGWIN_BINS) $(MINGW_BINS) |
0ad10c0f | 117 | |
59fb00ae BD |
118 | # test harness support (note: the "MINGW_BINS +=" should come after the |
119 | # "all:" above so that the testsuite is not run for "make" but only | |
120 | # "make check".) | |
121 | MINGW_BINS += testsuite.exe | |
122 | MINGW_OBJS += path-testsuite.o testsuite.o | |
123 | testsuite.exe: path-testsuite.o | |
124 | path-testsuite.cc: path.cc ; @test -L $@ || ln -sf ${filter %.cc,$^} $@ | |
125 | path-testsuite.o: MINGW_CXXFLAGS += -DTESTSUITE | |
126 | # this is necessary because this .c lives in the build dir instead of src | |
127 | path-testsuite.o: MINGW_CXX := ${patsubst -I.,-I$(utils_source),$(MINGW_CXX)} | |
128 | path-testsuite.cc path.cc testsuite.cc: testsuite.h | |
129 | check: testsuite.exe ; $(<D)/$(<F) | |
130 | ||
131 | # the rest of this file contains generic rules | |
132 | ||
68d2dd03 BD |
133 | # how to compile a MinGW object |
134 | $(MINGW_OBJS): %.o: %.cc | |
5601d536 | 135 | ${MINGW_CXX} -c -o $@ ${CXXFLAGS} $(MINGW_CXXFLAGS) $< |
d0d51791 | 136 | |
68d2dd03 BD |
137 | # how to link a MinGW binary |
138 | $(MINGW_BINS): %.exe: %.o | |
5b31f27f | 139 | $(MINGW_CXX) $(MINGW_CXXFLAGS) -o $@ ${filter %.o,$^} $(MINGW_LDFLAGS) |
64b94981 | 140 | |
68d2dd03 | 141 | # how to link a Cygwin binary |
9401a0f8 | 142 | $(CYGWIN_BINS): %.exe: %.o |
4c36016b | 143 | ${CXX} -o $@ $(filter %.o,$^) -B${cygwin_build}/ ${LDFLAGS} ${CYGWIN_LDFLAGS} |
ad466e2f | 144 | |
68d2dd03 | 145 | # note: how to compile a Cygwin object is covered by the pattern rule in Makefile.common |
ad466e2f | 146 | |
68d2dd03 | 147 | # these dependencies ensure that the required in-tree libs are built first |
4c36016b CF |
148 | $(MINGW_BINS): $(DEP_LDLIBS) |
149 | $(CYGWIN_BINS): $(DEP_LDLIBS) | |
c49fa762 | 150 | |
29413f06 CF |
151 | cygcheck.o cygpath.o module_info.o path.o ps.o regtool.o strace.o: loadlib.h |
152 | ||
4c36016b | 153 | .PHONY: clean |
1fd5e000 | 154 | clean: |
59fb00ae | 155 | rm -f *.o $(CYGWIN_BINS) $(MINGW_BINS) path-testsuite.cc testsuite.exe |
1fd5e000 | 156 | |
4c36016b | 157 | .PHONY: realclean |
1fd5e000 | 158 | realclean: clean |
68d2dd03 | 159 | rm -f Makefile config.cache |
1fd5e000 | 160 | |
4c36016b | 161 | .PHONY: install |
1fd5e000 | 162 | install: all |
4c36016b | 163 | /bin/mkdir -p ${DESTDIR}${bindir} |
92108f4e | 164 | for i in $(CYGWIN_BINS) ${filter-out testsuite.exe,$(MINGW_BINS)} ; do \ |
177d1568 | 165 | $(INSTALL_PROGRAM) $$i $(DESTDIR)$(bindir)/$$i; \ |
1fd5e000 CF |
166 | done |
167 | ||
168 | $(cygwin_build)/libcygwin.a: $(cygwin_build)/Makefile | |
169 | @$(MAKE) -C $(@D) $(@F) | |
170 | ||
4c36016b | 171 | .PHONY: warn_dumper |
0715614b | 172 | warn_dumper: |
8f8977bb CF |
173 | @echo '*** Not building dumper.exe since some required libraries or' |
174 | @echo '*** or headers are missing. Potential candidates are:' | |
175 | @echo '*** bfd.h, libbfd.a, libiconv.a, or libintl.a' | |
10e1fce6 | 176 | @echo '*** If you need this program, check out the naked-bfd and naked-intl' |
e3e942ac | 177 | @echo '*** sources from sourceware.org. Then, configure and build these' |
10e1fce6 | 178 | @echo '*** libraries. Otherwise, you can safely ignore this warning.' |
0715614b | 179 | |
4c36016b CF |
180 | Makefile: Makefile.in config.status |
181 | /bin/sh ./config.status |