SimpleOS

LXR

Navigation



Site hébergé par : enix

The LXR Cross Referencer for SOS

source navigation ]
diff markup ]
identifier search ]
general search ]
 
 
Article:1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 6.5 ] [ 7 ] [ 7.5 ] [ 8 ] [ 9 ] [ 9.5 ]

Diff markup

Differences between /userland/Makefile (Article 7.5) and /userland/Makefile (Article 9)


001 ## Copyright (C) 2005  David Decotigny            001 ## Copyright (C) 2005  David Decotigny
002 ##                                                002 ##
003 ## This program is free software; you can redi    003 ## This program is free software; you can redistribute it and/or
004 ## modify it under the terms of the GNU Genera    004 ## modify it under the terms of the GNU General Public License
005 ## as published by the Free Software Foundatio    005 ## as published by the Free Software Foundation; either version 2
006 ## of the License, or (at your option) any lat    006 ## of the License, or (at your option) any later version.
007 ##                                                007 ## 
008 ## This program is distributed in the hope tha    008 ## This program is distributed in the hope that it will be useful,
009 ## but WITHOUT ANY WARRANTY; without even the     009 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
010 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR    010 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
011 ## GNU General Public License for more details    011 ## GNU General Public License for more details.
012 ##                                                012 ## 
013 ## You should have received a copy of the GNU     013 ## You should have received a copy of the GNU General Public License
014 ## along with this program; if not, write to t    014 ## along with this program; if not, write to the Free Software
015 ## Foundation, Inc., 59 Temple Place - Suite 3    015 ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
016 ## USA.                                           016 ## USA. 
017                                                   017 
018 CC=gcc                                            018 CC=gcc
019 AR=ar                                             019 AR=ar
                                                   >> 020 CP=cp
                                                   >> 021 STRIP=strip
