Update plain Makefile and README.

This commit is contained in:
Nicholas J. Kain 2014-03-14 23:51:11 -04:00
parent 8faae4a0fd
commit 180ee36626
2 changed files with 10 additions and 14 deletions

View File

@ -1,15 +1,13 @@
# This is a pretty basic makefile. I generally use CMake, so this is mostly # This is a pretty basic makefile. I generally use CMake, so this is mostly
# for distros that want to avoid build dependencies. Produced exes will be # for distros that want to avoid build dependencies. Produced exes will be
# at './build/ndhc' and './build/ifchd'. # at './build/ndhc'.
NCM_SRCS = $(sort $(wildcard ncmlib/*.c)) NCM_SRCS = $(sort $(wildcard ncmlib/*.c))
IFCHD_SRCS = $(sort $(wildcard ifchd/*.c))
NDHC_SRCS = $(sort $(wildcard ndhc/*.c)) NDHC_SRCS = $(sort $(wildcard ndhc/*.c))
NCM_OBJS = $(NCM_SRCS:.c=.o) NCM_OBJS = $(NCM_SRCS:.c=.o)
IFCHD_OBJS = $(IFCHD_SRCS:.c=.o)
NDHC_OBJS = $(NDHC_SRCS:.c=.o) NDHC_OBJS = $(NDHC_SRCS:.c=.o)
NCM_INC = -I./ncmlib NCM_INC = -I./ncmlib
IFCH_INC = -I./ifchd NDHC_INC = -I./ndhc
BUILD_DIR = build BUILD_DIR = build
OBJ_DIR = $(BUILD_DIR)/objs OBJ_DIR = $(BUILD_DIR)/objs
@ -18,30 +16,27 @@ AR = ar
RANLIB = ranlib RANLIB = ranlib
CFLAGS = -O2 -s -std=gnu99 -pedantic -Wall -D_GNU_SOURCE -DHAVE_CLEARENV -DLINUX CFLAGS = -O2 -s -std=gnu99 -pedantic -Wall -D_GNU_SOURCE -DHAVE_CLEARENV -DLINUX
all: makedir ifchd-parse.o ncmlib.a ifchd ndhc all: makedir ifchd-parse.o ncmlib.a ndhc
clean: clean:
rm -Rf $(BUILD_DIR) rm -Rf $(BUILD_DIR)
makedir: makedir:
mkdir -p $(BUILD_DIR) $(OBJ_DIR)/ndhc $(OBJ_DIR)/ifchd $(OBJ_DIR)/ncmlib mkdir -p $(BUILD_DIR) $(OBJ_DIR)/ndhc $(OBJ_DIR)/ncmlib
ifchd-parse.o: ifchd-parse.o:
ragel -G2 -o $(BUILD_DIR)/ifchd-parse.c ifchd/ifchd-parse.rl ragel -G2 -o $(BUILD_DIR)/ifchd-parse.c ndhc/ifchd-parse.rl
$(CC) $(CFLAGS) $(IFCH_INC) $(NCM_INC) -c -o $(OBJ_DIR)/ifchd/$@ $(BUILD_DIR)/ifchd-parse.c $(CC) $(CFLAGS) $(NCM_INC) $(NDHC_INC) -c -o $(OBJ_DIR)/ndhc/$@ $(BUILD_DIR)/ifchd-parse.c
%.o: %.c %.o: %.c
$(CC) $(CFLAGS) $(IFCH_INC) $(NCM_INC) -c -o $(OBJ_DIR)/$@ $< $(CC) $(CFLAGS) $(NCM_INC) -c -o $(OBJ_DIR)/$@ $<
ncmlib.a: $(NCM_OBJS) ncmlib.a: $(NCM_OBJS)
$(AR) rc $(BUILD_DIR)/$@ $(subst ncmlib/,$(OBJ_DIR)/ncmlib/,$(NCM_OBJS)) $(AR) rc $(BUILD_DIR)/$@ $(subst ncmlib/,$(OBJ_DIR)/ncmlib/,$(NCM_OBJS))
$(RANLIB) $(BUILD_DIR)/$@ $(RANLIB) $(BUILD_DIR)/$@
ifchd: $(IFCHD_OBJS) ifchd-parse.o ndhc: $(NDHC_OBJS) ifchd-parse.o
$(CC) $(CFLAGS) $(NCM_INC) -o $(BUILD_DIR)/$@ $(subst ifchd/,$(OBJ_DIR)/ifchd/,$(IFCHD_OBJS)) $(BUILD_DIR)/objs/ifchd/ifchd-parse.o $(BUILD_DIR)/ncmlib.a -lcap $(CC) $(CFLAGS) $(NCM_INC) -o $(BUILD_DIR)/$@ $(subst ndhc/,$(OBJ_DIR)/ndhc/,$(NDHC_OBJS)) $(BUILD_DIR)/ncmlib.a $(BUILD_DIR)/objs/ndhc/ifchd-parse.o -lcap -lrt
ndhc: $(NDHC_OBJS)
$(CC) $(CFLAGS) $(IFCH_INC) $(NCM_INC) -o $(BUILD_DIR)/$@ $(subst ndhc/,$(OBJ_DIR)/ndhc/,$(NDHC_OBJS)) $(BUILD_DIR)/ncmlib.a -lcap -lrt
.PHONY: all clean .PHONY: all clean

1
README
View File

@ -6,6 +6,7 @@ Requirements:
Linux kernel Linux kernel
GNU Make (tested: 3.82) or CMake (tested: 2.8) GNU Make (tested: 3.82) or CMake (tested: 2.8)
libcap (available via ftp.kernel.org) libcap (available via ftp.kernel.org)
Ragel (tested: 6.7)
INTRODUCTION INTRODUCTION
------------ ------------