Subversion Repositories shark

Rev

Rev 1685 | Blame | Compare with Previous | Last modification | View Log | RSS feed

# Shark-specific bits of the build system.
# Include the configuration file.
topdir=$(if $(S),$(S),$(srctree))
include $(topdir)/shark.cfg

# Those are the targets used to build all the libraries that compose
# the system.  This is the only point (except local Makefiles, of course,
# that need to be added as needed) that has to be modified to add new files
# or directories to the main system.
# $(TARGETS) is the list of the main targets used to build the system,
# it contains all the directories recursed by the main Makefile, and the
# special target libgkern.a, that contains the base system.  To add a
# directory that specifies its own libraries simply put it in $(TARGETS).
TARGETS= libgkern.a drivers/ libc/ ports/ tracer/ $(fs-$(SHARK_FS))

# $(LIBGKERN-OBJS) is the list of targets that compose libgkern.a.  To
# add a directory to it, simply put it here.  The generic kernel used to
# be separed from the oslib and from the modules, but that hardly made
# sense for a Shark application, as all those three components are needed
# for it to run.
LIBGKERN-OBJS= arch/$(ARCH)/ kernel/ modules/

# Handle Shark configuration.  Really insane, indeed, btw there should
# not be the need to modify anything below this point in the file to
# handle common maintainance tasks.
options:=TSC APIC BIOS TRACER FG FB COMPILER
define strip-in-place
$(1):=$(strip $($(1)))
endef
$(foreach cfgopt,$(options),$(eval $(call strip-in-place,$(cfgopt))))

cpp-tsc-TRUE:= -D__TSC__
cpp-apic-TRUE:= -D__APIC__
cpp-bios-VM86:= -DVM86
cpp-tracer-NEW:= -D__NEW_TRACER__
cpp-tracer-OLD:= -D__OLD_TRACER__
cpp-fg-FORCE_PXC:= -D__FORCE_PXC__
cpp-fb-VESA:= -DCONFIG_FB_VESA -DCONFIG_LOGO
cpp-fb-FINDPCI:= -DCONFIG_FB_RIVA -DCONFIG_FB_RADEON -DCONFIG_FB_MATROX \
        -DCONFIG_LOGO -DCONFIG_FB_MATROX_G100                           \
        -DCONFIG_FB_MATROX_MILLENIUM -DCONFIG_FB_MATROX_MYSTIQUE
cpp-fb-VGA16:= -DCONFIG_FB_VGA16

include-dirs:=                                                          \
        -I$(topdir)/include -I$(topdir)/modules                         \
        -I$(topdir)/arch/$(ARCH)/include/arch                           \
        -I$(topdir)/libc/arch/$(ARCH)/include                           \
        -I$(topdir)/tracer/include

config:= -D__LINUX__                                                    \
        $(cpp-tsc-$(TSC)) $(cpp-apic-$(APIC)) $(cpp-bios-$(BIOS))       \
        $(cpp-tracer-$(TRACER)) $(cpp-fg-$(FG)) $(cpp-fb-$(FB))

exported-cppflags:= $(include-dirs) $(config)
exported-aflags:= -x assembler-with-cpp $(include-dirs) $(config)

cc-compiler-GCC4:= -Wimplicit-function-declaration -Wno-attributes      \
        -Wno-pointer-sign -Wall -O -fno-builtin -nostdinc               \
        -minline-all-stringops -fno-stack-protector
cc-compiler-GCC3:= -Wimplicit-function-declaration -Wall -O             \
        -fno-builtin -nostdinc -minline-all-stringops
cc-compiler-DJGPP:= -Wimplicit-function-declaration -Wall -O            \
        -fno-builtin -nostdinc -minline-all-stringops

exported-cflags:= $(cc-compiler-$(COMPILER))

fs-YES:= fs/

ifndef APP
# If we are not building an application, just build the system libraries.
targets:= $(TARGETS)
libgkern.a-objs:= $(LIBGKERN-OBJS)
all: install
else
# Rules to build a Shark application.  The following variables are used:
# APP:          the application to build.
# INIT:         the initialization object file.
# OTHEROBJS:    other objects to be linked to the application.
# OTHERLIBS:    other libraries to be linked to the application.
# OTHERINCL:    additional preprocessor flags for the app and its
#               additional objects.
# SHARKOPT:     options to specify which Shark components are to be
#               linked to the application.

# Directory where we search for the compiled Shark libraries.
libs-dir:= $(if $(B),$(B)/.lib,$(if $(S),$(S)/.lib,\
        $(if $(BASE),$(BASE)/.lib,../../.lib)))
