Listing 5. Makefile

#/home/ptkatch/src/SERIAL/Makefile to build
# IBM JDK compliant library:
# libSerial.so - to configure serial ports
#
JAVAHOME=/usr/local/java/ibmjdk118
JAVABIN=$(JAVAHOME)/bin
JAVAC=$(JAVABIN)/javac
JAVAH=$(JAVABIN)/javah
JAVA=$(JAVABIN)/java
INCLUDE=$(JAVAHOME)/include
SRCDIR=pos
INSTDIR=/usr/local/lib
CLASS=LinuxSerial
SOURCE=$(SRCDIR)/$(CLASS).java
#DEBUG=DEBUG
DEBUG=RELEASE
CFLAGS=-g -O -Wall -fPIC -DHAVE_CONFIG_H -D$(DEBUG)\
    -shared -I $(INCLUDE) -I $(INCLUDE)/linux -I $\
    (INCLUDE)/genunix -I $(INCLUDE)/native_threads\
    -I $(SRCDIR)
.PHONY: runtest clean install all
all: lib$(CLASS).so
lib$(CLASS).so: lib$(CLASS).c $(SRCDIR)/\
$(SRCDIR)_$(CLASS).c\
  $(SRCDIR)/$(SRCDIR)_$(CLASS).h
    @echo building [email protected]
    gcc $(CFLAGS) $< $(SRCDIR)/$(SRCDIR)_$(CLASS).c\
    -o [email protected]
$(SRCDIR)/$(SRCDIR)_$(CLASS).c: $(SRCDIR)/\
$(CLASS).class
    @echo generating stubs
    $(JAVAH) -d $(SRCDIR) -stubs $(SRCDIR).$(CLASS)
$(SRCDIR)/$(SRCDIR)_$(CLASS).h: $(SRCDIR)/\
$(CLASS).class
    @echo generating header
    $(JAVAH) -d $(SRCDIR) $(SRCDIR).$(CLASS)
$(SRCDIR)/$(CLASS).class: $(SOURCE)
    @echo compiling $<
    $(JAVAC) -O $<
clean:
    @echo cleaning
    -rm -f lib$(CLASS).so $(SRCDIR)/\
$(SRCDIR)_$(CLASS).*\
    $(SRCDIR)/$(CLASS).class $(INSTDIR)/\
lib$(CLASS).so
install:
    cp lib$(CLASS).so $(INSTDIR)