# ----------------------------------------------------------------------- # Makefile for curses user interface programs on eisfair # # Creation : 13.03.2004 # Last Modified: $Id$ # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # ---------------------------------------------------------------------- # ---------------------------------------------------------------------- # Tool settings # ---------------------------------------------------------------------- # Tools SHELL = @SHELL@ CC = @CC@ FLEX = @LEX@ SED = @SED@ # compile options CFLAGS = -Wall -Wextra -Wstrict-prototypes CFLAGS += -Wno-unused-function CFLAGS += -Wno-sign-compare CFLAGS += -D_XOPEN_SOURCE_EXTENDED CFLAGS += -D_GNU_SOURCE CFLAGS += @DEFS@ CFLAGS += -fPIC DBGFLAGS = -g # linker LDFLAGS = @CURSES_LIB@ -ldl # definitions TARGET = @PACKAGE_NAME@ VERSION = @PACKAGE_VERSION@ MAJOR_VER = $(firstword $(subst ., ,@PACKAGE_VERSION@)) prefix = @prefix@ exec_prefix = @exec_prefix@ INSTALLLIBDIR = @libdir@/cui-addons INSTALLINCDIR = @includedir@ DBG_DIR = Debug REL_DIR = Release BASE_DIR = . # ---------------------------------------------------------------------- # Objetcs to build # ---------------------------------------------------------------------- # files for libcui CUI_SOURCES = libmain.c CUI_SOURCES += chartools.c CUI_SOURCES += eisman.c CUI_SOURCES += eisman_api.c # targets DBG_CUI_OBJECTS := $(addprefix $(DBG_DIR)/,$(subst /,!,$(CUI_SOURCES:.c=.o))) REL_CUI_OBJECTS := $(addprefix $(REL_DIR)/,$(subst /,!,$(CUI_SOURCES:.c=.o))) # ---------------------------------------------------------------------- # Rules # ---------------------------------------------------------------------- # compile targets all: release release: $(REL_DIR)/$(TARGET).so.$(VERSION) release: $(REL_DIR)/$(TARGET).a debug: $(DBG_DIR)/$(TARGET).so.$(VERSION) debug: $(DBG_DIR)/$(TARGET).a $(REL_DIR)/$(TARGET).so.$(VERSION): $(REL_CUI_OBJECTS) @echo "linking $@ ..." @$(CC) -shared -Wl,-soname,$(TARGET).so.$(MAJOR_VER) -o $@ $^ $(LDFLAGS) $(DBG_DIR)/$(TARGET).so.$(VERSION): $(DBG_CUI_OBJECTS) @echo "linking $@ ..." @$(CC) -shared -Wl,-soname,$(TARGET).so.$(MAJOR_VER) -o $@ $^ $(LDFLAGS) $(REL_DIR)/$(TARGET).a: $(REL_CUI_OBJECTS) @echo "linking $@ ..." @rm -f $@ @ar rsc $@ $^ $(DBG_DIR)/$(TARGET).a: $(DBG_CUI_OBJECTS) @echo "linking $@ ..." @rm -f $@ @ar rsc $@ $^ # include dependencies -include $(REL_CUI_OBJECTS:.o=.d) -include $(DBG_CUI_OBJECTS:.o=.d) # pattern build rule for release target .SECONDEXPANSION: $(REL_DIR)/%.o: $(BASE_DIR)/$$(subst !,/,%).c @echo "building $*.c ..." @mkdir -p $(REL_DIR) @$(CC) -c $(CFLAGS) $< -o $@ @$(CC) -MM $(CFLAGS) $< > $(subst .o,.d,$@) @mv -f $(subst .o,.d,$@) $(subst .o,.d,$@).tmp @$(SED) -e 's|.*:|$@:|' < $(subst .o,.d,$@).tmp > $(subst .o,.d,$@) @cp -f $(subst .o,.d,$@) $(subst .o,.d,$@).tmp @$(SED) -e 's/.*://' -e 's/\\$$//' < $(subst .o,.d,$@).tmp | fmt -1 | $(SED) -e 's/^ *//' -e 's/$$/:/' >> $(subst .o,.d,$@) @rm -f $(subst .o,.d,$@).tmp # pattern build rule for debug target .SECONDEXPANSION: $(DBG_DIR)/%.o: $(BASE_DIR)/$$(subst !,/,%).c @echo "building $*.c ..." @mkdir -p $(DBG_DIR) @$(CC) -c $(CFLAGS) $(DBGFLAGS) $< -o $@ @$(CC) -MM $(CFLAGS) $(DBGFLAGS) $< > $(subst .o,.d,$@) @mv -f $(subst .o,.d,$@) $(subst .o,.d,$@).tmp @$(SED) -e 's|.*:|$@:|' < $(subst .o,.d,$@).tmp > $(subst .o,.d,$@) @cp -f $(subst .o,.d,$@) $(subst .o,.d,$@).tmp @$(SED) -e 's/.*://' -e 's/\\$$//' < $(subst .o,.d,$@).tmp | fmt -1 | $(SED) -e 's/^ *//' -e 's/$$/:/' >> $(subst .o,.d,$@) @rm -f $(subst .o,.d,$@).tmp # pattern build rule l->c %.c: $(BASE_DIR)/%.l @echo "generating $*.c from $*.l ..." @$(FLEX) -P$* -o$*.c $*.l # install install: release @echo "installing $(TARGET)..." @mkdir -p $(DESTDIR)/$(INSTALLLIBDIR) @install -m0644 $(REL_DIR)/$(TARGET).so.$(VERSION) $(DESTDIR)/$(INSTALLLIBDIR) @strip $(DESTDIR)/$(INSTALLLIBDIR)/$(TARGET).so.$(VERSION) @-rm -f $(DESTDIR)/$(INSTALLLIBDIR)/$(TARGET).so @-rm -f $(DESTDIR)/$(INSTALLLIBDIR)/$(TARGET).so.$(MAJOR_VER) @cd $(DESTDIR)/$(INSTALLLIBDIR) && ln -s $(TARGET).so.$(VERSION) $(TARGET).so @cd $(DESTDIR)/$(INSTALLLIBDIR) && ln -s $(TARGET).so.$(VERSION) $(TARGET).so.$(MAJOR_VER) @install cuieismanlib $(DESTDIR)/var/install/include # uninstall uninstall: @echo "uninstalling $(TARGET)..." @rm -f $(DESTDIR)/$(INSTALLLIBDIR)/$(TARGET).so.$(VERSION) @rm -f $(DESTDIR)/$(INSTALLLIBDIR)/$(TARGET).so @rm -f $(DESTDIR)/$(INSTALLLIBDIR)/$(TARGET).a @rm -f $(DESTDIR)/var/install/include/cuilib @ldconfig -n $(DESTDIR)/$(INSTALLLIBDIR) # clean build directory clean : @echo "cleaning up build directories ..." @rm -rf $(REL_DIR) @rm -rf $(DBG_DIR) .PHONY: all release debug install uninstall clean