Add Linux cross-compile capability, using Open Watcom:
* Flip \ to / where possible. * Introduce $(DIRSEP) (/ or \) for use inside commands in makefiles where / won't work in DOS. * Override various settings for Linux in owlinux.mak. * Add quotes in exeflat.c to avoid shell expansion of $$$$$. * Let "make all", "make clean", and "make clobber" do the job. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@1387 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
parent
dbd57dce42
commit
d6ad12a3dc
65
config.m
Normal file
65
config.m
Normal file
@ -0,0 +1,65 @@
|
||||
#
|
||||
# Linux cross compilation only!
|
||||
# config file that is included in the main makefile for configuration
|
||||
#
|
||||
|
||||
#****************************************************************
|
||||
# NOTICE! If you edit you must rename this file to config.mak!*
|
||||
#****************************************************************
|
||||
|
||||
#**********************************************************************
|
||||
#- define NASM executable
|
||||
#**********************************************************************
|
||||
XNASM=nasm
|
||||
|
||||
#**********************************************************************
|
||||
#- where is the BASE dir of your compiler(s) ??
|
||||
#**********************************************************************
|
||||
|
||||
# if WATCOM maybe you need to set your WATCOM environment variables
|
||||
# and path
|
||||
ifndef WATCOM
|
||||
WATCOM=$(HOME)/watcom
|
||||
PATH:=$(WATCOM)/binl:$(PATH)
|
||||
endif
|
||||
|
||||
#**********************************************************************
|
||||
# where is UPX and which options to use?
|
||||
#**********************************************************************
|
||||
XUPX=upx --8086 --best
|
||||
|
||||
# or use
|
||||
#unexport XUPX
|
||||
# without the # if you don't want to use it
|
||||
|
||||
#**********************************************************************
|
||||
# (optionally) which linker to use:
|
||||
# (otherwise will be determined automatically)
|
||||
|
||||
# WATCOM Link
|
||||
#XLINK=wlink
|
||||
|
||||
#*********************************************************************
|
||||
# optionally define your MAKE type here, if not then
|
||||
# it will be automatically determined, pick one of them
|
||||
# use MS nmake if you want to compile with MSCL
|
||||
#*********************************************************************
|
||||
|
||||
# Watcom MAKE in MS mode
|
||||
#MAKE=wmake -ms -h
|
||||
|
||||
#*********************************************************************
|
||||
# select your default target: required CPU and what FAT system to support
|
||||
#*********************************************************************
|
||||
|
||||
XCPU=86
|
||||
# XCPU=186
|
||||
# XCPU=386
|
||||
|
||||
XFAT=16
|
||||
# XFAT=32
|
||||
|
||||
# Give extra compiler DEFINE flags here
|
||||
# such as -DDEBUG : extra DEBUG output
|
||||
# -DDOSEMU : printf output goes to dosemu log
|
||||
# set ALLCFLAGS=-DDEBUG
|
@ -1,4 +1,7 @@
|
||||
To build the operating system, a batch file (BUILD.BAT) is included
|
||||
Building on DOS or Windows:
|
||||
===========================
|
||||
|
||||
To build the operating system a batch file (BUILD.BAT) is included
|
||||
to make life easier. This file is in the FDKERNEL directory of the
|
||||
distribution. In addition, there is a corresponding batch file
|
||||
(CLEAN.BAT) to clean up the source directories.
|
||||
@ -12,8 +15,28 @@ kernel come out, you can extract them over your previous source, and
|
||||
not have to worry about resetting up your configuration because your
|
||||
CONFIG.BAT file will not get replaced!
|
||||
|
||||
The recommended compiler and assembler at the time of writing (2004/01/31)
|
||||
are OpenWatcom 1.2 and NASM 0.98.38.
|
||||
Building on Linux:
|
||||
==================
|
||||
|
||||
To cross compile on Linux you need to install Open Watcom 1.8 from
|
||||
www.openwatcom.org and NASM which is probably included in your
|
||||
distribution. You can then copy config.m to config.mak and adjust
|
||||
for the same reasons mentioned above.
|
||||
|
||||
Use the following commands:
|
||||
- to build:
|
||||
make all
|
||||
- to build, overriding a config.mak setting, e.g.:
|
||||
make all XCPU=386
|
||||
- to clean:
|
||||
make clean
|
||||
- to clobber (delete everything that was generated):
|
||||
make clobber
|
||||
|
||||
Notes:
|
||||
======
|
||||
The recommended compiler and assembler at the time of writing (2009/05/19)
|
||||
are OpenWatcom 1.8 and NASM 2.05.01.
|
||||
|
||||
You may need to download the latest version of NASM and a C compiler
|
||||
Be sure to edit the CONFIG.BAT file to reflect where you put the tools.
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
OBJS = floppy.obj rdpcclk.obj wrpcclk.obj wratclk.obj
|
||||
|
||||
LIBOBJS= +floppy +rdpcclk +wrpcclk +wratclk
|
||||
LIBOBJS= +floppy.obj +rdpcclk.obj +wrpcclk.obj +wratclk.obj
|
||||
|
||||
|
||||
|
||||
@ -32,13 +32,13 @@ LIBOBJS= +floppy +rdpcclk +wrpcclk +wratclk
|
||||
# -----------------
|
||||
all: production
|
||||
|
||||
production: ..\lib\device.lib
|
||||
production: ../lib/device.lib
|
||||
|
||||
..\lib\device.lib: device.lib
|
||||
copy device.lib ..\lib
|
||||
../lib/device.lib: device.lib
|
||||
$(CP) device.lib ..$(DIRSEP)lib
|
||||
|
||||
clobber: clean
|
||||
-$(RM) device.lib status.me ..\lib\device.lib
|
||||
-$(RM) device.lib status.me ..$(DIRSEP)lib$(DIRSEP)device.lib
|
||||
|
||||
clean:
|
||||
-$(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.cod *.err
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
!include "../mkfiles/generic.mak"
|
||||
|
||||
LIBS=..\lib\device.lib ..\lib\libm.lib
|
||||
LIBS=..$(DIRSEP)lib$(DIRSEP)device.lib ..$(DIRSEP)lib$(DIRSEP)libm.lib
|
||||
HDR=../hdr/
|
||||
|
||||
# *List Macros*
|
||||
@ -29,15 +29,15 @@ OBJS=$(OBJS1) $(OBJS2) $(OBJS3) $(OBJS4) $(OBJS5) $(OBJS6) $(OBJS7)
|
||||
|
||||
# *Explicit Rules*
|
||||
|
||||
production: ..\bin\$(TARGET).sys
|
||||
production: ../bin/$(TARGET).sys
|
||||
|
||||
..\bin\$(TARGET).sys: kernel.sys
|
||||
copy kernel.sys ..\bin
|
||||
copy kernel.sys ..\bin\$(TARGET).sys
|
||||
copy kernel.map ..\bin\$(TARGET).map
|
||||
../bin/$(TARGET).sys: kernel.sys
|
||||
$(CP) kernel.sys ..$(DIRSEP)bin
|
||||
$(CP) kernel.sys ..$(DIRSEP)bin$(DIRSEP)$(TARGET).sys
|
||||
$(CP) kernel.map ..$(DIRSEP)bin$(DIRSEP)$(TARGET).map
|
||||
|
||||
kernel.sys: kernel.exe ..\utils\exeflat.exe
|
||||
..\utils\exeflat kernel.exe kernel.sys 0x60 -S0x10 -S0x74 $(UPXOPT) $(XUPX)
|
||||
kernel.sys: kernel.exe ../utils/exeflat.exe
|
||||
..$(DIRSEP)utils$(DIRSEP)exeflat.exe kernel.exe kernel.sys 0x60 -S0x10 -S0x74 $(UPXOPT) $(XUPX)
|
||||
|
||||
kernel.exe: $(TARGET).lnk $(OBJS) $(LIBS)
|
||||
$(LINK) @$(TARGET).lnk;
|
||||
@ -51,9 +51,7 @@ clean:
|
||||
# XXX: This is a very ugly way of linking the kernel, forced upon us by the
|
||||
# inability of Turbo `make' 2.0 to perform command line redirection. -- ror4
|
||||
|
||||
ECHOTO=..\utils\echoto
|
||||
|
||||
$(TARGET).lnk: turboc.cfg makefile ..\mkfiles\generic.mak ..\mkfiles\$(COMPILER).mak
|
||||
$(TARGET).lnk: turboc.cfg makefile ../mkfiles/generic.mak ../mkfiles/$(COMPILER).mak
|
||||
-$(RM) *.lnk
|
||||
$(ECHOTO) $(TARGET).lnk $(OBJS1)+
|
||||
$(ECHOTO) $(TARGET).lnk $(OBJS2)+
|
||||
|
@ -38,6 +38,11 @@ CPU XCPU
|
||||
%endif
|
||||
%endif
|
||||
|
||||
; for OW on Linux:
|
||||
%ifdef owlinux
|
||||
%define WATCOM
|
||||
%endif
|
||||
|
||||
group PGROUP PSP
|
||||
group LGROUP _IRQTEXT _LOWTEXT _IO_TEXT _IO_FIXED_DATA _TEXT
|
||||
group DGROUP _FIXED_DATA _BSS _DATA _DATAEND CONST CONST2 DCONST DYN_DATA
|
||||
|
56
makefile
56
makefile
@ -1,9 +1,12 @@
|
||||
# IF NOTHING COMPILES, CHECK IF YOUR CVS CHECKOUT USES CORRECT DOS LINEBREAKS
|
||||
# What you WANT on DOS is:
|
||||
# EDIT CONFIG.B, COPY CONFIG.B to CONFIG.BAT, RUN BUILD.BAT
|
||||
# On Linux, use config.mak, and "make all", "make clean", or "make clobber"
|
||||
|
||||
# What you WANT is: EDIT CONFIG.B, COPY CONFIG.B to CONFIG.BAT, RUN BUILD.BAT
|
||||
# THIS file is provided only for people who have a habit of typing MAKE ALL...
|
||||
default:
|
||||
@echo On DOS, please type build, clean, or clobber.
|
||||
@echo On Linux, please type make all, make clean, or make clobber.
|
||||
|
||||
all:
|
||||
build:
|
||||
build
|
||||
|
||||
bin\kwc8616.sys:
|
||||
@ -54,3 +57,48 @@ zipfat32: bin\kwc8632.sys
|
||||
|
||||
zip: zip_src zipfat16 zipfat32
|
||||
|
||||
#Linux part
|
||||
#defaults: override using config.mak
|
||||
export
|
||||
COMPILER=owlinux
|
||||
|
||||
XCPU=86
|
||||
XFAT=32
|
||||
ifndef WATCOM
|
||||
WATCOM=$(HOME)/watcom
|
||||
PATH:=$(WATCOM)/binl:$(PATH)
|
||||
endif
|
||||
XUPX=upx --8086 --best
|
||||
XNASM=nasm
|
||||
MAKE=wmake -ms -h
|
||||
XLINK=wlink
|
||||
#ALLCFLAGS=-DDEBUG
|
||||
|
||||
-include config.mak
|
||||
ifdef XUPX
|
||||
UPXOPT=-U
|
||||
endif
|
||||
|
||||
all:
|
||||
cd utils && $(MAKE) production
|
||||
cd lib && touch libm.lib
|
||||
cd drivers && $(MAKE) production
|
||||
cd boot && $(MAKE) production
|
||||
cd sys && $(MAKE) production
|
||||
cd kernel && $(MAKE) production
|
||||
|
||||
clean:
|
||||
cd utils && $(MAKE) clean
|
||||
cd lib && $(MAKE) clean
|
||||
cd drivers && $(MAKE) clean
|
||||
cd boot && $(MAKE) clean
|
||||
cd sys && $(MAKE) clean
|
||||
cd kernel && $(MAKE) clean
|
||||
|
||||
clobber:
|
||||
cd utils && $(MAKE) clobber
|
||||
cd lib && $(MAKE) clobber
|
||||
cd drivers && $(MAKE) clobber
|
||||
cd boot && $(MAKE) clobber
|
||||
cd sys && $(MAKE) clobber
|
||||
cd kernel && $(MAKE) clobber
|
||||
|
@ -25,11 +25,20 @@ NASMFLAGS = $(NASMFLAGS) -i../hdr/ -DXCPU=$(XCPU)
|
||||
LINK=$(XLINK)
|
||||
|
||||
INITPATCH=@rem
|
||||
DIRSEP=\ #a backslash
|
||||
RM=..\utils\rmfiles
|
||||
CP=copy
|
||||
ECHOTO=..\utils\echoto
|
||||
CLDEF=0
|
||||
|
||||
!include "..\mkfiles\$(COMPILER).mak"
|
||||
!include "../mkfiles/$(COMPILER).mak"
|
||||
|
||||
!if $(CLDEF) == 0
|
||||
CLT=$(CL) $(CFLAGST) $(TINY) -I$(INCLUDEPATH)
|
||||
CLC=$(CL) $(CFLAGSC) -I$(INCLUDEPATH)
|
||||
!endif
|
||||
|
||||
TARGET=$(TARGET)$(XCPU)$(XFAT)
|
||||
RM=..\utils\rmfiles
|
||||
|
||||
.asm.obj :
|
||||
$(NASM) -D$(COMPILER) $(NASMFLAGS) -f obj $*.asm
|
||||
|
19
mkfiles/owlinux.mak
Normal file
19
mkfiles/owlinux.mak
Normal file
@ -0,0 +1,19 @@
|
||||
#
|
||||
# WATCOM.MAK - kernel compiler options for Open Watcom on Linux (cross-compile)
|
||||
#
|
||||
|
||||
# Get definitions from watcom.mak, then override
|
||||
include "../mkfiles/watcom.mak"
|
||||
|
||||
DIRSEP=/
|
||||
INCLUDEPATH=$(COMPILERPATH)/h
|
||||
RM=rm -f
|
||||
CP=cp
|
||||
ECHOTO=$#
|
||||
INITPATCH=@echo > /dev/null
|
||||
CLDEF=1
|
||||
CLT=gcc -DDOSC_TIME_H -I../hdr -o $@
|
||||
CLC=$(CLT)
|
||||
CFLAGST=-fo=.obj $(CFLAGST)
|
||||
ALLCFLAGS=-fo=.obj $(ALLCFLAGS)
|
||||
XLINK=$(XLINK) debug all op symfile format dos option map op statics F { $(OBJS) ../lib/device.lib } N kernel.exe $#
|
@ -61,7 +61,7 @@ MATH_INSERT=+i4m
|
||||
# -3 optimization for 386 - given in CONFIG.MAK, not here
|
||||
#
|
||||
|
||||
ALLCFLAGS=-I..\hdr $(TARGETOPT) $(ALLCFLAGS)-zq-os-s-e5-j-zl-zp1-wx-we-zgf-zff-r
|
||||
ALLCFLAGS=-I..$(DIRSEP)hdr $(TARGETOPT) $(ALLCFLAGS)-zq-os-s-e5-j-zl-zp1-wx-we-zgf-zff-r
|
||||
INITCFLAGS=$(ALLCFLAGS)-ntINIT_TEXT-gTGROUP-ndI
|
||||
CFLAGS=$(ALLCFLAGS)-ntHMA_TEXT
|
||||
|
||||
|
34
sys/makefile
34
sys/makefile
@ -6,7 +6,7 @@
|
||||
|
||||
!include "../mkfiles/generic.mak"
|
||||
|
||||
CFLAGS = -I$(INCLUDEPATH) -I..\hdr -DFORSYS -DWITHFAT32 $(CFLAGST)
|
||||
CFLAGS = -I$(INCLUDEPATH) -I..$(DIRSEP)hdr -DFORSYS -DWITHFAT32 $(CFLAGST)
|
||||
NASMFLAGS = -DSYS=1
|
||||
|
||||
# *List Macros*
|
||||
@ -18,30 +18,30 @@ SYS_EXE_dependencies = \
|
||||
talloc.obj
|
||||
|
||||
# *Explicit Rules*
|
||||
production: bin2c.com ..\bin\sys.com
|
||||
production: bin2c.com ../bin/sys.com
|
||||
|
||||
bin2c.com: bin2c.c
|
||||
$(CL) $(CFLAGS) $(TINY) bin2c.c
|
||||
$(CLT) bin2c.c
|
||||
|
||||
..\bin\sys.com: sys.com
|
||||
copy sys.com ..\bin
|
||||
../bin/sys.com: sys.com
|
||||
$(CP) sys.com ..$(DIRSEP)bin
|
||||
|
||||
fat12com.h: ..\boot\fat12com.bin bin2c.com
|
||||
.\bin2c ..\boot\fat12com.bin fat12com.h fat12com
|
||||
fat12com.h: ../boot/fat12com.bin bin2c.com
|
||||
.$(DIRSEP)bin2c.com ../boot/fat12com.bin fat12com.h fat12com
|
||||
|
||||
fat16com.h: ..\boot\fat16com.bin bin2c.com
|
||||
.\bin2c ..\boot\fat16com.bin fat16com.h fat16com
|
||||
fat16com.h: ../boot/fat16com.bin bin2c.com
|
||||
.$(DIRSEP)bin2c.com ../boot/fat16com.bin fat16com.h fat16com
|
||||
|
||||
fat32chs.h: ..\boot\fat32chs.bin bin2c.com
|
||||
.\bin2c ..\boot\fat32chs.bin fat32chs.h fat32chs
|
||||
fat32chs.h: ../boot/fat32chs.bin bin2c.com
|
||||
.$(DIRSEP)bin2c.com ../boot/fat32chs.bin fat32chs.h fat32chs
|
||||
|
||||
fat32lba.h: ..\boot\fat32lba.bin bin2c.com
|
||||
.\bin2c ..\boot\fat32lba.bin fat32lba.h fat32lba
|
||||
fat32lba.h: ../boot/fat32lba.bin bin2c.com
|
||||
.$(DIRSEP)bin2c.com ../boot/fat32lba.bin fat32lba.h fat32lba
|
||||
|
||||
prf.obj: ..\kernel\prf.c
|
||||
$(CC) $(CFLAGS) ..\kernel\prf.c
|
||||
prf.obj: ../kernel/prf.c
|
||||
$(CC) $(CFLAGS) ..$(DIRSEP)kernel$(DIRSEP)prf.c
|
||||
|
||||
fdkrncfg.obj: fdkrncfg.c ..\hdr\kconfig.h
|
||||
fdkrncfg.obj: fdkrncfg.c ../hdr/kconfig.h
|
||||
|
||||
talloc.obj: talloc.c
|
||||
|
||||
@ -55,6 +55,6 @@ clean:
|
||||
-$(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.las *.cod *.err status.me
|
||||
|
||||
# *Individual File Dependencies*
|
||||
sys.obj: sys.c ..\hdr\portab.h ..\hdr\device.h fat12com.h fat16com.h fat32chs.h fat32lba.h
|
||||
sys.obj: sys.c ../hdr/portab.h ../hdr/device.h fat12com.h fat16com.h fat32chs.h fat32lba.h
|
||||
$(CC) $(CFLAGS) $*.c
|
||||
|
||||
|
@ -416,7 +416,10 @@ int main(int argc, char **argv)
|
||||
len += n;
|
||||
}
|
||||
cmdbuf[len++] = ' ';
|
||||
cmdbuf[len++] = '\'';
|
||||
memcpy(cmdbuf + len, tmpexe, len2);
|
||||
cmdbuf[len + len2 - 1] = '\'';
|
||||
cmdbuf[len + len2] = '\0';
|
||||
printf("%s\n", cmdbuf);
|
||||
if (system(cmdbuf))
|
||||
{
|
||||
|
@ -1,14 +1,14 @@
|
||||
!include "../mkfiles/generic.mak"
|
||||
|
||||
CFLAGS = -I$(INCLUDEPATH) -I..\hdr
|
||||
CFLAGS = -I..$(DIRSEP)hdr
|
||||
|
||||
production: patchobj.com exeflat.exe
|
||||
|
||||
patchobj.com: patchobj.c
|
||||
$(CL) $(CFLAGST) $(TINY) $(CFLAGS) patchobj.c
|
||||
$(CLT) $(CFLAGS) patchobj.c
|
||||
|
||||
exeflat.exe: exeflat.c ../hdr/exe.h
|
||||
$(CL) $(CFLAGSC) $(CFLAGS) exeflat.c
|
||||
$(CLC) $(CFLAGS) exeflat.c
|
||||
|
||||
|
||||
clobber: clean
|
||||
|
Loading…
Reference in New Issue
Block a user