diff --git a/.gitignore b/.gitignore index 6e97beb7..27d3957c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,7 @@ lib/ # Folders created at documentation generation doc/build/ + +# Makefile +*.d +*.o \ No newline at end of file diff --git a/Makefile b/Makefile index 2ed97e26..eba0ba93 100644 --- a/Makefile +++ b/Makefile @@ -1,22 +1,27 @@ +SQPROF_CXXFLAGS = -pg -pie -g3 +SQ64_CXXFLAGS = -m64 -D_SQ64 -SQUIRREL=. -MAKE=make +all: sq32 sq32: folders - cd squirrel; $(MAKE) - cd sqstdlib; $(MAKE) - cd sq; $(MAKE) + $(MAKE) -C squirrel + $(MAKE) -C sqstdlib + $(MAKE) -C sq sqprof: folders - cd squirrel; $(MAKE) sqprof - cd sqstdlib; $(MAKE) sqprof - cd sq; $(MAKE) sqprof + CXXFLAGS="$(SQPROF_CXXFLAGS)" $(MAKE) -C squirrel + CXXFLAGS="$(SQPROF_CXXFLAGS)" $(MAKE) -C sqstdlib + CXXFLAGS="$(SQPROF_CXXFLAGS)" $(MAKE) -C sq sq64: folders - cd squirrel; $(MAKE) sq64 - cd sqstdlib; $(MAKE) sq64 - cd sq; $(MAKE) sq64 + CXXFLAGS="$(SQ64_CXXFLAGS)" $(MAKE) -C squirrel + CXXFLAGS="$(SQ64_CXXFLAGS)" $(MAKE) -C sqstdlib + CXXFLAGS="$(SQ64_CXXFLAGS)" $(MAKE) -C sq folders: - mkdir -p lib - mkdir -p bin + mkdir -p lib bin + +clean: + $(MAKE) -C squirrel clean + $(MAKE) -C sqstdlib clean + $(MAKE) -C sq clean \ No newline at end of file diff --git a/sq/CMakeLists.txt b/sq/CMakeLists.txt index 0573df41..d657234b 100644 --- a/sq/CMakeLists.txt +++ b/sq/CMakeLists.txt @@ -1,6 +1,6 @@ set(CMAKE_C_STANDARD 99) if(NOT DISABLE_DYNAMIC) - add_executable(sq sq.c) + add_executable(sq sq.cpp) add_executable(squirrel::interpreter ALIAS sq) set_target_properties(sq PROPERTIES EXPORT_NAME interpreter) target_link_libraries(sq squirrel sqstdlib) @@ -14,7 +14,7 @@ if(NOT DISABLE_DYNAMIC) endif() if(NOT DISABLE_STATIC) - add_executable(sq_static sq.c) + add_executable(sq_static sq.cpp) add_executable(squirrel::interpreter_static ALIAS sq_static) set_target_properties(sq_static PROPERTIES EXPORT_NAME interpreter_static) target_link_libraries(sq_static squirrel_static sqstdlib_static) diff --git a/sq/Makefile b/sq/Makefile index 948fd1ea..29edd4ed 100644 --- a/sq/Makefile +++ b/sq/Makefile @@ -1,21 +1,18 @@ -SQUIRREL= .. +TARGET = ../bin/sq +SRCS = $(wildcard *.cpp) +OBJS = $(patsubst %.cpp,%.o,$(SRCS)) +DEPS = $(patsubst %.cpp,%.d,$(SRCS)) -OUT= $(SQUIRREL)/bin/sq -INCZ= -I$(SQUIRREL)/include -I. -I$(SQUIRREL)/sqlibs -LIBZ= -L$(SQUIRREL)/lib -LIB= -lsquirrel -lsqstdlib +DEPFLAGS = -MMD -MP -MF $*.d +CXXFLAGS += -O2 -fno-exceptions -fno-rtti -Wall -fno-strict-aliasing -I../include $(DEPFLAGS) +LDFLAGS += -L../lib -lsquirrel -lsqstdlib -OBJS= sq.o +all: $(TARGET) -SRCS= sq.c +$(TARGET): $(OBJS) ../lib/libsquirrel.a ../lib/libsqstdlib.a + $(CXX) $(OBJS) -o $@ $(LDFLAGS) - -sq32: - g++ -O2 -fno-exceptions -fno-rtti -o $(OUT) $(SRCS) $(INCZ) $(LIBZ) $(LIB) - -sqprof: - g++ -O2 -pg -fno-exceptions -fno-rtti -pie -gstabs -g3 -o $(OUT) $(SRCS) $(INCZ) $(LIBZ) $(LIB) - -sq64: - g++ -O2 -m64 -fno-exceptions -fno-rtti -D_SQ64 -o $(OUT) $(SRCS) $(INCZ) $(LIBZ) $(LIB) +.PHONY: clean +clean: + rm -f $(TARGET) *.o *.d \ No newline at end of file diff --git a/sq/sq.c b/sq/sq.cpp similarity index 100% rename from sq/sq.c rename to sq/sq.cpp diff --git a/sq/sq.dsp b/sq/sq.dsp index 0234f8cc..866a286e 100644 --- a/sq/sq.dsp +++ b/sq/sq.dsp @@ -86,7 +86,7 @@ LINK32=link.exe # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File -SOURCE=.\sq.c +SOURCE=.\sq.cpp # End Source File # End Group # Begin Group "Header Files" diff --git a/sqstdlib/Makefile b/sqstdlib/Makefile index 6ed1c12b..4be55cfd 100644 --- a/sqstdlib/Makefile +++ b/sqstdlib/Makefile @@ -1,44 +1,19 @@ -SQUIRREL= .. +TARGET = ../lib/libsqstdlib.a +SRCS = $(wildcard *.cpp) +OBJS = $(patsubst %.cpp,%.o,$(SRCS)) +DEPS = $(patsubst %.cpp,%.d,$(SRCS)) -CC?= gcc -OUT?= $(SQUIRREL)/lib/libsqstdlib.a -INCZ?= -I$(SQUIRREL)/include -I. -Iinclude -DEFS= $(CC_EXTRA_FLAGS) -LIB= +DEPFLAGS = -MMD -MP -MF $*.d +CXXFLAGS += -O2 -fno-exceptions -fno-rtti -Wall -fno-strict-aliasing -I../include $(DEPFLAGS) -OBJS= \ - sqstdblob.o \ - sqstdio.o \ - sqstdstream.o \ - sqstdmath.o \ - sqstdsystem.o \ - sqstdstring.o \ - sqstdaux.o \ - sqstdrex.o +all: $(TARGET) -SRCS= \ - sqstdblob.cpp \ - sqstdio.cpp \ - sqstdstream.cpp \ - sqstdmath.cpp \ - sqstdsystem.cpp \ - sqstdstring.cpp \ - sqstdaux.cpp \ - sqstdrex.cpp +$(TARGET): $(OBJS) + ar rc $@ $(OBJS) +-include $(DEPS) -sq32: - $(CC) -O2 -fno-exceptions -fno-rtti -Wall -fno-strict-aliasing -c $(SRCS) $(INCZ) $(DEFS) - ar rc $(OUT) *.o - rm *.o - -sqprof: - $(CC) -O2 -pg -fno-exceptions -fno-rtti -pie -gstabs -g3 -Wall -fno-strict-aliasing -c $(SRCS) $(INCZ) $(DEFS) - ar rc $(OUT) *.o - rm *.o - -sq64: - $(CC) -O2 -m64 -fno-exceptions -D_SQ64 -fno-rtti -Wall -fno-strict-aliasing -c $(SRCS) $(INCZ) $(DEFS) - ar rc $(OUT) *.o - rm *.o +.PHONY: clean +clean: + rm -f $(TARGET) *.o *.d \ No newline at end of file diff --git a/squirrel/Makefile b/squirrel/Makefile index 2422a834..9d7a4342 100644 --- a/squirrel/Makefile +++ b/squirrel/Makefile @@ -1,53 +1,19 @@ -SQUIRREL= .. +TARGET = ../lib/libsquirrel.a +SRCS = $(wildcard *.cpp) +OBJS = $(patsubst %.cpp,%.o,$(SRCS)) +DEPS = $(patsubst %.cpp,%.d,$(SRCS)) -CC?= gcc -OUT?= $(SQUIRREL)/lib/libsquirrel.a -INCZ?= -I$(SQUIRREL)/include -I. -Iinclude -DEFS= $(CC_EXTRA_FLAGS) -LIB= +DEPFLAGS = -MMD -MP -MF $*.d +CXXFLAGS += -O2 -fno-exceptions -fno-rtti -Wall -fno-strict-aliasing -I../include $(DEPFLAGS) -OBJS= \ - sqapi.o \ - sqbaselib.o \ - sqfuncstate.o \ - sqdebug.o \ - sqlexer.o \ - sqobject.o \ - sqcompiler.o \ - sqstate.o \ - sqtable.o \ - sqmem.o \ - sqvm.o \ - sqclass.o +all: $(TARGET) -SRCS= \ - sqapi.cpp \ - sqbaselib.cpp \ - sqfuncstate.cpp \ - sqdebug.cpp \ - sqlexer.cpp \ - sqobject.cpp \ - sqcompiler.cpp \ - sqstate.cpp \ - sqtable.cpp \ - sqmem.cpp \ - sqvm.cpp \ - sqclass.cpp +$(TARGET): $(OBJS) + ar rc $@ $(OBJS) +-include $(DEPS) - -sq32: - $(CC) -O2 -fno-exceptions -fno-rtti -Wall -fno-strict-aliasing -c $(SRCS) $(INCZ) $(DEFS) - ar rc $(OUT) *.o - rm *.o - -sqprof: - $(CC) -O2 -pg -fno-exceptions -fno-rtti -pie -gstabs -g3 -Wall -fno-strict-aliasing -c $(SRCS) $(INCZ) $(DEFS) - ar rc $(OUT) *.o - rm *.o - -sq64: - $(CC) -O2 -m64 -D_SQ64 -fno-exceptions -fno-rtti -Wall -fno-strict-aliasing -c $(SRCS) $(INCZ) $(DEFS) - ar rc $(OUT) *.o - rm *.o +.PHONY: clean +clean: + rm -f $(TARGET) *.o *.d \ No newline at end of file