Index: trunk/src/emx/Makefile
===================================================================
--- trunk/src/emx/Makefile	(revision 213)
+++ trunk/src/emx/Makefile	(revision 214)
@@ -52,5 +52,5 @@
 CFLAGS = -Wall -mstack-arg-probe -Zmt $(CFLAGS.INC) $(CFLAGS.$(MODE)) $(CFLAGS.KIND)
 # The additional C compiler flags for different build modes
-CFLAGS.opt = -s -O3 -fomit-frame-pointer
+CFLAGS.opt = -s -O3
 CFLAGS.dbg = -g
 CFLAGS.aout =
@@ -78,5 +78,5 @@
 LDFLAGS.KIND = $(foreach x,$(subst -, ,$(firstword $(subst /, ,$(subst $.,,$@)))),$(LDFLAGS.$x))
 # How to link a .exe file
-DO.LINK.exe = $(LD) $(strip $(LDFLAGS) $(filter-out -l%,$1)) -o $@ $(^O) $(^LIB) $(filter -l%,$1)
+DO.LINK.exe = $(LD) $(strip $(LDFLAGS) $(filter-out -l%,$1)) -o $@ $(^O) $(^DEF) $(^LIB) $(filter -l%,$1)
 # How to link a .dll file
 DO.LINK.dll = $(LD) $(strip $(LDFLAGS.DLL) $(filter-out -l%,$1)) -o $@ $(^O) $(^DEF) $(^LIB) $(filter -l%,$1)
@@ -133,5 +133,5 @@
 ^DEF = $(filter %.def,$^)
 # How to filter the libraries from $^
-^LIB = $(filter %.$(if $(findstring omf,$(.TKIND)),lib,a),$^)
+^LIB = $(strip $(filter %.a,$^) $(filter %.lib,$^))
 # This function finds a tool: if it has been already built, prefer it
 FINDTOOL = $(firstword $(wildcard $.$(TOOLFMT)/$1$E) $(wildcard $(OUT)dbg/aout/$1$E) $1)
Index: trunk/src/emx/src/ld/ld.smak
===================================================================
--- trunk/src/emx/src/ld/ld.smak	(revision 213)
+++ trunk/src/emx/src/ld/ld.smak	(revision 214)
@@ -13,2 +13,11 @@
 .TLDF   := -liberty
 include mkexe.smak
