# # make.rules - makefile rules for netboot # # Copyright (C) 2003 Gero Kuhlmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # $Id: make.rules,v 1.2 2003/03/30 21:04:17 gkminix Exp $ # # # Avoid the following rules to get executed when no target has been # specified on the make command line # .PHONY: all all: # # All source files for programs running on the host system require # this version header file. # VERSIONH = $(INCDIR)/version.h $(VERSIONH): @(cd $(INCDIR) && $(MAKE) version.h) || exit 1 # # Most host programs require the netboot library to be built # LIBNBA = $(LIBDIR)/libnb.a $(LIBNBA): @(cd $(LIBDIR) && $(MAKE) libnb.a) || exit 1 # # Rules to compile the source files for the host programs # %.o: %.c $(VERSIONH) $(CC) $(CFLAGS) $(CMODFLAGS) -c -o $@ $< # # We need a program to convert a binary file into C source code # MAKEC = $(MISCDIR)/makec $(MAKEC): @(cd $(MISCDIR) && $(MAKE) makec) || exit 1 # # Some x86 binaries need the i386 library # LIBI386A = $(I386DIR)/libi386.a $(LIBI386A): @(cd $(I386DIR) && $(MAKE) libi386.a) || exit 1 # # Rules to process target assembler files into object files # %.s86: %.S86 $(COMMONI86) $(CPP86) $(CPP86INCS) $(CPP86FLAGS) -D__ASSEMBLY__ -o $@ $< %.o86: %.s86 $(COMMONI86) ($(GASP) $(GASPFLAGS) $< | \ $(GAS86) -al=$(@:.o86=.lst) -o $@) || exit 1 @if test "x$(INSTLIB)" != "x"; then \ echo $(AR) ruv $(INSTLIB) $@; \ $(AR) ruv $(INSTLIB) $@ || exit 1; \ fi %-debug.o86: %.s86 $(COMMONI86) ($(GASP) $(GASPFLAGS) $< | \ $(GAS86) -al=$(@:.o86=.lst) $(GAS86DEBUG) -o $@) || exit 1 @if test "x$(INSTLIB)" != "x"; then \ echo $(AR) ruv $(INSTLIB:.a=-debug.a) $@; \ $(AR) ruv $(INSTLIB:.a=-debug.a) $@ || exit 1; \ fi # # Rules to generate target binary files from object files # # Note that the boot sector and DOS program files (.com and .sys) dont # get linked with the i386 library. This is because the library assumes # different code and data segments, and those files get compiled using # shared segments. # %.bin: $(LIBI386A) $(GLD86) $(GLD86FLAGS) -T $(SCRIPTDIR)/ldscript.bin \ -Map $(@:.bin=.map) -o $@ $^ $(GLD86LIBS) @chmod 644 $@ %.b86: $(LIBI386A) $(GLD86) $(GLD86FLAGS) -T $(SCRIPTDIR)/ldscript.bin \ -Map $(@:.b86=.map) -o $@ $^ $(GLD86LIBS) @chmod 644 $@ %.boot: $(GLD86) $(GLD86FLAGS) -T $(SCRIPTDIR)/ldscript.boot \ -Map $(@:.boot=.map) -o $@ $^ @chmod 644 $@ %.com: $(GLD86) $(GLD86FLAGS) -T $(SCRIPTDIR)/ldscript.com \ -Map $(@:.com=.map) -o $@ $^ @chmod 644 $@ %.sys: $(GLD86) $(GLD86FLAGS) -T $(SCRIPTDIR)/ldscript.sys \ -Map $(@:.sys=.map) -o $@ $^ @chmod 644 $@ # # Rule to make a library out of various object files # %.a: @if test "x$(INSTLIB)" = "x"; then \ echo $(AR) ruv $@ $?; \ $(AR) ruv $@ $?; \ echo $(RANLIB) $@; \ $(RANLIB) $@; \ fi # # Rule to generate dependency file # .PHONY: dep dep: $(COMMONI86) $(VERSIONH) dep-recursive @rm -f .depend @touch .depend @if test "x$(SRCS)" != "x"; then \ echo $(CPP) $(CFLAGS) $(CMODFLAGS) -MM $(SRCS); \ $(CPP) $(CFLAGS) $(CMODFLAGS) -MM $(SRCS) >>.depend; \ fi @if test "x$(CSRCS86)" != "x"; then \ echo $(CPP86) $(CPP86FLAGS) $(CPP86INCS) -MM $(CSRCS86); \ $(CPP86) $(CPP86FLAGS) $(CPP86INCS) -MM $(CSRCS86) >>.depend; \ fi @if test "x$(SSRCS86)" != "x"; then \ echo $(CPP86) $(CPP86FLAGS) $(CPP86INCS) -MM $(SSRCS86); \ $(CPP86) $(CPP86FLAGS) $(CPP86INCS) -MM $(SSRCS86) >>.depend; \ fi # Include dependencies if they exist ifneq ($(wildcard .depend),) include .depend endif # # Define all phony rules # .PHONY: distrib install clean distclean realclean distrib: install: clean: distclean: realclean: # # Rule to do general cleaning # clean-general: rm -f *.o *.o86 *.lst *.map $(TARGET) rm -f .depend core stamp-* # # Rule to process subdirectories # %-recursive: @target=`echo $@ | sed 's/-recursive//'`; \ for subdir in *; do \ if test -d $$subdir -a -r $$subdir/Makefile; then \ echo making $$target in $$subdir; \ (cd $$subdir && $(MAKE) $$target) || exit 1; \ fi; \ done