]>
Commit | Line | Data |
---|---|---|
1fd5e000 | 1 | # Makefile for Cygwin utilities |
4d7c0b51 | 2 | # Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, |
be822de2 | 3 | # 2005, 2006, 2007, 2008, 2009, 2010 Red Hat, Inc. |
1fd5e000 CF |
4 | |
5 | # This file is part of Cygwin. | |
6 | ||
7 | # This software is a copyrighted work licensed under the terms of the | |
8 | # Cygwin license. Please consult the file "CYGWIN_LICENSE" for | |
9 | # details. | |
10 | ||
1fd5e000 | 11 | srcdir:=@srcdir@ |
4c36016b CF |
12 | target_builddir:=@target_builddir@ |
13 | winsup_srcdir:=@winsup_srcdir@ | |
14 | configure_args=@configure_args@ | |
15 | ||
16 | export CC:=@CC@ | |
17 | export CXX:=@CXX@ | |
18 | ||
19 | include ${srcdir}/../Makefile.common | |
20 | ||
21 | cygwin_build:=${target_builddir}/winsup/cygwin | |
22 | ||
23 | cygwin_headers:=@cygwin_headers@ | |
24 | ||
25 | # environment variables used by ccwrap | |
26 | export CCWRAP_HEADERS:=. ${srcdir} $(call justdir,${cygwin_headers}) | |
27 | export CCWRAP_SYSTEM_HEADERS:=${cygwin_headers} @newlib_headers@ | |
28 | export CCWRAP_DIRAFTER_HEADERS:=@windows_headers@ | |
29 | ||
30 | WINDOWS_LIBDIR:=@windows_libdir@ | |
31 | ||
1fd5e000 CF |
32 | prefix:=@prefix@ |
33 | exec_prefix:=@exec_prefix@ | |
34 | ||
35 | bindir:=@bindir@ | |
1fd5e000 CF |
36 | program_transform_name:=@program_transform_name@ |
37 | ||
9ddd929f CF |
38 | override INSTALL:=@INSTALL@ |
39 | override INSTALL_PROGRAM:=@INSTALL_PROGRAM@ | |
40 | override INSTALL_DATA:=@INSTALL_DATA@ | |
1fd5e000 CF |
41 | |
42 | EXEEXT:=@EXEEXT@ | |
43 | EXEEXT_FOR_BUILD:=@EXEEXT_FOR_BUILD@ | |
44 | ||
1fd5e000 | 45 | CFLAGS:=@CFLAGS@ |
2c2473bc | 46 | CXXFLAGS:=@CXXFLAGS@ |
67763c0c | 47 | override CXXFLAGS+=-fno-exceptions -fno-rtti -DHAVE_DECL_GETOPT=0 |
1fd5e000 | 48 | |
68d2dd03 BD |
49 | .PHONY: all install clean realclean warn_dumper warn_cygcheck_zlib |
50 | ||
4c36016b CF |
51 | LDLIBS := -lnetapi32 -ladvapi32 -lkernel32 -luser32 |
52 | CYGWIN_LDFLAGS := -static-libgcc -Wl,--enable-auto-import -L${WINDOWS_LIBDIR} $(LDLIBS) | |
53 | DEP_LDLIBS := $(cygwin_build)/libcygwin.a | |
68d2dd03 | 54 | |
4c36016b | 55 | MINGW_CXX := @MINGW_CXX@ |
68d2dd03 BD |
56 | |
57 | # List all binaries to be linked in Cygwin mode. Each binary on this list | |
58 | # must have a corresponding .o of the same name. | |
c769bdf5 | 59 | CYGWIN_BINS := ${addsuffix .exe,cygpath getconf getfacl ldd locale kill mkgroup \ |
e2bf82d3 | 60 | mkpasswd mount passwd pldd ps regtool setfacl setmetamode ssp tzset umount} |
68d2dd03 BD |
61 | |
62 | # List all binaries to be linked in MinGW mode. Each binary on this list | |
63 | # must have a corresponding .o of the same name. | |
cea37699 | 64 | MINGW_BINS := ${addsuffix .exe,cygcheck cygwin-console-helper ldh strace} |
68d2dd03 BD |
65 | |
66 | # List all objects to be compiled in MinGW mode. Any object not on this | |
67 | # list will will be compiled in Cygwin mode implicitly, so there is no | |
68 | # need for a CYGWIN_OBJS. | |
2e13058e | 69 | MINGW_OBJS := bloda.o cygcheck.o dump_setup.o ldh.o path.o strace.o |
66444a6b | 70 | MINGW_LDFLAGS:=-L${WINDOWS_LIBDIR} -static-libgcc |
4c36016b CF |
71 | |
72 | CYGCHECK_OBJS:=cygcheck.o bloda.o path.o dump_setup.o | |
66444a6b | 73 | ZLIB:=-Wl,-dn,-lz,-dy |
4c36016b CF |
74 | |
75 | .PHONY: all | |
76 | all: | |
68d2dd03 BD |
77 | |
78 | # If a binary should link in any objects besides the .o with the same | |
79 | # name as the binary, then list those here. | |
80 | strace.exe: path.o | |
4c36016b | 81 | cygcheck.exe: cygcheck.o bloda.o path.o dump_setup.o |
68d2dd03 | 82 | |
1e497ebd | 83 | path-mount.o: path.cc |
4c36016b | 84 | ${COMPILE.cc} -c -DFSTAB_ONLY -o $@ $< |
1e497ebd CV |
85 | mount.exe: path-mount.o |
86 | ||
68d2dd03 | 87 | # Provide any necessary per-target variable overrides. |
4c36016b | 88 | |
66444a6b | 89 | cygcheck.exe: MINGW_LDFLAGS += ${ZLIB} -lpsapi -lntdll |
4c36016b CF |
90 | cygcheck.exe: ${CYGCHECK_OBJS} |
91 | ||
92 | cygpath.o: CXXFLAGS += -fno-threadsafe-statics | |
93 | cygpath.exe: CYGWIN_LDFLAGS += -luserenv -lntdll | |
94 | ps.exe: CYGWIN_LDFLAGS += -lpsapi -lntdll | |
02a7f96e | 95 | strace.exe: MINGW_LDFLAGS += -lntdll |
68d2dd03 | 96 | |
4c36016b CF |
97 | ldd.exe:CYGWIN_LDFLAGS += -lpsapi |
98 | pldd.exe: CYGWIN_LDFLAGS += -lpsapi | |
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 | |
4c36016b | 108 | dumper.o module_info.o parse_pe.o: CXXFLAGS += -I$(top_srcdir)/include |
68d2dd03 BD |
109 | dumper.o parse_pe.o: dumper.h |
110 | dumper.exe: module_info.o parse_pe.o | |
66444a6b | 111 | dumper.exe: CYGWIN_LDFLAGS += -lbfd -lintl -liconv -liberty ${ZLIB} |
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 | 133 | # how to compile a MinGW object |
4c36016b CF |
134 | ${MINGW_OBJS}: override CXX:=${MINGW_CXX} |
135 | ${MINGW_OBJS}: CCWRAP_HEADERS:=${srcdir} | |
136 | ${MINGW_OBJS}: CCWRAP_SYSTEM_HEADERS:= | |
137 | # ${MINGW_OBJS}: CCWRAP_DIRAFTER_HEADERS:= | |
68d2dd03 | 138 | $(MINGW_OBJS): %.o: %.cc |
4c36016b | 139 | c++wrap -c -o $@ ${CXXFLAGS} $(MINGW_CXXFLAGS) $< |
d0d51791 | 140 | |
68d2dd03 BD |
141 | # how to link a MinGW binary |
142 | $(MINGW_BINS): %.exe: %.o | |
5b31f27f | 143 | $(MINGW_CXX) $(MINGW_CXXFLAGS) -o $@ ${filter %.o,$^} $(MINGW_LDFLAGS) |
64b94981 | 144 | |
68d2dd03 | 145 | # how to link a Cygwin binary |
9401a0f8 | 146 | $(CYGWIN_BINS): %.exe: %.o |
4c36016b | 147 | ${CXX} -o $@ $(filter %.o,$^) -B${cygwin_build}/ ${LDFLAGS} ${CYGWIN_LDFLAGS} |
ad466e2f | 148 | |
68d2dd03 | 149 | # note: how to compile a Cygwin object is covered by the pattern rule in Makefile.common |
ad466e2f | 150 | |
68d2dd03 | 151 | # these dependencies ensure that the required in-tree libs are built first |
4c36016b CF |
152 | $(MINGW_BINS): $(DEP_LDLIBS) |
153 | $(CYGWIN_BINS): $(DEP_LDLIBS) | |
c49fa762 | 154 | |
4c36016b | 155 | .PHONY: clean |
1fd5e000 | 156 | clean: |
59fb00ae | 157 | rm -f *.o $(CYGWIN_BINS) $(MINGW_BINS) path-testsuite.cc testsuite.exe |
1fd5e000 | 158 | |
4c36016b | 159 | .PHONY: realclean |
1fd5e000 | 160 | realclean: clean |
68d2dd03 | 161 | rm -f Makefile config.cache |
1fd5e000 | 162 | |
4c36016b | 163 | .PHONY: install |
1fd5e000 | 164 | install: all |
4c36016b | 165 | /bin/mkdir -p ${DESTDIR}${bindir} |
92108f4e | 166 | for i in $(CYGWIN_BINS) ${filter-out testsuite.exe,$(MINGW_BINS)} ; do \ |
1fd5e000 | 167 | n=`echo $$i | sed '$(program_transform_name)'`; \ |
99fe2b78 | 168 | $(INSTALL_PROGRAM) $$i $(DESTDIR)$(bindir)/$$n; \ |
1fd5e000 CF |
169 | done |
170 | ||
171 | $(cygwin_build)/libcygwin.a: $(cygwin_build)/Makefile | |
172 | @$(MAKE) -C $(@D) $(@F) | |
173 | ||
4c36016b | 174 | .PHONY: warn_dumper |
0715614b | 175 | warn_dumper: |
8f8977bb CF |
176 | @echo '*** Not building dumper.exe since some required libraries or' |
177 | @echo '*** or headers are missing. Potential candidates are:' | |
178 | @echo '*** bfd.h, libbfd.a, libiconv.a, or libintl.a' | |
10e1fce6 | 179 | @echo '*** If you need this program, check out the naked-bfd and naked-intl' |
e3e942ac | 180 | @echo '*** sources from sourceware.org. Then, configure and build these' |
10e1fce6 | 181 | @echo '*** libraries. Otherwise, you can safely ignore this warning.' |
0715614b | 182 | |
4c36016b CF |
183 | Makefile: Makefile.in config.status |
184 | /bin/sh ./config.status |