2011-07-12 13:39:05 +05:30
|
|
|
# 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
|
2014-03-15 09:21:11 +05:30
|
|
|
# at './build/ndhc'.
|
2011-07-12 13:39:05 +05:30
|
|
|
|
2020-10-20 16:14:31 +05:30
|
|
|
NCM_SRCS = $(sort $(wildcard src/lib/*.c))
|
2014-04-07 02:27:06 +05:30
|
|
|
NDHC_SRCS = $(sort $(wildcard src/*.c))
|
2011-07-12 13:39:05 +05:30
|
|
|
NCM_OBJS = $(NCM_SRCS:.c=.o)
|
|
|
|
NDHC_OBJS = $(NDHC_SRCS:.c=.o)
|
2014-04-07 02:27:06 +05:30
|
|
|
NDHC_INC = -I./src
|
2011-07-12 13:39:05 +05:30
|
|
|
BUILD_DIR = build
|
2011-07-13 04:15:29 +05:30
|
|
|
OBJ_DIR = $(BUILD_DIR)/objs
|
2011-07-12 13:39:05 +05:30
|
|
|
|
|
|
|
CC = gcc
|
|
|
|
AR = ar
|
2014-04-01 01:36:41 +05:30
|
|
|
CFLAGS = -O2 -s -std=gnu99 -pedantic -Wall -D_GNU_SOURCE
|
2014-04-08 04:44:31 +05:30
|
|
|
# Not required for glibc >= 2.17, but older glibcs are still common.
|
|
|
|
# The CMake build script will perform detection, but this Makefile is simple.
|
|
|
|
LINK_LIBS = -lrt
|
2011-07-12 13:39:05 +05:30
|
|
|
|
2020-10-20 16:14:31 +05:30
|
|
|
all: makedir ifchd-parse.o cfg.o ndhc
|
2011-07-12 13:39:05 +05:30
|
|
|
|
|
|
|
clean:
|
2011-07-13 04:15:29 +05:30
|
|
|
rm -Rf $(BUILD_DIR)
|
2011-07-12 13:39:05 +05:30
|
|
|
|
|
|
|
makedir:
|
2020-10-20 16:14:31 +05:30
|
|
|
mkdir -p $(BUILD_DIR) $(OBJ_DIR)/src
|
2011-07-12 13:39:05 +05:30
|
|
|
|
2013-05-08 18:38:47 +05:30
|
|
|
ifchd-parse.o:
|
2014-04-07 02:27:06 +05:30
|
|
|
ragel -G2 -o $(BUILD_DIR)/ifchd-parse.c src/ifchd-parse.rl
|
2020-10-20 16:14:31 +05:30
|
|
|
$(CC) $(CFLAGS) $(NDHC_INC) -c -o $(OBJ_DIR)/src/$@ $(BUILD_DIR)/ifchd-parse.c
|
2013-05-08 18:38:47 +05:30
|
|
|
|
2014-04-16 06:20:54 +05:30
|
|
|
cfg.o:
|
|
|
|
ragel -G2 -o $(BUILD_DIR)/cfg.c src/cfg.rl
|
2020-10-20 16:14:31 +05:30
|
|
|
$(CC) $(CFLAGS) $(NDHC_INC) -c -o $(OBJ_DIR)/src/$@ $(BUILD_DIR)/cfg.c
|
2014-04-16 06:20:54 +05:30
|
|
|
|
2011-07-12 13:39:05 +05:30
|
|
|
%.o: %.c
|
2020-10-20 16:14:31 +05:30
|
|
|
$(CC) $(CFLAGS) -c -o $(OBJ_DIR)/$@ $<
|
2011-07-12 13:39:05 +05:30
|
|
|
|
2020-10-20 16:14:31 +05:30
|
|
|
ndhc: $(NCM_OBJS) $(NDHC_OBJS) ifchd-parse.o cfg.o
|
|
|
|
$(CC) $(CFLAGS) -o $(BUILD_DIR)/$@ $(subst src/,$(OBJ_DIR)/src/,$(NDHC_OBJS)) $(BUILD_DIR)/objs/src/ifchd-parse.o $(BUILD_DIR)/objs/src/cfg.o $(LINK_LIBS)
|
2011-07-12 13:39:05 +05:30
|
|
|
|
|
|
|
.PHONY: all clean
|
|
|
|
|