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 9.5) and /userland/Makefile (Article 8)


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                                             020 CP=cp
021 STRIP=strip                                       021 STRIP=strip
022 OBJCOPY=objcopy                                   022 OBJCOPY=objcopy
023 CFLAGS  = -Wall -nostdinc -ffreestanding -I. -    023 CFLAGS  = -Wall -nostdinc -ffreestanding -I. -I.. -O
024 LIBGCC  = $(shell $(CC) -print-libgcc-file-nam    024 LIBGCC  = $(shell $(CC) -print-libgcc-file-name) # To benefit from FP/64bits artihm.
025 LDFLAGS = -Wl,--warn-common -nostdlib -Wl,-Tld    025 LDFLAGS = -Wl,--warn-common -nostdlib -Wl,-Tldscript.lds
026                                                   026 
027 # Main target                                     027 # Main target
028 all: userprogs.kimg                               028 all: userprogs.kimg
029                                                   029 
030 -include .mkvars                                  030 -include .mkvars
031                                                   031 
032 PROGS := init myprog1 myprog2 myprog3 myprog4     032 PROGS := init myprog1 myprog2 myprog3 myprog4 myprog5 myprog6 \
033          myprog7 myprog8 myprog9 myprog10 mypr    033          myprog7 myprog8 myprog9 myprog10 myprog11 myprog12   \
034          myprog13 myprog14 banner fstest chart !! 034          myprog13 myprog14 banner fstest
035                                                   035 
036 # Build dependencies of the programs              036 # Build dependencies of the programs
037 init: fstest_utils.o                           << 
038 fstest: fstest_utils.o                            037 fstest: fstest_utils.o
039 chartest: fstest_utils.o                       << 
040 blktest: fstest_utils.o                        << 
041 shell: fstest_utils.o                          << 
042 $(PROGS) : % : %.o crt.o libc.a                   038 $(PROGS) : % : %.o crt.o libc.a
043                                                   039 
044 PWD := $(shell pwd | sed 's/"/\\\"/g;s/\$$/\\\ !! 040 PWD := $(shell pwd)
045                                                   041 
046 # Programs generation                             042 # Programs generation
047 $(PROGS):                                         043 $(PROGS):
048         $(CC) -static $(LDFLAGS) -o $@ $^ $(LI    044         $(CC) -static $(LDFLAGS) -o $@ $^ $(LIBGCC)
049                                                   045 
050 # Generation of the libC                          046 # Generation of the libC
051 libc.a: libc.o string.o stdarg.o debug.o          047 libc.a: libc.o string.o stdarg.o debug.o
052                                                   048 
053 # Create a program image to be integrated into    049 # Create a program image to be integrated into the Kernel
054 userprogs.kimg: $(PROGS)                          050 userprogs.kimg: $(PROGS)
055         @echo "# Generating ELF images for inc    051         @echo "# Generating ELF images for inclusion into the kernel image: $@"
056         @echo "SECTIONS { .userprogs . : { " >    052         @echo "SECTIONS { .userprogs . : { " > .userprogs.lds
057         @i=0 ;                                    053         @i=0 ;                                                              \
058          for f in $^ ; do                         054          for f in $^ ; do                                                   \
059            i=`expr $$i + 1` ;                     055            i=`expr $$i + 1` ;                                               \
060            echo "extern char _begin_userprog$$    056            echo "extern char _begin_userprog$$i, _end_userprog$$i;"         \
061                 > .userprog$$i.c ;                057                 > .userprog$$i.c ;                                          \
062            echo "char *_userprog"$$i"_entry[]"    058            echo "char *_userprog"$$i"_entry[]" >> .userprog$$i.c ;          \
063            echo "  __attribute__((section(\".u    059            echo "  __attribute__((section(\".userprogs_table\")))"          \
064                 >> .userprog$$i.c ;               060                 >> .userprog$$i.c ;                                         \
065            echo "  = { \"$$f\", &_begin_userpr    061            echo "  = { \"$$f\", &_begin_userprog$$i, &_end_userprog$$i };"  \
066                 >> .userprog$$i.c ;               062                 >> .userprog$$i.c ;                                         \
067            $(CC) $(CFLAGS) -c .userprog$$i.c -    063            $(CC) $(CFLAGS) -c .userprog$$i.c -o .userprog$$i.o ;            \
068            $(CP) $$f $$f.strip && $(STRIP) -sx    064            $(CP) $$f $$f.strip && $(STRIP) -sx $$f.strip ;                  \
069            $(OBJCOPY) --add-section .userprog$    065            $(OBJCOPY) --add-section .userprog$$i=$$f.strip .userprog$$i.o   \
070                 .userprog$$i.kimg ;               066                 .userprog$$i.kimg ;                                         \
071            echo "  . = ALIGN(4096);" >> .userp    067            echo "  . = ALIGN(4096);" >> .userprogs.lds ;                    \
072            echo "  _begin_userprog$$i = .;" >>    068            echo "  _begin_userprog$$i = .;" >> .userprogs.lds ;             \
073            echo "  .userprog$$i.kimg(.userprog    069            echo "  .userprog$$i.kimg(.userprog$$i);" >> .userprogs.lds ;    \
074            echo "  _end_userprog$$i = .;" >> .    070            echo "  _end_userprog$$i = .;" >> .userprogs.lds ;               \
075            echo "  .userprog$$i.kimg(.rodata);    071            echo "  .userprog$$i.kimg(.rodata); .userprog$$i.kimg(.data);"   \
076                 >> .userprogs.lds ;               072                 >> .userprogs.lds ;                                         \
077          done                                     073          done
078         @echo "  _userprogs_table = .; *(.user    074         @echo "  _userprogs_table = .; *(.userprogs_table) ; LONG(0);"      \
079                 >> .userprogs.lds                 075                 >> .userprogs.lds
080         @echo "} /DISCARD/ : { *(.text) *(.dat    076         @echo "} /DISCARD/ : { *(.text) *(.data) *(.bss) } }"               \
081                 >> .userprogs.lds                 077                 >> .userprogs.lds
082         @$(LD) -r -o $@ -T.userprogs.lds          078         @$(LD) -r -o $@ -T.userprogs.lds
083                                                   079 
084 # Create libraries from object files              080 # Create libraries from object files
085 %.a:                                              081 %.a:
086         $(AR) rcv $@ $^                           082         $(AR) rcv $@ $^
087                                                   083 
088 # Create objects from C source code               084 # Create objects from C source code
089 %.o: %.c                                          085 %.o: %.c
090         $(CC) "-I$(PWD)" -c "$<" $(CFLAGS) -o  !! 086         $(CC) -I$(PWD) -c $< $(CFLAGS) -o $@
091                                                   087 
092 # Create objects from assembler (.S) source co    088 # Create objects from assembler (.S) source code
093 %.o: %.S                                          089 %.o: %.S
094         $(CC) "-I$(PWD)" -c "$<" $(CFLAGS) -DA !! 090         $(CC) -I$(PWD) -c $< $(CFLAGS) -DASM_SOURCE=1 -o $@
095                                                   091 
096 # Clean directory                                 092 # Clean directory
097 clean:                                            093 clean:
098         $(RM) *.o *.a *~ $(PROGS) *.kimg *.str    094         $(RM) *.o *.a *~ $(PROGS) *.kimg *.strip
099         $(RM) .userprog*                          095         $(RM) .userprog*
                                                      

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