# simple smakefile

.c.o:
   sc $(CFLAGS) $<
   @ctags >tagfiles/$* $<


EXE = IPop
VER = 44
REV = 1

###############################################################################

C_SOURCE =  main.c arexx.c cx.c
HEADERS =   arexx.h arexx_cmds.h common.h protos.h system_headers.h

###############################################################################

CPU = 020

C_UTILITY = utillib
L_UTILITY = define __CXM33=__UCXM33 define __CXD33=__UCXD33 \
define __CXM22=__UCXM22 define __CXD22=__UCXD22

###############################################################################

#OPTIMIZE =  optimize opttime optschedule optdepth=10 optinlocal
OPTIMIZE =
#DEBUG = debug=symbolflush
DEBUG =  debug=line

INCLUDE = 
CFLAGS = params=r STRINGMERGE NOSTACKCHECK $(INCLUDE) \
IDLEN=64 STRINGSECTION=CODE GST=system_headers.gst VERBOSE $(OPTIMIZE) \
$(DEBUG) $(C_UTILITY)

LFLAGS = SMALLCODE SMALLDATA NOICONS $(L_UTILITY)

OBJS = main.o arexx.o cx.o

LIBS = lib:classact.lib lib:debug.lib

###############################################################################

####
# Rebuild the project
#
all: tagfiles system_headers.gst protos.h $(EXE) $(EXE)_rx.doc

$(EXE): $(OBJS)
   sc link TO $@.debug with <<
FROM $(OBJS) LIBRARY $(LIBS) $(LFLAGS) ADDSYM MAP MAPHUNK MAPXREFERENCE VERBOSE
<
   slink $@.debug to $@ noicons nodebug
   @type tagfiles/\#? >tags

####
# Delete all object files
#
clean:
   execute <<
   Echo "Removing object and executable files..."
   delete $(OBJS) $(EXE) all quiet
   Echo "Done."
<

####
# Bump the revision..
#
bumprev:
   bumprev2 version=$(VER) file=version TAG=$(EXE)
   setdate main.c
<

####
# Build autodoc
#
$(EXE)_rx.doc: $(EXE).rexx
   autodoc -C >$(EXE)_rx.doc $(EXE).rexx

####
# dependencies
#
main.o: main.c common.h version.h
arexx.o: arexx.c common.h
cx.o: cx.c common.h

###############################################################################

system_headers.gst: system_headers.h system_headers.c
        gst unload $@
        sc utillib nogst makegst=$@ noobjname system_headers.c

protos.h: $(C_SOURCE)
        mkptypes -c >protos.h $(C_SOURCE)

###############################################################################

tagfiles:
        makedir $@
