Improve source tree
This commit is contained in:
parent
61d4e2fc64
commit
efc292af2c
17 changed files with 77 additions and 35 deletions
6
.gitignore
vendored
6
.gitignore
vendored
|
@ -1,8 +1,6 @@
|
||||||
# executables
|
# object files/output directories
|
||||||
moxerver
|
|
||||||
|
|
||||||
# object files
|
|
||||||
*.o
|
*.o
|
||||||
|
*.dir
|
||||||
|
|
||||||
# logs directory during development
|
# logs directory during development
|
||||||
logs
|
logs
|
||||||
|
|
52
Makefile
52
Makefile
|
@ -1,43 +1,33 @@
|
||||||
# target name
|
# components
|
||||||
TARGET = moxerver
|
MOXERVER = moxerver
|
||||||
|
MOXANIX = moxanix
|
||||||
|
|
||||||
# special include directories
|
# installation root
|
||||||
INCDIRS = -I.
|
INSTALL_ROOT = ./install.dir
|
||||||
# special library directories
|
|
||||||
LIBDIRS = -L.
|
|
||||||
# used libraries
|
|
||||||
#LIBS = -lm
|
|
||||||
LIBS = -lpthread
|
|
||||||
|
|
||||||
# compiler and flags
|
# ==============================================================================
|
||||||
CC = gcc
|
|
||||||
CFLAGS = -Wall $(INCDIRS) $(LIBDIRS) $(LIBS)
|
|
||||||
|
|
||||||
# objects are .o files created from all .c files in the directory (same name)
|
MOXERVER_BUILDDIR = build.dir
|
||||||
OBJECTS = $(patsubst %.c,%.o,$(wildcard *.c))
|
|
||||||
# headers are all .h files in the directory
|
|
||||||
HEADERS = $(wildcard *.h)
|
|
||||||
|
|
||||||
# all objects are built from their .c files and all headers in the directory
|
# ==============================================================================
|
||||||
%.o: %.c $(HEADERS)
|
|
||||||
$(CC) $(CFLAGS) -c $< -o $@
|
|
||||||
|
|
||||||
# target is built from all object files
|
# supported make options (clean, install...)
|
||||||
$(TARGET): $(OBJECTS)
|
|
||||||
$(CC) $(OBJECTS) $(CFLAGS) -o $@
|
|
||||||
|
|
||||||
|
|
||||||
# support for default, clean and all options
|
|
||||||
.PHONY: default all clean
|
.PHONY: default all clean
|
||||||
|
|
||||||
# all calls all other options
|
# all calls all other options
|
||||||
all: default
|
all: default
|
||||||
|
|
||||||
# default builds target
|
# default builds moxerver
|
||||||
default: $(TARGET)
|
default:
|
||||||
|
cd $(MOXERVER) && make OUTDIR=$(MOXERVER_BUILDDIR)
|
||||||
|
|
||||||
# clean removed object files and target
|
# install handles moxerver and moxanix installation
|
||||||
|
install: default
|
||||||
|
mkdir -p $(INSTALL_ROOT)
|
||||||
|
cp $(MOXERVER)/$(MOXERVER_BUILDDIR)/$(MOXERVER) $(INSTALL_ROOT)/$(MOXERVER)
|
||||||
|
cp $(MOXANIX)/$(MOXANIX).* $(INSTALL_ROOT)/
|
||||||
|
|
||||||
|
# clean removes build and install results
|
||||||
clean:
|
clean:
|
||||||
-rm -f *.o
|
cd $(MOXERVER) && make clean
|
||||||
-rm -f $(TARGET)
|
-rm -rf $(INSTALL_ROOT)
|
||||||
|
|
||||||
|
|
54
moxerver/Makefile
Normal file
54
moxerver/Makefile
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
# target name
|
||||||
|
TARGET = moxerver
|
||||||
|
|
||||||
|
# directory for build results
|
||||||
|
BUILDDIR = build.dir
|
||||||
|
|
||||||
|
# ==============================================================================
|
||||||
|
|
||||||
|
# add include directories
|
||||||
|
INCDIRS = -I.
|
||||||
|
# add library directories
|
||||||
|
LIBDIRS = -L.
|
||||||
|
# list used libraries
|
||||||
|
#LIBS = -lm
|
||||||
|
LIBS = -lpthread
|
||||||
|
|
||||||
|
# ==============================================================================
|
||||||
|
|
||||||
|
# compiler and flags
|
||||||
|
CC = gcc
|
||||||
|
CFLAGS = -Wall $(INCDIRS) $(LIBDIRS) $(LIBS)
|
||||||
|
|
||||||
|
# ==============================================================================
|
||||||
|
|
||||||
|
# build everything in a dedicated directory $(OUTDIR)
|
||||||
|
|
||||||
|
# objects are .o files created from all .c files in the directory (same name)
|
||||||
|
OBJECTS = $(patsubst %.c, $(BUILDDIR)/%.o, $(wildcard *.c))
|
||||||
|
# headers are all .h files in the directory
|
||||||
|
HEADERS = $(wildcard *.h)
|
||||||
|
|
||||||
|
# all objects are built from their .c files in the directory
|
||||||
|
$(BUILDDIR)/%.o: %.c
|
||||||
|
mkdir -p $(BUILDDIR)
|
||||||
|
$(CC) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
# target is built from all object files
|
||||||
|
$(BUILDDIR)/$(TARGET): $(OBJECTS)
|
||||||
|
$(CC) $(OBJECTS) $(CFLAGS) -o $@
|
||||||
|
|
||||||
|
# ==============================================================================
|
||||||
|
|
||||||
|
# supported make options (clean, install...)
|
||||||
|
.PHONY: default all clean
|
||||||
|
|
||||||
|
# all calls all other options
|
||||||
|
all: default
|
||||||
|
|
||||||
|
# default builds target
|
||||||
|
default: $(BUILDDIR)/$(TARGET)
|
||||||
|
|
||||||
|
# clean removes object files and target (ignore errors with "-" before commands)
|
||||||
|
clean:
|
||||||
|
-rm -rf $(BUILDDIR)
|
Loading…
Add table
Add a link
Reference in a new issue