include include.mk
UNAME ?= $(shell uname)
-CYGWIN = $(findstring CYGWIN, $(UNAME))
-MINGW = $(findstring MINGW32, $(UNAME))
+CYGWIN = $(findstring CYGWIN, $(UNAME))
+MINGW = $(findstring MINGW, $(UNAME))
CFLAGS += -Wall -Wextra -Werror -Wstrict-aliasing -Wno-attributes
#turn on tons of warnings if clang is present
# do this last otherwise there is whitespace in the command output and
# it makes my OCD act up
-CFLAGS += $(OPTIONAL)
+CFLAGS += $(OPTIONAL_CFLAGS)
+LDFLAGS += $(OPTIONAL_LDFLAGS)
#we have duplicate object files when dealing with creating a simple list
#for dependinces. To combat this we use some clever recrusive-make to
.NOTPARALLEL: base
.NOTPARALLEL: upload
+HEADER=\e[5;32;40m
+RESET=\e[0;37;40m
+INFO=\e[5;33;40m
+
base:
- $(MAKE) -C deb/
- $(MAKE) -C deb/ CARCH=i686
- $(MAKE) -C archlinux/this/
- $(MAKE) -C archlinux/this/ CARCH=i686
- $(MAKE) -C win32/
- $(MAKE) -C slackware/this/
- $(MAKE) -C slackware/this/ CARCH=i686
- @mv deb/*.deb ./
- @mv archlinux/this/*pkg.tar.xz ./
- @mv win32/*.zip ./
- @mv slackware/this/*.txz ./
+ @echo -e "\n$(HEADER)Building Debian packages ...$(RESET)"
+ @echo -e " $(INFO)=> building 64-bit package$(RESET)"
+ @$(MAKE) -C deb/ >/dev/null
+ @echo -e " $(INFO)=> building 32-bit package$(RESET)"
+ @$(MAKE) -C deb/ CARCH=i686 OPTIONAL_CFLAGS=-m32 OPTIONAL_LDFLAGS=-m32 >/dev/null
+
+ @echo -e "\n$(HEADER)Building ArchLinux packages ...$(RESET)"
+ @echo -e " $(INFO)=> building 64-bit package$(RESET)"
+ @$(MAKE) -C archlinux/this/ >/dev/null
+ @echo -e " $(INFO)=> building 32-bit package$(RESET)"
+ @$(MAKE) -C archlinux/this/ CARCH=i686 OPTIONAL_CFLAGS=-m32 OPTIONAL_LDFLAGS=-m32 >/dev/null
+
+ @echo -e "\n$(HEADER)Building ArchBSD packages ...$(RESET)"
+ @echo -e " $(INFO)=> building 64-bit package$(RESET)"
+ @$(MAKE) -C archbsd/this/ >/dev/null
+ @echo -e " $(INFO)=> building 32-bit package$(RESET)"
+ @$(MAKE) -C archbsd/this/ CARCH=i686 OPTIONAL_CFLAGS=-m32 OPTIONAL_LDFLAGS=-m32 >/dev/null
+
+ @echo -e "\n$(HEADER)Building Slackware packages ...$(RESET)"
+ @echo -e " $(INFO)=> building 64-bit package$(RESET)"
+ @$(MAKE) -C slackware/this/ >/dev/null
+ @echo -e " $(INFO)=> building 32-bit package$(RESET)"
+ @$(MAKE) -C slackware/this/ CARCH=i686 OPTIONAL_CFLAGS=-m32 OPTIONAL_LDFLAGS=-m32 >/dev/null
+
+ @echo -e "\n$(HEADER)Building Fedora packages ...$(RESET)"
+ @echo -e " $(INFO)=> building 64-bit package$(RESET)"
+ @$(MAKE) -C fedora/this/ >/dev/null
+ @echo -e "\n\$(HEADER)Building Windows packages ...$(RESET)"
+ @echo -e " $(INFO)=> building 64-bit package$(RESET)"
+ @$(MAKE) -C win64/ >/dev/null
+ @echo -e " $(INFO)=> building 32-bit package$(RESET)"
+ @$(MAKE) -C win32/ >/dev/null
+
+ @rm -rf pkgs/
+ @mkdir pkgs/
+ @mv deb/*.deb ./pkgs/
+ @mv archlinux/this/*pkg.tar.xz ./pkgs/
+ @mv archbsd/this/*pkg.tar.xz ./pkgs/
+ @mv win32/*.zip ./pkgs/
+ @mv win64/*.zip ./pkgs/
+ @mv slackware/this/*.txz ./pkgs/
+ @mv fedora/this/*.rpm ./pkgs/
+
+ @echo -e "\n\n$(HEADER)Completed:$(RESET)"
+ @find ./pkgs/ -type f -regex ".*/.*\.\(xz\|deb\|zip\|txz\|rpm\)" -exec echo -e " $(INFO)=>$(RESET) {}" \;
+
upload:
@echo "APPKEY:76vh3q42hnvmzm3" > dropbox_config
@echo "APPSECRET:tmeecht2cmh72xa" >> dropbox_config
@wget -q "http://raw.github.com/andreafabrizi/Dropbox-Uploader/master/dropbox_uploader.sh"
@chmod +x dropbox_uploader.sh
@sed -i -e "s/~\/.dropbox_uploader/.\/dropbox_config/g" $$(basename $(DROPBOX))
- @find . -type f -regex ".*/.*\.\(xz\|deb\|zip\|txz\)" -exec ./$$(basename $(DROPBOX)) upload {} \;
+ @find ./pkgs -type f -regex ".*/.*\.\(xz\|deb\|zip\|txz\|rpm\)" -exec ./$$(basename $(DROPBOX)) upload {} \;
@rm dropbox_config dropbox_uploader.sh
website:
@git stash apply
clean:
- @rm -f *.deb
- @rm -f *.pkg.tar.xz
- @rm -f *.zip
- @rm -f *.gen
+ @rm -rf pkgs/
@rm -f *.html
- @rm -f *.txz
all: base upload
all:
$(MAKE) -f ../../archlinux/this/Makefile \
LIBC_DEPEND=libc \
- DESTDIR=distro/archbsd/this
+ DESTDIR=distro/archbsd/this \
+ SUFFIX=archbsd
MINOR := $(shell sed -n -e '/GMQCC_VERSION_MINOR/{s/.* .* //;p;q;}' $(HEADER))
PATCH := $(shell sed -n -e '/GMQCC_VERSION_PATCH/{s/.* .* //;p;q;}' $(HEADER))
PKGREL := 1
+SUFFIX ?= archlinux
CARCH := $(shell uname -m)
-PKGDIR := gmqcc-$(MAJOR).$(MINOR).$(PATCH)-$(PKGREL)-$(CARCH)
+PKGDIR := gmqcc-$(MAJOR).$(MINOR).$(PATCH)-$(PKGREL)-$(CARCH)-$(SUFFIX)
TARCOMP := -J
PKG := $(PKGDIR).pkg.tar.xz
PKGINFO := $(PKGDIR)/.PKGINFO
LIBC_DEPEND := glibc
-ifneq (, $(findstring i686, $(CARCH)))
- CFLAGS += -m32
- LDFLAGS += -m32
-endif
-
base:
$(MAKE) -C $(BASEDIR) clean
CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \
@bsdtar -C $(PKGDIR) -czf $(PKGDIR)/.MTREE \
--format=mtree \
--options='!all,use-set,type,uid,gid,mode,time,size,md5,sha256,link' \
- .PKGINFO usr/
- @bsdtar $(TARCOMP) -cvf $(PKG) -C $(PKGDIR)/ .PKGINFO .MTREE usr/
+ .PKGINFO usr/ 2>&1 >/dev/null
+ @bsdtar $(TARCOMP) -cvf $(PKG) -C $(PKGDIR)/ .PKGINFO .MTREE usr/ 2>&1 >/dev/null
@rm -rf $(PKGDIR)
clean:
@tar czf data.tar.gz -C $(DEBDIR)/ . --exclude=DEBIAN
@tar czf control.tar.gz -C $(DEBDIR)/DEBIAN/ .
@echo 2.0 > debian-binary
- @ar r $(DEB) debian-binary control.tar.gz data.tar.gz
+ @ar r $(DEB) debian-binary control.tar.gz data.tar.gz 2>&1 >/dev/null
@rm -rf debian-binary control.tar.gz data.tar.gz $(DEBDIR)
clean:
+++ /dev/null
-File is constantly updated!
-
-Since Fedora 19 we have this package in main repos. Please use it!
-
-For install gmqcc do this:
-# yum install gmqcc
-
-For install qcvm do this:
-# yum install qcvm
-
-For install gmqpak do this:
-# yum install gmqpak
-
-To use the spec files in this fedora directory you need the core
-development tools , building enviroment for the user, and
-the directory structure for it. If you don't already have these, issue
-the following commands.
-
-# yum groupinstall "Development Tools"
-# yum install rpmdevtools
-$ rm -rf ~/rpmbuild
-$ rpmdev-setuptree
-
-Prepare and build the RPMs.
-
-$ cp gmqcc.spec ~/rpmbuild/SPECS/
-$ wget https://github.com/graphitemaster/gmqcc/archive/0.3.5.tar.gz -o ~/rpmbuild/SOURCES/gmqcc-0.3.5.tar.gz
-$ rpmbuild -ba ~/rpmbuild/SPECS/gmqcc.spec
-
-Now we have RPMs in ~/rpmbuild/RPMS/ and you can install it via yum.
-
+++ /dev/null
-Name: gmqcc
-Version: 0.3.5
-Release: 2%{?dist}
-Summary: Improved Quake C Compiler
-License: MIT
-URL: http://graphitemaster.github.io/gmqcc/
-Source0: https://github.com/graphitemaster/%{name}/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz
-# fix build on big endian arches - stdlib.h required for exit()
-Patch0: %{name}-0.3.5-stdlib.patch
-
-# tests fail on big endians
-ExclusiveArch: %{ix86} x86_64 %{arm}
-
-%description
-Modern written-from-scratch compiler for the QuakeC language with
-support for many common features found in other QC compilers.
-
-%package -n qcvm
-Summary: Standalone QuakeC VM binary executor
-
-%description -n qcvm
-Executor for QuakeC VM binary files created using a QC compiler such
-as gmqcc or fteqcc. It provides a small set of built-in functions, and
-by default executes the main function if there is one. Some options
-useful for debugging are available as well.
-
-%package -n gmqpak
-Summary: Standalone Quake PAK file utility
-
-%description -n gmqpak
-Standalone Quake PAK file utility supporting the extraction of files,
-directories, or whole PAKs, as well as the opposite (creation of PAK files).
-
-%prep
-%setup -q
-%patch0 -p1
-echo '#!/bin/sh' > ./configure
-chmod +x ./configure
-
-# and for all for all of those switches they increase the runtime of the compile
-# making compiles of code slower
-
-# we don't need compiel time buffer protection, we test with clangs address
-# sanatizer and valgrind before releases
-%global optflags %(echo %{optflags} | sed 's/-D_FORTIFY_SOURCE=2 //')
-# there is no exceptions in C
-%global optflags %(echo %{optflags} | sed 's/-fexceptions //')
-# same with clangs address sanatizer and valgrind testing
-%global optflags %(echo %{optflags} | sed 's/-fstack-protector-strong //')
-# buffer overflow protection is unrequired since most (if not all) allocations
-# happen dynamically and we have our own memory allocator which checks this
-# (with valgrind integration), also clangs address santatizer cathes it as
-# for grecord-gcc-switches, that just adds pointless information to the binary
-# increasing it size
-%global optflags %(echo %{optflags} | sed 's/--param=ssp-buffer-size=4 //')
-
-%build
-%configure
-make %{?_smp_mflags}
-
-%install
-%make_install PREFIX=%{_prefix}
-
-%check
-make check
-
-%files
-%doc LICENSE README AUTHORS CHANGES TODO
-%doc gmqcc.ini.example
-%{_mandir}/man1/gmqcc.1*
-%{_bindir}/gmqcc
-
-%files -n qcvm
-%doc LICENSE README AUTHORS CHANGES TODO
-%{_mandir}/man1/qcvm.1*
-%{_bindir}/qcvm
-
-%files -n gmqpak
-%doc LICENSE README AUTHORS CHANGES TODO
-%{_mandir}/man1/gmqpak.1*
-%{_bindir}/gmqpak
-
-%changelog
-* Sat Nov 16 2013 Dan Horák <dan[at]danny.cz> - 0.3.5-2
-- fix build on big endian arches
-- use the standard wildcarded filename for man pages
-- and make it Exclusive for little endians because tests fail on big endians
-
-* Thu Nov 14 2013 Igor Gnatenko <i.gnatenko.brain@gmail.com> - 0.3.5-1
-- 0.3.5 upstream release
-
-* Thu Sep 26 2013 Igor Gnatenko <i.gnatenko.brain@gmail.com> - 0.3.0-2
-- Optimizing compile flags
-
-* Fri Sep 20 2013 Igor Gnatenko <i.gnatenko.brain@gmail.com> - 0.3.0-1
-- Update to 0.3.0 (improved new package: gmqpak)
-
-* Sat Jul 27 2013 Igor Gnatenko <i.gnatenko.brain@gmail.com> - 0.2.9-1
-- Initial release
--- /dev/null
+File is constantly updated!
+
+Since Fedora 19 we have this package in main repos. Please use it!
+
+For install gmqcc do this:
+# yum install gmqcc
+
+For install qcvm do this:
+# yum install qcvm
+
+For install gmqpak do this:
+# yum install gmqpak
+
+To use the spec files in this fedora directory you need the core
+development tools , building enviroment for the user, and
+the directory structure for it. If you don't already have these, issue
+the following commands.
+
+# yum groupinstall "Development Tools"
+# yum install rpmdevtools
+$ rm -rf ~/rpmbuild
+$ rpmdev-setuptree
+
+Prepare and build the RPMs.
+
+$ cp gmqcc.spec ~/rpmbuild/SPECS/
+$ wget https://github.com/graphitemaster/gmqcc/archive/0.3.5.tar.gz -o ~/rpmbuild/SOURCES/gmqcc-0.3.5.tar.gz
+$ rpmbuild -ba ~/rpmbuild/SPECS/gmqcc.spec
+
+Now we have RPMs in ~/rpmbuild/RPMS/ and you can install it via yum.
+
--- /dev/null
+Name: gmqcc
+Version: 0.3.6
+Release: 2%{?dist}
+Summary: Improved Quake C Compiler
+License: MIT
+URL: http://graphitemaster.github.io/gmqcc/
+Source0: https://github.com/graphitemaster/%{name}/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz
+
+# tests fail on big endians
+ExclusiveArch: %{ix86} x86_64 %{arm}
+
+%description
+Modern written-from-scratch compiler for the QuakeC language with
+support for many common features found in other QC compilers.
+
+%package -n qcvm
+Summary: Standalone QuakeC VM binary executor
+
+%description -n qcvm
+Executor for QuakeC VM binary files created using a QC compiler such
+as gmqcc or fteqcc. It provides a small set of built-in functions, and
+by default executes the main function if there is one. Some options
+useful for debugging are available as well.
+
+%package -n gmqpak
+Summary: Standalone Quake PAK file utility
+
+%description -n gmqpak
+Standalone Quake PAK file utility supporting the extraction of files,
+directories, or whole PAKs, as well as the opposite (creation of PAK files).
+
+%prep
+%setup -q
+echo '#!/bin/sh' > ./configure
+chmod +x ./configure
+
+# and for all for all of those switches they increase the runtime of the compile
+# making compiles of code slower
+
+# we don't need compile time buffer protection, we test with clang's address
+# sanatizer and valgrind before releases
+%global optflags %(echo %{optflags} | sed 's/-D_FORTIFY_SOURCE=2 //')
+# there is no exceptions in C
+%global optflags %(echo %{optflags} | sed 's/-fexceptions //')
+# same with clangs address sanatizer and valgrind testing
+%global optflags %(echo %{optflags} | sed 's/-fstack-protector-strong //')
+# buffer overflow protection is unrequired since most (if not all) allocations
+# happen dynamically and we have our own memory allocator which checks this
+# (with valgrind integration), also clang's address santatizer cathes it as
+# for grecord-gcc-switches, that just adds pointless information to the binary
+# increasing its size
+%global optflags %(echo %{optflags} | sed 's/--param=ssp-buffer-size=4 //')
+
+%build
+%configure
+make %{?_smp_mflags}
+
+%install
+%make_install PREFIX=%{_prefix}
+
+%check
+make check
+
+%files
+%doc LICENSE README AUTHORS CHANGES TODO
+%doc gmqcc.ini.example
+%{_mandir}/man1/gmqcc.1*
+%{_bindir}/gmqcc
+
+%files -n qcvm
+%doc LICENSE README AUTHORS CHANGES TODO
+%{_mandir}/man1/qcvm.1*
+%{_bindir}/qcvm
+
+%files -n gmqpak
+%doc LICENSE README AUTHORS CHANGES TODO
+%{_mandir}/man1/gmqpak.1*
+%{_bindir}/gmqpak
+
+%changelog
+* Sat Nov 16 2013 Dan Horák <dan[at]danny.cz> - 0.3.5-2
+- fix build on big endian arches
+- use the standard wildcarded filename for man pages
+- and make it Exclusive for little endians because tests fail on big endians
+
+* Thu Nov 14 2013 Igor Gnatenko <i.gnatenko.brain@gmail.com> - 0.3.5-1
+- 0.3.5 upstream release
+
+* Thu Sep 26 2013 Igor Gnatenko <i.gnatenko.brain@gmail.com> - 0.3.0-2
+- Optimizing compile flags
+
+* Fri Sep 20 2013 Igor Gnatenko <i.gnatenko.brain@gmail.com> - 0.3.0-1
+- Update to 0.3.0 (improved new package: gmqpak)
+
+* Sat Jul 27 2013 Igor Gnatenko <i.gnatenko.brain@gmail.com> - 0.2.9-1
+- Initial release
--- /dev/null
+BASEDIR := $(CURDIR)/../../..
+HEADER := $(BASEDIR)/gmqcc.h
+MAJOR := `sed -n -e '/GMQCC_VERSION_MAJOR/{s/.* .* //;p;q;}' $(HEADER)`
+MINOR := `sed -n -e '/GMQCC_VERSION_MINOR/{s/.* .* //;p;q;}' $(HEADER)`
+PATCH := `sed -n -e '/GMQCC_VERSION_PATCH/{s/.* .* //;p;q;}' $(HEADER)`
+NAME := gmqcc-$(MAJOR).$(MINOR).$(PATCH)
+TARFILE := $(NAME).tar.gz
+
+all:
+ @mkdir -p ~/rpmbuild/SPECS
+ @mkdir -p ~/rpmbuild/SOURCES
+ @cp ../spec/gmqcc.spec ~/rpmbuild/SPECS
+ @mkdir -p /tmp/$(NAME)
+ @cp -R $(BASEDIR) /tmp/$(NAME)/
+ @cd /tmp && tar -zcf ~/rpmbuild/SOURCES/$(TARFILE) $(NAME)/
+ @rm -rf /tmp/$(NAME)
+ @rpmbuild -ba ../spec/gmqcc.spec 2>&1 >/dev/null
+
+ @mv ~/rpmbuild/RPMS/x86_64/gmqcc*.rpm . 2>/dev/null; true
+ @mv ~/rpmbuild/RPMS/x86_64/qcvm*.rpm . 2>/dev/null; true
+ @mv ~/rpmbuild/RPMS/x86_64/gmqpak*.rpm . 2>/dev/null; true
BINDIR := gmqcc-$(MAJOR).$(MINOR).$(PATCH)
base:
- $(MAKE) CC=i486-mingw32-gcc UNAME=MINGW32 -C $(BASEDIR) clean
- $(MAKE) CC=i486-mingw32-gcc UNAME=MINGW32 -C $(BASEDIR) DESTDIR=distro/win32/$(BINDIR) PREFIX=/ strip install
+ $(MAKE) CC=i686-w64-mingw32-gcc UNAME=MINGW -C $(BASEDIR) clean
+ $(MAKE) CC=i686-w64-mingw32-gcc UNAME=MINGW -C $(BASEDIR) DESTDIR=distro/win32/$(BINDIR) PREFIX=/ strip install
@mkdir -p $(BINDIR)/doc
@groff -mandoc $(BINDIR)/man1/gmqpak.1 | ps2pdf - $(BINDIR)/doc/gmqpak.pdf
@groff -mandoc $(BINDIR)/man1/qcvm.1 | ps2pdf - $(BINDIR)/doc/qcvm.pdf
--- /dev/null
+BASEDIR := ../..
+HEADER := $(BASEDIR)/gmqcc.h
+MAJOR := `sed -n -e '/GMQCC_VERSION_MAJOR/{s/.* .* //;p;q;}' $(HEADER)`
+MINOR := `sed -n -e '/GMQCC_VERSION_MINOR/{s/.* .* //;p;q;}' $(HEADER)`
+PATCH := `sed -n -e '/GMQCC_VERSION_PATCH/{s/.* .* //;p;q;}' $(HEADER)`
+BINDIR := gmqcc-$(MAJOR).$(MINOR).$(PATCH)
+
+base:
+ $(MAKE) CC=x86_64-w64-mingw32-gcc UNAME=MINGW -C $(BASEDIR) clean
+ $(MAKE) CC=x86_64-w64-mingw32-gcc UNAME=MINGW -C $(BASEDIR) DESTDIR=distro/win64/$(BINDIR) PREFIX=/ strip install
+ @mkdir -p $(BINDIR)/doc
+ @groff -mandoc $(BINDIR)/man1/gmqpak.1 | ps2pdf - $(BINDIR)/doc/gmqpak.pdf
+ @groff -mandoc $(BINDIR)/man1/qcvm.1 | ps2pdf - $(BINDIR)/doc/qcvm.pdf
+ @groff -mandoc $(BINDIR)/man1/gmqcc.1 | ps2pdf - $(BINDIR)/doc/gmqcc.pdf
+ @rm -rf $(BINDIR)/man1/
+ @zip -r $(BINDIR)-win64.zip $(BINDIR)
+ @rm -rf $(BINDIR)
+clean:
+ $(MAKE) -C $(BASEDIR) clean
+ @rm -f *.zip
+
+all: base
lex_file *inlex;
bool old_inmacro;
+ bool strip = false;
int nextok;
if (nextok == '#') {
/* raw concatenation */
++o;
+ strip = true;
break;
}
if ( (nextok == TOKEN_IDENT ||
macro_params_find(macro, macro->output[o+1]->value, &pi))
{
++o;
+
ftepp_stringify(ftepp, ¶ms[pi]);
break;
}
ftepp_out(ftepp, "\n", false);
break;
default:
- ftepp_out(ftepp, out->value, false);
+ buffer = out->value;
+ if (vec_size(macro->output) > o + 1 && macro->output[o+1]->token == '#')
+ buffer++;
+ if (strip) {
+ while (util_isspace(*buffer)) buffer++;
+ strip = false;
+ }
+ ftepp_out(ftepp, buffer, false);
break;
}
}
# default directories and paths
DESTDIR :=
-OPTIONAL:=
PREFIX := /usr/local
BINDIR := $(PREFIX)/bin
DATADIR := $(PREFIX)/share
#common objects
COMMON = ansi.o util.o hash.o stat.o fs.o opts.o conout.o
+#optional flags
+OPTIONAL_CFLAGS :=
+OPTIONAL_LDFLAGS :=
+
#objects
OBJ_C = $(COMMON) main.o lexer.o parser.o code.o ast.o ir.o ftepp.o utf8.o correct.o fold.o intrin.o
OBJ_P = $(COMMON) pak.o
# define ALPHA(SEL) ALPHA_##SEL
-# define ABC ALPHA(a)##ALPHA(b)##ALPHA(c)
+# define ABC ALPHA(a)ALPHA(b)ALPHA(c)
void() main = {
if (ABC == "abc")
SCONS(hello, world)
#define FOO(X) X##X
-#define BAR(X) FOO(X)##FOO(X)
+#define BAR(X) FOO(X)FOO(X)
-REDIR(BAR(hello), BAR(world))
+REDIR(BAR(hello),BAR(world))