########################################################### # normal make targets # # .PHONY: all all: $(MAKE) -C $(SRC_DIR) all ###########################################################
# # Config stuff, we recall ourselves to load the new config.arch before # running the kernel and other config scripts # .PHONY: config config: $(CONFIG_DIR)/config.in cd $(CONFIG_DIR); $(CONFIG_SHELL) $(SCRIPTS_DIR)/Configure $(CONFIG_DIR)/config.in @rm -f $(SRC_DIR)/arch.config @if egrep "^CONFIG_DEFAULTS_INTEL_I386" $(CONFIG_DIR)/.config > /dev/null; then \ ln -s "$(CONFIG_DIR)/arch.i386" $(SRC_DIR)/arch.config; \ fi @if egrep "^CONFIG_DEFAULTS_MOTOROLA_M5272C3" $(CONFIG_DIR)/.config > /dev/null; then \ ln -s "$(CONFIG_DIR)/arch.m68k" $(SRC_DIR)/arch.config; \ fi @echo "#This dir.config file is automaticly generated by make config!" > $(SRC_DIR)/dir.config @echo "ROOT_DIR="$(ROOT_DIR) >> $(SRC_DIR)/dir.config @echo "CONFIG_DIR="$(CONFIG_DIR) >> $(SRC_DIR)/dir.config @echo "SRC_DIR="$(SRC_DIR) >> $(SRC_DIR)/dir.config @echo "SCRIPTS_DIR="$(SCRIPTS_DIR) >> $(SRC_DIR)/dir.config @echo "HPATH="$(HPATH) >> $(SRC_DIR)/dir.config @echo "FINDPATH="$(FINDPATH) >> $(SRC_DIR)/dir.config
########################################################### # # normal make dependancy # # .PHONY: dep dep: $(MAKE) -C $(SRC_DIR) dep
# This one removes all executables from the tree and forces their relinking clean: $(MAKE) -C $(SRC_DIR) clean
test: $(MAKE) -C $(SRC_DIR) test
run: $(MAKE) -C $(SRC_DIR) run
config_error: @echo "*************************************************" @echo "You have not run make config." @echo "The build sequence for this source tree is:" @echo "1. 'make config' or 'make xconfig'" @echo "2. 'make dep'" @echo "3. 'make'" @echo "*************************************************" @exit 1 ###########################################################
# # Rule to compile a set of .o files into one .a file # ifdef L_TARGET $(L_TARGET): $(LX_OBJS) $(L_OBJS) rm -f $@ $(AR) $(EXTRA_ARFLAGS) rcs $@ $(LX_OBJS) $(L_OBJS) endif
# # This make dependencies quickly # fastdep: dummy @echo "make fastdep" if [ -n "$(wildcard *.[chS])" ]; then \ $(SCRIPTS_DIR)/mkdep *.[chS] > .depend; fi if [ -n "$(wildcard *.cpp)" ]; then \ $(SCRIPTS_DIR)/mkdep *.cpp >> .depend; fi
# # A rule to make subdirectories # sub_dirs: dummy ifdef SUB_DIRS set -e; for i in $(SUB_DIRS); do $(MAKE) -C $$i; done endif # # A rule to do nothing # dummy:
# # This is useful for testing # script: $(SCRIPT)
run: test @echo ... running ... @echo `pwd`/test @./test
# # This sets version suffixes on exported symbols # Uses SYMTAB_OBJS # Separate the object into "normal" objects and "exporting" objects # Exporting objects are: all objects that define symbol tables #
在config 目录下,编写两个和架构有关的文件,对于x86平台,是arch.i386,如下: .EXPORT_ALL_VARIABLES: ################################################################### # # Vendor specific settings #
CONSOLE_BAUD_RATE = 19200
################################################################### # # The makefiles need to know how to do things in different contexts # To save some pain we put it all here # # First settings we always want for all build #
# We've used -m5307 here because the bulk of the 5272 instruction timings # happen to be closer to the 5307 than the 5200 series. Luckily, the # actual instructions on the two processors are essentially identical. # This should be fixed at some stage. CPUFLAGS = CC = $(CROSS_COMPILE)gcc AS = $(CROSS_COMPILE)as CXX = $(CROSS_COMPILE)g++ AR = $(CROSS_COMPILE)ar LD = $(CROSS_COMPILE)ld OBJCOPY = $(CROSS_COMPILE)objcopy RANLIB = $(CROSS_COMPILE)ranlib
UCLINUX_BUILD_SET = 0 # have we set a special config below
################################################################### # # General purpose lib building rules, uClibc.config uses these when # possible #
################################################################### # Settings for building user apps # CFLAGS = -Wall -Wstrict-prototypes -O2 -g #CFLAGS = -Wstrict-prototypes -g LDFLAGS = -m elf_i386 ################################################################### # fall through, do other config options perhaps # ifeq ($(UCLINUX_BUILD_SET),1) endif ###################################################################
在config 目录下,对于嵌入式平台,是arch.m68k,如下:
.EXPORT_ALL_VARIABLES: ################################################################### # # Vendor specific settings # CONSOLE_BAUD_RATE = 19200 ################################################################### # # The makefiles need to know how to do things in different contexts # To save some pain we put it all here # # First settings we always want for all build # # ARCH = kernel, TARGET_ARCH = uClibc
# We've used -m5307 here because the bulk of the 5272 instruction timings # happen to be closer to the 5307 than the 5200 series. Luckily, the # actual instructions on the two processors are essentially identical. # This should be fixed at some stage. CPUFLAGS = -m5200 CC = $(CROSS_COMPILE)gcc AS = $(CROSS_COMPILE)as CXX = $(CROSS_COMPILE)g++ AR = $(CROSS_COMPILE)ar LD = $(CROSS_COMPILE)ld OBJCOPY = $(CROSS_COMPILE)objcopy RANLIB = $(CROSS_COMPILE)ranlib ELF2FLT = elf2flt STRIPTOOL = $(CROSS_COMPILE)strip STRIP = $(STRIPTOOL)
UCLINUX_BUILD_SET = 0 # have we set a special config below
################################################################### # # Settings for building user apps # #CFLAGS = -m5200 -msep-data -g CFLAGS = -m5200 -msep-data LDFLAGS = -Wl,-elf2flt SYSLIBS = -lc -lstdc++ -lgcc ################################################################### # # fall through, do other config options perhaps #