Improve Makefiles with build and install directories
This commit is contained in:
parent
efc292af2c
commit
aae67971ff
3 changed files with 68 additions and 17 deletions
30
Makefile
30
Makefile
|
@ -2,32 +2,42 @@
|
|||
MOXERVER = moxerver
|
||||
MOXANIX = moxanix
|
||||
|
||||
# installation root
|
||||
# ==============================================================================
|
||||
|
||||
# system install root directory
|
||||
INSTALL_ROOT = ./install.dir
|
||||
|
||||
# ==============================================================================
|
||||
|
||||
MOXERVER_BUILDDIR = build.dir
|
||||
# directories used for local component builds
|
||||
BUILDDIR = build.dir
|
||||
INSTALLDIR = install.dir
|
||||
|
||||
# ==============================================================================
|
||||
|
||||
# supported make options (clean, install...)
|
||||
.PHONY: default all clean
|
||||
.PHONY: all default install clean
|
||||
|
||||
# all calls all other options
|
||||
all: default
|
||||
all: default install
|
||||
|
||||
# default builds moxerver
|
||||
# default builds components
|
||||
default:
|
||||
cd $(MOXERVER) && make OUTDIR=$(MOXERVER_BUILDDIR)
|
||||
cd $(MOXERVER) && make BUILDDIR=$(BUILDDIR) INSTALLDIR=$(INSTALLDIR)
|
||||
cd $(MOXANIX) && make BUILDDIR=$(BUILDDIR) INSTALLDIR=$(INSTALLDIR)
|
||||
|
||||
# install handles moxerver and moxanix installation
|
||||
# install handles component installation
|
||||
install: default
|
||||
mkdir -p $(INSTALL_ROOT)
|
||||
cp $(MOXERVER)/$(MOXERVER_BUILDDIR)/$(MOXERVER) $(INSTALL_ROOT)/$(MOXERVER)
|
||||
cp $(MOXANIX)/$(MOXANIX).* $(INSTALL_ROOT)/
|
||||
|
||||
cd $(MOXERVER) && make install BUILDDIR=$(BUILDDIR) INSTALLDIR=$(INSTALLDIR)
|
||||
cp -r $(MOXERVER)/$(INSTALLDIR)/* $(INSTALL_ROOT)/
|
||||
|
||||
cd $(MOXANIX) && make install BUILDDIR=$(BUILDDIR) INSTALLDIR=$(INSTALLDIR)
|
||||
cp -r $(MOXANIX)/$(INSTALLDIR)/* $(INSTALL_ROOT)/
|
||||
|
||||
# clean removes build and install results
|
||||
clean:
|
||||
cd $(MOXERVER) && make clean
|
||||
cd $(MOXERVER) && make clean BUILDDIR=$(BUILDDIR) INSTALLDIR=$(INSTALLDIR)
|
||||
cd $(MOXANIX) && make clean BUILDDIR=$(BUILDDIR) INSTALLDIR=$(INSTALLDIR)
|
||||
-rm -rf $(INSTALL_ROOT)
|
||||
|
|
31
moxanix/Makefile
Normal file
31
moxanix/Makefile
Normal file
|
@ -0,0 +1,31 @@
|
|||
# target names
|
||||
TARGET_CONTROL = moxanix.sh
|
||||
TARGET_CONFIG = moxanix.cfg
|
||||
|
||||
# ==============================================================================
|
||||
|
||||
# directory for build results
|
||||
BUILDDIR = build.dir
|
||||
# installation root
|
||||
INSTALLDIR = install.dir
|
||||
|
||||
# ==============================================================================
|
||||
|
||||
# supported make options (clean, install...)
|
||||
.PHONY: default install clean
|
||||
|
||||
# default does nothing
|
||||
default:
|
||||
|
||||
# install targets
|
||||
install:
|
||||
# install control script
|
||||
mkdir -p $(INSTALLDIR)/bin
|
||||
cp $(TARGET_CONTROL) $(INSTALLDIR)/bin/
|
||||
# install configuration file
|
||||
mkdir -p $(INSTALLDIR)/etc
|
||||
cp $(TARGET_CONFIG) $(INSTALLDIR)/etc/
|
||||
|
||||
# clean removes object files and target (ignore errors with "-" before commands)
|
||||
clean:
|
||||
-rm -rf $(INSTALLDIR)
|
|
@ -1,8 +1,12 @@
|
|||
# target name
|
||||
TARGET = moxerver
|
||||
# target names
|
||||
TARGET_BINARY = moxerver
|
||||
|
||||
# ==============================================================================
|
||||
|
||||
# directory for build results
|
||||
BUILDDIR = build.dir
|
||||
# installation root
|
||||
INSTALLDIR = install.dir
|
||||
|
||||
# ==============================================================================
|
||||
|
||||
|
@ -22,7 +26,7 @@ CFLAGS = -Wall $(INCDIRS) $(LIBDIRS) $(LIBS)
|
|||
|
||||
# ==============================================================================
|
||||
|
||||
# build everything in a dedicated directory $(OUTDIR)
|
||||
# build everything in a dedicated directory $(BUILDDIR)
|
||||
|
||||
# objects are .o files created from all .c files in the directory (same name)
|
||||
OBJECTS = $(patsubst %.c, $(BUILDDIR)/%.o, $(wildcard *.c))
|
||||
|
@ -35,20 +39,26 @@ $(BUILDDIR)/%.o: %.c
|
|||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
# target is built from all object files
|
||||
$(BUILDDIR)/$(TARGET): $(OBJECTS)
|
||||
$(BUILDDIR)/$(TARGET_BINARY): $(OBJECTS)
|
||||
$(CC) $(OBJECTS) $(CFLAGS) -o $@
|
||||
|
||||
# ==============================================================================
|
||||
|
||||
# supported make options (clean, install...)
|
||||
.PHONY: default all clean
|
||||
.PHONY: all default install clean
|
||||
|
||||
# all calls all other options
|
||||
all: default
|
||||
all: default install
|
||||
|
||||
# default builds target
|
||||
default: $(BUILDDIR)/$(TARGET)
|
||||
default: $(BUILDDIR)/$(TARGET_BINARY)
|
||||
|
||||
# install target
|
||||
install: default
|
||||
mkdir -p $(INSTALLDIR)/bin
|
||||
cp $(BUILDDIR)/$(TARGET_BINARY) $(INSTALLDIR)/bin/
|
||||
|
||||
# clean removes object files and target (ignore errors with "-" before commands)
|
||||
clean:
|
||||
-rm -rf $(BUILDDIR)
|
||||
-rm -rf $(INSTALLDIR)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue