From a56edef9dbcbd8e6bbe9dab3f7a84673bee6bc75 Mon Sep 17 00:00:00 2001 From: Alex Baines Date: Sun, 6 Nov 2016 02:31:45 +0000 Subject: [PATCH] fix building on linux --- Makefile | 4 +-- Makefile.inso | 70 ++++++++++++++++++++++++++++++++++++++++++++ build.cpp | 16 ++++++---- site/meta_parser.cpp | 4 +++ 4 files changed, 86 insertions(+), 8 deletions(-) create mode 100644 Makefile.inso diff --git a/Makefile b/Makefile index 199c7700..80794482 100755 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ C_FILES := $(wildcard *.c) $(wildcard **/*.c) H_FILES := $(wildcard *.h) $(wildcard **/*.h) WARNINGS := -Wno-write-strings -FLAGS := -D_GNU_SOURCE -fPIC +FLAGS := -D_GNU_SOURCE -fPIC -fpermissive debug: FLAGS += -DDEV_BUILD debug: ../build/build @@ -12,7 +12,7 @@ package: FLAGS += -DPACKAGE package: ../build/build ../build/build: $(CPP_FILES) $(C_FILES) $(H_FILES) - gcc $(WARNINGS) $(FLAGS) build.c -g -o $@ + g++ $(WARNINGS) $(FLAGS) build.cpp -g -o $@ ../build/build clean: diff --git a/Makefile.inso b/Makefile.inso new file mode 100644 index 00000000..9096786e --- /dev/null +++ b/Makefile.inso @@ -0,0 +1,70 @@ +FLAGS := -Wno-write-strings -D_GNU_SOURCE -fno-threadsafe-statics \ + -pthread -I../foreign -I. -Wno-literal-suffix +LIBS := -lX11 -lXfixes -lGL -lrt -ldl -lm -lfreetype -lfontconfig + +# main targets + +debug: FLAGS += -DFRED_SUPER=1 -DFRED_INTERNAL=1 -O0 -g +debug: ../4ed ../4ed_app.so ../4coder_custom.so + +super: FLAGS += -DFRED_SUPER=1 +super: alpha ../4coder_custom.so + +alpha: FLAGS += -O3 -Wl,-s -fno-stack-protector -U_FORTIFY_SOURCE -DFRED_KEEP_ASSERT=1 +alpha: ../4ed ../4ed_app.so + +# auto-generated dependencies + +-include ../build/*.d + +# file targets + +../build: + mkdir $@ + +../build/fsmgen: fsm_table_generator.cpp | ../build + $(CXX) -MMD $(FLAGS) $< -o $@ + $@ + +../build/metagen: 4ed_metagen.cpp | ../build + $(CXX) -MMD $(FLAGS) $< -o $@ + $@ + +../4ed: linux_4ed.cpp ../build/fsmgen ../build/metagen + $(CXX) -MMD -MF ../build/4ed.d $(FLAGS) $(shell pkg-config --cflags freetype2) $< -o $@ $(LIBS) + +../4ed_app.so: 4ed_app_target.cpp ../build/fsmgen ../build/metagen + $(CXX) -MMD -MF ../build/app.d $(FLAGS) -fPIC -shared $< -o $@ + +../4coder_custom.so: power/4coder_experiments.cpp ../build/fsmgen ../build/metagen + $(CXX) -MMD -MF ../build/custom.d $(FLAGS) -I. -fPIC -shared $< -o $@ + +# cleaning + +clean: + $(RM) ../4ed_app.so ../4ed ../4coder_custom.so + +veryclean: clean + $(RM) ../build/fsmgen ../build/metagen ../build/*.d + +# packaging + +PACKAGE_FILES := ../4ed ../4ed_app.so README.txt TODO.txt +V_MAJ := $(shell grep "define MAJOR" 4coder_version.h | cut -d\ -f 3) +V_MIN := $(shell grep "define MINOR" 4coder_version.h | cut -d\ -f 3) +V_PCH := $(shell grep "define PATCH" 4coder_version.h | cut -d\ -f 3) + +super_zip: PACKAGE_FILES += ../4coder_custom.so 4coder_*.h 4coder_*.cpp buildsuper.sh +super_zip: ../4coder-linux-64-$(V_MAJ)-$(V_MIN)-$(V_PCH)-super.zip +alpha_zip: ../4coder-linux-64-$(V_MAJ)-$(V_MIN)-$(V_PCH)-alpha.zip + +../4coder-linux-64-$(V_MAJ)-$(V_MIN)-$(V_PCH)-%.zip: % + @echo === Creating $@ === + zip -j $@ $(PACKAGE_FILES) + $(MAKE) clean + +package: clean + $(MAKE) alpha_zip + $(MAKE) super_zip + +.PHONY: debug alpha super all clean veryclean package alpha_zip super_zip diff --git a/build.cpp b/build.cpp index c9bfa18c..eedf5ffd 100644 --- a/build.cpp +++ b/build.cpp @@ -557,10 +557,13 @@ build_cl(uint32_t flags, } +// NOTE(inso): added ../code to GCC_OPTS to allow metagen to build. +// this is currently needed because it is built with cwd ../meta but includes +// 4cpp_lexer.h which is in code/ whereas metagen.cpp is in code/site #define GCC_OPTS \ "-Wno-write-strings -D_GNU_SOURCE -fPIC " \ -"-fno-threadsafe-statics -pthread" +"-fno-threadsafe-statics -pthread -I../code" #define GCC_INCLUDES \ "-I../foreign" @@ -825,17 +828,18 @@ do_buildsuper(char *cdir){ //copy_sc(&str, "../code/internal_4coder_tests.cpp"); //terminate_with_null(&str); //buildsuper(cdir, BUILD_DIR, str.str); -#else - copy_sc(&str, "../code/power/4coder_experiments.cpp"); - terminate_with_null(&str); - buildsuper(cdir, BUILD_DIR, str.str); -#endif copy_sc(&str, "../code/power/4coder_casey.cpp"); terminate_with_null(&str); buildsuper(cdir, BUILD_DIR, str.str); //copy_sc(&str, "../4vim/4coder_chronal.cpp"); //terminate_with_null(&str); //buildsuper(cdir, BUILD_DIR, str.str); +#else + copy_sc(&str, "../code/power/4coder_experiments.cpp"); + terminate_with_null(&str); + buildsuper(cdir, BUILD_DIR, str.str); +#endif + END_TIME_SECTION("build custom"); } diff --git a/site/meta_parser.cpp b/site/meta_parser.cpp index 65badc77..1e21591d 100644 --- a/site/meta_parser.cpp +++ b/site/meta_parser.cpp @@ -1215,7 +1215,11 @@ compile_meta_unit(Partition *part, char *code_directory, char **files, Meta_Keyw char str_space[512]; String name = make_fixed_width_string(str_space); append_sc(&name, code_directory); +#ifdef _WIN32 append_sc(&name, "\\"); +#else + append_sc(&name, "/"); +#endif append_sc(&name, *file_ptr); terminate_with_null(&name);