#!/bin/sh
# $id: $

# Makefile for SCSM.
# Created by Liang Hongbin, 2003-09-25

CC = gcc
CFLAGS=-D_REENTRANT -g -Wall
oldincludedir = /usr/include
M_COMPILE.c=$(CC) $(CFLAGS)
M_LINK.c=$(CC) $(CFLAGS)
COMPILE.c=$(CC) $(CFLAGS) 
LINK.c=$(CC) $(CFLAGS)


LIB_OBJ = comfunc.o daemon.o debug.o error.o errorlog.o ppsfun.o iofunc.o ipcfunc.o logfunc.o queuefunc.o signal.o time.o version.o 


all : CHECK $(LIB_OBJ)
	ar r libppsfuns.a $(LIB_OBJ)

comfunc.o:comfunc.c
	$(M_COMPILE.c) -c comfunc.c
	
daemon.o:daemon.c
	$(M_COMPILE.c) -c daemon.c
		
debug.o:debug.c
	$(M_COMPILE.c) -c debug.c

error.o:error.c
	$(M_COMPILE.c) -c error.c

errorlog.o:errorlog.c
	$(M_COMPILE.c) -c errorlog.c

ppsfun.o:ppsfun.c
	$(M_COMPILE.c) -c ppsfun.c

iofunc.o:iofunc.c
	$(M_COMPILE.c) -c iofunc.c

ipcufnc.o:ipcfunc.c
	$(M_COMPILE.c) -c ipcfunc.c

logfunc.o:logfunc.c
	$(M_COMPILE.c) -c logfunc.c

queuefunc.o:queuefunc.c
	$(M_COMPILE.c) -c queuefunc.c

signal.o:signal.c
	$(M_COMPILE.c) -c signal.c

time.o:time.c
	$(M_COMPILE.c) -c time.c

version.o:version.c
	$(M_COMPILE.c) -c version.c

.SUFFIXES:
.SUFFIXES: .c .o

CHECK:
	@echo "Using FLAGS = $(CFLAGS)"
	@echo "Using LIBS = $(LIB_FLAGS)"


MAKEDIR = || exec false; \
	  if test -d "$$dir"; then :; else \
	  echo mkdir "$$dir"; \
	  mkdir -p "$$dir" >/dev/null 2>&1 || \
	  test -d "$$dir" || \
	  mkdir "$$dir" || \
	  exec false; fi || exec false

.c.o: # .deps/.dummy
	@if (: >> $@ || : > $@) >/dev/null 2>&1; then rm -f $@; else \
	 dir=`echo $@ | sed 's,/[^/]*$$,,;s,^$$,.,'` $(MAKEDIR); fi
#	@if (: >> .deps/$@ || : > .deps/$@) >/dev/null 2>&1; then :; \
#	 else dir=.deps/`echo $@ | sed 's,/[^/]*$$,,;s,^$$,.,'` \
#	      $(MAKEDIR); fi; rm -f .deps/$@ .deps/$@d
	@echo Compiling $*.c
	@$(CC) -I. $(CFLAGS) $(INCLUDE_FLAGS) -c $< \
	  -o $@ # -Wp,-MD,.deps/$@
clean:
	-rm -f core *.o *.c~ *.h~ *.a

#	cd mapp;make clean;cd ..
#	cd capp;make clean;cd ..

