搜尋此網誌

2013年11月6日 星期三

Watcom C makefile example

###########################################################################
#makefile_test
###########################################################################
PROJECTNAME = test_project
OUTPUTNAME = run

#which memory model and processor to use by default
#PROCESSOR =     # for the 16-bit compilers
#PROCESSOR = 386 # for the 32-bit compilers
DEBUG = true
REPORT = true

# name the compiler
CC = wcc$(PROCESSOR)
FC = wfc$(PROCESSOR)
ASM = wasm

!ifeq PROCESSOR 386
MODEL = f       # flat
OS = dos4g
!else
MODEL = h       # large
OS = dos
!endif

CFLAGS = -m$(MODEL) -zq -3
CFLAGS+= -d_DOS_
#CFLAGS+= -wcd=135
#CFLAGS+= -wcd=135 -fpc
CFLAGS+= -fp3 #hardware float
#CFLAGS+= -zdp

LISTOPT = echo $^&
FFLAGS = -m$(MODEL) -noterm -quiet
AFLAGS =
LNKOPT = option quiet option stack=8192

# options to use
!ifeq DEBUG true
CFLAGS+= -od -d2 -db+
#CFLAGS+= -v
CFLAGS+= -wx
LNKOPT+= debug all
LNKOPT+= option map
#else
CFLAGS+= -s
!endif

!ifeq REPORT true
LISTOPT = wdis $^& -s -l=$^&.lst# -a
#LISTOPT+= -s=$^&.c
!endif

!ifeq OS dos
CFLAGS+= -bt=dos
!endif

.EXTENSIONS:
.EXTENSIONS: .exe .rex .lib .obj .wbj .asm .c .for

.BEFORE
        @set INCLUDE=.;$(%watcom)\h;$(%watcom)\h\win
        @set LIB=.;$(%watcom)\lib286;$(%watcom)\lib286\dos
        @set FINCLUDE=$(%watcom)\src\fortran;$(%watcom)\src\fortran\dos
        @set DOS4G=QUIET

S =
OBJS = main.obj
OBJS+= asmlib.obj
OBJS+= tool.obj
OBJS+= funs.obj
OBJS+= mmio.obj
OBJS+= test.obj

# explicit rules

all :   clean $(OUTPUTNAME).exe .SYMBOLIC
        #copy $(OUTPUTNAME).exe  t1.exe
        @%null

$(OUTPUTNAME).exe : .PRECIOUS $(OBJS)
                @echo file > (PROJECTNAME).lnk
                @for %i in ($(OBJS)) do @echo %i, >> (PROJECTNAME).lnk
        wlink $(LNKOPT) system $(OS) name $(OUTPUTNAME) @(PROJECTNAME).lnk
        @del (PROJECTNAME).lnk


run_all:    .SYMBOLIC
        %make run_mix

clean : .SYMBOLIC
        del *.obj /s
        del *.wbj /s
        del *.rex /s
        del *.exp /s
        del *.lst /s
       

# implicit rules

.c.obj :
        $(CC) $^& $(CFLAGS)
        $(LISTOPT)

.c.wbj :
        $(CC) $^& $(CFLAGS) -zw -fo=$^&.wbj

.for.obj :
        $(FC) $^& $(FFLAGS)

.asm.obj :
        $(ASM) $(AFLAGS) $^&
###########################################################################

Building command>> wmake -f makefile_test /a DEBUG=%DEBUG% PROCESSOR=%PROCESSOR%

沒有留言:

張貼留言