# Makefile for CLISP module set pcre

srcdir = .
CC = gcc
PCRECPPFLAGS = -I/usr/pkg/include -I/usr/include
CFLAGS = -O2 -fno-builtin-calloc -fno-builtin-malloc -fno-builtin-memalign -fno-builtin-realloc -fno-builtin-valloc -fno-builtin-free -I/usr/pkg/include -I/usr/include -I/usr/pkg/include/glib-2.0 -I/usr/pkg/include/gio-unix-2.0 -I/usr/pkg/lib/glib-2.0/include -Dz_off_t=long -W -Wswitch -Wcomment -Wpointer-arith -Wimplicit -Wreturn-type -Wmissing-declarations -O -DNO_SINGLEMAP -DNO_TRIVIALMAP -DENABLE_UNICODE -DDYNAMIC_FFI -DDYNAMIC_MODULES -I. -fPIC
CLISP = /usr/pkg/bin/clisp -norc -q
CLISP_LINKKIT = /usr/pkg/lib/clisp/linkkit

LN = ln
LN_S = ln -s

MAKE = make

SHELL = /bin/sh

GENERATED = pcre.fas cpcre.o preload.lisp
DISTRIBFILES = link.sh Makefile $(GENERATED) $(srcdir)/pcre.lisp
distribdir =

# default target: make the module
clisp-module : $(GENERATED)

pcre.fas: $(srcdir)/pcre.lisp
	$(CLISP) -c $(srcdir)/pcre.lisp -o ./

cpcre.o : cpcre.m.c config.h
	$(CC) $(CPPFLAGS) $(PCRECPPFLAGS) $(CFLAGS) -I$(CLISP_LINKKIT) \
		-c cpcre.m.c -o cpcre.o

cpcre.m.c : $(srcdir)/cpcre.c
	$(CLISP) -C $(CLISP_LINKKIT)/modprep $(srcdir)/cpcre.c ./

preload.lisp : $(srcdir)/preload.lisp
	$(LN_S) $(srcdir)/preload.lisp .

# Make a module distribution into $(distribdir)
clisp-module-distrib : clisp-module force
	$(LN) $(DISTRIBFILES) $(distribdir)

clean : force
	rm -f core *.o *.a *.m.c *.fas *.lib

distclean : clean

force :

