Commit 4086d007 authored by Jeroen Vreeken's avatar Jeroen Vreeken
Browse files

New build system (build.mk in each subdir)

Converted common libraries to new system
parent 14f5e286
.PHONY: clean all rel_mktemp_dir console controller help
include build.mk
CONTROLLER_REL_TAR:=$(CURDIR)/controller_$(shell date +%Y%m%d%H%M).tar.gz
CONSOLE_REL_TAR:=$(CURDIR)/console_$(shell date +%Y%m%d%H%M).tar.gz
all:
$(MAKE) -C common/utils
$(MAKE) -C common/log
$(MAKE) -C common/trace
$(MAKE) -C common/command
$(MAKE) -C common/trace
all: subdirs
$(MAKE) -C controller
cd libnova-0.13.0 ; ./configure -enable-static -disable-shared --prefix=${CURDIR} ; make; make install
$(MAKE) -C console
......@@ -35,27 +32,15 @@ help:
echo "golden repository (on eris.camras.nl)."
controller:
$(MAKE) -C common/utils
$(MAKE) -C common/log
$(MAKE) -C common/trace
$(MAKE) -C common/command
controller: subdirs
$(MAKE) -C controller
console:
$(MAKE) -C common/utils
$(MAKE) -C common/log
$(MAKE) -C common/trace
$(MAKE) -C common/command
console: subdirs
cd libnova-0.13.0 ; ./configure -enable-static -disable-shared --prefix=${CURDIR} ; make; make install
$(MAKE) -C console
clean:
clean: subdirs_CLEAN
rm -rf common/lib/*
$(MAKE) -C common/log clean
$(MAKE) -C common/utils clean
$(MAKE) -C common/trace clean
$(MAKE) -C common/command clean
$(MAKE) -C controller clean
cd libnova-0.13.0 ; make clean || true
$(MAKE) -C console clean
......@@ -121,3 +106,36 @@ $(CONTROLLER_REL_TAR): rel_ctrl
release: $(CONSOLE_REL_TAR) $(CONTROLLER_REL_TAR)
release_console: $(CONSOLE_REL_TAR)
release_controller: $(CONTROLLER_REL_TAR)
DIR := .
SRCS :=
TARGETS :=
CLEAN :=
define SUBDIR
ifeq ($(DIR),.)
DIR := $1
else
DIR := $(DIR)/$1
endif
include $(DIR)/$1/build.mk
DIR := $(DIR)
endef
$(eval $(call SUBDIR,common))
CFLAGS := -Icommon -Icommon/include
LDFLAGS := -Lcommon/lib
subdirs: $(TARGETS)
SRCS_TMP=$(SRCS:.il=.il.d)
-include $(SRCS_TMP:.c=.d) $(patsubst %.c,.libs/%.d,$(SRCS_TMP))
subdirs_CLEAN:
rm -rf $(CLEAN)
# Some make rules to make output pretty....
# default ARFLAGS also has 'v', but we don't want it to be verbose.
ARFLAGS= -r
# make sure libs from /usr/local/lib are found
VPATH= /lib64 /usr/lib64 /usr/local/lib64 /lib /usr/lib /usr/local/lib
LIBTOOL=libtool
OS= $(shell uname -s)
ifneq ($(OS), FreeBSD)
FLEX=flex
else
FLEX=/usr/local/bin/flex
endif
%.o : %.c
@echo " CC $<"
@$(CC) -MMD $(CFLAGS) -c $< -o $@
%.o : %.il2c.c
@echo "LT CCil $<"
@${LIBTOOL} --quiet --mode=compile --tag=CC $(CC) -MMD $(CFLAGS) -c $< -o $@
@sed -e "s:\.il2c.c:\.il:" -i -i $*.il2c.d
%: %.o
@echo " LD $@"
@${LIBTOOL} --quiet --mode=link --tag=CC $(LINK.o) $(filter %.o,$^) $(LOADLIBS) $(LDLIBS) $($@_LDFLAGS) -o $@
%.lo: %.c
@echo "LT CC $<"
@${LIBTOOL} --quiet --mode=compile --tag=CC $(CC) -MMD $(CFLAGS) -c $< -o $@
@cat $(dir $*).libs/$(*F).d | sed -e "s:\.libs/::" -e "s:\.o:\.lo:" > $*.d
%.lo: %.il2c.c
@echo "LT ilCC $<"
@${LIBTOOL} --quiet --mode=compile --tag=CC $(CC) -MMD $(CFLAGS) -c $<
@cat $(dir $*).libs/$(*F).d | sed -e "s:\.libs/::" -e "s:\.o:\.lo:" -e "s:\.il2c.c:\.il:" > $*.d
define LIB_LINK
@echo "LT LD $@"
@${LIBTOOL} --quiet --mode=link gcc $(filter %.lo,$^) -o $@ $(LDFLAGS) $($@_LDFLAGS) -static-libtool-libs
@echo "LT INST $@"
@${LIBTOOL} --quiet --mode=install install $@ $(abspath $(@D))
endef
(%): %
@echo " AR $^ in $@"
@$(AR) $(ARFLAGS) $@ $^
%.tab.c %.tab.h: %.y
@echo "BISON $<"
@bison -d $<
%.yy.c %.yy.h: %.l %.tab.h
@echo " FLEX $<"
@echo $(FLEX) --header-file=$*.yy.h -o $*.yy.c $<
@$(FLEX) --header-file=$*.yy.h -o $*.yy.c $<
# il2c: instruction list 2 c 'compiler'
%.il2c.c: %.il
@echo " IL2C $<"
@$(IL2C) $<
# dot -> pdf
%.pdf: %.dot
@echo " DOT $<"
@dot $< -o $@ -Tpdf
# Some make rules to make output pretty....
# default ARFLAGS also has 'v', but we don't want it to be verbose.
ARFLAGS= -r
LIBDIR:=$(DIR)/lib
ABSLIBDIR:=$(abspath $(LIBDIR))
# make sure libs from /usr/local/lib are found
VPATH= /lib64 /usr/lib64 /usr/local/lib64 /lib /usr/lib /usr/local/lib
LIBTOOL=libtool
%.o : %.c
@echo " CC $<"
@$(CC) -MMD $(CFLAGS) -c $<
%: %.o
@echo " LD $@"
@${LIBTOOL} --quiet --mode=link --tag=CC $(LINK.o) $(filter %.o,$^) $(LOADLIBS) $(LDLIBS) $($@_LDFLAGS) -o $@
%.lo: %.c
@echo "LT CC $<"
@${LIBTOOL} --quiet --mode=compile --tag=CC $(CC) -MMD $(CFLAGS) -c $<
%.la:
@echo "LIBTOOL $@"
@${LIBTOOL} --quiet --mode=link gcc $^ -o $@ $(LDFLAGS) $($@_LDFLAGS) -static-libtool-libs
(%): %
@echo " AR $^ in $@"
@$(AR) $(ARFLAGS) $@ $^
%.tab.c %.tab.h: %.y
@echo "BISON $<"
@bison -d $<
%.yy.h: %.l %.tab.h
@echo " FLEX $<"
@flex --header-file=$*.yy.h $<
%.yy.c: %.l %.tab.h
@echo " FLEX $<"
@flex -o $@ $<
# il2c: instruction list 2 c 'compiler'
%.c %.h: %.il
@echo " IL2C $<"
@$(IL2C) $<
# dot -> pdf
%.pdf: %.dot
@echo " DOT $<"
@dot $< -o $@ -Tpdf
-include $(SRCS:.c=.d)
$(eval $(call SUBDIR,log))
$(eval $(call SUBDIR,utils))
$(eval $(call SUBDIR,command))
$(eval $(call SUBDIR,trace))
CFLAGS+= -Wall -O3 -I../utils/ -I.. -I../include
LDFLAGS+= -L../lib
LOBJS= command.lo
#SRCS= trace_dump.c trace_dumpdiff.c trace_fft.c
all: libs bins libs_install
libs: libcommand.la
libs_install: libcommand.la_install
bins: command_list
#bins: trace_dump trace_dumpdiff trace_fft trace_view trace_list
${CURDIR}/../lib:
@mkdir ${CURDIR}/../lib
libcommand.la_LDFLAGS= -lutils -lm -llog -rpath ${CURDIR}/../lib
libcommand.la: command.lo command_tcp.lo
libcommand.la_install: libcommand.la ${CURDIR}/../lib
@echo "CP $^ to libdir"
@${LIBTOOL} --quiet --mode=install install libcommand.la ${CURDIR}/../lib
#trace_dump_LDFLAGS= -ltrace -lutils
#trace_dump: trace_dump.o libs_install
#trace_dumpdiff_LDFLAGS= -ltrace -lutils
#trace_dumpdiff: trace_dumpdiff.o libs_install
#trace_fft_LDFLAGS= -lm -lutils -ltrace -lfftw3
#trace_fft: trace_fft.o libs_install
command_list_LDFLAGS= -lcommand
command_list: command_list.o libs_install
#trace_view_LDFLAGS= -ltrace
#trace_view: trace_view.o libs_install
clean:
rm -rf *.o *.a *.d *.lo *.la .libs
# trace_dump trace_dumpdiff trace_fft trace_list trace_view
include ../build.mk
COMMAND_TARGETS += $(LIBDIR)/libcommand.la
COMMAND_TARGETS += $(DIR)/command_list
ARCHSRCS := $(DIR)/command.c $(DIR)/command_tcp.c
ARCHOBJS := $(ARCHSRCS:.c=.lo)
$(LIBDIR)/libcommand.la: $(LIBDIR)/libutils.la $(LIBDIR)/liblog.la
$(LIBDIR)/libcommand.la: CFLAGS += -Wall -O3 -fPIC
$(LIBDIR)/libcommand.la: LDFLAGS += -lutils -lm -llog -rpath $(ABSLIBDIR)
$(LIBDIR)/libcommand.la: $(ARCHOBJS)
$(LIB_LINK)
COMMAND_LIST_SRCS := $(DIR)/command_list.c
COMMAND_LIST_OBJS := $(COMMAND_LIST_SRCS:.c=.o)
$(DIR)/command_list: $(LIBDIR)/libcommand.la
$(DIR)/command_list: LDFLAGS += -lcommand
$(DIR)/command_list: $(COMMAND_LIST_OBJS)
SRCS += $(ARCHSRCS) $(COMMAND_LIST_SRCS)
TARGETS += $(COMMAND_TARGETS)
CLEAN += $(COMMAND_TARGETS) $(ARCHOBJS) $(COMMAND_LIST_OBJS)
......@@ -21,7 +21,7 @@
#include <command/command.h>
#include <command/command_def.h>
#include <tcp_connect.h>
#include <utils/tcp_connect.h>
#include <log/log.h>
#include <stdio.h>
......
......@@ -21,7 +21,7 @@ trac
#include <command/command_def.h>
#include <command/command.h>
#include <log/log.h>
#include <tcp_connect.h>
#include <utils/tcp_connect.h>
#include <unistd.h>
#include <stdlib.h>
......
CFLAGS= -Wall -O3 -I../utils -fPIC
LDFLAGS= -lutils
ARCHSRCS = log.c
ARCHOBJS = $(ARCHSRCS:.c=.lo)
SRCS=$(ARCHSRCS)
all: $(ARCHOBJS) liblog.la_install
liblog.la_LDFLAGS=-rpath ${CURDIR}/../lib
liblog.la: $(ARCHOBJS)
liblog.la_install: liblog.la
@echo "CP $^ to libdir"
@${LIBTOOL} --quiet --mode=install install liblog.la ${CURDIR}/../lib
clean:
rm -rf *.o *.a *.d *.lo *.la libs
include ../build.mk
ARCHSRCS = $(DIR)/log.c
ARCHOBJS = $(ARCHSRCS:.c=.lo)
SRCS+=$(ARCHSRCS)
TARGETS += $(LIBDIR)/liblog.la
$(LIBDIR)/liblog.la: $(LIBDIR)/libutils.la
$(LIBDIR)/liblog.la: LDFLAGS += -lutils -rpath $(ABSLIBDIR)
$(LIBDIR)/liblog.la: CFLAGS += -Wall -O3 -fPIC
$(LIBDIR)/liblog.la: $(ARCHOBJS)
$(LIB_LINK)
CLEAN += $(TARGETS) $(ARCHOBJS)
......@@ -36,9 +36,9 @@
#include <stdarg.h>
#include <stdbool.h>
#include <tcp_connect.h>
#include <utils/tcp_connect.h>
#include "log.h"
#include <log/log.h>
static int listen_port = 0;
......
CFLAGS+= -Wall -O3 -I../utils/ -I.. -I../include -fPIC
LDFLAGS+= -L../lib
LOBJS= trace.lo
SRCS= trace_dump.c trace_dumpdiff.c trace_fft.c trace_tcp.c trace.c trace_tcp.c
all: libs bins
libs: libtrace.la
libs_install: libtrace.la_install
bins: trace_dump trace_dumpdiff trace_view trace_list
${CURDIR}/../lib:
@mkdir ${CURDIR}/../lib
libtrace.la_LDFLAGS= -lutils -llog -lm -rpath ${CURDIR}/../lib
libtrace.la: trace.lo trace_tcp.lo
libtrace.la_install: libtrace.la ${CURDIR}/../lib
@echo "CP $^ to libdir"
@${LIBTOOL} --quiet --mode=install install libtrace.la ${CURDIR}/../lib
trace_dump_LDFLAGS= -ltrace -lutils
trace_dump: trace_dump.o libs_install
trace_dumpdiff_LDFLAGS= -ltrace -lutils
trace_dumpdiff: trace_dumpdiff.o libs_install
trace_fft_LDFLAGS= -lm -lutils -ltrace -lfftw3
trace_fft: trace_fft.o libs_install
trace_list_LDFLAGS= -ltrace
trace_list: trace_list.o libs_install
trace_view_LDFLAGS= -ltrace
trace_view: trace_view.o libs_install
clean:
rm -rf *.o *.a *.d *.lo *.la .libs \
trace_dump trace_dumpdiff trace_fft trace_list trace_view
include ../build.mk
TRACE_TARGETS += $(LIBDIR)/libtrace.la
TRACE_TARGETS += $(DIR)/trace_dump
TRACE_TARGETS += $(DIR)/trace_dumpdiff
#TRACE_TARGETS += $(DIR)/trace_fft
TRACE_TARGETS += $(DIR)/trace_list
TRACE_TARGETS += $(DIR)/trace_view
ARCHSRCS := $(DIR)/trace.c $(DIR)/trace_tcp.c
ARCHOBJS := $(ARCHSRCS:.c=.lo)
$(LIBDIR)/libtrace.la: $(LIBDIR)/libutils.la $(LIBDIR)/liblog.la
$(LIBDIR)/libtrace.la: CFLAGS += -Wall -O3 -fPIC
$(LIBDIR)/libtrace.la: LDFLAGS += -lutils -llog -lm -rpath $(ABSLIBDIR)
$(LIBDIR)/libtrace.la: $(ARCHOBJS)
$(LIB_LINK)
TRACE_DUMP_SRCS := $(DIR)/trace_dump.c
TRACE_DUMP_OBJS := $(TRACE_DUMP_SRCS:.c=.o)
$(DIR)/trace_dump: $(LIBDIR)/libtrace.la
$(DIR)/trace_dump: LDFLAGS += -ltrace
$(DIR)/trace_dump: $(TRACE_DUMP_OBJS)
TRACE_DUMPDIFF_SRCS := $(DIR)/trace_dumpdiff.c
TRACE_DUMPDIFF_OBJS := $(TRACE_DUMPDIFF_SRCS:.c=.o)
$(DIR)/trace_dumpdiff: $(LIBDIR)/libtrace.la
$(DIR)/trace_dumpdiff: LDFLAGS += -ltrace
$(DIR)/trace_dumpdiff: $(TRACE_DUMPDIFF_OBJS)
TRACE_FFT_SRCS := $(DIR)/trace_fft.c
TRACE_FFT_OBJS := $(TRACE_FFT_SRCS:.c=.o)
$(DIR)/trace_fft: $(LIBDIR)/libtrace.la
$(DIR)/trace_fft: LDFLAGS += -ltrace -lm -lfftw3
$(DIR)/trace_fft: $(TRACE_FFT_OBJS)
TRACE_LIST_SRCS := $(DIR)/trace_list.c
TRACE_LIST_OBJS := $(TRACE_LIST_SRCS:.c=.o)
$(DIR)/trace_list: $(LIBDIR)/libtrace.la
$(DIR)/trace_list: LDFLAGS += -ltrace
$(DIR)/trace_list: $(TRACE_LIST_OBJS)
TRACE_VIEW_SRCS := $(DIR)/trace_view.c
TRACE_VIEW_OBJS := $(TRACE_VIEW_SRCS:.c=.o)
$(DIR)/trace_view: $(LIBDIR)/libtrace.la
$(DIR)/trace_view: LDFLAGS += -ltrace
$(DIR)/trace_view: $(TRACE_VIEW_OBJS)
TARGETS += $(TRACE_TARGETS)
CLEAN += $(TRACE_TARGETS) $(ARCHOBJS)
CLEAN += $(TRACE_DUMP_OBJS)
CLEAN += $(TRACE_DUMPDIFF_OBJS)
CLEAN += $(TRACE_FFT_OBJS)
CLEAN += $(TRACE_LIST_OBJS)
CLEAN += $(TRACE_VIEW_OBJS)
......@@ -22,7 +22,7 @@
#include <trace/trace.h>
#include <trace/trace_def.h>
#include <tcp_connect.h>
#include <utils/tcp_connect.h>
#include <log/log.h>
#include <stdio.h>
......
......@@ -29,7 +29,7 @@
#include <fftw3.h>
#include <math.h>
#include "trace.h"
#include <trace/trace.h>
static char *tmpfilename;
static FILE *fdplot = NULL;
......
......@@ -21,7 +21,7 @@
#include <trace/trace_def.h>
#include <trace/trace.h>
#include <log/log.h>
#include <tcp_connect.h>
#include <utils/tcp_connect.h>
#include <unistd.h>
#include <stdlib.h>
......
......@@ -27,7 +27,7 @@
#include <math.h>
#include <time.h>
#include "trace/trace.h"
#include <trace/trace.h>
time_t starttime;
......
CFLAGS= -Wall -g -fPIC
LDFLAGS= -lpthread
CFLAGS+=`pkg-config --cflags glib-2.0`
LDFLAGS+=`pkg-config --libs glib-2.0`
UTILSRCS= tcp_connect.c tcp_listen.c command_server.c status_server.c \
config.c weather.c dt_model.c location.c dt_host.c
LIBUTILOBJS= $(UTILSRCS:.c=.lo)
all: $(LIBUTILOBJS) weather_test libutils.la libutils.la_install
libutils.la_LDFLAGS= -lm -rpath ${CURDIR}/../lib -lrt
libutils.la: $(LIBUTILOBJS)
${CURDIR}/../lib:
@mkdir ${CURDIR}/../lib
libutils.la_install: libutils.la ${CURDIR}/../lib
@echo "CP $^ to libdir"
@${LIBTOOL} --quiet --mode=install install libutils.la ${CURDIR}/../lib
weather_test: weather_test.o weather.o tcp_connect.o
clean:
rm -rf *.o *.a *.la *.lo .libs *.d weather_test
SRCS= $(UTILSRCS) weather_test.c
include ../build.mk
TARGETS += $(LIBDIR)/libutils.la
TARGETS += $(DIR)/weather_test
WEATHER_SRCS := $(DIR)/weather_test.c $(DIR)/weather.c $(DIR)/tcp_connect.c
WEATHER_OBJS := $(WEATHER_SRCS:.c=.o)
$(DIR)/weather_test: LDFLAGS += -lpthread
$(DIR)/weather_test: $(WEATHER_OBJS)
ARCHSRCS := $(DIR)/tcp_connect.c \
$(DIR)/tcp_listen.c \
$(DIR)/command_server.c \
$(DIR)/status_server.c \
$(DIR)/config.c \
$(DIR)/weather.c \
$(DIR)/dt_model.c \
$(DIR)/location.c \
$(DIR)/dt_host.c
ARCHOBJS := $(ARCHSRCS:.c=.lo)
LU_CFLAGS := -Wall -g -fPIC
LU_LDFLAGS := -lpthread -lrt -lm -rpath $(ABSLIBDIR)
LU_CFLAGS += `pkg-config --cflags glib-2.0`
LU_LDFLAGS += `pkg-config --libs glib-2.0`
$(LIBDIR)/libutils.la: CFLAGS += $(LU_CFLAGS)
$(LIBDIR)/libutils.la: LDFLAGS += $(LU_LDFLAGS)
$(LIBDIR)/libutils.la: $(ARCHOBJS)
$(LIB_LINK)
CLEAN += $(LIBDIR)/libutils.la
CLEAN += $(DIR)/weather_test
CLEAN += $(WEATHER_OBJS) $(ARCHOBJS)
SRCS += $(ARCHSRCS) $(WEATHER_SRCS)
......@@ -7,7 +7,7 @@ CFLAGS+=-Wall -g \
-I../../../common/trace \
-I../../../common/utils \
-I../../../common/include
LDFLAGS+=-L../../../common/trace -ltrace
LDFLAGS+=-L../../../common/lib -ltrace
all: mod_websocket_dt.so_install
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment