compile only if .o older than .c .. for zcc

Requests for features
Post Reply
norecess
Member
Posts: 73
Joined: Thu Mar 20, 2008 12:58 am

compile only if .o older than .c .. for zcc

Post by norecess »

Hi,

z80asm has the nice -d switch which avoids to compile files which do not need to.

Would it be possible to add same feature to zcc C compiler ? that would save me some precious time while compiling :)

Thank you,
Arnaud
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

norecess wrote:z80asm has the nice -d switch which avoids to compile files which do not need to.

Would it be possible to add same feature to zcc C compiler ? that would save me some precious time while compiling :)
Need to save those precious seconds I guess :lol:

The first thought I have is this task is usually handled by make....
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

My thoughts are the same as Alvins; that this should be handled by make which can do proper dependency management, here's the makefile I used for zsock:

Code: Select all

TARGET   = +z88
#TARGET   = +cpm


CC       = zcc
CFLAGS   = -vn -DNETSTAT -DINACTIVETO=1200 -make-app -O3  -preserve
INCLUDES = -I. -I../include
LIBS     = -lnetdev -lmalloc
LDFLAGS  = 

SOURCES  := setup.c icmp.c ip.c udp.c tcp.c udp_dom.c  \
        handler_call.c net_utils.c loopback.c pbuf.c socket.c socket_int.c \
        pppset.c slip_dev.c z80.c time.c tcp_int.c ping.c lowlevel2.c device.c

ifeq (+z88,$(TARGET))
        SOURCES +=  config_read.c main.c app.c
        LDFLAGS = -create-app -nt
        LIBS += -lz88
endif

ifeq (+cpm,$(TARGET))
        SOURCES += unixmain.c
endif

ASMS      := $(SOURCES:.c=.opt)

all:    $(ASMS)
        $(CC) $(TARGET) $(LDFLAGS) -o zsock $(CFLAGS) $(ASMS) $(LIBS)



%.opt: %.c zsock.h
        $(CC) $(TARGET) $(CFLAGS) -a $(INCLUDES)  $<


clean:
        rm -f *.opt *~ zsock zsock.62 zsock.63 zcc_opt.def
Note the use of the -preserve flag - this prevents the zcc_opt.def from being deleted between unit compilations.

I'm unsure why I decided to create the final executable from .opt files rather than .o files however.
norecess
Member
Posts: 73
Joined: Thu Mar 20, 2008 12:58 am

Post by norecess »

Cool, I did the changes using a Make/MAKEFILE and now it works as expected - it only compiles when needed.

Anyway, would be nice for coherency to add that z80asm's -d switch to zcc :)

Thank you,
Arnaud
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

norecess wrote:Anyway, would be nice for coherency to add that z80asm's -d switch to zcc :)
heh heh. well z80asm's on the way out, although Gerton's probably done the same with mpm. Not sure why he would do such a thing given make is ubiquitous.
Post Reply