Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
a86e6ae9b0 | |||
2afdc3aada | |||
d3e158a717 | |||
1f93c2c86a | |||
7826c03ebc | |||
b75fc10cea | |||
2e529e785a | |||
b5d49ab82e | |||
35e6a0c428 |
27
.github/workflows/deforaos-c-ci_ubuntu-latest.yml
vendored
Normal file
27
.github/workflows/deforaos-c-ci_ubuntu-latest.yml
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
name: DeforaOS C CI (ubuntu-latest)
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: bootstrap libSystem
|
||||
run: git clone https://github.com/DeforaOS/libSystem.git libSystem && for dir in include data src; do (cd libSystem/$dir && make PREFIX="$HOME/opt/DeforaOS" install); done
|
||||
- name: bootstrap configure
|
||||
run: git clone https://github.com/DeforaOS/configure.git configure && (cd configure/src && PKG_CONFIG_PATH="$HOME/opt/DeforaOS/lib/pkgconfig" make PREFIX="$HOME/opt/DeforaOS" install)
|
||||
- name: configure
|
||||
run: $HOME/opt/DeforaOS/bin/configure -p "$HOME/opt/DeforaOS"
|
||||
- name: make
|
||||
run: PKG_CONFIG_PATH="$HOME/opt/DeforaOS/lib/pkgconfig" make CCSHARED="cc -shared"
|
||||
- name: make tests
|
||||
run: PKG_CONFIG_PATH="$HOME/opt/DeforaOS/lib/pkgconfig" make CCSHARED="cc -shared" tests
|
||||
- name: make distcheck
|
||||
run: PKG_CONFIG_PATH="$HOME/opt/DeforaOS/lib/pkgconfig" make CCSHARED="cc -shared" distcheck
|
44
README.md
Normal file
44
README.md
Normal file
|
@ -0,0 +1,44 @@
|
|||
DeforaOS CPP
|
||||
============
|
||||
|
||||
About CPP
|
||||
---------
|
||||
|
||||
CPP is a macro preprocessor for the C programming language. It provides the
|
||||
ability for the inclusion of header files, macro expansions, conditional
|
||||
compilation, and line control.
|
||||
|
||||
CPP depends on the DeforaOS libSystem library (version 0.4.3 or above),
|
||||
which is found on the website for the DeforaOS Project:
|
||||
<https://www.defora.org/>.
|
||||
|
||||
|
||||
Compiling CPP
|
||||
-------------
|
||||
|
||||
CPP depends on the following components:
|
||||
|
||||
* DeforaOS libSystem
|
||||
* An implementation of `make`
|
||||
* GTK-Doc for the API documentation
|
||||
|
||||
With GCC, this should then be enough to compile and install CPP:
|
||||
|
||||
$ make install
|
||||
|
||||
To install CPP in a dedicated directory, like `/path/to/CPP`:
|
||||
|
||||
$ make PREFIX="/path/to/CPP" install
|
||||
|
||||
Distributing CPP
|
||||
----------------
|
||||
|
||||
DeforaOS CPP is subject to the terms of the GNU LGPL license (version 3).
|
||||
Please see the `COPYING` file for more information.
|
||||
|
||||
Known issues
|
||||
------------
|
||||
|
||||
* The cpp(1) binary may conflict with the system's own version.
|
||||
* Macro expansions are not fully supported yet.
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
#$Id$
|
||||
#Copyright (c) 2011-2020 Pierre Pronchery <khorben@defora.org>
|
||||
#Copyright (c) 2011-2022 Pierre Pronchery <khorben@defora.org>
|
||||
#
|
||||
#Redistribution and use in source and binary forms, with or without
|
||||
#modification, are permitted provided that the following conditions are met:
|
||||
|
@ -31,7 +31,7 @@ DEVNULL="/dev/null"
|
|||
PROGNAME="pkgconfig.sh"
|
||||
#executables
|
||||
DEBUG="_debug"
|
||||
INSTALL="install -m 0644"
|
||||
INSTALL="install"
|
||||
MKDIR="mkdir -m 0755 -p"
|
||||
RM="rm -f"
|
||||
SED="sed"
|
||||
|
@ -40,6 +40,101 @@ SED="sed"
|
|||
|
||||
|
||||
#functions
|
||||
#pkgconfig
|
||||
_pkgconfig()
|
||||
{
|
||||
#check the variables
|
||||
if [ -z "$PACKAGE" ]; then
|
||||
_error "The PACKAGE variable needs to be set"
|
||||
return $?
|
||||
fi
|
||||
if [ -z "$VERSION" ]; then
|
||||
_error "The VERSION variable needs to be set"
|
||||
return $?
|
||||
fi
|
||||
[ -z "$BINDIR" ] && BINDIR="$PREFIX/bin"
|
||||
[ -z "$DATADIR" ] && DATADIR="$PREFIX/share"
|
||||
[ -z "$INCLUDEDIR" ] && INCLUDEDIR="$PREFIX/include"
|
||||
[ -z "$LIBDIR" ] && LIBDIR="$PREFIX/lib"
|
||||
[ -z "$LIBEXECDIR" ] && LIBEXECDIR="$PREFIX/libexec"
|
||||
[ -z "$MANDIR" ] && MANDIR="$DATADIR/man"
|
||||
[ -z "$SBINDIR" ] && SBINDIR="$PREFIX/sbin"
|
||||
if [ -z "$SYSCONFDIR" ]; then
|
||||
SYSCONFDIR="$PREFIX/etc"
|
||||
[ "$PREFIX" = "/usr" ] && SYSCONFDIR="/etc"
|
||||
fi
|
||||
PKGCONFIG="$PREFIX/lib/pkgconfig"
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
target="$1"
|
||||
shift
|
||||
|
||||
#clean
|
||||
[ "$clean" -ne 0 ] && continue
|
||||
|
||||
#uninstall
|
||||
if [ "$uninstall" -eq 1 ]; then
|
||||
$DEBUG $RM -- "$PKGCONFIG/$target" || return 2
|
||||
continue
|
||||
fi
|
||||
|
||||
#install
|
||||
if [ "$install" -eq 1 ]; then
|
||||
source="${target#$OBJDIR}"
|
||||
$DEBUG $MKDIR -- "$PKGCONFIG" || return 2
|
||||
mode="-m 0644"
|
||||
basename="$source"
|
||||
if [ "${source##*/}" != "$source" ]; then
|
||||
basename="${source##*/}"
|
||||
fi
|
||||
$DEBUG $INSTALL $mode "$target" "$PKGCONFIG/$basename" \
|
||||
|| return 2
|
||||
continue
|
||||
fi
|
||||
|
||||
#portability
|
||||
RPATH=
|
||||
if [ "$PREFIX" != "/usr" ]; then
|
||||
RPATH="-Wl,-rpath-link,\${libdir} -Wl,-rpath,\${libdir}"
|
||||
case $(uname -s) in
|
||||
"Darwin")
|
||||
RPATH="-Wl,-rpath,\${libdir}"
|
||||
;;
|
||||
"SunOS")
|
||||
RPATH="-Wl,-R\${libdir}"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
#create
|
||||
source="${target#$OBJDIR}"
|
||||
source="${source}.in"
|
||||
([ -z "$OBJDIR" ] || $DEBUG $MKDIR -- "${target%/*}") \
|
||||
|| return 2
|
||||
$DEBUG $SED -e "s;@VENDOR@;$VENDOR;g" \
|
||||
-e "s;@PACKAGE@;$PACKAGE;g" \
|
||||
-e "s;@VERSION@;$VERSION;g" \
|
||||
-e "s;@PREFIX@;$PREFIX;g" \
|
||||
-e "s;@BINDIR@;$BINDIR;g" \
|
||||
-e "s;@DATADIR@;$DATADIR;g" \
|
||||
-e "s;@INCLUDEDIR@;$INCLUDEDIR;g" \
|
||||
-e "s;@LIBDIR@;$LIBDIR;g" \
|
||||
-e "s;@LIBEXECDIR@;$LIBEXECDIR;g" \
|
||||
-e "s;@MANDIR@;$MANDIR;g" \
|
||||
-e "s;@PWD@;$PWD;g" \
|
||||
-e "s;@RPATH@;$RPATH;g" \
|
||||
-e "s;@SBINDIR@;$SBINDIR;g" \
|
||||
-e "s;@SYSCONFDIR@;$SYSCONFDIR;g" \
|
||||
-- "$source" > "$target"
|
||||
if [ $? -ne 0 ]; then
|
||||
$RM -- "$target" 2> "$DEVNULL"
|
||||
return 2
|
||||
fi
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
#debug
|
||||
_debug()
|
||||
{
|
||||
|
@ -94,91 +189,10 @@ while getopts "ciuO:P:" name; do
|
|||
esac
|
||||
done
|
||||
shift $(($OPTIND - 1))
|
||||
if [ $# -lt 0 ]; then
|
||||
if [ $# -lt 1 ]; then
|
||||
_usage
|
||||
exit $?
|
||||
fi
|
||||
|
||||
#check the variables
|
||||
if [ -z "$PACKAGE" ]; then
|
||||
_error "The PACKAGE variable needs to be set"
|
||||
exit $?
|
||||
fi
|
||||
if [ -z "$VERSION" ]; then
|
||||
_error "The VERSION variable needs to be set"
|
||||
exit $?
|
||||
fi
|
||||
[ -z "$BINDIR" ] && BINDIR="$PREFIX/bin"
|
||||
[ -z "$DATADIR" ] && DATADIR="$PREFIX/share"
|
||||
[ -z "$INCLUDEDIR" ] && INCLUDEDIR="$PREFIX/include"
|
||||
[ -z "$LIBDIR" ] && LIBDIR="$PREFIX/lib"
|
||||
[ -z "$LIBEXECDIR" ] && LIBEXECDIR="$PREFIX/libexec"
|
||||
[ -z "$MANDIR" ] && MANDIR="$DATADIR/man"
|
||||
if [ -z "$SYSCONFDIR" ]; then
|
||||
SYSCONFDIR="$PREFIX/etc"
|
||||
[ "$PREFIX" = "/usr" ] && SYSCONFDIR="/etc"
|
||||
fi
|
||||
|
||||
PKGCONFIG="$PREFIX/lib/pkgconfig"
|
||||
exec 3>&1
|
||||
while [ $# -gt 0 ]; do
|
||||
target="$1"
|
||||
shift
|
||||
|
||||
#clean
|
||||
[ "$clean" -ne 0 ] && continue
|
||||
|
||||
#uninstall
|
||||
if [ "$uninstall" -eq 1 ]; then
|
||||
$DEBUG $RM -- "$PKGCONFIG/$target" || exit 2
|
||||
continue
|
||||
fi
|
||||
|
||||
#install
|
||||
if [ "$install" -eq 1 ]; then
|
||||
source="${target#$OBJDIR}"
|
||||
$DEBUG $MKDIR -- "$PKGCONFIG" || exit 2
|
||||
basename="$source"
|
||||
if [ "${source##*/}" != "$source" ]; then
|
||||
basename="${source##*/}"
|
||||
fi
|
||||
$DEBUG $INSTALL "$target" "$PKGCONFIG/$basename"|| exit 2
|
||||
continue
|
||||
fi
|
||||
|
||||
#portability
|
||||
RPATH=
|
||||
if [ "$PREFIX" != "/usr" ]; then
|
||||
RPATH="-Wl,-rpath-link,\${libdir} -Wl,-rpath,\${libdir}"
|
||||
case $(uname -s) in
|
||||
"Darwin")
|
||||
RPATH="-Wl,-rpath,\${libdir}"
|
||||
;;
|
||||
"SunOS")
|
||||
RPATH="-Wl,-R\${libdir}"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
#create
|
||||
source="${target#$OBJDIR}"
|
||||
source="${source}.in"
|
||||
([ -z "$OBJDIR" ] || $DEBUG $MKDIR -- "${target%/*}") || exit 2
|
||||
$DEBUG $SED -e "s;@PACKAGE@;$PACKAGE;g" \
|
||||
-e "s;@VERSION@;$VERSION;g" \
|
||||
-e "s;@PREFIX@;$PREFIX;g" \
|
||||
-e "s;@BINDIR@;$BINDIR;g" \
|
||||
-e "s;@DATADIR@;$DATADIR;g" \
|
||||
-e "s;@INCLUDEDIR@;$INCLUDEDIR;g" \
|
||||
-e "s;@LIBDIR@;$LIBDIR;g" \
|
||||
-e "s;@LIBEXECDIR@;$LIBEXECDIR;g" \
|
||||
-e "s;@MANDIR@;$MANDIR;g" \
|
||||
-e "s;@PWD@;$PWD;g" \
|
||||
-e "s;@RPATH@;$RPATH;g" \
|
||||
-e "s;@SYSCONFDIR@;$SYSCONFDIR;g" \
|
||||
-- "$source" > "$target"
|
||||
if [ $? -ne 0 ]; then
|
||||
$DEBUG $RM -- "$target"
|
||||
exit 2
|
||||
fi
|
||||
done
|
||||
_pkgconfig "$@"
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package=CPP
|
||||
version=0.0.5
|
||||
version=0.0.6
|
||||
vendor=Devel
|
||||
config=ent,h,sh
|
||||
|
||||
subdirs=data,doc,include,src,tests
|
||||
targets=tests
|
||||
dist=Makefile,COPYING,config.ent,config.h,config.sh
|
||||
dist=Makefile,COPYING,README.md,config.ent,config.h,config.sh
|
||||
|
||||
#modes
|
||||
[mode::debug]
|
||||
|
@ -25,3 +25,6 @@ phony=1
|
|||
#dist
|
||||
[COPYING]
|
||||
install=$(PREFIX)/share/doc/$(PACKAGE)
|
||||
|
||||
[README.md]
|
||||
install=$(PREFIX)/share/doc/$(PACKAGE)
|
||||
|
|
24
src/main.c
24
src/main.c
|
@ -1,5 +1,5 @@
|
|||
/* $Id$ */
|
||||
/* Copyright (c) 2007-2013 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2007-2022 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Devel cpp */
|
||||
/* 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
|
||||
|
@ -24,6 +24,10 @@
|
|||
#include <errno.h>
|
||||
#include "CPP.h"
|
||||
|
||||
#ifndef PROGNAME_CPP
|
||||
# define PROGNAME_CPP "cpp"
|
||||
#endif
|
||||
|
||||
|
||||
/* cpp */
|
||||
/* private */
|
||||
|
@ -62,13 +66,13 @@ static int _cpp(Prefs * prefs, int filec, char * filev[])
|
|||
if(prefs->outfile == NULL)
|
||||
fp = stdout;
|
||||
else if((fp = fopen(prefs->outfile, "w")) == NULL)
|
||||
return error_set_print("cpp", 1, "%s: %s", prefs->outfile,
|
||||
strerror(errno));
|
||||
return error_set_print(PROGNAME_CPP, 1, "%s: %s",
|
||||
prefs->outfile, strerror(errno));
|
||||
for(i = 0; i < filec; i++)
|
||||
ret |= _cpp_do(prefs, fp, filev[i]);
|
||||
if(fclose(fp) != 0)
|
||||
return error_set_print("cpp", 1, "%s: %s", prefs->outfile,
|
||||
strerror(errno));
|
||||
return error_set_print(PROGNAME_CPP, 1, "%s: %s",
|
||||
prefs->outfile, strerror(errno));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -143,7 +147,7 @@ static void _do_print_token(FILE * fp, Token * token)
|
|||
/* cpp_error */
|
||||
static int _cpp_error(void)
|
||||
{
|
||||
return error_print("cpp");
|
||||
return error_print(PROGNAME_CPP);
|
||||
}
|
||||
|
||||
|
||||
|
@ -151,7 +155,7 @@ static int _cpp_error(void)
|
|||
/* FIXME -E prints metadata? */
|
||||
static int _usage(void)
|
||||
{
|
||||
fputs("Usage: cpp [-D name[=value]]...[-I directory][-o file][-t][-U name]... input...\n"
|
||||
fputs("Usage: " PROGNAME_CPP " [-D name[=value]]...[-I directory][-o file][-t][-U name]... input...\n"
|
||||
" -D Add a substitution\n"
|
||||
" -I Add a directory to the search path\n"
|
||||
" -o Write output to a file\n"
|
||||
|
@ -218,7 +222,7 @@ static int _main_add_define(Prefs * prefs, char * define)
|
|||
value = strtok(define, "=");
|
||||
if((p = realloc(prefs->defines, sizeof(*p) * (prefs->defines_cnt + 1)))
|
||||
== NULL)
|
||||
return error_set_print("cpp", 1, "%s", strerror(errno));
|
||||
return error_set_print(PROGNAME_CPP, 1, "%s", strerror(errno));
|
||||
prefs->defines = p;
|
||||
prefs->defines[prefs->defines_cnt++] = define;
|
||||
return 0;
|
||||
|
@ -230,7 +234,7 @@ static int _main_add_path(Prefs * prefs, char const * path)
|
|||
|
||||
if((p = realloc(prefs->paths, sizeof(*p) * (prefs->paths_cnt + 1)))
|
||||
== NULL)
|
||||
return error_set_print("cpp", 1, "%s", strerror(errno));
|
||||
return error_set_print(PROGNAME_CPP, 1, "%s", strerror(errno));
|
||||
prefs->paths = p;
|
||||
prefs->paths[prefs->paths_cnt++] = path;
|
||||
return 0;
|
||||
|
@ -244,7 +248,7 @@ static int _main_add_undefine(Prefs * prefs, char const * undefine)
|
|||
return 1;
|
||||
if((p = realloc(prefs->undefines, sizeof(*p)
|
||||
* (prefs->undefines_cnt + 1))) == NULL)
|
||||
return error_set_print("cpp", 1, "%s", strerror(errno));
|
||||
return error_set_print(PROGNAME_CPP, 1, "%s", strerror(errno));
|
||||
prefs->undefines = p;
|
||||
prefs->undefines[prefs->undefines_cnt++] = undefine;
|
||||
return 0;
|
||||
|
|
|
@ -19,6 +19,8 @@ cflags=-W -Wall -O2 -pedantic -D_FORTIFY_SOURCE=2 -fstack-protector
|
|||
[cpp]
|
||||
type=binary
|
||||
sources=main.c
|
||||
#XXX should really use this (race condition with "make -k")
|
||||
depends=$(OBJDIR)lib/libcpp$(SOEXT)
|
||||
depends=$(OBJDIR)lib/libcpp.a
|
||||
ldflags=-L$(OBJDIR)lib -L$(LIBDIR) -Wl,-rpath,$(LIBDIR) -lcpp
|
||||
install=$(BINDIR)
|
||||
|
|
|
@ -122,7 +122,7 @@ _fixme_callback()
|
|||
echo "_fixme_callback_python"
|
||||
return 0
|
||||
;;
|
||||
"<html"*|"<?xml"*)
|
||||
"<!DOCTYPE"*|"<!doctype"*|"<HTML"*|"<html"*|"<?xml"*)
|
||||
echo "_fixme_callback_xml"
|
||||
return 0
|
||||
;;
|
||||
|
|
Loading…
Reference in New Issue
Block a user