Build libcpp in its own folder

This commit is contained in:
Pierre Pronchery 2022-01-31 18:59:54 +01:00
parent df68815cb5
commit 67e0f4b38f
9 changed files with 43 additions and 31 deletions

24
src/lib/project.conf Normal file
View File

@ -0,0 +1,24 @@
targets=libcpp
cppflags_force=-I ../../include
cppflags=
cflags_force=`pkg-config --cflags libSystem` -fPIC
cflags=-W -Wall -g -O2 -pedantic -D_FORTIFY_SOURCE=2 -fstack-protector-all
ldflags_force=`pkg-config --libs libSystem`
ldflags=
dist=Makefile,common.h,parser.h
#targets
[libcpp]
type=library
sources=cpp.c,parser.c,scanner.c
install=$(LIBDIR)
#sources
[cpp.c]
depends=common.h,../../include/CPP.h
[parser.c]
depends=parser.h,../../include/CPP.h
[scanner.c]
depends=common.h,../../include/CPP.h

View File

@ -1,34 +1,21 @@
targets=libcpp,cpp
subdirs=lib
targets=cpp
cppflags_force=-I ../include
cppflags=
cflags_force=`pkg-config --cflags libSystem`
cflags_force=`pkg-config --cflags libSystem` -fPIE
cflags=-W -Wall -g -O2 -pedantic -D_FORTIFY_SOURCE=2 -fstack-protector-all
ldflags_force=`pkg-config --libs libSystem`
ldflags=
ldflags=-pie -Wl,-z,relro -Wl,-z,now
dist=Makefile,common.h,parser.h
[libcpp]
type=library
sources=cpp.c,parser.c,scanner.c
cflags=-fPIC
install=$(LIBDIR)
[cpp.c]
depends=common.h,../include/CPP.h
[parser.c]
depends=parser.h,../include/CPP.h
[scanner.c]
depends=common.h,../include/CPP.h
#targets
[cpp]
type=binary
sources=main.c
depends=$(OBJDIR)libcpp.so
cflags=-fPIE
ldflags=-L$(OBJDIR). -L$(LIBDIR) -Wl,-rpath,$(LIBDIR) -lcpp -pie -Wl,-z,relro -Wl,-z,now
depends=$(OBJDIR)lib/libcpp.a
ldflags=-L$(OBJDIR)lib -L$(LIBDIR) -Wl,-rpath,$(LIBDIR) -lcpp
install=$(BINDIR)
#sources
[main.c]
depends=../include/CPP.h

View File

@ -27,8 +27,7 @@
#variables
PROGNAME="cpp.sh"
#executables
CPP="../src/cpp"
[ -n "$OBJDIR" ] && CPP="${OBJDIR}../src/cpp"
CPP="$OBJDIR../src/cpp"
#functions
@ -64,14 +63,14 @@ fi
if [ $# -eq 1 -a -n "$output" ]; then
target="$1"
LD_LIBRARY_PATH="../src" $CPP "$target" > "$output"
LD_LIBRARY_PATH="$OBJDIR../src/lib" $CPP "$target" > "$output"
elif [ $# -ge 1 -a -z "$output" ]; then
while [ $# -gt 0 ]; do
target="$1"
output="${target%.cpp}.o"
shift
LD_LIBRARY_PATH="../src" $CPP "$target" > "$output"
LD_LIBRARY_PATH="$OBJDIR../src/lib" $CPP "$target" > "$output"
done
else
_usage

View File

@ -3,14 +3,12 @@ cxx=./cpp.sh
cxxflags=
dist=Makefile,cpp.sh,include-define.cpp
#targets
[define.o]
type=object
sources=define.cpp
depends=../src/cpp
[define.cpp]
depends=cpp.sh
[fixme.log]
type=script
script=./fixme.sh
@ -22,13 +20,17 @@ type=object
sources=if.cpp
depends=../src/cpp
[if.cpp]
depends=cpp.sh
[include.o]
type=object
sources=include.cpp
depends=../src/cpp
#sources
[define.cpp]
depends=cpp.sh
[if.cpp]
depends=cpp.sh
[include.cpp]
depends=cpp.sh