+
+.TARGET := ldstub.bin
+.TKIND	:= omf
+.TSRC.386 := src/ld/ldstub.asm
+.TSRC	:= $(.TSRC.$(CPU))
+.TAF.src/ld/ldstub.asm = -DMICRO
+.TDEP	:= @O@os2$A src/ld/ldstub.def
+.TLDF	:= -nostdlib
+include mkexe.smak
Index: trunk/src/emx/src/ld/ldstub.asm
===================================================================
--- trunk/src/emx/src/ld/ldstub.asm	(revision 214)
+++ trunk/src/emx/src/ld/ldstub.asm	(revision 214)
@@ -0,0 +1,174 @@
+; $Id$
+;
+; Micro stub for <app> -> <app>.exe forwarding
+;
+; Build Instructions:
+;   Stantard version:
+;       alp ldstub.asm
+;       ilink /pmtype:vio /ALIGN:1 /OUT:ldstub.bin ldstub.obj ldstub.def os2386.lib
+;
+;   Microversion:
+;       alp -D:MICRO=1 ldstub.asm
+;       ilink /pmtype:vio /ALIGN:1 /OUT:ldstub.bin ldstub.obj ldstub.def os2386.lib
+;
+; OVERLAY may be defined for execv()/spawnv(OVERLAY,..) is to be emulated.
+;
+; InnoTek Systemberatung GmbH Confidential
+;
+; Copyright (c) 2003 InnoTek Systemberatung GmbH
+; Author: knut st. osmundsen <bird@anduin.net>
+;
+; All Rights Reserved
+;
+;
+
+    .486
+
+;*******************************************************************************
+;* Structures and Typedefs                                                     *
+;*******************************************************************************
+RESULTCODES	STRUC
+resc_codeTerminate	DD	?
+resc_codeResult	DD	?
+RESULTCODES	ENDS
+
+extrn DosExecPgm:near
+extrn DosQueryModuleName:near
+
+
+DATA32 segment use32 para public 'DATA'
+DATA32 ends
+
+BSS32	segment use32 para public 'BSS'
+; buffer for modifying the executable name
+achNewExeName   db 260 dup(?)
+padding         db   8 dup(?)           ; safety precaution.
+
+; DosExecPgm result buffer.
+res             RESULTCODES <?,?>
+BSS32	ends
+
+STACK32 segment use32 para stack 'STACK'
+    dd  1800h dup(?)                    ; size doesn't matter as DosExecPgm uses thunk stack in any case. :/
+STACK32 ends
+
+ifndef MICRO
+DGROUP group DATA32, BSS32, STACK32
+else
+DGROUP group CODE32, DATA32, BSS32, STACK32
+endif
+
+
+ifndef MICRO
+CODE32 segment use32 para public 'CODE'
+else
+CODE32 segment use32 para public 'DATA'
+endif
+
+; Program startup registers are defined as follows. 
+;    EIP = Starting program entry address. 
+;    ESP = Top of stack address. 
+;    CS = Code selector for base of linear address space. 
+;    DS = ES = SS = Data selector for base of linear address space. 
+;    FS = Data selector of base of Thread Information Block (TIB). 
+;    GS = 0. 
+;    EAX = EBX = 0. 
+;    ECX = EDX = 0. 
+;    ESI = EDI = 0. 
+;    EBP = 0.   
+;    [ESP+0] = Return address to routine which calls DosExit(1,EAX). 
+;    [ESP+4] = Module handle for program module. 
+;    [ESP+8] = Reserved. 
+;    [ESP+12] = Environment data object address. 
+;    [ESP+16] = Command line linear address in environment data object. 
+;
+; @remark   I don't care about cleaning up arguments as the leave does so.
+;
+start:
+    ASSUME ss:FLAT, ds:FLAT, es:FLAT, fs:nothing, gs:nothing
+    push    ebp        
+    mov     ebp, esp
+    
+    ;
+    ; Get the executable name.
+    ;
+    ; ULONG DosQueryModuleName(HMODULE hmod, ULONG ulNameLength, PCHAR pNameBuf);
+    ;   
+    push    offset FLAT:achNewExeName   ; pNameBuf
+    push    size achNewExeName          ; ulNameLength
+    push    dword ptr [ebp+8]           ; hmod
+    call    DosQueryModuleName
+    or      eax, eax
+    jz      modname_ok
+    
+    ; this ain't supposed to happen
+    mov     edx, [ebp+4]
+    int     3    
+
+modname_ok:
+    ;
+    ; Append .EXE to the module name.
+    ;
+    xor     ecx, ecx
+    dec     ecx
+    mov     edi, offset FLAT:achNewExeName
+    repne scasb
+    mov     dword ptr [edi-1], 'EXE.'
+    mov     dword ptr [edi+3], 0
+
+    ;
+    ; Try execute the .EXE appended module name.
+    ;
+    ; APIRET APIENTRY DosExecPgm(PCHAR pObjname,
+    ;                            LONG cbObjname,
+    ;                            ULONG execFlag,
+    ;                            PCSZ  pArg,
+    ;                            PCSZ  pEnv,
+    ;                            PRESULTCODES pRes,
+    ;                            PCSZ  pName);
+    ;
+    xor     ecx, ecx
+    push    offset FLAT:achNewExeName   ; pName
+    push    offset FLAT:res             ; pRes
+    push    dword ptr [ebp + 10h]       ; pEnv
+    push    dword ptr [ebp + 14h]       ; pArg
+ifdef OVERLAY
+    push    1                           ; execFlag = EXEC_ASYNC
+else
+    push    ecx                         ; execFlag = EXEC_SYNC = 0
+endif    
+    push    ecx                         ; cbObjname
+    push    ecx                         ; pObjname
+    call    DosExecPgm
+    or      eax, eax
+    jz      exec_success
+    
+exec_failed:
+    mov     eax, 07fh
+    jmp     done
+    
+exec_success:        
+ifndef OVERLAY
+    ;
+    ; Retrieve the result code.
+    ;
+    mov     eax, res.resc_codeResult
+    mov     edx, res.resc_codeTerminate
+    or      edx, edx
+    jz      done
+    
+    ;
+    ; Something bad happend and the result code is 0.
+    ; We shouldn't return 0 when we trap, crash or is killed.
+    ; 
+    mov     eax, 0ffh
+endif            
+
+
+done:
+    leave   
+    ret     
+CODE32 ends
+
+end start
+
Index: trunk/src/emx/src/ld/ldstub.def
===================================================================
--- trunk/src/emx/src/ld/ldstub.def	(revision 214)
+++ trunk/src/emx/src/ld/ldstub.def	(revision 214)
@@ -0,0 +1,14 @@
+; $Id$
+;
+; Definition file for the ldstub
+;
+; InnoTek Systemberatung GmbH confidential
+;
+; Copyright (c) 2003 InnoTek Systemberatung GmbH
+; Author: knut st. osmundsen <bird@anduin.net>
+;
+; All Rights Reserved
+;
+NAME ldstub
+STUB NONE
+
Index: trunk/src/emx/src/ldstub.asm
===================================================================
--- trunk/src/emx/src/ldstub.asm	(revision 213)
+++ 	(revision )
@@ -1,174 +1,0 @@
-; $Id$
-;
-; Micro stub for <app> -> <app>.exe forwarding
-;
-; Build Instructions:
-;   Stantard version:
-;       alp ldstub.asm
-;       ilink /pmtype:vio /ALIGN:1 /OUT:ldstub.bin ldstub.obj ldstub.def os2386.lib
-;
-;   Microversion:
-;       alp -D:MICRO=1 ldstub.asm
-;       ilink /pmtype:vio /ALIGN:1 /OUT:ldstub.bin ldstub.obj ldstub.def os2386.lib
-;
-; OVERLAY may be defined for execv()/spawnv(OVERLAY,..) is to be emulated.
-;
-; InnoTek Systemberatung GmbH Confidential
-;
-; Copyright (c) 2003 InnoTek Systemberatung GmbH
-; Author: knut st. osmundsen <bird@anduin.net>
-;
-; All Rights Reserved
-;
-;
-
-    .486
-
-;*******************************************************************************
-;* Structures and Typedefs                                                     *
-;*******************************************************************************
-RESULTCODES	STRUC
-resc_codeTerminate	DD	?
-resc_codeResult	DD	?
-RESULTCODES	ENDS
-
-extrn DosExecPgm:near
-extrn DosQueryModuleName:near
-
-
-DATA32 segment use32 para public 'DATA'
-DATA32 ends
-
-BSS32	segment use32 para public 'BSS'
-; buffer for modifying the executable name
-achNewExeName   db 260 dup(?)
-padding         db   8 dup(?)           ; safety precaution.
-
-; DosExecPgm result buffer.
-res             RESULTCODES <?,?>
-BSS32	ends
-
-STACK32 segment use32 para stack 'STACK'
-    dd  1800h dup(?)                    ; size doesn't matter as DosExecPgm uses thunk stack in any case. :/
-STACK32 ends
-
-ifndef MICRO
-DGROUP group DATA32, BSS32, STACK32
-else
-DGROUP group CODE32, DATA32, BSS32, STACK32
-endif
-
-
-ifndef MICRO
-CODE32 segment use32 para public 'CODE'
-else
-CODE32 segment use32 para public 'DATA'
-endif
-
-; Program startup registers are defined as follows. 
-;    EIP = Starting program entry address. 
-;    ESP = Top of stack address. 
-;    CS = Code selector for base of linear address space. 
-;    DS = ES = SS = Data selector for base of linear address space. 
-;    FS = Data selector of base of Thread Information Block (TIB). 
-;    GS = 0. 
-;    EAX = EBX = 0. 
-;    ECX = EDX = 0. 
-;    ESI = EDI = 0. 
-;    EBP = 0.   
-;    [ESP+0] = Return address to routine which calls DosExit(1,EAX). 
-;    [ESP+4] = Module handle for program module. 
-;    [ESP+8] = Reserved. 
-;    [ESP+12] = Environment data object address. 
-;    [ESP+16] = Command line linear address in environment data object. 
-;
-; @remark   I don't care about cleaning up arguments as the leave does so.
-;
-start:
-    ASSUME ss:FLAT, ds:FLAT, es:FLAT, fs:nothing, gs:nothing
-    push    ebp        
-    mov     ebp, esp
-    
-    ;
-    ; Get the executable name.
-    ;
-    ; ULONG DosQueryModuleName(HMODULE hmod, ULONG ulNameLength, PCHAR pNameBuf);
-    ;   
-    push    offset FLAT:achNewExeName   ; pNameBuf
-    push    size achNewExeName          ; ulNameLength
-    push    dword ptr [ebp+8]           ; hmod
-    call    DosQueryModuleName
-    or      eax, eax
-    jz      modname_ok
-    
-    ; this ain't supposed to happen
-    mov     edx, [ebp+4]
-    int     3    
-
-modname_ok:
-    ;
-    ; Append .EXE to the module name.
-    ;
-    xor     ecx, ecx
-    dec     ecx
-    mov     edi, offset FLAT:achNewExeName
-    repne scasb
-    mov     dword ptr [edi-1], 'EXE.'
-    mov     dword ptr [edi+3], 0
-
-    ;
-    ; Try execute the .EXE appended module name.
-    ;
-    ; APIRET APIENTRY DosExecPgm(PCHAR pObjname,
-    ;                            LONG cbObjname,
-    ;                            ULONG execFlag,
-    ;                            PCSZ  pArg,
-    ;                            PCSZ  pEnv,
-    ;                            PRESULTCODES pRes,
-    ;                            PCSZ  pName);
-    ;
-    xor     ecx, ecx
-    push    offset FLAT:achNewExeName   ; pName
-    push    offset FLAT:res             ; pRes
-    push    dword ptr [ebp + 10h]       ; pEnv
-    push    dword ptr [ebp + 14h]       ; pArg
-ifdef OVERLAY
-    push    1                           ; execFlag = EXEC_ASYNC
-else
-    push    ecx                         ; execFlag = EXEC_SYNC = 0
-endif    
-    push    ecx                         ; cbObjname
-    push    ecx                         ; pObjname
-    call    DosExecPgm
-    or      eax, eax
-    jz      exec_success
-    
-exec_failed:
-    mov     eax, 07fh
-    jmp     done
-    
-exec_success:        
-ifndef OVERLAY
-    ;
-    ; Retrieve the result code.
-    ;
-    mov     eax, res.resc_codeResult
-    mov     edx, res.resc_codeTerminate
-    or      edx, edx
-    jz      done
-    
-    ;
-    ; Something bad happend and the result code is 0.
-    ; We shouldn't return 0 when we trap, crash or is killed.
-    ; 
-    mov     eax, 0ffh
-endif            
-
-
-done:
-    leave   
-    ret     
-CODE32 ends
-
-end start
-
Index: trunk/src/emx/src/ldstub.c
===================================================================
--- trunk/src/emx/src/ldstub.c	(revision 213)
+++ 	(revision )
@@ -1,21 +1,0 @@
-/*
- * This stub file is used by LD and EMXOMFLD as a null file when run with -Zexe
- * switch. This program does nothing except running another program with
- * same name, but appending the .exe extension.
- */
-
-#include <string.h>
-#include <alloca.h>
-#include <process.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/dirent.h>
-
-int main (int argc, char *argv[])
-{
-  char name[MAXNAMLEN + 4];
-  _execname (name, MAXNAMLEN);
-  execv (strcat(name, ".exe"), argv);
-  /* If we get here, the executable has not been found */
-  return 127;
-}
Index: trunk/src/emx/src/ldstub.def
===================================================================
--- trunk/src/emx/src/ldstub.def	(revision 213)
+++ 	(revision )
@@ -1,14 +1,0 @@
-; $Id$
-;
-; Definition file for the ldstub
-;
-; InnoTek Systemberatung GmbH confidential
-;
-; Copyright (c) 2003 InnoTek Systemberatung GmbH
-; Author: knut st. osmundsen <bird@anduin.net>
-;
-; All Rights Reserved
-;
-NAME ldstub
-STUB NONE
-
