boot linux with gnu make

…continuation of the previous post…

what is still missing from the picture I was presenting in the previous post was handling events as some of the sys v init replacement try to do.

well, a separate process should handle events, and touch/create some files with standard format with updated event information, then one could write sthg. like

event_handler: event

!webserver: stop_all_services_event

 

booting linux or gnu make negative target

Booting linux is a slow process. And it is slow as there is no good order in organizing that process… I do not pretend perfect order, but good order. That is if process X could be already started, it should be started… And is nonsense to wait for y,z,w etc. to finish to start. There are some experiments like upstart or whatsoever, but they go to far from classical unix concepts.

I was therefore playing arround with the idea of using classical gnu make to implement the build process. Each script (boot script, service script etc) should create a status file at the end. So these files would be targets. We would have rules like:

webserver: networking

networking: kernel_modules

There is however something that I would call negative target, that is missing in makefile. It in impossible to write something like:

!networking: !webserver

!kernel_modules: !networking

So this is the magic that is missing from the gnu make… Maybe it makes sense to add sthg. like that…

 

makefile for boost

boost is a wonderfull library, but bjam sucks! The documentation of the config files is ambiguous. I spent few hours to find out how to capture the command lines during build (without hack), and how to influence cxxflags. Did not work. On the other annoying part of bjam is that parallel build does not work either. So I packed together a makefile. This is version 0.0.0.0.1, I will add later several other variables (CXXFLAGS, VERSION, LDFLAGS etc.)… At the moment there are 2 control variables, and they are the source directory and the build directory.

 

BOOST_SRCDIR=/data/build/boost/boost
BOOST_BUILDDIR=/data/build/boost/boostbuild
BOOST_INCLUDEDIR=$(BOOST_SRCDIR)

 

SYSTEM_SOURCEDIR=$(BOOST_SRCDIR)/libs/system/src
SYSTEM_OBJECT_NAMES=error_code.o
SYSTEM_BUILDDIR=$(BOOST_BUILDDIR)/system
SYSTEM_OBJECTS=$(patsubst %.o,$(SYSTEM_BUILDDIR)/%.o, $(SYSTEM_OBJECT_NAMES))
SYSTEM_LIBNAME=system.so
SYSTEM_LIB=$(SYSTEM_BUILDDIR)/$(SYSTEM_LIBNAME)

$(SYSTEM_LIB): $(SYSTEM_BUILDDIR) $(SYSTEM_OBJECTS)
 gcc $(SYSTEM_OBJECTS) -shared  -o $@

$(SYSTEM_BUILDDIR):
 mkdir $(SYSTEM_BUILDDIR)
 
$(SYSTEM_OBJECTS): $(SYSTEM_BUILDDIR)/%.o: $(SYSTEM_SOURCEDIR)/%.cpp
 gcc -c $< -o $@ -I $(BOOST_INCLUDEDIR) -c  -fPIC -fno-stack-protector

 

FILESYSTEM_SOURCEDIR=$(BOOST_SRCDIR)/libs/filesystem/src
FILESYSTEM_OBJECT_NAMES= operations.o \
         path.o \
         portability.o \
         utf8_codecvt_facet.o
FILESYSTEM_BUILDDIR=$(BOOST_BUILDDIR)/filesystem
FILESYSTEM_OBJECTS=$(patsubst %.o,$(FILESYSTEM_BUILDDIR)/%.o, $(FILESYSTEM_OBJECT_NAMES))
FILESYSTEM_LIBNAME=filesystem.so
FILESYSTEM_LIB=$(FILESYSTEM_BUILDDIR)/$(FILESYSTEM_LIBNAME)

$(FILESYSTEM_LIB): $(FILESYSTEM_BUILDDIR) $(FILESYSTEM_OBJECTS)
 gcc $(FILESYSTEM_OBJECTS) -shared  -o $@

$(FILESYSTEM_BUILDDIR):
 mkdir $(FILESYSTEM_BUILDDIR)
 
