# Makefile for LibReadINI for GP2X/GP32
#
# David Skywalker aka D_Skywalk
# 
# http://david.dantoine.org
# dskywalk@gmail.com
# Jul-07-2006
#
# do "make RELEASE=TRUE" for no debug binaries
# do "make LINUX=TRUE" for linux binaries
# 
# 

ifdef LINUX
  prefix = /usr
else
  prefix = /opt/gp2x
  exe_prefix = $(prefix)/bin/arm-gp2x-linux-
endif

CC=$(exe_prefix)gcc

AR= $(exe_prefix)ar cru
RANLIB= $(exe_prefix)ranlib
LIBNAME= libReadINI.a

INCLUDES=  -I. 

# replace -O with -g in order to debug

DEFINES= $(INCLUDES) $(DEFS) 
#-DSYS_UNIX=1
CFLAGS_DEBUG= -g -ggdb -DDEBUG -Wall -pedantic

ifdef DEBUG
#rename it for debug compile
CFLAGS = $(CFLAGS_DEBUG) -O $(DEFINES)
else
#release compile
CFLAGS = -O3 $(DEFINES)
endif

SRCS = LibReadINI.c libbase.c
OBJS = LibReadINI.o libbase.o

.c.o:
	rm -f $@
	$(CC) $(CFLAGS) -c $*.c

all: $(LIBNAME)

$(LIBNAME): $(OBJS)
	rm -f $@
	$(AR) $@ $(OBJS)
	$(RANLIB) $@

clean:
	rm -f $(OBJS) $(LIBNAME) core test libbase.o

install:
	cp $(LIBNAME) $(prefix)/lib
	cp LibReadINI.h $(prefix)/include

test: 
	$(CC) $(CFLAGS) test.c -o test $(LIBNAME)

