######################################################### # Makefile for Deadlock Detector (dldet) # Requires GNU make! # pfh 10/2000 ######################################################### export # Figure out which operating system to build for OPSYS = $(shell uname -s) # Destinations BIN_DIR = . # Include directory INC_DIR = . # Destination for HTML-ized source WEB_DIR = . ######################################################### # Linux version ifeq ($(OPSYS), Linux) CC = gcc CC_FLAGS = -ggdb -g3 -pthread -Wall -O CC_INCLUDES = -I$(INC_DIR) CC_DEFINES = external_LIBS = -lpthread LINKER = gcc LINKER_FLAGS = -ggdb -g3 LINKER_ENTRY = CODETOHTML = code2html -lc CTOHFLAGS = MAKEDEP = makedepend endif ######################################################### # Solaris ifeq ($(OPSYS), SunOS) CC = cc CC_FLAGS = -xCC -Xa -g $(VFLAGS) CC_INCLUDES = -I$(INC_DIR) CC_DEFINES = -D_POSIX_C_SOURCE=199506L -D__EXTENSIONS__ -D_REENTRANT external_LIBS = -lm -lpthread -lposix4 -lc -lucb LINKER = cc LINKER_FLAGS = -z muldefs -L/usr/ucblib -R/usr/ucblib LINKER_ENTRY = CODETOHTML = code2html -lc CTOHFLAGS = MAKEDEP = makedepend endif ######################################################### # Irix 6.5 or greater, I think. ifeq ($(OPSYS), IRIX64) CC = cc CC_FLAGS = -n32 -mips3 -g -O2 CC_INCLUDES = -I$(INC_DIR) CC_DEFINES = external_LIBS = -lds -lpthread -lgen LINKER = cc LINKER_FLAGS = LINKER_ENTRY = CODETOHTML = code2html -lc CTOHFLAGS = MAKEDEP = makedepend endif ######################################################### # OS-common stuff follows ######################################################### ######################################################### # List of object files OBJECTS = dldet.o # Convert to list of source files SOURCE = $(OBJECTS:.o=.c) # Convert to basename + html, eg dldet.html HTML = $(SOURCE:.c=.html) # Emacs tag file TAGS = TAGS # Final target TARGET = dldet ######################################################### # Build targets default-build: depend $(TARGET) all: depend $(TARGET) web # Cleanup target # Note that leading dash means ignore return code of rm clean: @echo "Cleaning up" -rm -f $(TARGET) -rm -f core -rm -f $(OBJECTS) -rm -f $(TAGS) -rm -f $(HTML) # end build targets ######################################################### # Rulesets, new (GNU) syntax # %.o : %.c $(CC) -c $< $(CC_FLAGS) $(CC_DEFINES) $(CC_INCLUDES) $(WEB_DIR)/%.html: %.c -$(CODETOHTML) $(CTOHFLAGS) $< $(WEB_DIR)/$(basename $< ).html ######################################################### # # Build rules/dependencies # $(client): $(OBJECTS) $(LINKER) -o $(TARGET) $(LINKER_ENTRY) $(LINKER_FLAGS) \ $(external_LIBS) $(OBJECTS) # Make etags for Emacs fans; ignore errors if not installed $(TAGS): $(SOURCE) -etags $(SOURCE) # Web (HTML-ized code) target is just a dependency, work done by above rules web: $(SOURCE) # Auto-dependency checking - perhaps should ignore return code? # Hmm. Makedepend is Hardwired for C. Hmm. depend: $(MAKEDEP) -- $(CC_FLAGS) -- $(CC_INCLUDES) $(SOURCE)