020 OBJCOPY=objcopy                                   022 OBJCOPY=objcopy
021 CFLAGS  = -Wall -nostdinc -ffreestanding -I. - !! 023 CFLAGS  = -Wall -nostdinc -ffreestanding -I. -I.. -O
022 LIBGCC := $(shell $(CC) -print-libgcc-file-nam !! 024 LIBGCC  = $(shell $(CC) -print-libgcc-file-name) # To benefit from FP/64bits artihm.
023 LDFLAGS = -Wl,--warn-common -nostdlib -Wl,-Tld    025 LDFLAGS = -Wl,--warn-common -nostdlib -Wl,-Tldscript.lds
024                                                   026 
025 # Main target                                     027 # Main target
026 all: userprogs.kimg                               028 all: userprogs.kimg
027                                                   029 
028 -include .mkvars                                  030 -include .mkvars
029                                                   031 
030 PROGS := init myprog1 myprog2 myprog3 myprog4     032 PROGS := init myprog1 myprog2 myprog3 myprog4 myprog5 myprog6 \
031          myprog7 myprog8 myprog9 myprog10 mypr    033          myprog7 myprog8 myprog9 myprog10 myprog11 myprog12   \
032          myprog13 myprog14 banner              !! 034          myprog13 myprog14 banner fstest devtest shell
033                                                   035 
034 # Build dependencies of the programs              036 # Build dependencies of the programs
                                                   >> 037 init: fstest_utils.o
                                                   >> 038 fstest: fstest_utils.o
                                                   >> 039 devtest: fstest_utils.o
                                                   >> 040 shell: fstest_utils.o
035 $(PROGS) : % : %.o crt.o libc.a                   041 $(PROGS) : % : %.o crt.o libc.a
036                                                   042 
037 PWD := $(shell pwd)                            !! 043 PWD := $(shell pwd | sed 's/"/\\\"/g;s/\$$/\\\$$/g')
038                                                   044 
039 # Programs generation                             045 # Programs generation
040 $(PROGS):                                         046 $(PROGS):
041         $(CC) -static $(LDFLAGS) -o $@ $^ $(LI    047         $(CC) -static $(LDFLAGS) -o $@ $^ $(LIBGCC)
042                                                   048 
043 # Generation of the libC                          049 # Generation of the libC
044 libc.a: libc.o string.o stdarg.o debug.o          050 libc.a: libc.o string.o stdarg.o debug.o
045                                                   051 
046 # Create a program image to be integrated into    052 # Create a program image to be integrated into the Kernel
047 userprogs.kimg: $(PROGS)                          053 userprogs.kimg: $(PROGS)
048         @echo "# Generating ELF images for inc    054         @echo "# Generating ELF images for inclusion into the kernel image: $@"
049         @echo "SECTIONS { .userprogs . : { " >    055         @echo "SECTIONS { .userprogs . : { " > .userprogs.lds
050         @i=0 ;                                    056         @i=0 ;                                                              \
051          for f in $^ ; do                         057          for f in $^ ; do                                                   \
052            i=`expr $$i + 1` ;                     058            i=`expr $$i + 1` ;                                               \
053            echo "extern char _begin_userprog$$    059            echo "extern char _begin_userprog$$i, _end_userprog$$i;"         \
054                 > .userprog$$i.c ;                060                 > .userprog$$i.c ;                                          \
055            echo "char *_userprog"$$i"_entry[]"    061            echo "char *_userprog"$$i"_entry[]" >> .userprog$$i.c ;          \
056            echo "  __attribute__((section(\".u    062            echo "  __attribute__((section(\".userprogs_table\")))"          \
057                 >> .userprog$$i.c ;               063                 >> .userprog$$i.c ;                                         \
058            echo "  = { \"$$f\", &_begin_userpr    064            echo "  = { \"$$f\", &_begin_userprog$$i, &_end_userprog$$i };"  \
059                 >> .userprog$$i.c ;               065                 >> .userprog$$i.c ;                                         \
060            $(CC) $(CFLAGS) -c .userprog$$i.c -    066            $(CC) $(CFLAGS) -c .userprog$$i.c -o .userprog$$i.o ;            \
061            $(OBJCOPY) --add-section .userprog$ !! 067            $(CP) $$f $$f.strip && $(STRIP) -sx $$f.strip ;                  \
                                                   >> 068            $(OBJCOPY) --add-section .userprog$$i=$$f.strip .userprog$$i.o   \
062                 .userprog$$i.kimg ;               069                 .userprog$$i.kimg ;                                         \
063            echo "  . = ALIGN(4096);" >> .userp    070            echo "  . = ALIGN(4096);" >> .userprogs.lds ;                    \
064            echo "  _begin_userprog$$i = .;" >>    071            echo "  _begin_userprog$$i = .;" >> .userprogs.lds ;             \
065            echo "  .userprog$$i.kimg(.userprog    072            echo "  .userprog$$i.kimg(.userprog$$i);" >> .userprogs.lds ;    \
066            echo "  _end_userprog$$i = .;" >> .    073            echo "  _end_userprog$$i = .;" >> .userprogs.lds ;               \
067            echo "  .userprog$$i.kimg(.rodata);    074            echo "  .userprog$$i.kimg(.rodata); .userprog$$i.kimg(.data);"   \
068                 >> .userprogs.lds ;               075                 >> .userprogs.lds ;                                         \
069          done                                     076          done
070         @echo "  _userprogs_table = .; *(.user    077         @echo "  _userprogs_table = .; *(.userprogs_table) ; LONG(0);"      \
071                 >> .userprogs.lds                 078                 >> .userprogs.lds
072         @echo "} /DISCARD/ : { *(.text) *(.dat    079         @echo "} /DISCARD/ : { *(.text) *(.data) *(.bss) } }"               \
073                 >> .userprogs.lds                 080                 >> .userprogs.lds
074         @$(LD) -r -o $@ -T.userprogs.lds          081         @$(LD) -r -o $@ -T.userprogs.lds
075                                                   082 
076 # Create libraries from object files              083 # Create libraries from object files
077 %.a:                                              084 %.a:
078         $(AR) rcv $@ $^                           085         $(AR) rcv $@ $^
079                                                   086 
080 # Create objects from C source code               087 # Create objects from C source code
081 %.o: %.c                                          088 %.o: %.c
082         $(CC) -I$(PWD) -c $< $(CFLAGS) -o $@   !! 089         $(CC) "-I$(PWD)" -c "$<" $(CFLAGS) -o "$@"
083                                                   090 
084 # Create objects from assembler (.S) source co    091 # Create objects from assembler (.S) source code
085 %.o: %.S                                          092 %.o: %.S
086         $(CC) -I$(PWD) -c $< $(CFLAGS) -DASM_S !! 093         $(CC) "-I$(PWD)" -c "$<" $(CFLAGS) -DASM_SOURCE=1 -o "$@"
087                                                   094 
088 # Clean directory                                 095 # Clean directory
089 clean:                                            096 clean:
090         $(RM) *.o *.a *~ $(PROGS) *.kimg       !! 097         $(RM) *.o *.a *~ $(PROGS) *.kimg *.strip
091         $(RM) .userprog*                          098         $(RM) .userprog*
                                                      

source navigation ] diff markup ] identifier search ] general search ]