blob: 8332ef6a3818f657cc178f33aaad9ecba0b1f062 [file] [log] [blame]
#
# @(#)Program.gmk 1.1 97/09/07
#
# Generic makefile for building executables.
.PHONY: all optimized debug classes clean clobber
all: optimized debug
TSPROGRAM = $(PROGRAM:%=$(TSOBJDIR)/%)
DEBUG = $(BINDIR)/$(ARCH)/$(TSPROGRAM)_g $(BINDIR)/$(PROGRAM)_g
OPTIMIZED = $(BINDIR)/$(ARCH)/$(TSPROGRAM) $(BINDIR)/$(PROGRAM)
include $(TOPDIR)/build/$(PLATFORM)/makefiles/Rules.gmk
FILES_o = $(patsubst %.c,$(OBJDIR)/%.o,$(FILES_c))
FILES_o += $(patsubst %.s,$(OBJDIR)/%.o,$(FILES_s))
CLASSES.export = $(shell echo $(FILES_export) | \
sed "s:\.java::g" | sed "s:/:\.:g")
.PHONY : $(PROGRAM)_g $(PROGRAM)
$(PROGRAM)_g: debug
$(PROGRAM): optimized
# Make a generic link to the executable, for casual users
$(BINDIR)/$(ARCH)/$(TSPROGRAM)_g $(BINDIR)/$(ARCH)/$(TSPROGRAM) \
:: $(INIT) $(OBJDIR)/.program.dirs.$(ARCH) classes $(PROGRAM_HEADERS)
@true
$(BINDIR)/$(ARCH)/$(TSPROGRAM)_g $(BINDIR)/$(ARCH)/$(TSPROGRAM) \
:: $(FILES_o)
@set -- $?; \
echo Rebuilding $@ because of $$1 $$2 $$3 $$4 $$5 $$6 $${7:+...};
$(CC) $(LDFLAGS) $(FILES_o) $(LDLIBS) -o $(OBJDIR)/$(@F)
-(cp $(OBJDIR)/$(@F) $(BINDIR)/$(ARCH)/$(TSOBJDIR)/$(@F) \
&& echo "Copying" $(@F) "to" \
$(BINDIR)/$(ARCH)/$(TSOBJDIR)) 2>/dev/null
$(BINDIR)/$(PROGRAM)_g: $(BINDIR)/.java_wrapper .java_wrapper_local
rm -f $(BINDIR)/$(@F) ; ln -s .java_wrapper $(BINDIR)/$(@F)
rm -f $(@F) ; ln -s .java_wrapper_local $(@F)
$(BINDIR)/$(PROGRAM): $(BINDIR)/.java_wrapper .java_wrapper_local
rm -f $(BINDIR)/$(@F) ; ln -s .java_wrapper $(BINDIR)/$(@F)
rm -f $(@F) ; ln -s .java_wrapper_local $(@F)
$(BINDIR)/.java_wrapper: $(PLATFORM_SRC)/bin/java_wrapper.sh
rm -f $(BINDIR)/.java_wrapper
cp $(PLATFORM_SRC)/bin/java_wrapper.sh $(BINDIR)/.java_wrapper
chmod +x $(BINDIR)/.java_wrapper
.java_wrapper_local: $(PLATFORM_SRC)/bin/java_wrapper_local.sh
rm -f .java_wrapper_local
cp $(PLATFORM_SRC)/bin/java_wrapper_local.sh .java_wrapper_local
chmod +x .java_wrapper_local
$(OBJDIR)/.program.dirs.$(ARCH):
mkdir -p $(OBJDIRS) $(BINDIR)/$(ARCH)/$(TSOBJDIR) \
$(CLASSBINDIR)
-touch $(OBJDIR)/.program.dirs.$(ARCH)
$(PROGRAM_HEADERS): $(FILES_export:%.java=$(CLASSBINDIR)/%.class)
$(JAVAH) $(JAVAHFLAGS) -classpath $(CLASSPATH) -d $(CLASSHDRDIR)/ \
$(CLASSES.export)
@-touch $@
classstubs.c: $(FILES_export:%.java=$(CLASSBINDIR)/%.class)
$(JAVAH) $(JAVAHFLAGS) -classpath $(CLASSPATH) -o $@ \
-stubs $(CLASSES.export)
@-touch $@ # javah only writes file if changed
clean :: FORCE
rm -rf $(OBJROOTS)
rm -f classstubs.c .program*
clobber :: FORCE
rm -f $(OPTIMIZED) $(DEBUG) $(PROGRAM) $(PROGRAM)_g
rm -f .java_wrapper_local
#
# Now include make dependencies
#
files := $(foreach file, $(wildcard */$(ARCH)/$(TSOBJDIR)/*.d), $(file))
ifneq ($(strip $(files)),)
include $(files)
endif