9os

Experimental kernel using plan9 ideas for embedded device
git clone git://git.simple-cc.org/9os
Log | Files | Refs | README | LICENSE

rules.mk (2157B)


      1 # Define the target all as default
      2 all:
      3 
      4 # Define default configuration variables
      5 CONF     = amd64-linux
      6 TOOL     = gnu
      7 
      8 # Define helper macros for project directories
      9 INCDIR    = $(PROJECTDIR)/include
     10 LIBDIR    = $(PROJECTDIR)/lib
     11 BINDIR    = $(PROJECTDIR)/bin
     12 DRVDIR    = $(PROJECTDIR)/drivers
     13 FSDIR     = $(PROJECTDIR)/fs
     14 SRCDIR    = $(PROJECTDIR)/src
     15 SCRIPTDIR = $(PROJECTDIR)/scripts
     16 BUILDDIR  = $(PROJECTDIR)/scripts/build
     17 CONFDIR   = $(PROJECTDIR)/config
     18 
     19 # library dependences helpers
     20 LIBDEP =\
     21 	$(LIBDIR)/libk.a\
     22 	$(LIBDIR)/libc.a\
     23 	$(LIBDIR)/lib9p.a\
     24 
     25 # Include configuration definitions
     26 include $(BUILDDIR)/conf/$(CONF).mk
     27 include $(BUILDDIR)/tool/$(TOOL).mk
     28 
     29 # Locations for -I or -L in compiler, assembler or linker
     30 INCLUDES  = -I$(INCDIR) -I$(INCDIR)/bits/$(ARCH)/ -I$(INCDIR)/bits/$(SYS)
     31 
     32 # Definition of command line for cc, as, ld and emu
     33 PROJ_CFLAGS =\
     34 	$(MORECFLAGS)\
     35 	$(INCLUDES)\
     36 	$(TOOLCFLAGS)\
     37 	$(SYSCFLAGS)\
     38 	$(CFLAGS)
     39 
     40 PROJ_LDFLAGS =\
     41 	$(MORELDFLAGS)\
     42 	-L$(LIBDIR)\
     43 	$(TOOLLDFLAGS)\
     44 	$(SYSLDFLAGS)\
     45 	$(LDFLAGS)
     46 
     47 PROJ_ASFLAGS =\
     48 	$(MOREASFLAGS)\
     49 	$(TOOLASFLAGS)\
     50 	$(SYSASFLAGS)\
     51 	$(ASFLAGS)
     52 
     53 PROJ_LDLIBS =\
     54 	$(MORELDLIBS)\
     55 	$(TOOLLDLIBS)\
     56 	$(SYSLDLIBS)\
     57 	$(LDLIBS)
     58 
     59 # Definition of tools
     60 CC = $(CROSS_COMPILE)$(COMP)
     61 AS = $(CROSS_COMPILE)$(ASM)
     62 LD = $(CROSS_COMPILE)$(LINKER)
     63 OC = $(CROSS_COMPILE)$(OBJCOPY)
     64 OD = $(CROSS_COMPILE)$(OBJDUMP)
     65 RL = $(CROSS_COMPILE)$(RANLIB)
     66 AR = $(CROSS_COMPILE)$(ARCHIVE)
     67 HOSTCC=$(COMP)
     68 
     69 FORALL= +@set -e ;\
     70 	for i in $(DIRS); \
     71 	do \
     72 		cd $$i; \
     73 		$(MAKE) $@; \
     74 		cd -; \
     75 	done
     76 
     77 $(DIRS): FORCE
     78 	+@cd $@ && $(MAKE)
     79 
     80 # Generic rules
     81 .SUFFIXES: .map .dump .elf .bin .i
     82 
     83 .c.o:
     84 	$(CC) $(PROJ_CFLAGS) -o $@ -c $<
     85 
     86 .c:
     87 	$(HOSTCC) $(PROJ_CFLAGS) -o $@  $<
     88 
     89 .c.s:
     90 	$(CC) $(PROJ_CFLAGS) -o $@ -S $<
     91 
     92 .c.i:
     93 	$(CPP) $(PROJ_CFLAGS) -o $@ $<
     94 
     95 .s.o:
     96 	$(AS) $(PROJ_ASFLAGS) -o $@ $<
     97 
     98 .elf.bin:
     99 	$(OC) -O binary $< $@
    100 
    101 .elf.dump:
    102 	$(OD) -D $< > $@
    103 
    104 .o.dump:
    105 	$(OD) -D $< > $@
    106 
    107 .elf.map:
    108 	$(LD) -Map=$@ $< -o /dev/null
    109 
    110 FORCE:
    111 
    112 clean: clean-files clean-dirs
    113 
    114 clean-dirs:
    115 	+@set -e; \
    116 	for i in $(DIRS); \
    117 	do \
    118 		cd $$i; \
    119 		$(MAKE) clean; \
    120 		cd -; \
    121 	done
    122 
    123 clean-files:
    124 	rm -f *.i *.d *.o *.a $(TARGET)
    125 
    126 -include *.d