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