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_force=-I ../include
cppflags= 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 cflags=-W -Wall -g -O2 -pedantic -D_FORTIFY_SOURCE=2 -fstack-protector-all
ldflags_force=`pkg-config --libs libSystem` ldflags_force=`pkg-config --libs libSystem`
ldflags= ldflags=-pie -Wl,-z,relro -Wl,-z,now
dist=Makefile,common.h,parser.h dist=Makefile,common.h,parser.h
[libcpp] #targets
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
[cpp] [cpp]
type=binary type=binary
sources=main.c sources=main.c
depends=$(OBJDIR)libcpp.so depends=$(OBJDIR)lib/libcpp.a
cflags=-fPIE ldflags=-L$(OBJDIR)lib -L$(LIBDIR) -Wl,-rpath,$(LIBDIR) -lcpp
ldflags=-L$(OBJDIR). -L$(LIBDIR) -Wl,-rpath,$(LIBDIR) -lcpp -pie -Wl,-z,relro -Wl,-z,now
install=$(BINDIR) install=$(BINDIR)
#sources
[main.c] [main.c]
depends=../include/CPP.h depends=../include/CPP.h

View File

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

View File

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