ifeq ($(wildcard $(libs-dir)),)
$(error Cannod find Shark build directory)
endif

# Handle $(SHARKOPT).  Always link the generic kernel and the architecture
# support code, as they're needed for the application to run.  Link the
# libc too, as we still don't have proper interface separation.
# XXX Bring back tracer and filesystem.
# XXX The old build system included also the ports and other libs...
app-libs:= -lgkern -lc -lcons -lserial
app-cppflags:= -I$(topdir)/drivers/linuxc26/include\
        -I$(topdir)/drivers/cons/include

wants-option=$(if $(filter $(1),$(uselib)),y)

use-zlib-y:= __ZLIB__
uselib:= $(SHARKOPT)

# PCI
libs-__PCI__-y:= -lpci
cppflags-__PCI__-y:= -I$(topdir)/drivers/pci/include

# Network
libs-__NET__-y:= -lnet
cppflags-__NET__-y:= -I$(topdir)/drivers/net/include

# grx
libs-__GRX__-y:= -lgrx
cppflags-__GRX__-y:= -I$(topdir)/drivers/grx/include

# Framebuffer
libs-__FB__-y:= -lfb
cppflags-__FB__-y:= -I$(topdir)/drivers/fb/include

# Oldchar
libs-__OLDCHAR__-y:= -loldch
cppflags-__OLDCHAR__-y:= -I$(topdir)/drivers/oldchar/include

# Linux compatibility layer
libs-__LINUXC26__-y:= -lcomp26

# PCL833
libs-__PCL833__-y:= -lpcl833
cppflags-__PCL833__-y:= -I$(topdir)/drivers/pcl833/include

# Parport
libs-__PPORT__-y:= -lpport
cppflags-__PPORT__-y:= -I$(topdir)/drivers/parport/include

# PCLAB
libs-__PCLAB__-y:= -lpclab
cppflags-__PCLAB__-y:= -I$(topdir)/drivers/pcl812/include

# BTTV
libs-__BTTV__-y:= -lbttv
cppflags-__BTTV__-y:= -I$(topdir)/drivers/bttv/include

# Input
libs-__INPUT__-y:= -linput
cppflags-__INPUT__-y:= -I$(topdir)/drivers/input/include

# CPU
libs-__CPU__-y:= -lcpu
cppflags-__CPU__-y:= -I$(topdir)/drivers/cpu/include

# USB
libs-__USB__-y:= -lusb
cppflags-__USB__-y:= -I$(topdir)/drivers/usb/include

# I2C
libs-__I2C__-y:= -li2c
cppflags-__I2C__-y:= -I$(topdir)/drivers/i2c/include

# 6025e
libs-__6025E__-y:= -l6025e
cppflags-__6025E__-y:= -I$(topdir)/drivers/pci6025e/include

# Mesa
libs-__OSMESA__-y:= -losmesa -lglut -lglu
cppflags-__OSMESA__-y:= -I$(topdir)/ports/mesa/include

# Servo
libs-__SERVO__-y:= -lservo
cppflags-__SERVO__-y:= -I$(topdir)/ports/servo/include

# TFTP
libs-__TFTP__-y:= -ltftp
cppflags-__TFTP__-y:= -I$(topdir)/ports/tftp/include

libs-tracer-OLD:= -ltracer -lnet -lpci -lcomp26
libs-tracer-NEW:= $(libs-tracer-OLD)

options= __PCI__ __NET__ __GRX__ __FB__ __OLDCHAR__ __LINUXC26__ __PCL833__\
        __PPORT__ __PCLAB__ __BTTV__ __INPUT__ __CPU__ __USB__ __I2C__ \
        __6025E__ __OSMESA__ __SERVO__ __TFTP__

app-libs+= $(foreach opt,$(options),$(libs-$(opt)-$(call wants-option,$(opt))))
app-cppflags+= $(foreach opt,$(options),$(cppflags-$(opt)-$(call\
        wants-option,$(opt))))

app-libs+= $(libs-tracer-$(TRACER))

targets:= $(APP)
$(APP)-objs:= $(APP).o $(OTHEROBJS)
$(APP)-startup:= $(libs-dir)/x0.o
$(APP)-cppflags+= $(OTHERINCL) $(app-cppflags)
$(APP)-ldflags+= -Bstatic -Ttext $(MEM_START) -s -nostartfiles -nostdlib\
        -L$(libs-dir) --start-group $(sort $(app-libs)) $(OTHERLIBS) --end-group
endif