# makefile for ogdspl
# (display process for ogrcvr)


# The current directory is passed to sub-makes as argument
PWD := $(shell pwd)


#  which machine are we running on?
host-name := $(shell hostname)

#  program version

#  PRGVER = ${VERSION}.${PATCHLEVEL}.${SUBLEVEL}

OGR_DEF := -DPCIBOARD=$(is_pci_board) -DCHECK_CORR_OUTPUT=$(check_corr_output) \
    -DPROGRAMVERSION=\"$(OPENGPSRELEASE)\"

# compiler & linker

CC := gcc
LD := ld


# it is assumed that these directories exist 
# and point to the correct set of header files ...

LINUX_HDR := /usr/src/kernel-headers-`uname -r`/include
RTAI_HDR  := /usr/realtime/include

OGR_HDR   := ../include

BINDIR    := ../../bin
LIBDIR    := ../../lib

# compiler flags
# (-Wuninitialized not supported without -O)

WARN       := -W -Wall -Wstrict-prototypes -Wmissing-prototypes \
   -Wno-trigraphs -Wunused

#  WARNMOD    := -W -Wstrict-prototypes -Wmissing-prototypes \
#   -Wno-trigraphs -Wunused-variable

# include directories

INCLUDE    := -I${RTAI_HDR} -I${LINUX_HDR} -I${OGR_HDR} 

#  INCLUDEMOD := -isystem ${RTAI_HDR} -isystem ${LINUX_HDR} -I${OGR_HDR}

CFLAGS       := -g ${INCLUDE} ${WARN} -fomit-frame-pointer \
    -fno-strict-aliasing -fno-common -pipe ${OGR_DEF}

#  EXTRA_CFLAGS := -I/usr/realtime/include -I/usr/include/ -ffast-math -mhard-float

LDFLAGS      := -L${LIBDIR}

# rules

all: ${BINDIR}/ogdspl

SRC := $(wildcard *.c)

.depend: $(SRC)
	  $(RM) $@
	  gcc -MM $(CFLAGS) $(SRC) > $@

.PHONY: clean

include .depend

objects := $(patsubst %.c,%.o,$(wildcard *.c))
     
${BINDIR}/ogdspl : $(objects) ${LIBDIR}/libopengps.a
	${CC} ${CFLAGS} ${LDFLAGS} -o ${BINDIR}/ogdspl $(objects) -lm -lopengps

clean:
	  $(RM) -r *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions
	  $(RM) ${BINDIR}/ogdspl

# end of makefile

