
#
# MAKEFILE for Rigal in C, version 4.45.1
#

# C compiler to use (Compiler path can be changed by the user)
CCFLAGS = -g -D LE -m32 -I/usr/include/malloc/
PCA =  cc $(CCFLAGS) -D STATIC_CCFLAGS='"$(CCFLAGS)"' -c -D xsun=1 -I../include/
# Specify -DLE for Little-endian architectures (Big-endian is default)!
# Specify -Dbbs for BBS-version of scaner (LaTeX version is default)!

LIBS = -lm
# This is for sin, cos, sqrt etc.

#  Other things are usually not changed by the user
.INIT:  check$(rig)

# -------------------------------------------------
#  MACRO DEFINITIONS
# -----------------------------------------------
# Object files for "rc"
RCF_SRC = defsun3.o ley_.o nef2.o ou2.o  sevice.o
# They are in src/ subdirectory

# Object files for "ic"
ICF_SRC = cim.o defsun3.o erm.o ic.o ley_.o scan.o scanmif.o usemod.o nef2.o ou2.o sevice.o


# Object files for "rc -c" (library)
CCF_SRC = defsun3.o ley_.o scan.o scanmif.o usemod.o c1.o c2.o c3.o c4.o nef2.o ou2.o sevice.o


DISTLIB =  defsun3.c ley_.c scan.c scanmif.c usemod.c c1.c c2.c c3.c c4.c nef2.c ou2.c sevice.c

# All include files
INCLIB_SRC = ../include/c1.h ../include/define.h  \
 ../include/defpage.h ../include/ley.h \
 ../include/scan.h ../include/cim.h \
 ../include/def180.h   ../include/nef2.h\
 ../include/usemod.h   ../include/globrig.h

#--------------------------------------------------------
# TARGET DEFINITIONS
#---------------------------------------------------------

# Normally builds all necessary after unpack and performs test.
normal:   bins ../lib/riglib.a ../bin/anrig ../bin/genrigd ../bin/rig_lint test clean

bins:     bin ../bin/rc ../bin/ic ../bin/v
bin:
	-mkdir ../bin
../bin/rc:$(RCF_SRC) rc_.o
	cc $(CCFLAGS)  -o ../bin/rc rc_.o $(RCF_SRC)

../bin/ic:$(ICF_SRC)
	cc  $(CCFLAGS) -o ../bin/ic    $(ICF_SRC) $(LIBS)


../bin/v:$(RCF_SRC) v.o
	cc  $(CCFLAGS) -o ../bin/v  v.o  $(RCF_SRC) $(LIBS)

../lib/riglib.a:$(CCF_SRC)
	@echo '*Starting creating library'
	-mkdir ../lib
	-rm -f ../lib/riglib.a
	ar rv ../lib/riglib.a $(CCF_SRC)
	-ranlib ../lib/riglib.a
	@echo '*Library created'

../bin/anrig:$(INCLIB_SRC) ../lib/riglib.a
	cc  $(CCFLAGS) -w \
	 -Ianrig/ -I../include/\
	 anrig/xcrg.c  anrig/xcrg_0.c\
	 anrig/xcrg_1.c\
	 anrig/xcrg_2.c\
	 anrig/xcrg_3.c\
	 anrig/xcrg_4.c\
	 anrig/xcrg_5.c\
	 anrig/xcrg_6.c\
	 anrig/xcrg_7.c\
	 anrig/xcrg_8.c\
	 anrig/xcrg_9.c\
	 -o ../bin/anrig ../lib/riglib.a $(LIBS)
	-rm -f anrig/*.o

../bin/genrigd:$(INCLIB_SRC) ../lib/riglib.a
	cc  $(CCFLAGS) -w \
	 -Igenrig/ -I../include/\
	 genrig/xcrg.c\
	 genrig/xcrg_1.c\
	 genrig/xcrg_2.c\
	 genrig/xcrg_3.c\
	 genrig/xcrg_4.c\
	 genrig/xcrg_5.c\
	 genrig/xcrg_6.c\
	 genrig/xcrg_7.c\
	 genrig/xcrg_8.c\
	 genrig/xcrg_9.c\
	 genrig/xcrg_10.c\
	 -o ../bin/genrigd ../lib/riglib.a $(LIBS)
	-rm -f genrig/*.o

../bin/rig_lint: ../lint/rig_lint.rig ../bin/rc ../lib/riglib.a ../bin/anrig ../bin/genrigd
	(cd ../lint;../bin/rc rig_lint -c -P '-O';cd ..)
	-mv ../lint/rig_lint ../bin/

test: ../test/rigcrf.rig  ../bin/rc ../lib/riglib.a ../bin/anrig ../bin/genrigd
	(cd ../test;\
	 $(rig)/rc rigcrf;\
	 $(rig)/ic rigcrf rigcrf;\
	 $(rig)/rc  rigcrf -c;\
	 rigcrf rigcrf)

##------------------ Hidden possibilities
z:       anrigz genrigz
anrigz:
	(cd anrig;\
	 ../../bin/rc anrig;\
	 ../../bin/anrig;\
         ../../bin/genrigd S -p N.TMP;\
	 /bin/rm *.RC2 *.RC4 *.TMP)

genrigz:
	(cd genrig;\
	 ../../bin/rc genrigd;\
	 ../../bin/anrig;\
         ../../bin/genrigd S -p N.TMP;\
	 /bin/rm *.RC2 *.RC4 *.TMP)
##---------------------------------------
VERSION = 446
tar:	clean
	-rm -f ../rigsc.$(VERSION).tar.Z
	(cd ..;tar -cvf rigsc.$(VERSION).tar include src examples lint doc test)
	compress ../rigsc.$(VERSION).tar
	cp ../rigsc.$(VERSION).tar.Z /info/ftp/pub/labs/pelab/rigal/
##--------------------------------------
clean:
	mv ../test/rigcrf.rig .
	-rm -f *.o */*.o  *.RC2 */*.RC2  *.RC4 */*.RC4    */*.rsc  ../lint/*.o ../lint/*.RC2 ../lint/*.RC4  \
	 ../examples/hanoi ../*/*.rsc ../*/*.out ../*/*/*.out ../test/*
	mv rigcrf.rig ../test/
##--------------------------------------
.c.o:   $(INCLIB_SRC)
	$(PCA) $< -o $@
check:
	@echo '********************************************************'
	@echo '*' User ERROR: you have not set \"rig\" environment variable to $(PWD)/../bin
	@echo '********************************************************'
	____FATAL___ERROR___
check$(rig):
	@echo VARIABLE rig have been set to $(rig)
	@echo ---------------------------------------
##----------------------------------------
# Prepare distribution
mkdist$(RFILE)$(RDIR):
	@echo '*** to prepare for distribution write make mkdist RFILE=fff RDIR=/u/vaden/xyz/xyz/'
mkdist:
	(cd $(RDIR);\
	$(rig)/rc $(RFILE);\
	$(rig)/anrig;\
	$(rig)/genrigd S -p N.TMP;\
	/bin/rm *.RC2 *.RC4 *.TMP)
	cp ../include/*  $(RDIR)
	cp $(DISTLIB) $(RDIR)
	(cd $(RDIR);\
	echo 'cc -O  -w  -D xsun=1 ' $(DISTLIB) ' xc*.c -o ' $(RFILE) $(LIBS)   > cmd)
mkdist2:
	(cd 	$(RDIR);\
	cc -O -w -D xsun=1  $(DISTLIB)  xc*.c -o $(RFILE) $(LIBS)  ;/bin/rm *.o)
