瀏覽代碼

Merged revisions 10895,10973,10996,11068,11071 via svnmerge from
svn+ssh://[email protected]/FPC/svn/fpc/trunk

........
r10895 | jonas | 2008-05-06 17:39:37 +0200 (Tue, 06 May 2008) | 3 lines

+ necessary linklib, pascalmainname and linkframework statements to
allow usage on Darwin without having to know the magic incantation

........
r10973 | jonas | 2008-05-14 19:18:37 +0200 (Wed, 14 May 2008) | 2 lines

* fixed Pos(WideChar,AnsiString)

........
r10996 | jonas | 2008-05-18 11:49:44 +0200 (Sun, 18 May 2008) | 3 lines

* always pass (g)crt1.o/bundle1.o as first argument to the linker
for darwin (see #11270)

........
r11068 | jonas | 2008-05-24 10:36:36 +0200 (Sat, 24 May 2008) | 3 lines

* don't set CROSSCOMPILE when compiling from darwin to darwin
(regardless of source and target architectures)

........
r11071 | jonas | 2008-05-24 11:01:38 +0200 (Sat, 24 May 2008) | 2 lines

* fixed fpcdir setting

........

git-svn-id: branches/fixes_2_2@11140 -

Jonas Maebe 17 年之前
父節點
當前提交
109f8eb4bd
共有 6 個文件被更改,包括 218 次插入210 次删除
  1. 36 30
      compiler/systems/t_bsd.pas
  2. 2 2
      packages/numlib/examples/Makefile.fpc
  3. 3 0
      packages/sdl/src/sdl.pas
  4. 3 16
      rtl/inc/wustrings.inc
  5. 168 162
      utils/fpcm/fpcmake.inc
  6. 6 0
      utils/fpcm/fpcmake.ini

+ 36 - 30
compiler/systems/t_bsd.pas

@@ -61,6 +61,7 @@ implementation
       LdSupportsNoResponseFile : boolean;
       LibrarySuffix : Char;
       Function  WriteResponseFile(isdll:boolean) : Boolean;
+      Function GetDarwinPrtobjName(isdll: boolean): TCmdStr;
     public
       constructor Create;override;
       procedure SetDefaultInfo;override;
@@ -151,11 +152,11 @@ begin
            end
          else
            begin
-             ExeCmd[1]:='ld $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP -multiply_defined suppress -L. -o $EXE `cat $RES`';
+             ExeCmd[1]:='ld $PRTOBJ $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP -multiply_defined suppress -L. -o $EXE `cat $RES`';
              if (apptype<>app_bundle) then
-               DllCmd[1]:='libtool $OPT -dynamic -multiply_defined suppress -L. -o $EXE `cat $RES`'
+               DllCmd[1]:='libtool $PRTOBJ $OPT -dynamic -multiply_defined suppress -L. -o $EXE `cat $RES`'
              else
-               DllCmd[1]:='ld $OPT -dynamic -bundle -multiply_defined suppress -L. -o $EXE `cat $RES`'
+               DllCmd[1]:='ld $PRTOBJ $OPT -dynamic -bundle -multiply_defined suppress -L. -o $EXE `cat $RES`'
            end
        end
      else
@@ -197,6 +198,33 @@ else
    end;
 End;
 
+
+Function TLinkerBSD.GetDarwinPrtobjName(isdll: boolean): TCmdStr;
+begin
+  if not(isdll) then
+    if not(cs_profile in current_settings.moduleswitches) then
+      begin
+        if not librarysearchpath.FindFile('crt1.o',false,result) then
+          result:='/usr/lib/crt1.o';
+      end
+    else
+      begin
+        if not librarysearchpath.FindFile('gcrt1.o',false,result) then
+          result:='/usr/lib/gcrt1.o';
+      end
+  else
+    begin
+      if (apptype=app_bundle) then
+        begin
+          if not librarysearchpath.FindFile('bundle1.o',false,result) then
+            result:='/usr/lib/bundle1.o'
+        end
+      else
+        result:=''
+    end;
+end;    
+
+
 Function TLinkerBSD.WriteResponseFile(isdll:boolean) : Boolean;
 Var
   linkres      : TLinkRes;
@@ -258,33 +286,7 @@ begin
         AddSharedLibrary('SystemStubs_profile');
 {$endif MACOSX104ORHIGHER}
       reorder:=reorderentries;
-      if not(isdll) then
-        if not(cs_profile in current_settings.moduleswitches) then
-          begin
-            if librarysearchpath.FindFile('crt1.o',false,s) then
-             prtobj:=s
-            else
-             prtobj:='/usr/lib/crt1.o';
-          end
-        else
-          begin
-            if librarysearchpath.FindFile('gcrt1.o',false,s) then
-             prtobj:=s
-            else
-             prtobj:='/usr/lib/gcrt1.o';
-          end
-      else
-        begin
-          if (apptype=app_bundle) then
-            begin
-              if librarysearchpath.FindFile('bundle1.o',false,s) then
-                prtobj:=s
-              else
-                prtobj:='/usr/lib/bundle1.o'
-            end
-          else
-            prtobj:=''
-        end;
+      prtobj:='';
     end;
 
   if reorder Then
@@ -538,6 +540,8 @@ begin
   Replace(cmdstr,'$STRIP',StripStr);
   Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
   Replace(cmdstr,'$DYNLINK',DynLinkStr);
+  if (target_info.system in systems_darwin) then
+    Replace(cmdstr,'$PRTOBJ',GetDarwinPrtobjName(false));
   BinStr:=FindUtil(utilsprefix+BinStr);
 
   { create dsym file? }
@@ -623,6 +627,8 @@ begin
   Replace(cmdstr,'$INIT',InitStr);
   Replace(cmdstr,'$FINI',FiniStr);
   Replace(cmdstr,'$SONAME',SoNameStr);
+  if (target_info.system in systems_darwin) then
+    Replace(cmdstr,'$PRTOBJ',GetDarwinPrtobjName(true));
   BinStr:=FindUtil(utilsprefix+BinStr);
 
   { create dsym file? }

+ 2 - 2
packages/numlib/examples/Makefile.fpc

@@ -21,7 +21,7 @@ files=$(wildcard ../units/$(CPU_TARGET)-$(OS_TARGET)/*$(OEXT)) \
       $(wildcard ../units/$(CPU_TARGET)-$(OS_TARGET)/*$(RSTEXT))
 
 [default]
-fpcdir=../../../..
+fpcdir=../../..
 
 
 [rules]
@@ -37,4 +37,4 @@ all:
 	$(MAKE) --assume-new=iomwrmex.pas iomwrmex$(EXEEXT)
 	$(MAKE) --assume-new=iomwrvex.pas iomwrvex$(EXEEXT)
 #-----------------------------------------------------------------------------
-# end.
+# end.

+ 3 - 0
packages/sdl/src/sdl.pas

@@ -333,6 +333,9 @@ const
 {$IFDEF DARWIN}
   SDLLibName = 'libSDL-1.2.0.dylib';
   {$linklib libSDL-1.2.0}
+  {$linklib SDLmain}
+  {$linkframework Cocoa}
+  {$PASCALMAINNAME SDL_main}
 {$ELSE}
   {$IFDEF FPC}
   SDLLibName = 'libSDL.so';

+ 3 - 16
rtl/inc/wustrings.inc

@@ -1311,22 +1311,9 @@ end;
 
 
 Function Pos (c : WideChar; Const s : AnsiString) : SizeInt;
-var
-  i: SizeInt;
-  pc : pchar;
-begin
-  pc:=@s[1];
-  for i:=1 to length(s) do
-   begin
-     if widechar(pc^)=c then
-      begin
-        pos:=i;
-        exit;
-      end;
-     inc(pc);
-   end;
-  pos:=0;
-end;
+  begin
+    result:=Pos(c,WideString(s));
+  end;
 
 
 Function Pos (c : AnsiString; Const s : WideString) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}

File diff suppressed because it is too large
+ 168 - 162
utils/fpcm/fpcmake.inc


+ 6 - 0
utils/fpcm/fpcmake.ini

@@ -264,9 +264,15 @@ SOURCESUFFIX=$(FULL_SOURCE)
 endif
 
 # Cross compile flag
+ifeq  ($(OS_TARGET),darwin)
+ifneq ($(OS_SOURCE),darwin)
+CROSSCOMPILE=1
+endif
+else
 ifneq ($(FULL_TARGET),$(FULL_SOURCE))
 CROSSCOMPILE=1
 endif
+endif
 
 # Check if the Makefile supports this target, but not
 # when the make target is to rebuild the makefile

Some files were not shown because too many files changed in this diff