# Generic GNU Makefile # Version 2.21 # # Mark Allman (mallman@ir.bbn.com) # BBN Technologies/NASA GRC # # Last Updated: Fri Apr 5, 2002 # General variables... CC := gcc CFLAGS := -g CCC := g++ CCFLAGS := $(CFLAGS) YACC := yacc YFLAGS := LEX := lex LFLAGS := PC := pc PFLAGS := -g FC := f77 FFLAGS := -g AS := $(CC) ASFLAGS := -g -c JAVACC := gcj JAVAFLAGS := -g JLIBS := LD := $(CC) EXE := a.out # Find all source files... CSRCS := $(notdir $(wildcard *.[cs])) CCSRCS := $(notdir $(wildcard *.cc)) PSRCS := $(notdir $(wildcard *.p)) FSRCS := $(notdir $(wildcard *.f)) JSRCS := $(notdir $(wildcard *.java)) YSRCS := $(notdir $(wildcard *.y)) ifneq ($(strip $(YSRCS)),) ODD_OBJS += y.tab.o endif LSRCS := $(notdir $(wildcard *.l)) ifneq ($(strip $(LSRCS)),) ODD_OBJS += lex.yy.o endif SOURCES := $(CSRCS) $(CCSRCS) $(PSRCS) $(FSRCS) OBJECTS := $(ODD_OBJS) $(addsuffix .o, $(basename $(SOURCES))) JCLASS := $(addsuffix .class, $(basename $(JSRCS))) JCLASS_ALL := $(addsuffix *.class, $(basename $(JSRCS))) # Include needed libraries... LIBS := -lm ifneq ($(strip $(PSRCS)),) LIBS += -lp endif ifneq ($(strip $(FSRCS)),) LIBS += -lf2c endif ifneq ($(strip $(CCSRCS)),) LIBS += -lg++ endif ifneq ($(strip $(LSRCS)),) LIBS += -ll endif ARCH := $(shell uname) ifeq ($(ARCH),SunOS) VERS := $(shell uname -r) ifeq ($(basename $(VERS)),5) LIBS += -L/usr/ucblib -lsocket -lnsl -lelf -lucb endif endif ifeq ($(ARCH),FreeBSD) JLIBS += -pthread endif # Determine what output we need to generate... TODO := ifneq ($(strip $(OBJECTS)),) TODO += standard endif ifneq ($(strip $(JCLASS)),) TODO += javabin MAIN := $(shell jv-scan --print-main *.java) endif default: $(TODO) # Compile a binary from a bunch of non-java sources. standard: $(OBJECTS) $(LD) $(CFLAGS) $(OBJECTS) -o $(EXE) $(LIBS) # Compile to byte-code... javabin: $(JCLASS) $(JAVACC) -o $(EXE) --main=$(MAIN) $(JCLASS) $(JLIBS) %.class: %.java $(JAVACC) -C $(JAVAFLAGS) $< # Lex/Yacc Rules... y.tab.o: y.tab.c $(CC) -c y.tab.c y.tab.c: $(YSRCS) $(YACC) -dvt $(YFLAGS) $< lex.yy.c: $(LSRCS) $(LEX) $(LFLAGS) $< # Cleaning rules... clean: rm -f $(OBJECTS) $(JCLASS_ALL) lex.yy.c y.tab.c y.tab.h y.output core clobber: clean rm -f $(EXE)