#!make -f
#
# LDG : Gem Dynamical Libraries
# Copyright (c) 1997-2004 Olivier Landemarre, Dominique Bereziat & Arnaud Bercegeay
#
# Makefile for compiling the LDG CPX
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
#
# $Id$

# Pure C directory
#PURECDIR = /h/gemapps/devel/pure_c

ifeq ($(CROSS),yes)
CC      = m68k-atari-mint-gcc
else
CC      = gcc
endif

CFLAGS  = -I. -I../../include -I../share -DNOSTARTUP -DUSE_LDGLOAD
#STDLIB  = $(PURECLIB)/pcstdlib.lib $(PURECLIB)/pctoslib.lib
#GEMLIB  = $(PURECLIB)/gem.lib
LDLIBS  = -lldg -lgem 
LDFLAGS = -L../../lib/gcc
SPECIAL = -nostartfiles -Wl,--entry -Wl,_main

OBJECTS = main.o evnt.o funcs.o bubble.o utils.o internal.o
TARGET  = ../../cpx/ldg.cpx

all: cpxhdr $(TARGET)

$(TARGET): ldg.hdr ldg.cp; cat $^ > $@
ldg.hdr: ldg.rsc; ./cpxhdr $< $@
ldg.cp: $(OBJECTS)
	$(CC) $^ -o $@ $(SPECIAL) $(LDFLAGS) $(LDLIBS)

# Dependencies
internal.o: ../share/internal.c
main.o: global.h resource.h
evnt.o funcs.o bubble.o utils.o: global.h

# Compilation of cpxhdr (a tool to build CPX header)
cpxhdr: cpxhdr.o

# Generate a clean RSH resource from Interface output
resource.h: ldgcpx.rsh ldgcpx.rh
	sed -f rshconv.sed ldgcpx.rsh > resource.h && grep 'define' ldgcpx.rh >> resource.h

clean:; $(RM) $(OBJECTS) ldg.cp ldg.hdr resource.h
veryclean: clean; $(RM) cpxhdr cpxhdr.o

install:; cp ../../cpx/cpx.ldg /h/gemsys/cpx
