#*******************************************************************
# uLan Communication - Makefile for uLan library compilation
#
#
# (C) Copyright 2001 by Pavel Pisa - Originator
#
# The uLan driver is distributed under the Gnu General Public License. 
# See file COPYING for details.
#
# Originator reserve the right to use and publish sources
# under different conditions too. If third party contributors
# do not accept this condition, they can delete this statement
# and only GNU license will apply.
#*******************************************************************

all : default

default : library tests

.PHONY : depend

# Select compiler
CC=gcc

# Basic compilation flags
CFLAGS += -Wall -Wstrict-prototypes 
CFLAGS += -O2
CFLAGS += -I.
CFLAGS += -ggdb
#CFLAGS += -pg
#CFLAGS += -std=c99
#CFLAGS += -std=gnu99 -DWITH_C99

# CFLAGS for the uLan library
# note: some macro expansions require at least -O
LCFLAGS=  $(CFLAGS)
LCFLAGS+= $(CPUFLAGS)
# uncomment the next line if you want a shared library
# LIB_SHARED = 1
#LCFLAGS += -pg

#LDFLAGS += -pg

LIB_OBJS = ul_gsa.lo ul_gsacust.lo ul_gavlprim.lo ul_gavl.lo 
LIB_OBJS += ul_htimer.lo ul_htimbase.lo ul_htimmstime.lo 
LIB_OBJS += ul_hptree.lo
LIB_OBJS += ul_dbufbase.lo ul_dbufmore.lo 
LIB_OBJS += ul_evcbase.lo

# DJGPP = 1

ifndef LIB_SHARED

LIBULUT = libulut.a

%.lo: %.c
	$(CC) -o $@ $(LCFLAGS) -c $<

$(LIBULUT): $(LIB_OBJS)
	ar rcs $(LIBULUT) $^
	ranlib $(LIBULUT)

else

%.lo: %.c
	$(CC) --shared -o $@ $(LCFLAGS) -c $<

LIBULUT = libulut.so.0.0.4

$(LIBULUT): $(LIB_OBJS)
	ld --shared --soname=$(LIBULUT) -o $(LIBULUT) $^
	ln -s -f $(LIBULUT) libulan.so

endif

library: $(LIBULUT)

.SUFFIXES: .i .s
%.c : %.i
	$(CC) -E $(CFLAGS) $< >$@

%.c : %.s
	$(CC) -S $(CFLAGS) $<

dep:
	$(CC) $(CFLAGS) $(CPPFLAGS) -w -E -M *.c $(MORE_C_FILES) | \
	sed 's/^\([^:]*\)\.o *:/\1.o \1.lo:/g' > depend

depend:
	@touch depend

clean :
	rm -f depend *.o *.lo *~ *.a *.so *.so.* ul_gavlchk ul_htimchk ul_gsachk test

tests: ul_gsachk ul_gavlchk ul_htimchk

ul_gavlchk: ul_gavlchk.o libulut.a

ul_htimchk: ul_htimchk.o libulut.a

ul_gsachk: ul_gsachk.o libulut.a

-include depend
