From 06816f09c2ab7d363dfa783945344dfb534652cb Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Fri, 27 Nov 2009 21:37:38 +0000 Subject: [PATCH] Introduced the script target --- src/Makefile | 2 +- src/configure.c | 2 +- src/configure.h | 2 +- src/makefile.c | 84 ++++++++++++++++++++++++++++++++++++++++++------ src/makefile.h | 2 +- src/project.conf | 2 +- 6 files changed, 80 insertions(+), 14 deletions(-) diff --git a/src/Makefile b/src/Makefile index 5db1cb3..08fec6c 100644 --- a/src/Makefile +++ b/src/Makefile @@ -34,7 +34,7 @@ makedepend: $(makedepend_OBJS) configure.o: configure.c configure.h makefile.h ../config.h $(CC) $(configure_CFLAGS) -c configure.c -makefile.o: makefile.c configure.h settings.h +makefile.o: makefile.c configure.h settings.h ../config.h $(CC) $(configure_CFLAGS) -c makefile.c settings.o: settings.c settings.h diff --git a/src/configure.c b/src/configure.c index fc8e45c..1a8153d 100644 --- a/src/configure.c +++ b/src/configure.c @@ -66,7 +66,7 @@ const struct HostKernel sHostKernel[] = }; const String * sTargetType[TT_COUNT] = { "binary", "library", "libtool", - "object", "plugin", NULL }; + "object", "plugin", "script", NULL }; const String * sObjectType[OT_COUNT] = { "c", "cc", "cpp", "S", NULL }; String const * _source_extension(String const * source) diff --git a/src/configure.h b/src/configure.h index 5a5729c..001d819 100644 --- a/src/configure.h +++ b/src/configure.h @@ -66,7 +66,7 @@ extern const struct HostKernel sHostKernel[HK_COUNT]; typedef enum _TargetType { - TT_BINARY = 0, TT_LIBRARY, TT_LIBTOOL, TT_OBJECT, TT_PLUGIN, + TT_BINARY = 0, TT_LIBRARY, TT_LIBTOOL, TT_OBJECT, TT_PLUGIN, TT_SCRIPT, TT_UNKNOWN } TargetType; # define TT_LAST TT_UNKNOWN diff --git a/src/makefile.c b/src/makefile.c index a0b7191..b419d74 100644 --- a/src/makefile.c +++ b/src/makefile.c @@ -21,6 +21,7 @@ #include #include "settings.h" #include "configure.h" +#include "../config.h" ARRAY(Config *, config) @@ -131,7 +132,7 @@ static int _variables_package(Configure * configure, FILE * fp, { if(configure->prefs->flags & PREFS_v) fputc('\n', stdout); - fprintf(stderr, "%s%s%s", "configure: ", directory, + fprintf(stderr, "%s%s%s", PACKAGE ": ", directory, ": \"package\" needs \"version\"\n"); return 1; } @@ -253,6 +254,7 @@ static int _variables_targets(Configure * configure, FILE * fp) { case TT_BINARY: case TT_OBJECT: + case TT_SCRIPT: case TT_UNKNOWN: fprintf(fp, " %s", prints); break; @@ -365,6 +367,7 @@ static void _executables_variables(Configure * configure, FILE * fp, _variables_libtool(configure, fp, done); break; case TT_OBJECT: + case TT_SCRIPT: case TT_UNKNOWN: break; } @@ -677,6 +680,8 @@ static int _target_object(Configure * configure, FILE * fp, String const * target); static int _target_plugin(Configure * configure, FILE * fp, String const * target); +static int _target_script(Configure * configure, FILE * fp, + String const * target); static int _targets_target(Configure * configure, FILE * fp, String const * target) { @@ -685,7 +690,7 @@ static int _targets_target(Configure * configure, FILE * fp, if((type = config_get(configure->config, target, "type")) == NULL) { - fprintf(stderr, "%s%s%s", "configure: ", target, + fprintf(stderr, "%s%s%s", PACKAGE ": ", target, ": no type defined for target\n"); return 1; } @@ -702,8 +707,10 @@ static int _targets_target(Configure * configure, FILE * fp, return _target_object(configure, fp, target); case TT_PLUGIN: return _target_plugin(configure, fp, target); + case TT_SCRIPT: + return _target_script(configure, fp, target); case TT_UNKNOWN: - fprintf(stderr, "%s%s%s", "configure: ", target, + fprintf(stderr, "%s%s%s", PACKAGE ": ", target, ": unknown type for target\n"); return 1; } @@ -727,7 +734,7 @@ static int _target_objs(Configure * configure, FILE * fp, tt = enum_string(TT_LAST, sTargetType, p); if((p = config_get(configure->config, target, "sources")) == NULL) { - fprintf(stderr, "%s%s%s", "configure: ", target, + fprintf(stderr, "%s%s%s", PACKAGE ": ", target, ": no sources defined for target\n"); return 1; } @@ -763,7 +770,7 @@ static int _objs_source(Prefs * prefs, FILE * fp, String * source, if((extension = _source_extension(source)) == NULL) { - fprintf(stderr, "%s%s%s", "configure: ", source, + fprintf(stderr, "%s%s%s", PACKAGE ": ", source, ": no extension for source\n"); return 1; } @@ -782,7 +789,7 @@ static int _objs_source(Prefs * prefs, FILE * fp, String * source, break; case OT_UNKNOWN: ret = 1; - fprintf(stderr, "%s%s%s", "configure: ", source, + fprintf(stderr, "%s%s%s", PACKAGE ": ", source, ": unknown extension for source\n"); break; } @@ -996,13 +1003,13 @@ static int _target_object(Configure * configure, FILE * fp, if((p = config_get(configure->config, target, "sources")) == NULL) { - fprintf(stderr, "%s%s%s", "configure: ", target, + fprintf(stderr, "%s%s%s", PACKAGE ": ", target, ": No sources for target\n"); return 1; } if(strchr(p, ',') != NULL) { - fprintf(stderr, "%s%s%s", "configure: ", target, + fprintf(stderr, "%s%s%s", PACKAGE ": ", target, ": An object can have only one source file\n"); return 1; } @@ -1043,7 +1050,7 @@ static int _target_object(Configure * configure, FILE * fp, fputc('\n', fp); break; case OT_UNKNOWN: - fprintf(stderr, "%s%s%s", "configure: ", target, + fprintf(stderr, "%s%s%s", PACKAGE ": ", target, ": Unknown source type for object\n"); return 1; } @@ -1112,6 +1119,28 @@ static int _write_objects(Configure * configure, FILE * fp) return ret; } +static int _target_script(Configure * configure, FILE * fp, + String const * target) +{ + String const * script; + String const * p; + + if((script = config_get(configure->config, target, "script")) == NULL) + { + fprintf(stderr, "%s%s%s", PACKAGE ": ", target, + ": No script for target\n"); + return 1; + } + if(configure->prefs->flags & PREFS_n) + return 0; + fprintf(fp, "\n%s:", target); + if((p = config_get(configure->config, target, "depends")) != NULL) + fprintf(fp, " %s", p); + fputc('\n', fp); + fprintf(fp, "\t%s \"%s\"\n", script, target); + return 0; +} + static int _target_source(Configure * configure, FILE * fp, String const * target, String * source); static int _objects_target(Configure * configure, FILE * fp, @@ -1510,6 +1539,8 @@ static void _install_target_object(Config * config, FILE * fp, String const * target); static void _install_target_plugin(Config * config, FILE * fp, String const * target); +static void _install_target_script(Config * config, FILE * fp, + String const * target); static int _install_target(Config * config, FILE * fp, String const * target) { int ret = 0; @@ -1535,6 +1566,9 @@ static int _install_target(Config * config, FILE * fp, String const * target) case TT_PLUGIN: _install_target_plugin(config, fp, target); break; + case TT_SCRIPT: + _install_target_script(config, fp, target); + break; case TT_UNKNOWN: break; } @@ -1619,6 +1653,21 @@ static void _install_target_plugin(Config * config, FILE * fp, ".so $(DESTDIR)", path, target, ".so\n"); } +static void _install_target_script(Config * config, FILE * fp, + String const * target) +{ + String const * path; + String const * script; + + if((path = config_get(config, target, "install")) == NULL) + return; + if((script = config_get(config, target, "script")) == NULL) + return; + fprintf(fp, "\t%s%s%s%s%s%s%s", script, " -p \"$(PREFIX)", + *path ? "/" : "", *path ? path : "", "\" install \"", + target, "\"\n"); +} + static int _install_include(Config * config, FILE * fp, String const * include); static int _install_includes(Configure * configure, FILE * fp) { @@ -1782,6 +1831,8 @@ static int _write_uninstall(Configure * configure, FILE * fp) static void _uninstall_target_library(Config * config, FILE * fp, String const * target, String const * path); +static void _uninstall_target_script(Config * config, FILE * fp, + String const * target, String const * path); static int _uninstall_target(Config * config, FILE * fp, String const * target) { String const * type; @@ -1814,6 +1865,9 @@ static int _uninstall_target(Config * config, FILE * fp, String const * target) fprintf(fp, "\t%s%s/%s%s\n", rm_destdir, path, target, ".so"); break; + case TT_SCRIPT: + _uninstall_target_script(config, fp, target, path); + break; case TT_UNKNOWN: break; } @@ -1841,6 +1895,18 @@ static void _uninstall_target_library(Config * config, FILE * fp, fprintf(fp, format, rm_destdir, path, target, ".so\n"); } +static void _uninstall_target_script(Config * config, FILE * fp, + String const * target, String const * path) +{ + String const * script; + + if((script = config_get(config, target, "script")) == NULL) + return; + fprintf(fp, "\t%s%s%s%s%s%s%s", script, " -p \"$(PREFIX)", + *path ? "/" : "", *path ? path : "", "\" uninstall \"", + target, "\"\n"); +} + static int _uninstall_include(Config * config, FILE * fp, String const * include) { diff --git a/src/makefile.h b/src/makefile.h index 386c8f1..1017c21 100644 --- a/src/makefile.h +++ b/src/makefile.h @@ -1,5 +1,5 @@ /* $Id$ */ -/* Copyright (c) 2007 Pierre Pronchery */ +/* Copyright (c) 2009 Pierre Pronchery */ /* This file is part of DeforaOS Devel configure */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/project.conf b/src/project.conf index fbb00b7..932abb1 100644 --- a/src/project.conf +++ b/src/project.conf @@ -14,7 +14,7 @@ install=$(BINDIR) depends=configure.h,makefile.h,../config.h [makefile.c] -depends=configure.h,settings.h +depends=configure.h,settings.h,../config.h [settings.c] depends=settings.h