# # make.defs - Global definitions for bootrom Makefiles # # Copyright (C) 1996-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.defs.in,v 1.8 2003/03/09 00:24:26 gkminix Exp $ # # Directory names prefix = exec_prefix = ${prefix} bindir = ${exec_prefix}/bin libdir = ${exec_prefix}/lib mandir = ${prefix}/man srcdir = /mnt/gmirror/ports/net/netboot/work/netboot-0.9.8/bootrom nblibdir = ${exec_prefix}/lib/netboot top_srcdir = /mnt/gmirror/ports/net/netboot/work/netboot-0.9.8 bindestdir = $(srcdir)/binaries rulesdir = $(top_srcdir)/misc/rules # Version information VER_MAJOR = 0 VER_MINOR = 9 NBVERSION = 0.9.8 COPYRIGHT = 1995-2003 G. Kuhlmann # Where to find programs CC = cc BCC = CPP = cc -E AS86 = /usr/local/bin/as86 LD86 = /usr/local/bin/ld86 COPT = AWK = gawk AR = ar INSTALL = /usr/bin/install -c -o root -g wheel MD5SUM = md5sum # How to sort an assembler map file MAPSORT = sort +4 +3 # Compile time flags DEV86=no86 OPTIMIZE=-DOPTIMIZE # Names of object files from C and assembler source files OBJS = $(CSRCS:.c=.o) $(ASRCS:.S=.o) OBJS_M = $(OBJS:.o=.om) OBJS_16 = $(OBJS:.o=.o16) # Common subdirectories in each module directory MODINCDIR = $(srcdir)/$(MODULE)/public MODOBJDIR = $(srcdir)/$(MODULE)/obj # Assembler and compiler flags INCLUDE = -I$(srcdir)/headers BCCFLAGS = $(BCCDEBUG) $(INCLUDE) AFLAGS = $(A86DEBUG) $(INCLUDE) $(OPTIMIZE) COPTFLAGS = -c! -b16 -h"use16 386" -d$(rulesdir) COPTRULES = rules.start rules.net rules.386 rules.net.386 rules.86 rules.end.386 COPTFLAGS_16 = -c! -b16 -h"use16 86" -d$(rulesdir) COPTRULES_16 = rules.start rules.net rules.86 rules.end AS86OPTFLAGS = -u -w -j AS86FLAGS = -0 LD86FLAGS = -0 -d -i # # Rule to generate everything. It has to appear here as an empty rule # in order to avoid that one of the following rules gets executed when # make is called without an argument. # .PHONY: all all: # # Rules to create object files from source files. Each rule will generate # two or three files: .o for normal bootrom version, .om for menu version # and .o16 for 16 bit version. In order to use these rules, the following # variables have to be defined: # # MODULE - name of module subdirectory relative to $(srcdir) # FLAGS - C and assembler flags for normal version # FLAGS_M - C and assembler flags for menu version # BCCDEBUG - debugger flags for C compiler (usually defined in make.config) # A86DEBUG - debugger flags for as86 (usually defined in make.config) # # The object files for the menu version will only be generated for the # bootrom kernel. # .SUFFIXES: .c .S .s .o .c.o: @if test -n "$(OPTIMIZE)"; then \ echo $(BCC) $(BCCFLAGS) $(FLAGS) -S -o $(<:.c=.s.tmp) $<; \ $(BCC) $(BCCFLAGS) $(FLAGS) -S -o $(<:.c=.s.tmp) $< || exit 1; \ echo $(COPT) $(COPTFLAGS) -f$(<:.c=.s.tmp) -o$(<:.c=.s) $(COPTRULES); \ $(COPT) $(COPTFLAGS) -f$(<:.c=.s.tmp) -o$(<:.c=.s) $(COPTRULES) || exit 1; \ rm -f $(<:.c=.s.tmp); \ echo $(AS86) $(AS86FLAGS) $(AS86OPTFLAGS) -o $@ $(<:.c=.s); \ $(AS86) $(AS86FLAGS) $(AS86OPTFLAGS) -o $@ $(<:.c=.s) || exit 1; \ else \ echo $(BCC) $(BCCFLAGS) $(FLAGS) -c -o $@ $<; \ $(BCC) $(BCCFLAGS) $(FLAGS) -c -o $@ $< || exit 1; \ fi @if test "$(MODULE)" = "kernel"; then \ if test -n "$(OPTIMIZE)"; then \ echo $(BCC) $(BCCFLAGS) $(FLAGS_M) -S -o $(<:.c=.s.tmp) $<; \ $(BCC) $(BCCFLAGS) $(FLAGS_M) -S -o $(<:.c=.s.tmp) $< || exit 1; \ echo $(COPT) $(COPTFLAGS) -f$(<:.c=.s.tmp) -o$(<:.c=.sm) $(COPTRULES); \ $(COPT) $(COPTFLAGS) -f$(<:.c=.s.tmp) -o$(<:.c=.sm) $(COPTRULES) || exit 1; \ rm -f $(<:.c=.s.tmp); \ echo $(AS86) $(AS86FLAGS) $(AS86OPTFLAGS) -o $(@:.o=.om) $(<:.c=.sm); \ $(AS86) $(AS86FLAGS) $(AS86OPTFLAGS) -o $(@:.o=.om) $(<:.c=.sm) || exit 1; \ else \ echo $(BCC) $(BCCFLAGS) $(FLAGS_M) -c -o $(@:.o=.om) $<; \ $(BCC) $(BCCFLAGS) $(FLAGS_M) -c -o $(@:.o=.om) $< || exit 1; \ fi; \ fi @if test -n "$(OPTIMIZE)"; then \ echo $(BCC) $(BCCFLAGS) $(FLAGS) -S -o $(<:.c=.s.tmp) $<; \ $(BCC) $(BCCFLAGS) $(FLAGS) -S -o $(<:.c=.s.tmp) $< || exit 1; \ echo $(COPT) $(COPTFLAGS_16) -f$(<:.c=.s.tmp) -o$(<:.c=.s16) $(COPTRULES_16); \ $(COPT) $(COPTFLAGS_16) -f$(<:.c=.s.tmp) -o$(<:.c=.s16) $(COPTRULES_16) || exit 1; \ rm -f $(<:.c=.s.tmp); \ echo $(AS86) $(AS86FLAGS) $(AS86OPTFLAGS) -o $(@:.o=.o16) $(<:.c=.s16); \ $(AS86) $(AS86FLAGS) $(AS86OPTFLAGS) -o $(@:.o=.o16) $(<:.c=.s16) || exit 1; \ else \ echo $(BCC) $(BCCFLAGS) $(FLAGS) -c -o $(@:.o=.o16) $<; \ $(BCC) $(BCCFLAGS) $(FLAGS) -c -o $(@:.o=.o16) $< || exit 1; \ fi .S.s: @( \ echo $(CPP) $(AFLAGS) $(FLAGS) -o $(<:.S=.s) $<; \ $(CPP) $(AFLAGS) $(FLAGS) -o $(<:.S=.s) $< || exit 1; \ ) @if test "$(MODULE)" = "kernel"; then \ echo $(CPP) $(AFLAGS) $(FLAGS_M) -o $(<:.S=.sm) $<; \ $(CPP) $(AFLAGS) $(FLAGS_M) -o $(<:.S=.sm) $< || exit 1; \ fi @( \ echo $(CPP) $(AFLAGS) $(FLAGS) -DP86 -o $(<:.S=.s16) $<; \ $(CPP) $(AFLAGS) $(FLAGS) -DP86 -o $(<:.S=.s16) $< || exit 1; \ ) .s.o: @( \ echo $(AS86) $(AS86FLAGS) -o $@ $(<:.S=.s); \ $(AS86) $(AS86FLAGS) -o $@ $(<:.S=.s) || exit 1; \ ) @if test "$(MODULE)" = "kernel"; then \ echo $(AS86) $(AS86FLAGS) -o $(@:.o=.om) $(<:.S=.sm); \ $(AS86) $(AS86FLAGS) -o $(@:.o=.om) $(<:.S=.sm) || exit 1; \ fi @( \ echo $(AS86) $(AS86FLAGS) -o $(@:.o=.o16) $(<:.S=.s16); \ $(AS86) $(AS86FLAGS) -o $(@:.o=.o16) $(<:.S=.s16) || exit 1; \ ) .S.o: @( \ echo $(CPP) $(AFLAGS) $(FLAGS) -o $(<:.S=.s) $<; \ $(CPP) $(AFLAGS) $(FLAGS) -o $(<:.S=.s) $< || exit 1; \ echo $(AS86) $(AS86FLAGS) -o $@ $(<:.S=.s); \ $(AS86) $(AS86FLAGS) -o $@ $(<:.S=.s) || exit 1; \ ) @if test "$(MODULE)" = "kernel"; then \ echo $(CPP) $(AFLAGS) $(FLAGS_M) -o $(<:.S=.sm) $<; \ $(CPP) $(AFLAGS) $(FLAGS_M) -o $(<:.S=.sm) $< || exit 1; \ echo $(AS86) $(AS86FLAGS) -o $(@:.o=.om) $(<:.S=.sm); \ $(AS86) $(AS86FLAGS) -o $(@:.o=.om) $(<:.S=.sm) || exit 1; \ fi @( \ echo $(CPP) $(AFLAGS) $(FLAGS) -DP86 -o $(<:.S=.s16) $<; \ $(CPP) $(AFLAGS) $(FLAGS) -DP86 -o $(<:.S=.s16) $< || exit 1; \ echo $(AS86) $(AS86FLAGS) -o $(@:.o=.o16) $(<:.S=.s16); \ $(AS86) $(AS86FLAGS) -o $(@:.o=.o16) $(<:.S=.s16) || exit 1; \ ) # # Rules to create a library from source files. Each rule will generate # two or three files: .a for normal bootrom version, .am for menu version # and .a16 for 16 bit version. In order to use these rules, the following # variables have to be defined: # # MODULE - name of module subdirectory relative to $(srcdir) # LIBTARGET - name of target library # CSRCS - C source files # ASRCS - assembler source files # FLAGS - C and assembler flags for normal version # FLAGS_M - C and assembler flags for menu version # BCCDEBUG - debugger flags for C compiler (usually defined in make.config) # A86DEBUG - debugger flags for as86 (usually defined in make.config) # # The library file for the menu version will not be generated when the # FLAGS_M variables is undefined. The same is true for the 16 bit version. # # These rules will only be used by make, if LIBTARGET is used somewhere # as a dependency in the Makefile. # # The dummy.a is just needed to make 'make' happy in case no LIBTARGET # has been defined. If LIBTARGET has been set correctly, the $@ variable # will lateron be substituted by the target which caused this rule to run, # e.g. LIBTARGET. # dummy.a $(LIBTARGET): $(OBJS) @( \ echo $(AR) r $@ $?; \ $(AR) r $@ $? || exit 1; \ touch $@; \ cp $@ $(MODOBJDIR)/$@; \ ) @if test "$(MODULE)" = "kernel"; then \ echo $(AR) r $(@:.a=.am) $(?:.o=.om); \ $(AR) r $(@:.a=.am) $(?:.o=.om) || exit 1; \ touch $(@:.a=.am); \ cp $(@:.a=.am) $(MODOBJDIR)/$(@:%.a=%-m.a); \ fi @( \ echo $(AR) r $(@:.a=.a16) $(?:.o=.o16); \ $(AR) r $(@:.a=.a16) $(?:.o=.o16) || exit 1; \ touch $(@:.a=.a16); \ cp $(@:.a=.a16) $(MODOBJDIR)/$(@:%.a=%-16.a); \ ) # # Generate module dependencies. In order to use this rule, the following # variables have to be defined: # # MODULE - name of module subdirectory relative to $(srcdir) # CSRCS - C source files # ASRCS - assembler source files # .PHONY: dep-defs dep-defs: sed '/\#\#\# Dependencies/q' tmp_make @if test -n "$(CSRCS)"; then \ $(CPP) -DDEP $(BCCFLAGS) -M $(CSRCS) >>tmp_make; \ fi @if test -n "$(ASRCS)"; then \ $(CPP) -DDEP $(AFLAGS) -M $(ASRCS) >>tmp_make; \ fi mv tmp_make Makefile # # This target cleans out all files generated above, and some other. # .PHONY: clean-defs distclean-defs realclean-defs clean-defs: rm -f *.o *.om *.o16 *.s *.sm *.s16 *.s.tmp *.a *.am *.a16 rm -f *.b *.lst *.map *.bak core tmp_make distclean-defs: clean-defs realclean-defs: clean-defs sed '/\#\#\# Dependencies/q' tmp_make mv tmp_make Makefile