| 1 |
# Generic configuration for Hurd compilation -*- makefile-gmake -*- |
| 2 |
|
| 3 |
# Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2003, |
| 4 |
# 2006, 2007, 2008, 2010, 2011, 2012, 2013 Free Software Foundation, Inc. |
| 5 |
# |
| 6 |
# This program is free software; you can redistribute it and/or |
| 7 |
# modify it under the terms of the GNU General Public License as |
| 8 |
# published by the Free Software Foundation; either version 2, or (at |
| 9 |
# your option) any later version. |
| 10 |
# |
| 11 |
# This program is distributed in the hope that it will be useful, but |
| 12 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 |
# General Public License for more details. |
| 15 |
# |
| 16 |
# You should have received a copy of the GNU General Public License |
| 17 |
# along with this program; if not, write to the Free Software |
| 18 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 19 |
|
| 20 |
# Directory makefiles should set the variable makemode to either |
| 21 |
# `server' if they compile and install a single program for /hurd |
| 22 |
# `utility' if they compile and install a single program for /bin |
| 23 |
# `servers' if they compile and install multiple programs for /hurd |
| 24 |
# `utilities' if they compile and install multiple programs for /bin |
| 25 |
# `library' if they compile and install a library |
| 26 |
# `misc' if they do none of those |
| 27 |
|
| 28 |
# Every makefile should define |
| 29 |
# SRCS (all actual source code) |
| 30 |
# OBJS (all .o files used to produce some target). |
| 31 |
# HURDLIBS (all Hurd libraries used; with no directory name or `lib' attached) |
| 32 |
# For types `server' and `utility' an automatic dependency will be |
| 33 |
# written for these, and type `library' will include a .so dependency. |
| 34 |
# Types `servers' and `utilities'; you have to do it yourself. |
| 35 |
# DISTFILES (any built files to be included in distributions). |
| 36 |
|
| 37 |
# Types `server' and `utility' should define |
| 38 |
# target (the name of the program built) |
| 39 |
|
| 40 |
# Types `servers' and `utilities' should define |
| 41 |
# targets (the names of all the programs built) |
| 42 |
# special-targets (targets which should not be built the normal way |
| 43 |
# and have their own rules) |
| 44 |
|
| 45 |
# Type `library' should define |
| 46 |
# libname (the name of the library, without .a.) |
| 47 |
# installhdrs (header files that should be installed in /include) |
| 48 |
# installhdrsubdir (the subdirectory they should go in, default `hurd') |
| 49 |
# and must not define $(targets). |
| 50 |
|
| 51 |
# Put this first so it's the default |
| 52 |
all: |
| 53 |
|
| 54 |
# Figure out how to locate the parent directory from here. |
| 55 |
ifeq (.,$(dir)) |
| 56 |
.. = |
| 57 |
else |
| 58 |
.. = ../ |
| 59 |
endif |
| 60 |
|
| 61 |
ifndef srcdir |
| 62 |
# We are building in the source directory itself. |
| 63 |
srcdir = . |
| 64 |
ifeq (.,$(dir)) |
| 65 |
top_srcdir = . |
| 66 |
else |
| 67 |
top_srcdir = .. |
| 68 |
endif |
| 69 |
endif |
| 70 |
|
| 71 |
# Generic compiler options, appended to whatever the particular makefile set. |
| 72 |
# The config.make file will append the values chosed by configure. |
| 73 |
INCLUDES = -I. $(srcdirinc) |
| 74 |
ifneq (.,$(dir)) |
| 75 |
INCLUDES += -I.. $(top_srcdirinc) |
| 76 |
endif |
| 77 |
INCLUDES += -I$(..)include -I$(top_srcdir)/include |
| 78 |
CPPFLAGS += $(INCLUDES) \ |
| 79 |
-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 \ |
| 80 |
$($*-CPPFLAGS) |
| 81 |
CFLAGS += -std=gnu99 $(gnu89-inline-CFLAGS) -Wall -Werror=old-style-definition \ |
| 82 |
-Werror=implicit-function-declaration -Werror=strict-prototypes \ |
| 83 |
-g -O3 -fno-strict-aliasing $($*-CFLAGS) |
| 84 |
|
| 85 |
# Include the configure-generated file of parameters. |
| 86 |
# This sets up variables for build tools and installation directories. |
| 87 |
ifneq (,$(wildcard $(..)config.make)) |
| 88 |
include $(..)config.make |
| 89 |
# Set a flag for the makefiles to indicated config.make was included. |
| 90 |
configured = yes |
| 91 |
endif |
| 92 |
|
| 93 |
# If we're not configured, don't do deps; then `make TAGS' and such can work. |
| 94 |
ifndef configured |
| 95 |
no_deps = t |
| 96 |
endif |
| 97 |
|
| 98 |
# Test build options set by configure. |
| 99 |
ifeq (no,$(build-profiled)) |
| 100 |
no_prof = t |
| 101 |
endif |
| 102 |
|
| 103 |
|
| 104 |
# Flags for compilation. |
| 105 |
# It is important to have this inclusion first; that picks up our |
| 106 |
# library header files locally rather than from installed copies. |
| 107 |
# Append to any value set by the specific Makefile or by configure. |
| 108 |
ifeq ($(srcdir),.) |
| 109 |
srcdirinc= |
| 110 |
else |
| 111 |
srcdirinc=-I$(srcdir) |
| 112 |
endif |
| 113 |
ifeq ($(top_srcdir),..) |
| 114 |
top_srcdirinc= |
| 115 |
else |
| 116 |
top_srcdirinc=-I$(top_srcdir) |
| 117 |
endif |
| 118 |
|
| 119 |
# More useful version of HURDLIBS |
| 120 |
library_deps=$(foreach lib,$(HURDLIBS),$(..)lib$(lib)/lib$(lib).so) |
| 121 |
|
| 122 |
# Local programs: |
| 123 |
MKINSTALLDIRS = $(top_srcdir)/mkinstalldirs |
| 124 |
move-if-change = $(SHELL) $(top_srcdir)/move-if-change |
| 125 |
|
| 126 |
# Decode makemode. |
| 127 |
# After this section, $(targets) and $(progtarg) will be defined, |
| 128 |
# and everything else should use only those and not $(target). |
| 129 |
# targets will have all the (one or more) targets that should be installed; |
| 130 |
# progtarg will have all the (one or more) programs that should be linked; |
| 131 |
# linktarg will have the complete set of linked targets, including both |
| 132 |
# .static versions of $(progtarg) and/or shared library object targets. |
| 133 |
|
| 134 |
ifeq ($(makemode),server) |
| 135 |
doinst := one |
| 136 |
makemode-instdir := hurd |
| 137 |
clean := yes |
| 138 |
targets = $(target) |
| 139 |
progtarg = $(targets) |
| 140 |
endif |
| 141 |
|
| 142 |
ifeq ($(makemode),utility) |
| 143 |
doinst := one |
| 144 |
makemode-instdir := bin |
| 145 |
clean := yes |
| 146 |
targets = $(target) |
| 147 |
endif |
| 148 |
|
| 149 |
ifeq ($(makemode),servers) |
| 150 |
doinst := many |
| 151 |
makemode-instdir := hurd |
| 152 |
clean := yes |
| 153 |
progtarg := $(targets) |
| 154 |
endif |
| 155 |
|
| 156 |
ifeq ($(makemode),utilities) |
| 157 |
doinst := many |
| 158 |
makemode-instdir := bin |
| 159 |
clean := yes |
| 160 |
progtarg := $(targets) |
| 161 |
endif |
| 162 |
|
| 163 |
ifeq ($(makemode),library) |
| 164 |
|
| 165 |
linktarg := $(libname).so.$(hurd-version) |
| 166 |
|
| 167 |
clean := yes |
| 168 |
cleantarg := $(linktarg) $(addprefix $(libname),.a _p.a _pic.a \ |
| 169 |
.so .so.$(hurd-version)) |
| 170 |
|
| 171 |
targets := $(libname).a $(libname).so |
| 172 |
ifneq ($(no_pic),t) |
| 173 |
targets += $(libname)_pic.a |
| 174 |
endif |
| 175 |
ifneq ($(no_prof),t) |
| 176 |
targets += $(libname)_p.a |
| 177 |
endif |
| 178 |
|
| 179 |
ifndef installhdrsubdir |
| 180 |
installhdrsubdir = hurd |
| 181 |
endif |
| 182 |
|
| 183 |
else |
| 184 |
|
| 185 |
ifeq ($(makemode),misc) |
| 186 |
ifndef doinst |
| 187 |
doinst := many |
| 188 |
endif |
| 189 |
ifeq ($(doinst),one) |
| 190 |
targets = $(target) |
| 191 |
endif |
| 192 |
ifeq (,$(installationdir)) |
| 193 |
ifneq (,$(targets)) |
| 194 |
?Error subdir Makefile must define installationdir |
| 195 |
else |
| 196 |
makemode-instdir := NOINSTALL |
| 197 |
endif |
| 198 |
endif |
| 199 |
else # server/utility modes |
| 200 |
progtarg := $(filter-out $(special-targets),$(targets)) |
| 201 |
linktarg := $(progtarg) $(progtarg:=.static) |
| 202 |
endif |
| 203 |
|
| 204 |
endif |
| 205 |
|
| 206 |
ifndef installationdir |
| 207 |
installationdir := $($(makemode-instdir)dir) |
| 208 |
endif |
| 209 |
|
| 210 |
ifeq ($(cleantarg),) |
| 211 |
cleantarg := $(linktarg) |
| 212 |
endif |
| 213 |
|
| 214 |
|
| 215 |
# This is a hack to give all hurd utilities a default bug-reporting |
| 216 |
# address (defined in libhurdbugaddr/bugaddr.c). |
| 217 |
BUGADDR = $(..)libhurdbugaddr/libhurdbugaddr.a |
| 218 |
BUGADDR_REF = -uargp_program_bug_address |
| 219 |
|
| 220 |
# Standard targets |
| 221 |
|
| 222 |
.PHONY: all install libs relink dist-hook clean objs |
| 223 |
|
| 224 |
# Just build all the object files. |
| 225 |
objs: $(OBJS) |
| 226 |
ifneq ($(no_prof),t) |
| 227 |
objs: $(OBJS:%.o=%_p.o) |
| 228 |
endif |
| 229 |
ifeq ($(makemode),library) |
| 230 |
ifneq ($(no_pic),t) |
| 231 |
objs: $(OBJS:%.o=%_pic.o) |
| 232 |
endif |
| 233 |
endif |
| 234 |
|
| 235 |
# Installation |
| 236 |
ifneq ($(makemode),library) |
| 237 |
|
| 238 |
# not library |
| 239 |
installable := $(sort $(linktarg) $(targets)) |
| 240 |
install-targets := $(targets) $(filter $(build-static:=.static),$(linktarg)) |
| 241 |
all: $(install-targets) |
| 242 |
install: $(DESTDIR)$(installationdir) $(addprefix $(DESTDIR)$(installationdir)/,$(install-targets)) |
| 243 |
$(DESTDIR)$(installationdir): |
| 244 |
@$(MKINSTALLDIRS) $@ |
| 245 |
$(addprefix $(DESTDIR)$(installationdir)/,$(installable)): $(DESTDIR)$(installationdir)/%: % |
| 246 |
$(INSTALL_PROGRAM) $(INSTALL-$<-ops) $< $@ |
| 247 |
else |
| 248 |
|
| 249 |
# library (several parts, library itself, headers, etc.) |
| 250 |
|
| 251 |
all: libs |
| 252 |
install libs: add-to-librecord |
| 253 |
add-to-librecord: $(targets) |
| 254 |
install: $(DESTDIR)$(libdir) $(DESTDIR)$(includedir)/$(installhdrsubdir) $(DESTDIR)$(libdir)/$(libname).so.$(hurd-version) $(addprefix $(DESTDIR)$(libdir)/,$(targets)) $(addprefix $(DESTDIR)$(includedir)/$(installhdrsubdir)/,$(installhdrs)) |
| 255 |
|
| 256 |
install-headers: $(DESTDIR)$(includedir)/$(installhdrsubdir) $(addprefix $(DESTDIR)$(includedir)/$(installhdrsubdir)/,$(installhdrs)) |
| 257 |
|
| 258 |
$(DESTDIR)$(includedir)/$(installhdrsubdir): $(DESTDIR)$(includedir) |
| 259 |
@$(MKINSTALLDIRS) $@ |
| 260 |
|
| 261 |
# Arrange to have the headers installed locally anytime we build the library. |
| 262 |
# Not quite perfect, but at least it does end up getting done; and once done |
| 263 |
# it never needs to be repeated for a particular header. |
| 264 |
local-installhdrsubdir = include/$(installhdrsubdir) |
| 265 |
INSTALLED_LOCAL_HEADERS := $(installhdrs:%=../$(local-installhdrsubdir)/%) |
| 266 |
$(INSTALLED_LOCAL_HEADERS): ../$(local-installhdrsubdir)/%: Makefile |
| 267 |
@rm -f $@ |
| 268 |
@test -d $(@D)/ || $(MKINSTALLDIRS) $(@D) |
| 269 |
echo '#include "../$(dir)/$*"' > $@ |
| 270 |
libs: $(INSTALLED_LOCAL_HEADERS) |
| 271 |
# Make sure we make those before compiling, since -MG will be unhelpful. |
| 272 |
$(patsubst %.o,%.d,$(filter %.o,$(OBJS))): $(INSTALLED_LOCAL_HEADERS) |
| 273 |
|
| 274 |
# The installed local headers referring to our own files will use |
| 275 |
# relative names with ../$(dir) and make won't notice that's us. |
| 276 |
../$(dir)/%: % ; |
| 277 |
|
| 278 |
$(addprefix $(DESTDIR)$(libdir)/$(libname),_p.a .a _pic.a): $(DESTDIR)$(libdir)/%: % |
| 279 |
$(INSTALL_DATA) $< $@ |
| 280 |
$(RANLIB) $@ |
| 281 |
|
| 282 |
$(DESTDIR)$(libdir)/$(libname).so.$(hurd-version): $(libname).so.$(hurd-version) |
| 283 |
$(INSTALL_DATA) $< $@ |
| 284 |
|
| 285 |
$(DESTDIR)$(libdir)/$(libname).so: $(DESTDIR)$(libdir)/$(libname).so.$(hurd-version) |
| 286 |
ln -f -s $(<F) $@ |
| 287 |
|
| 288 |
$(addprefix $(DESTDIR)$(includedir)/$(installhdrsubdir)/,$(installhdrs)): $(DESTDIR)$(includedir)/$(installhdrsubdir)/%: % |
| 289 |
$(INSTALL_DATA) $< $@ |
| 290 |
|
| 291 |
# Arrange to have the shared libraries available locally in one single |
| 292 |
# directory. This is not used by the build system itself, but is just for easy |
| 293 |
# testing. |
| 294 |
local-libdir = lib |
| 295 |
../$(local-libdir)/$(libname).so.$(hurd-version): $(libname).so.$(hurd-version) |
| 296 |
@test -d $(@D)/ || $(MKINSTALLDIRS) $(@D) |
| 297 |
ln -sf ../$(dir)/$< $@ |
| 298 |
libs: ../$(local-libdir)/$(libname).so.$(hurd-version) |
| 299 |
|
| 300 |
endif |
| 301 |
|
| 302 |
# Provide default. |
| 303 |
install: |
| 304 |
install-headers: |
| 305 |
|
| 306 |
# Making installation directories |
| 307 |
$(addprefix $(DESTDIR),$(installationdirlist)): %: |
| 308 |
@$(MKINSTALLDIRS) $@ |
| 309 |
|
| 310 |
# Building the target |
| 311 |
ifneq ($(makemode),misc) |
| 312 |
|
| 313 |
ifeq ($(doinst),one) |
| 314 |
$(linktarg): $(OBJS) $(library_deps) |
| 315 |
endif |
| 316 |
|
| 317 |
# Determine which sort of library we should link against from whether -static |
| 318 |
# is used in LDFLAGS. |
| 319 |
__libext=.so |
| 320 |
__libext-static=.a |
| 321 |
_libext=$(__libext$(findstring -static,$(LDFLAGS) $($*-LDFLAGS))) |
| 322 |
|
| 323 |
libsubst=$(basename ${lib})$(_libext) |
| 324 |
libsubst-override=${$(notdir $(basename ${lib}))-libsubst} |
| 325 |
_libsubst=${libsubst$(patsubst %,-override,${libsubst-override})} |
| 326 |
|
| 327 |
# Direct the linker where to find shared objects specified in the |
| 328 |
# dependencies of other shared objects it encounters. |
| 329 |
lib_dirs := $(dir $(wildcard ../lib*/lib*.so)) |
| 330 |
lpath := -L. $(lib_dirs:%=-L%) $(lib_dirs:%=-Wl,-rpath-link=%) |
| 331 |
|
| 332 |
# Main rule to link executables |
| 333 |
# |
| 334 |
# (prof-depend is a special kind of run not normally used; see the rules |
| 335 |
# below for %.prof_d which uses it.) |
| 336 |
ifeq ($(prof-depend),) |
| 337 |
|
| 338 |
define link-executable |
| 339 |
$(CC) $(lpath) $(CFLAGS) $($*-CFLAGS) $(LDFLAGS) $($*-LDFLAGS) \ |
| 340 |
$(BUGADDR_REF) \ |
| 341 |
-o $@ |
| 342 |
endef |
| 343 |
$(progtarg): %$(target-suffix): $(BUGADDR) |
| 344 |
$(link-executable) \ |
| 345 |
$(filter %.o,$^) \ |
| 346 |
'-Wl,-(' $(foreach lib,$(filter-out %.o,$^),${_libsubst}) \ |
| 347 |
$($*-LDLIBS) $(LDLIBS) \ |
| 348 |
'-Wl,-)' |
| 349 |
|
| 350 |
$(addsuffix .static,$(progtarg)): %$(target-suffix).static: $(BUGADDR) |
| 351 |
$(link-executable) -static \ |
| 352 |
'-Wl,-(' $(patsubst %.so,%.a,$^) $($*.static-LDLIBS) $(LDLIBS) \ |
| 353 |
'-Wl,-)' \ |
| 354 |
$(and $(filter %/libstore_part.a,$^), $(PARTED_LIBS)) |
| 355 |
endif |
| 356 |
|
| 357 |
# Just like above, but tell how to make .prof versions of programs. |
| 358 |
$(addsuffix .prof,$(progtarg)): %$(target-suffix).prof: $(BUGADDR) |
| 359 |
$(CC) -pg $(CFLAGS) $($*-CFLAGS) $(LDFLAGS) $($*-LDFLAGS) \ |
| 360 |
$(BUGADDR_REF) -static \ |
| 361 |
-o $@ \ |
| 362 |
'-Wl,-(' $^ $($*.static-LDLIBS) $(LDLIBS) \ |
| 363 |
'-Wl,-)' |
| 364 |
|
| 365 |
ifeq ($(makemode),library) |
| 366 |
$(libname).a: $(OBJS) |
| 367 |
rm -f $(libname).a |
| 368 |
$(AR) r $@ $^ |
| 369 |
$(RANLIB) $@ |
| 370 |
|
| 371 |
$(libname)_p.a: $(patsubst %.o,%_p.o,$(OBJS)) |
| 372 |
rm -f $(libname)_p.a |
| 373 |
$(AR) r $@ $^ |
| 374 |
$(RANLIB) $@ |
| 375 |
|
| 376 |
$(libname)_pic.a: $(patsubst %.o,%_pic.o,$(OBJS)) |
| 377 |
rm -f $(libname)_pic.a |
| 378 |
$(AR) r $@ $^ |
| 379 |
$(RANLIB) $@ |
| 380 |
|
| 381 |
# The shared object needs to be findable in the build directory as |
| 382 |
# libfoo.so.VERSION (i.e. its soname) so that ld finds it when looking |
| 383 |
# for dependencies of other shared libraries. |
| 384 |
# But we also need the libfoo.so name that -lfoo looks for, so |
| 385 |
# we make that a symlink. |
| 386 |
$(libname).so.$(hurd-version): $(patsubst %.o,%_pic.o,$(OBJS)) $(library_deps) |
| 387 |
$(CC) -shared -Wl,-soname=$@ -o $@ \ |
| 388 |
$(lpath) $(CFLAGS) $(LDFLAGS) $($(libname).so-LDFLAGS) \ |
| 389 |
'-Wl,-(' $(filter-out %.map,$^) \ |
| 390 |
$($(libname).so-LDLIBS) $(LDLIBS) \ |
| 391 |
'-Wl,-)' $(filter %.map,$^) |
| 392 |
|
| 393 |
$(libname).so: $(libname).so.$(hurd-version) |
| 394 |
ln -f -s $< $@ |
| 395 |
endif |
| 396 |
|
| 397 |
# Providing directory dependencies |
| 398 |
ifneq ($(makemode),library) |
| 399 |
hurd-bug-addr-dir-dep = libhurdbugaddr |
| 400 |
endif |
| 401 |
|
| 402 |
endif # makemode != misc |
| 403 |
|
| 404 |
directory-depend: $(..)$(dir).d |
| 405 |
$(..)$(dir).d: $(srcdir)/Makefile |
| 406 |
rm -f $@ |
| 407 |
echo $(dir): $(hurd-bug-addr-dir-dep) $(addprefix lib,$(HURDLIBS)) > $@ |
| 408 |
|
| 409 |
# TAGS files |
| 410 |
ifneq ($(dir),.) |
| 411 |
ifdef configured |
| 412 |
ifneq ($(OBJS:.o=.d),) |
| 413 |
DEP_SRCS = sed -e 's/^.*://' -e 's/ \\$$//' | tr ' ' '\012'| \ |
| 414 |
sed -n -e 's@^$(srcdir)@&@p' -e 's@^[^/]@&@p' | sort -ur |
| 415 |
TAGSFILES=$(OBJS:.o=.d) $(OTHERTAGS) |
| 416 |
else |
| 417 |
TAGSFILES=$(OTHERTAGS) |
| 418 |
endif |
| 419 |
else |
| 420 |
TAGSFILES=$(SRCS) $(OTHERTAGS) |
| 421 |
endif |
| 422 |
|
| 423 |
TAGS: $(TAGSFILES) |
| 424 |
ifeq ($(strip ($(TAGSFILES))),) |
| 425 |
# no tags, but parent will include this file, so make empty one. |
| 426 |
> $@ |
| 427 |
else |
| 428 |
ifdef DEP_SRCS |
| 429 |
cat $(OBJS:.o=.d) | $(DEP_SRCS) | etags -o $@ - $(OTHERTAGS) |
| 430 |
else |
| 431 |
etags -o $@ $^ |
| 432 |
endif |
| 433 |
endif |
| 434 |
endif |
| 435 |
|
| 436 |
.PHONY: dist-hook |
| 437 |
ifdef DISTFILES |
| 438 |
dist-hook: dist.tar |
| 439 |
else |
| 440 |
# Don't bother creating an empty tarball. |
| 441 |
dist-hook: |
| 442 |
endif |
| 443 |
|
| 444 |
# FORCE is needed as $(dist-version) can change between two invocations. |
| 445 |
dist.tar: $(DISTFILES) FORCE |
| 446 |
@[ x$(dist-version) != x ] || \ |
| 447 |
{ echo >&2 Can\''t make $@ without dist-version set.' && \ |
| 448 |
false; } |
| 449 |
tar -c -f $@ --files-from=/dev/null |
| 450 |
# Every file from $(DISTFILES) can exist either in the build directory or in |
| 451 |
# the source directory, but that must not affect the name it gets in dist.tar. |
| 452 |
for f in $(DISTFILES); do \ |
| 453 |
if test -e "$$f"; then d=.; else d=$(srcdir); fi && \ |
| 454 |
if test "$(dir)" = "."; then subdir=""; else subdir="$(dir)/"; fi && \ |
| 455 |
tar --append -f $@ --owner=0 --group=0 \ |
| 456 |
--transform="s%^%$(dist-version)/$$subdir%" -C "$$d" "$$f" \ |
| 457 |
|| exit $$?; \ |
| 458 |
done |
| 459 |
|
| 460 |
# Cleaning |
| 461 |
clean: |
| 462 |
rm -f dist.tar |
| 463 |
ifeq ($(clean),yes) |
| 464 |
rm -f *.d *.o *Server.c *User.c *_S.h *_U.h *.[su]defsi *.stamp \ |
| 465 |
$(cleantarg) |
| 466 |
endif |
| 467 |
|
| 468 |
relink: |
| 469 |
ifeq ($(clean),yes) |
| 470 |
rm -f $(linktarg) |
| 471 |
endif |
| 472 |
|
| 473 |
# Subdependencies |
| 474 |
|
| 475 |
# We record which libraries have been built in this run in the file |
| 476 |
# $(librecord). That file contains a series of lines like |
| 477 |
# `../libfoo/libfoo.a ../libfoo/libfoo.so: ; /bin/true' |
| 478 |
# that serve to inhibit the pattern rule which follows from doing anything. |
| 479 |
# Above, when we make `libs' in library directories, we always append |
| 480 |
# to $(librecord), so that future make invocations don't bother repeating |
| 481 |
# the effort. |
| 482 |
|
| 483 |
# if this is the first level, then set librecord. Otherwise, read it in. |
| 484 |
#ifeq ($(MAKELEVEL),0) |
| 485 |
#librecord:=/tmp/hurd-make-$(shell echo $$$$) |
| 486 |
#export librecord |
| 487 |
#else |
| 488 |
#include $(librecord) |
| 489 |
#endif |
| 490 |
|
| 491 |
# How to create it. |
| 492 |
#$(librecord): |
| 493 |
# touch $(librecord) |
| 494 |
|
| 495 |
# `libs' target depends on this. |
| 496 |
#add-to-librecord: |
| 497 |
# echo $(addprefix ../$(dir)/,$(targets)) : \; /bin/true >> $(librecord) |
| 498 |
|
| 499 |
# Building libraries from other directories. We force both libraries to be |
| 500 |
# built if either is, because it will use the appropriate one even if the other |
| 501 |
# is specified in someone's dependency list. |
| 502 |
#../%.a ../%.so: FORCE |
| 503 |
# $(MAKE) -C $(dir $@) libs |
| 504 |
|
| 505 |
# Tell make where to find other -l libraries that we use |
| 506 |
vpath libutil.% $(libdir)/ |
| 507 |
vpath libpthread.% $(libdir)/ |
| 508 |
vpath libbz2.% $(libdir)/ |
| 509 |
vpath libz.% $(libdir)/ |
| 510 |
|
| 511 |
# The libstore_%.a files fetch symbols from libstore.so |
| 512 |
ifneq ($(dir),libstore) |
| 513 |
$(boot-store-types:%=../libstore/libstore_%.a): ../libstore/libstore.so |
| 514 |
endif |
| 515 |
|
| 516 |
# Default rules to build PIC object files. |
| 517 |
%_pic.o: %.c |
| 518 |
$(COMPILE.c) $< -DPIC -fPIC -o $@ |
| 519 |
|
| 520 |
%_pic.o: %.S |
| 521 |
$(COMPILE.S) $< -DPIC -o $@ |
| 522 |
|
| 523 |
# Default rules to build profiled object files. |
| 524 |
%_p.o: %.c |
| 525 |
$(COMPILE.c) $< -DPROF -pg -o $@ |
| 526 |
|
| 527 |
%_p.o: %.S |
| 528 |
$(COMPILE.S) $< -DPROF -o $@ |
| 529 |
|
| 530 |
# How to build RPC stubs |
| 531 |
|
| 532 |
# We always need this setting, because libc does not include the bogus names. |
| 533 |
MIGCOMFLAGS := -subrprefix __ |
| 534 |
|
| 535 |
# User settable variables: |
| 536 |
# mig-sheader-prefix prepend to foo_S.h for name of foo.defs stub header |
| 537 |
# MIGSFLAGS flags to CPP when building server stubs and headers |
| 538 |
# foo-MIGSFLAGS same, but only for interface `foo' |
| 539 |
# MIGCOMSFLAGS flags to MiG when building server stubs and headers |
| 540 |
# foo-MIGCOMSFLAGS same, but only for interface `foo' |
| 541 |
# MIGUFLAGS flags to CPP when building user stubs and headers |
| 542 |
# foo-MIGUFLAGS same, but only for interface `foo' |
| 543 |
# MIGCOMUFLAGS flags to MiG when building user stubs and headers |
| 544 |
# foo-MIGCOMUFLAGS same, but only for interface `foo' |
| 545 |
# CPPFLAGS flags to CPP |
| 546 |
|
| 547 |
# Implicit rules for building server and user stubs from mig .defs files. |
| 548 |
|
| 549 |
# These chained rules could be (and used to be) single rules using pipes. |
| 550 |
# But it's convenient to be able to explicitly make the intermediate |
| 551 |
# files when you want to deal with a problem in the MiG stub generator. |
| 552 |
|
| 553 |
%.sdefs.stamp: %.defs |
| 554 |
$(CPP) $(CPPFLAGS) $(MIGSFLAGS) $($*-MIGSFLAGS) -DSERVERPREFIX=S_ \ |
| 555 |
-DHURD_SERVER=1 \ |
| 556 |
-MD -MF $*.sdefs.d.new \ |
| 557 |
$< -o $*.sdefsi |
| 558 |
sed -e 's#[^:]*:#$*Server.c $(mig-sheader-prefix)$*_S.h:#' \ |
| 559 |
< $*.sdefs.d.new > $*.sdefs.d |
| 560 |
rm $*.sdefs.d.new |
| 561 |
touch $@ |
| 562 |
%.sdefsi %.sdefs.d: %.sdefs.stamp |
| 563 |
: |
| 564 |
|
| 565 |
%Server.stamp: %.sdefsi |
| 566 |
$(MIGCOM) $(MIGCOMFLAGS) $(MIGCOMSFLAGS) $($*-MIGCOMSFLAGS) \ |
| 567 |
-sheader $(mig-sheader-prefix)$*_S.h -server $*Server.c \ |
| 568 |
-user /dev/null -header /dev/null < $< |
| 569 |
touch $@ |
| 570 |
$(mig-sheader-prefix)%_S.h %Server.c: %Server.stamp |
| 571 |
: |
| 572 |
|
| 573 |
%.udefs.stamp: %.defs |
| 574 |
$(CPP) $(CPPFLAGS) $(MIGUFLAGS) $($*-MIGUFLAGS) \ |
| 575 |
-MD -MF $*.udefs.d.new \ |
| 576 |
$< -o $*.udefsi |
| 577 |
sed -e 's#[^:]*:#$*User.c $*_U.h:#' \ |
| 578 |
< $*.udefs.d.new > $*.udefs.d |
| 579 |
rm $*.udefs.d.new |
| 580 |
touch $@ |
| 581 |
%.udefsi %.udefs.d: %.udefs.stamp |
| 582 |
: |
| 583 |
|
| 584 |
%User.stamp: %.udefsi |
| 585 |
$(MIGCOM) $(MIGCOMFLAGS) $(MIGCOMUFLAGS) $($*-MIGCOMUFLAGS) < $< \ |
| 586 |
-user $*User.c -server /dev/null -header $*_U.h |
| 587 |
touch $@ |
| 588 |
%_U.h %User.c: %User.stamp |
| 589 |
: |
| 590 |
|
| 591 |
# Where to find .defs files. |
| 592 |
vpath %.defs $(top_srcdir)/hurd |
| 593 |
|
| 594 |
# These we want to find in the libc include directory... |
| 595 |
mach_defs_names = bootstrap exc mach mach4 \ |
| 596 |
mach_host mach_port mach_timer_reply memory_object \ |
| •597 |
memory_object_default notify experimental \ |
| 598 |
gnumach \ |
| 599 |
task_notify \ |
| 600 |
|
| 601 |
mach_i386_defs_names = mach_i386 |
| 602 |
mach_debug_defs_names = mach_debug |
| 603 |
device_defs_names = dev_forward device device_reply device_request |
| 604 |
|
| 605 |
mach_defs = $(addsuffix .defs,$(mach_defs_names)) |
| 606 |
mach_i386_defs = $(addsuffix .defs,$(mach_i386_defs_names)) |
| 607 |
mach_debug_defs = $(addsuffix .defs,$(mach_debug_defs_names)) |
| 608 |
device_defs = $(addsuffix .defs,$(device_defs_names)) |
| 609 |
|
| 610 |
$(mach_defs): %.defs: |
| 611 |
echo '#include <mach/$@>' > $@ |
| 612 |
$(mach_i386_defs): %.defs: |
| 613 |
echo '#include <mach/machine/$@>' > $@ |
| 614 |
$(mach_debug_defs): %.defs: |
| 615 |
echo '#include <mach_debug/$@>' > $@ |
| 616 |
$(device_defs): %.defs: |
| 617 |
echo '#include <device/$@>' > $@ |
| 618 |
|
| 619 |
|
| 620 |
FORCE: |
| 621 |
|
| 622 |
|
| 623 |
# How to build automatic dependencies |
| 624 |
|
| 625 |
# Don't include dependencies if $(no_deps) is set; the master makefile |
| 626 |
# does this for clean and other such targets that don't need |
| 627 |
# dependencies. That then avoids rebuilding dependencies. |
| 628 |
|
| 629 |
ifneq ($(no_deps),t) |
| 630 |
|
| 631 |
# The MIG stubs depend on their definition files. |
| 632 |
# These lines assume that every Makefile that uses a foo_S.h or foo_U.h file |
| 633 |
# also mentions the associated fooServer.o or fooUser.o file. |
| 634 |
-include $(subst Server.o,.sdefs.d,$(filter %Server.o,$(OBJS))) /dev/null |
| 635 |
-include $(subst User.o,.udefs.d,$(filter %User.o,$(OBJS))) /dev/null |
| 636 |
|
| 637 |
ifneq ($(prof-depend),t) |
| 638 |
ifneq ($(no_prof),t) |
| 639 |
-include $(addsuffix .prof_d,$(progtarg)) /dev/null |
| 640 |
endif |
| 641 |
endif |
| 642 |
|
| 643 |
# For each .o file we need a .d file. |
| 644 |
-include $(subst .o,.d,$(filter %.o,$(OBJS))) /dev/null |
| 645 |
|
| 646 |
endif |
| 647 |
|
| 648 |
# Here is how to build those dependency files |
| 649 |
|
| 650 |
%.prof_d: $(srcdir)/Makefile |
| 651 |
$(MAKE) $* prof-depend=t |
| 652 |
|
| 653 |
ifeq ($(prof-depend),t) |
| 654 |
$(progtarg): %: FORCE |
| 655 |
rm -f [email protected]_d |
| 656 |
echo [email protected]: $(subst .so,_p.a,$(subst .o,_p.o,$(filter-out FORCE,$+))) > [email protected]_d |
| 657 |
endif |
| 658 |
|
| 659 |
define make-deps |
| 660 |
set -e; $(CC) $(CFLAGS) $(CPPFLAGS) -M -MG $< | \ |
| 661 |
sed > [email protected] -e 's%$*\.o:%$*.o $*_pic.o $*_p.o $@: $($*-DEPS)%' \ |
| 662 |
-e 's% [^ ]*/gcc-lib/[^ ]*\.h%%g' |
| 663 |
mv -f [email protected] $@ |
| 664 |
endef |
| 665 |
|
| 666 |
# Here is how to make .d files from .c files |
| 667 |
%.d: %.c; $(make-deps) |
| 668 |
# Here is how to make .d files from .S files |
| 669 |
%.d: %.S; $(make-deps) |
| 670 |
|
| 671 |
# .s files don't go through the preprocessor, so we do this |
| 672 |
# This rule must come *after* the genuine ones above, so that |
| 673 |
# make doesn't build a .s file and then make an empty dependency |
| 674 |
# list. |
| 675 |
%.d: %.s |
| 676 |
echo '$*.o: $<' > $@ |
| 677 |
|
| 678 |
# Rule to make executable shell scripts from .sh files. |
| 679 |
%: %.sh $(..)config.make |
| 680 |
sed -e 's/STANDARD_HURD_VERSION_\(.[^_]*\)_/\1 (GNU Hurd) $(package-version)/' < $< > $@ |
| 681 |
chmod +x $@ |
| •682 |
|
| 683 |
fsServer-CFLAGS += -DTypeCheck=0 |
| 684 |
ioServer-CFLAGS += -DTypeCheck=0 |