$(FILESYSTEM_OBJECTS): $(FILESYSTEM_BUILDDIR)/%.o: $(FILESYSTEM_SOURCEDIR)/%.cpp
 gcc -c $< -o $@ -I $(BOOST_INCLUDEDIR) -c  -fPIC -fno-stack-protector

 

REGEX_SOURCEDIR=$(BOOST_SRCDIR)/libs/regex/src
REGEX_OBJECT_NAMES=cpp_regex_traits.o \
       cregex.o \
       c_regex_traits.o \
       fileiter.o \
       icu.o \
       instances.o \
       posix_api.o \
       regex.o \
       regex_debug.o \
       regex_raw_buffer.o \
       regex_traits_defaults.o \
       static_mutex.o \
       usinstances.o \
       w32_regex_traits.o \
       wc_regex_traits.o \
       wide_posix_api.o \
       winstances.o
REGEX_BUILDDIR=$(BOOST_BUILDDIR)/regex
REGEX_OBJECTS=$(patsubst %.o,$(REGEX_BUILDDIR)/%.o, $(REGEX_OBJECT_NAMES))
REGEX_LIBNAME=regex.so
REGEX_LIB=$(REGEX_BUILDDIR)/$(REGEX_LIBNAME)

$(REGEX_LIB): $(REGEX_BUILDDIR) $(REGEX_OBJECTS)
 gcc $(REGEX_OBJECTS) -shared  -o $@

$(REGEX_BUILDDIR):
 mkdir $(REGEX_BUILDDIR)
 
$(REGEX_OBJECTS): $(REGEX_BUILDDIR)/%.o: $(REGEX_SOURCEDIR)/%.cpp
 gcc -c $< -o $@ -I $(BOOST_INCLUDEDIR) -c  -fPIC -fno-stack-protector

 
PROGRAM_OPTIONS_SOURCEDIR=$(BOOST_SRCDIR)/libs/program_options/src
PROGRAM_OPTIONS_OBJECT_NAMES= cmdline.o \
           config_file.o \
           convert.o \
           options_description.o \
           parsers.o \
           positional_options.o \
           utf8_codecvt_facet.o \
           value_semantic.o \
           variables_map.o \
           winmain.o
PROGRAM_OPTIONS_BUILDDIR=$(BOOST_BUILDDIR)/program_options
PROGRAM_OPTIONS_OBJECTS=$(patsubst %.o,$(PROGRAM_OPTIONS_BUILDDIR)/%.o, $(PROGRAM_OPTIONS_OBJECT_NAMES))
PROGRAM_OPTIONS_LIBNAME=program_options.so
PROGRAM_OPTIONS_LIB=$(PROGRAM_OPTIONS_BUILDDIR)/$(PROGRAM_OPTIONS_LIBNAME)

$(PROGRAM_OPTION_SLIB): $(PROGRAM_OPTIONS_BUILDDIR) $(PROGRAM_OPTIONS_OBJECTS)
 gcc $(PROGRAM_OPTIONSOBJECTS) -shared  -o $@

$(PROGRAM_OPTIONS_BUILDDIR):
 mkdir $(PROGRAM_OPTIONS_BUILDDIR)
 
$(PROGRAM_OPTIONS_OBJECTS): $(PROGRAM_OPTIONS_BUILDDIR)/%.o: $(PROGRAM_OPTIONS_SOURCEDIR)/%.cpp
 gcc -c $< -o $@ -I $(BOOST_INCLUDEDIR) -c  -fPIC -fno-stack-protector

 

LIBS=$(SYSTEM_LIB) $(FILESYSTEM_LIB) $(REGEX_LIB) $(PROGRAM_OPTIONSLIB)

all: $(LIBS)
# echo $(LIBS) $(SYSTEM_LIB) $(SYSTEM_OBJECTS) $(SYSTEM_BUILDDIR)/%.o: $(SYSTEM_SOURCEDIR)/%.cpp