
# This is a compile kit to suggest how to port to your machine
#
# "config.h" MUST have at least 1 of the 2 below
#define HAVE_STDINT_H    1 /* uint*_t types must be defined */
#define HAVE_INTTYPES_H  1 /* this was an older way on some */

# without this it will default to a big-endian machine
#define JU_LITTLE_ENDIAN 1 /* intel, DEC processors         */

#define JU_NOINLINE      1 /* compilers no support inline   */

#define JU_BIT64         1 /* if it is a 64bit compile      */
# end of what is necessary for config.h

# Optimization
COPT='-O'

# Shared library option
#CPIC='-fPIC'
CPIC=''

# Common to Judy1 and JudyL
cd JudyCommon
cc -Wall $COPT $CPIC -I. -I.. -c JudyMalloc.c 
cc -Wall $COPT $CPIC -I. -I.. -c JudySearchLeaf.c
cd ..

# Compile the Judy1 routines
cd Judy1
ln -sf ../JudyCommon/JudyByCount.c      	Judy1ByCount.c   
ln -sf ../JudyCommon/JudyCascade.c      	Judy1Cascade.c
ln -sf ../JudyCommon/JudyCount.c        	Judy1Count.c
ln -sf ../JudyCommon/JudyCreateBranch.c 	Judy1CreateBranch.c
ln -sf ../JudyCommon/JudyDecascade.c    	Judy1Decascade.c
ln -sf ../JudyCommon/JudyDel.c          	Judy1Unset.c
ln -sf ../JudyCommon/JudyFirst.c        	Judy1First.c
ln -sf ../JudyCommon/JudyFreeArray.c    	Judy1FreeArray.c
ln -sf ../JudyCommon/JudyGet.c          	Judy1Test.c
ln -sf ../JudyCommon/JudyGet.c          	__Judy1Test.c
ln -sf ../JudyCommon/JudyInsArray.c     	Judy1SetArray.c
ln -sf ../JudyCommon/JudyIns.c          	Judy1Set.c
ln -sf ../JudyCommon/JudyInsertBranch.c 	Judy1InsertBranch.c
ln -sf ../JudyCommon/JudyMallocIF.c     	Judy1MallocIF.c
ln -sf ../JudyCommon/JudyMemActive.c    	Judy1MemActive.c
ln -sf ../JudyCommon/JudyMemUsed.c      	Judy1MemUsed.c
ln -sf ../JudyCommon/JudyPrevNext.c     	Judy1Next.c
ln -sf ../JudyCommon/JudyPrevNext.c     	Judy1Prev.c
ln -sf ../JudyCommon/JudyPrevNextEmpty.c	Judy1NextEmpty.c
ln -sf ../JudyCommon/JudyPrevNextEmpty.c	Judy1PrevEmpty.c
ln -sf ../JudyCommon/JudyTables.c	Judy1TablesGen.c

# This table is constructed from Judy1.h data to match malloc(3) needs
cc  -Wall -I.. -I../JudyCommon -DJUDY1 Judy1TablesGen.c -o Judy1TablesGen
rm -f Judy1TablesGen.o
./Judy1TablesGen > Judy1Tables.c
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDY1 Judy1Tables.c 

cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDY1 Judy1Test.c 
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDY1 -DJUDYGETINLINE __Judy1Test.c
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDY1 -DJU_COV_INLINES Judy1Set.c
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDY1  Judy1SetArray.c
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDY1  Judy1Unset.c
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDY1  Judy1First.c
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDY1 -DJUDYNEXT Judy1Next.c
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDY1 -DJUDYPREV Judy1Prev.c
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDY1 -DJUDYNEXT Judy1NextEmpty.c
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDY1 -DJUDYPREV Judy1PrevEmpty.c
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDY1 Judy1Count.c
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDY1 -DNOSMARTJBB -DNOSMARTJBU -DNOSMARTJLB Judy1ByCount.c
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDY1 Judy1FreeArray.c
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDY1 Judy1MemUsed.c
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDY1 Judy1MemActive.c
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDY1 Judy1Cascade.c
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDY1 Judy1Decascade.c
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDY1 Judy1CreateBranch.c
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDY1 Judy1InsertBranch.c
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDY1 Judy1MallocIF.c
cd ..

# Compile the JudyL routines
cd JudyL
ln -sf ../JudyCommon/JudyByCount.c      	JudyLByCount.c   
ln -sf ../JudyCommon/JudyCascade.c       JudyLCascade.c
ln -sf ../JudyCommon/JudyCount.c        	JudyLCount.c
ln -sf ../JudyCommon/JudyCreateBranch.c 	JudyLCreateBranch.c
ln -sf ../JudyCommon/JudyDecascade.c    	JudyLDecascade.c
ln -sf ../JudyCommon/JudyDel.c          	JudyLDel.c
ln -sf ../JudyCommon/JudyFirst.c        	JudyLFirst.c
ln -sf ../JudyCommon/JudyFreeArray.c    	JudyLFreeArray.c
ln -sf ../JudyCommon/JudyGet.c          	JudyLGet.c
ln -sf ../JudyCommon/JudyGet.c          	__JudyLGet.c
ln -sf ../JudyCommon/JudyInsArray.c     	JudyLInsArray.c
ln -sf ../JudyCommon/JudyIns.c          	JudyLIns.c
ln -sf ../JudyCommon/JudyInsertBranch.c 	JudyLInsertBranch.c
ln -sf ../JudyCommon/JudyMallocIF.c     	JudyLMallocIF.c
ln -sf ../JudyCommon/JudyMemActive.c    	JudyLMemActive.c
ln -sf ../JudyCommon/JudyMemUsed.c      	JudyLMemUsed.c
ln -sf ../JudyCommon/JudyPrevNext.c     	JudyLNext.c
ln -sf ../JudyCommon/JudyPrevNext.c     	JudyLPrev.c
ln -sf ../JudyCommon/JudyPrevNextEmpty.c	JudyLNextEmpty.c
ln -sf ../JudyCommon/JudyPrevNextEmpty.c	JudyLPrevEmpty.c
ln -sf ../JudyCommon/JudyTables.c	JudyLTablesGen.c

# This table is constructed from JudyL.h data to match malloc(3) needs
cc  -Wall -I.. -I../JudyCommon -DJUDYL JudyLTablesGen.c -o JudyLTablesGen
rm -f JudyLTablesGen.o
./JudyLTablesGen > JudyLTables.c
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDYL JudyLTables.c 

cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDYL JudyLGet.c
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDYL -DJUDYGETINLINE __JudyLGet.c
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDYL -DJU_COV_INLINES JudyLIns.c
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDYL JudyLInsArray.c
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDYL JudyLDel.c
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDYL JudyLFirst.c
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDYL -DJUDYNEXT JudyLNext.c
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDYL -DJUDYPREV JudyLPrev.c
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDYL -DJUDYNEXT JudyLNextEmpty.c
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDYL -DJUDYPREV JudyLPrevEmpty.c
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDYL JudyLCount.c
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDYL -DNOSMARTJBB -DNOSMARTJBU -DNOSMARTJLB JudyLByCount.c
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDYL JudyLFreeArray.c
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDYL JudyLMemUsed.c
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDYL JudyLMemActive.c
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDYL JudyLCascade.c
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDYL JudyLDecascade.c
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDYL JudyLCreateBranch.c
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDYL JudyLInsertBranch.c
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c -DJUDYL JudyLMallocIF.c
cd ..

# Compile the JudySL routines
cd JudySL
cc -Wall $COPT $CPIC -I.. -I../JudyCommon -c JudySL.c
cd ..

# Make a Judy shared library with CPIC='-fPIC' above
#ld -shared -o libJudy.so Judy*/*.o
#
#  -OR-
#
# Make a Judy static library 
ar -r libJudy.a Judy*/*.o

# This step makes Judy.h suitable for user programs
# -DHAVE_STDINT_H and -UHAVE_INTTYPES_h must be same as config.h
cc -Wall ../tool/unifdef.c -o unifdef
./unifdef -UJU_FLAVOR_DEBUG     \
          -UJU_FLAVOR_COV       \
          -DHAVE_STDINT_H       \
          -UHAVE_INTTYPES_H     \
         < Judy.h | grep -v '^#pragma' > Judy.h_user
echo Done
