# Generic configuration for Hurd compilation # Directory makefiles should set the variable makemode to either # `server' if they compile and install a single program for /hurd # `utility' if they compile and install a single program for /bin # `servers' if they compile and install multiple programs for /hurd # `utilities' if they compile and install multiple programs for /bin # `library' if they compile and install a library # `misc' if they do none of those # Every makefile should define # SRCS (all actual source code) # LCLHDRS (all source headers in this directory [NOT MiG created]) # REMHDRS (all Hurd headers in other directories [NOT .defs files]) # Types `server', `utility', and `library' should define # OBJS (all .o files used to produce the target). # Types `server', `utility', `servers', and `utilities' should define # HURDLIBS (all Hurd libraries used, omitting the dirname and the .a.) # Types `server' and `utility' should define # OTHERLIBS (all other libraries used) # target (the name of the program built) # Types `servers' and `utilities' should define # targets (the names of all the programs built) # Type `library' should define # libname (the name of the library, without .a.) # installhdrs (header files that should be installed in /include) # # If you define a new library, then you need to add it to the list # below under the comment `Hurd libraries' in the same form as the # other libraries listed there. # Put this first so it's the default all: # Root of installation and source directories prefix := /home/gd4/hurdinst exec_prefix := $(prefix) srcdir := /home/gd4/gnu/hurd # Where to install things hurddir := $(exec_prefix)/hurd bindir := $(exec_prefix)/bin libdir := $(exec_prefix)/lib infodir := $(prefix)/info includedir := $(prefix)/include # END CONFIGURATION AREA # Decode makemode: ifeq ($(makemode),server) doinst := one installationdir := $(hurddir) clean := yes cleantarg := $(target) endif ifeq ($(makemode),utility) doinst := one installationdir := $(bindir) clean := yes cleantarg := $(target) endif ifeq ($(makemode),servers) doinst := many installationdir := $(hurddir) clean := yes cleantarg := $(targets) endif ifeq ($(makemode),utilities) doinst := many installationdir := $(bindir) clean := yes cleantarg := $(targets) endif ifeq ($(makemode),library) clean := yes cleantarg := $(libname).a endif # Finding binaries include $(srcdir)/Maketools # Flags for compilation. # It is important to have this inclusion first; that picks up our # library header files locally rather than from installed copies. # Append to any value set by the specific Makefile. CPPFLAGS += -I$(srcdir) CFLAGS += -Wall -g # Standard targets # Installation ifeq ($(doinst),one) all: $(target) install: $(target) $(INSTALL_BIN) $(target) $(installationdir)/$(target) endif ifeq ($(doinst),many) all: $(targets) install: $(targets) for i in $(targets) ; do $(INSTALL_BIN) $$i $(installationdir)/$$i ; done endif ifeq ($(makemode),library) all: $(libname).a install: $(libname).a $(installhdrs) ifdef installhdrs $(INSTALL_DATA) $(installhdrs) $(includedir)/hurd/ endif $(INSTALL_DATA) $(libname).a $(libdir)/$(libname).a $(RANLIB) $(libdir)/$(libname).a endif # Provide default. install: LDFLAGS += -static # Each word of $(HURDLIBS) is a library name `libfoo', which is defined as # a variable above with the complete file name to find it. # Yippee! A use for computed variable references! ifeq ($(filter-out -static,$(LDFLAGS)),$(LDFLAGS)) HURDLIBS-files := $(foreach lib,$(HURDLIBS), ../$(lib)/$(lib).so) else HURDLIBS-files := $(foreach lib,$(HURDLIBS), ../$(lib)/$(lib).a) endif HURDLIBS-libs := $(foreach lib,$(HURDLIBS), -L../$(lib) \ $(patsubst lib%,-l%,$(lib))) # Building the target ifeq ($(doinst),one) $(target): $(OBJS) $(HURDLIBS-files) $(OTHERLIBS) $(libc) $(CC) $(CFLAGS) $(LDFLAGS) -o $(target) '-Wl,-(' \ $(OBJS) $(HURDLIBS-libs) $(OTHERLIBS) $(libc) '-Wl,-)' endif ifeq ($(makemode),library) $(libname).a: $(OBJS) rm -f $(libname).a $(AR) r $@ $^ $(RANLIB) $@ endif # Making a snapshot distfiles = Makefile ChangeLog $(SRCS) $(LCLHDRS) $(DIST_FILES) lndist: $(distfiles) $(srcdir)/hurd-snap/$(dir) FORCE ln $(distfiles) $(srcdir)/hurd-snap/$(dir) ifeq ($(dir),.) $(srcdir)/hurd-snap/$(dir): else $(srcdir)/hurd-snap/$(dir): mkdir $(srcdir)/hurd-snap/$(dir) endif # TAGS files ifneq ($(dir),.) TAGS: $(SRCS) $(LCLHDRS) $(REMHDRS) $(OTHERTAGS) etags -o $@ $(HURDLIBS:-i ../%/TAGS) $(SRCS) \ $(LCLHDRS) $(REMHDRS) $(OTHERTAGS) endif # Cleaning ifeq ($(clean),yes) clean: rm -f *.o *Server.c *User.c *_S.h *_U.h $(cleantarg) ifneq ($(makemode),library) relink: rm -f $(cleantarg) endif endif clean: relink: # Subdependencies # Building Hurd libraries $(HURDLIBS-files): FORCE $(MAKE) -C $(dir $@) $(notdir $@) # How to build RPC stubs # User settable variables: # MIGSFLAGS flags to CPP when building server stubs and headers # foo-MIGSFLAGS same, but only for interface `foo' # MIGCOMSFLAGS flags to MiG when building server stubs and headers # foo-MIGCOMSFLAGS same, but only for interface `foo' # MIGUFLAGS flags to CPP when building user stubs and headers # foo-MIGUFLAGS same, but only for interface `foo' # MIGCOMUFLAGS flags to MiG when building user stubs and headers # foo-MIGCOMUFLAGS same, but only for interface `foo' # CPPFLAGS flags to CPP hurddefs := $(notdir $(basename $(wildcard $(srcdir)/hurd/*.defs))) ht := $(srcdir)/hurd/hurd_types.defs # Implicit rules for building server and user stubs from mig .defs files. %_S.h %Server.c: %.defs $(CPP) $(CPPFLAGS) $(MIGSFLAGS) $($*-MIGSFLAGS) -DSERVERPREFIX=S_ $< \ | $(MIGCOM) $(MIGCOMSFLAGS) $($*-MIGCOMSFLAGS) \ -sheader $*_S.h -server $*Server.c \ -user /dev/null -header /dev/null %_U.h %User.c: %.defs $(CPP) $(CPPFLAGS) $(MIGUFLAGS) $($*-MIGUFLAGS) $< \ | $(MIGCOM) $(MIGCOMUFLAGS) $($*-MIGCOMUFLAGS) \ -user $*User.c -server /dev/null -header $*_U.h # Where to find .defs files. vpath %.defs $(srcdir)/hurd:$(crossheaders)/mach:$(crossheaders)/device # Files generated from the Hurd .defs files depend on hurd_types.defs. $(foreach if,$(hurddefs),$(if)_S.h $(if)Server.c $(if)_U.h $(if)User.c): $(ht) FORCE: