From 4e869640036110df20ccde74fcb5a5167f28622a Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Thu, 26 Nov 2009 03:01:32 +0000 Subject: [PATCH] Ported to Cygwin and Bison 2.3. --- CYGWIN_NT-6.1.mk | 3 +++ Cycript.y.in => Cycript.yy.in | 26 ++++++++++++++------------ Execute.mk | 2 +- FreeBSD.mk | 1 + Linux.mk | 1 + makefile | 25 +++++++++++++------------ 6 files changed, 33 insertions(+), 25 deletions(-) create mode 100644 CYGWIN_NT-6.1.mk rename Cycript.y.in => Cycript.yy.in (99%) diff --git a/CYGWIN_NT-6.1.mk b/CYGWIN_NT-6.1.mk new file mode 100644 index 0000000..b1d81ac --- /dev/null +++ b/CYGWIN_NT-6.1.mk @@ -0,0 +1,3 @@ +lib := +dll := dll +library += -liconv diff --git a/Cycript.y.in b/Cycript.yy.in similarity index 99% rename from Cycript.y.in rename to Cycript.yy.in index 3b7d21f..ece104f 100644 --- a/Cycript.y.in +++ b/Cycript.yy.in @@ -37,13 +37,13 @@ */ /* }}} */ -%code top { -#include "Cycript.tab.hh" -#define scanner driver.scanner_ +%{ +#define cyscanner driver.scanner_ #define YYSTACKEXPANDABLE 1 -} +#define yyerrok (yyerrstatus_ = 0) +%} -%code requires { +%{ #include "Parser.hpp" @begin ObjectiveC @@ -111,15 +111,17 @@ typedef struct { }; } YYSTYPE; -} +#define YYSTYPE YYSTYPE -%code provides { -int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner); -} +%} -%name-prefix "cy" +%{ +int cylex(YYSTYPE *, cy::location *, void *); +%} -%language "C++" +%name-prefix="cy" + +%skeleton "lalr1.cc" %locations %initial-action { @@ -134,7 +136,7 @@ int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner); %error-verbose %parse-param { CYDriver &driver } -%lex-param { void *scanner } +%lex-param { void *cyscanner } @begin E4X %token XMLCDATA diff --git a/Execute.mk b/Execute.mk index 0ca2737..053d55f 100644 --- a/Execute.mk +++ b/Execute.mk @@ -2,7 +2,7 @@ CY_EXECUTE := 1 flags += -DCY_EXECUTE code += sig/ffi_type.o sig/parse.o sig/copy.o code += Execute.o Bridge.o -library += $(apr) -lffi +library += -lffi filters += C Bridge.gperf: Bridge.def Bridge.sh diff --git a/FreeBSD.mk b/FreeBSD.mk index c8b2607..0584b3d 100644 --- a/FreeBSD.mk +++ b/FreeBSD.mk @@ -1,3 +1,4 @@ export PATH := /usr/local/bin:/usr/local/GNUstep/System/Tools:$(PATH) gcc := g++42 +flags += -fPIC include PkgConfig.mk diff --git a/Linux.mk b/Linux.mk index 87d0af4..0f8c8ce 100644 --- a/Linux.mk +++ b/Linux.mk @@ -1 +1,2 @@ +flags += -fPIC include PkgConfig.mk diff --git a/makefile b/makefile index 8e1d55f..3100f0a 100644 --- a/makefile +++ b/makefile @@ -36,9 +36,10 @@ inject := filters := #E4X ldid := true entitle := $(ldid) +lib := lib dll := so apr := $(shell apr-1-config --link-ld) -library := +library := $(apr) console := $(apr) -lreadline depends := @@ -58,10 +59,10 @@ endif endif flags += -Wall -Werror -Wno-parentheses #-Wno-unused -flags += -fPIC -fno-common +flags += -fno-common flags += -I. -Iinclude -I$(shell apr-1-config --includedir) -all += libcycript.$(dll) +all += $(lib)cycript.$(dll) ifdef arch deb := $(shell grep ^Package: control.in | cut -d ' ' -f 2-)_$(shell grep ^Version: control.in | cut -d ' ' -f 2 | sed -e 's/\#/$(svn)/')_$(arch).deb @@ -71,12 +72,12 @@ all: $(deb) extra:: ifeq ($(depends)$(dll),dylib) -control.tmp: control.in cycript libcycript.dylib +control.tmp: control.in cycript $(lib)cycript.dylib sed -e 's/&/'"$$(dpkg-query -S $$(otool -lah cycript *.dylib | grep dylib | grep -v ':$$' | sed -e 's/^ *name //;s/ (offset [0-9]*)$$//' | sort -u) 2>/dev/null | sed -e 's/:.*//; /^cycript$$/ d; s/$$/,/' | sort -u | tr '\n' ' ')"'/;s/, $$//;s/#/$(svn)/;s/%/$(arch)/' $< >$@ else ifeq ($(depends)$(dll),so) -control.tmp: control.in cycript libcycript.so - sed -e 's/&/'"$$(dpkg-query -S $$(ldd cycript libcycript.so | sed -e '/:$$/ d; s/^[ \t]*\([^ ]* => \)\?\([^ ]*\) .*/\2/' | sort -u) 2>/dev/null | sed -e 's/:.*//; /^cycript$$/ d; s/$$/,/' | sort -u | tr '\n' ' ')"'/;s/, $$//;s/#/$(svn)/;s/%/$(arch)/' $< >$@ +control.tmp: control.in cycript $(lib)cycript.so + sed -e 's/&/'"$$(dpkg-query -S $$(ldd cycript $(lib)cycript.so | sed -e '/:$$/ d; s/^[ \t]*\([^ ]* => \)\?\([^ ]*\) .*/\2/' | sort -u) 2>/dev/null | sed -e 's/:.*//; /^cycript$$/ d; s/$$/,/' | sort -u | tr '\n' ' ')"'/;s/, $$//;s/#/$(svn)/;s/%/$(arch)/' $< >$@ else control.tmp: control.in sed -e 's/&/$(foreach depend,$(depends),$(depend),)/;s/,$$//;s/#/$(svn)/;s/%/$(arch)/' $< >$@ @@ -92,7 +93,7 @@ $(deb): $(all) control cp -pR control package/DEBIAN mkdir -p package/usr/{bin,lib,sbin} $(restart) extra - cp -pR libcycript.$(dll) package/usr/lib + cp -pR $(lib)cycript.$(dll) package/usr/lib cp -pR cycript package/usr/bin #cp -pR cyrver package/usr/sbin dpkg-deb -b package $(deb) @@ -101,15 +102,15 @@ endif all: $(all) clean: - rm -f *.o libcycript.$(dll) $(all) Struct.hpp lex.cy.c Cycript.tab.cc Cycript.tab.hh location.hh position.hh stack.hh cyrver Cycript.y Cycript.l control Bridge.hpp + rm -f *.o $(lib)cycript.$(dll) $(all) Struct.hpp lex.cy.c Cycript.tab.cc Cycript.tab.hh location.hh position.hh stack.hh cyrver Cycript.yy Cycript.l control Bridge.hpp -%.y: %.y.in +%.yy: %.yy.in ./Filter.sh <$< >$@ $(filters) %.l: %.l.in ./Filter.sh <$< >$@ $(filters) -Cycript.tab.cc Cycript.tab.hh location.hh position.hh: Cycript.y +Cycript.tab.cc Cycript.tab.hh location.hh position.hh: Cycript.yy bison -v --report=state $< lex.cy.c: Cycript.l @@ -131,11 +132,11 @@ lex.cy.o: lex.cy.c $(header) %.o: %.mm $(header) $(target)$(gcc) $(objc) $(flags) -c -o $@ $< -libcycript.$(dll): $(code) +$(lib)cycript.$(dll): $(code) $(target)$(gcc) $(flags) -shared -dynamiclib -o $@ $(filter %.o,$^) $(library) $(link) $(ldid) $@ -cycript: Console.o libcycript.$(dll) $(inject) +cycript: Console.o $(lib)cycript.$(dll) $(inject) $(target)$(gcc) $(flags) -o $@ $(filter %.o,$^) -L. -lcycript $(console) $(link) $(entitle) cycript -- 2.45.2