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