diff --git a/src/common.h b/src/lib/common.h similarity index 100% rename from src/common.h rename to src/lib/common.h diff --git a/src/cpp.c b/src/lib/cpp.c similarity index 100% rename from src/cpp.c rename to src/lib/cpp.c diff --git a/src/parser.c b/src/lib/parser.c similarity index 100% rename from src/parser.c rename to src/lib/parser.c diff --git a/src/parser.h b/src/lib/parser.h similarity index 100% rename from src/parser.h rename to src/lib/parser.h diff --git a/src/lib/project.conf b/src/lib/project.conf new file mode 100644 index 0000000..c4d0abb --- /dev/null +++ b/src/lib/project.conf @@ -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 diff --git a/src/scanner.c b/src/lib/scanner.c similarity index 100% rename from src/scanner.c rename to src/lib/scanner.c diff --git a/src/project.conf b/src/project.conf index 1491d2c..d0f7999 100644 --- a/src/project.conf +++ b/src/project.conf @@ -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 diff --git a/tests/cpp.sh b/tests/cpp.sh index 4ad944d..2ef6614 100755 --- a/tests/cpp.sh +++ b/tests/cpp.sh @@ -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 diff --git a/tests/project.conf b/tests/project.conf index d8c152b..7d1b420 100644 --- a/tests/project.conf +++ b/tests/project.conf @@ -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