From f01f2777f70c5179def70706902c71e2317da3d5 Mon Sep 17 00:00:00 2001 From: polyfloyd Date: Thu, 8 May 2025 13:49:51 +0200 Subject: [PATCH] Swap waf for a Makefile --- Makefile | 49 +++++++++++++------- configure | 5 -- config.c => src/config.c | 0 config.h => src/config.h | 0 database.c => src/database.c | 0 database.h => src/database.h | 0 hook_script.c => src/hook_script.c | 0 hook_script.h => src/hook_script.h | 0 includes.h => src/includes.h | 0 jsonbot.c => src/jsonbot.c | 0 jsonbot.h => src/jsonbot.h | 0 sia.c => src/sia.c | 0 sia.h => src/sia.h | 0 siahs.c => src/siahs.c | 0 siahs.h => src/siahs.h | 0 siahsd.c => src/siahsd.c | 0 status.c => src/status.c | 0 status.h => src/status.h | 0 wscript | 73 ------------------------------ 19 files changed, 32 insertions(+), 95 deletions(-) delete mode 100755 configure rename config.c => src/config.c (100%) rename config.h => src/config.h (100%) rename database.c => src/database.c (100%) rename database.h => src/database.h (100%) rename hook_script.c => src/hook_script.c (100%) rename hook_script.h => src/hook_script.h (100%) rename includes.h => src/includes.h (100%) rename jsonbot.c => src/jsonbot.c (100%) rename jsonbot.h => src/jsonbot.h (100%) rename sia.c => src/sia.c (100%) rename sia.h => src/sia.h (100%) rename siahs.c => src/siahs.c (100%) rename siahs.h => src/siahs.h (100%) rename siahsd.c => src/siahsd.c (100%) rename status.c => src/status.c (100%) rename status.h => src/status.h (100%) delete mode 100644 wscript diff --git a/Makefile b/Makefile index 9d32b6c..f316bd9 100644 --- a/Makefile +++ b/Makefile @@ -1,19 +1,34 @@ -all: - @waf build +LIBS := \ + dbi \ + glib-2.0 \ + gmp \ + hogweed \ + nettle \ + talloc \ + tevent + +CC := gcc +CFLAGS := -O -g -ggdb -std=gnu99 -Wall -Wextra -Winit-self -Wformat-security -Wshadow -pedantic -Wpointer-arith -Wcast-align -Wwrite-strings -Wno-unused-parameter -Werror-implicit-function-declaration -Wstrict-prototypes -fPIC -pie -fstack-protector -D_FORTIFY_SOURCE=2 +LDFLAGS := -fPIC -pie -z relro -z now -fstack-protector + +SRCDIR=src +BUILD=build + +CFLAGS += $(shell pkg-config --cflags $(LIBS)) +LDFLAGS += $(shell pkg-config --libs $(LIBS)) + +$(BUILD)/%.o: $(SRCDIR)/%.c + @echo [CC] $@ + @mkdir -p `dirname $@` + @$(CC) -o $@ -c $< $(CFLAGS) + +$(BUILD)/siahsd: $(patsubst %, $(BUILD)/%.o, siahsd database config status sia siahs jsonbot hook_script) + @echo [LD] $@ + @$(CC) $(LDFLAGS) -o $@ $^ + +.PHONY: all clean + +all: $(BUILD)/siahsd clean: - @waf clean - -distclean: - @waf distclean - @rm tags - -ctags: - @ctags `find -name \*.[ch]` - -coverity: - @if [ -d cov-int ]; then rm -rf cov-int;fi - @mkdir cov-int - @cov-build --dir=cov-int waf configure clean build - @tar cvzf coverity_siahsd.tgz cov-int - @rm -rf cov-int + @rm -rf $(BUILD) diff --git a/configure b/configure deleted file mode 100755 index d27fcb7..0000000 --- a/configure +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -# apt install libglib-dev libdbi-dev libtalloc-dev nettle-dev - -waf configure diff --git a/config.c b/src/config.c similarity index 100% rename from config.c rename to src/config.c diff --git a/config.h b/src/config.h similarity index 100% rename from config.h rename to src/config.h diff --git a/database.c b/src/database.c similarity index 100% rename from database.c rename to src/database.c diff --git a/database.h b/src/database.h similarity index 100% rename from database.h rename to src/database.h diff --git a/hook_script.c b/src/hook_script.c similarity index 100% rename from hook_script.c rename to src/hook_script.c diff --git a/hook_script.h b/src/hook_script.h similarity index 100% rename from hook_script.h rename to src/hook_script.h diff --git a/includes.h b/src/includes.h similarity index 100% rename from includes.h rename to src/includes.h diff --git a/jsonbot.c b/src/jsonbot.c similarity index 100% rename from jsonbot.c rename to src/jsonbot.c diff --git a/jsonbot.h b/src/jsonbot.h similarity index 100% rename from jsonbot.h rename to src/jsonbot.h diff --git a/sia.c b/src/sia.c similarity index 100% rename from sia.c rename to src/sia.c diff --git a/sia.h b/src/sia.h similarity index 100% rename from sia.h rename to src/sia.h diff --git a/siahs.c b/src/siahs.c similarity index 100% rename from siahs.c rename to src/siahs.c diff --git a/siahs.h b/src/siahs.h similarity index 100% rename from siahs.h rename to src/siahs.h diff --git a/siahsd.c b/src/siahsd.c similarity index 100% rename from siahsd.c rename to src/siahsd.c diff --git a/status.c b/src/status.c similarity index 100% rename from status.c rename to src/status.c diff --git a/status.h b/src/status.h similarity index 100% rename from status.h rename to src/status.h diff --git a/wscript b/wscript deleted file mode 100644 index 0d3b72d..0000000 --- a/wscript +++ /dev/null @@ -1,73 +0,0 @@ -#! /usr/bin/env python -# encoding: utf-8 - -def dist(ctx): - ctx.base_name = 'siahsd' - ctx.algo = 'tar.bz2' - ctx.excl = ' **/.waf-1* **/*~ **/*.o **/*.swp **/.lock-w*' - ctx.files = ctx.path.ant_glob('**/wscript') - -def configure(conf): - conf.env.CC = 'gcc' - conf.load('gcc') - - # Check for glib - conf.check_cfg(package='glib-2.0', uselib_store='glib-2.0', - args=['--cflags', '--libs']) - - # Check for talloc - conf.check_cfg(package='talloc', uselib_store='talloc', - args=['--cflags', '--libs' ]) - - # Check for tevent - conf.check_cfg(package='tevent', uselib_store='tevent', - args=['--cflags', '--libs' ]) - - # Check for headers - conf.check(header_name='stdio.h', features='c cprogram') - conf.check(header_name='stdlib.h', features='c cprogram') - conf.check(header_name='stdint.h', features='c cprogram') - conf.check(header_name='stdbool.h', features='c cprogram') - conf.check(header_name='sys/time.h', features='c cprogram') - conf.check(header_name='sys/types.h', features='c cprogram') - conf.check(header_name='sys/stat.h', features='c cprogram') - conf.check(header_name='netinet/in.h', features='c cprogram') - conf.check(header_name='arpa/inet.h', features='c cprogram') - conf.check(header_name='unistd.h', features='c cprogram') - conf.check(header_name='string.h', features='c cprogram') - conf.check(header_name='fcntl.h', features='c cprogram') - conf.check(header_name='errno.h', features='c cprogram') - - # Used libraries - conf.check(header_name='talloc.h', use='samba', features='c cprogram') - conf.check(header_name='glib.h', use='glib-2.0', features='c cprogram') - conf.check(header_name='dbi/dbi.h', features='c cprogram') - - conf.check_cc(lib='dbi', uselib_store='dbi') - conf.check_cc(lib='talloc', uselib_store='samba') - conf.check_cc(lib='hogweed', uselib_store='nettle') - conf.check_cc(lib='nettle', uselib_store='nettle') - - # Purposefully at the bottom because waf configuration tests fail with -Wstrict-prototypes and -Werror - conf.env.LDFLAGS = ['-fPIC', '-pie', '-z', 'relro', '-z', 'now', '-fstack-protector', '-L/usr/local/samba/lib'] - conf.env.CFLAGS = ['-O0', '-g', '-ggdb', '-std=gnu99', '-Wall', '-Wextra', '-Winit-self', '-Wformat-security','-Wshadow', '-pedantic', - '-Wpointer-arith', '-Wcast-align', '-Wwrite-strings', '-Wno-unused-parameter', - '-Werror-implicit-function-declaration', '-Wstrict-prototypes', '-fPIC', '-pie', '-fstack-protector', - '-D_FORTIFY_SOURCE=2'] - -def build(bld): - bld.stlib(source="database.c", target="database", use='glib-2.0') - bld.stlib(source="status.c", target="status", use='glib-2.0') - bld.stlib(source="hook_script.c", target="hook_script", use='glib-2.0') - bld.stlib(source="config.c", target="config", use='glib-2.0 database jsonbot hook_script') - bld.stlib(source="sia.c", target="sia", use='glib-2.0') - bld.stlib(source="siahs.c", target="siahs", use='glib-2.0') - bld.stlib(source="jsonbot.c", target="jsonbot", use='glib-2.0') - - bld.program( - source = 'siahsd.c', - target = 'siahsd', - use = [ 'database', 'config', 'status', 'sia', 'siahs', 'jsonbot', 'hook_script', 'dbi', 'talloc', 'glib-2.0', 'nettle' ]) - -def clean(ctx): - pass